mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-31 18:59:08 +00:00
Merge branch 'master' of github.com:webnotes/erpnext
This commit is contained in:
@@ -84,13 +84,13 @@ cur_frm.cscript.update_totals = function(doc) {
|
|||||||
var td=0.0; var tc =0.0;
|
var td=0.0; var tc =0.0;
|
||||||
var el = getchildren('Journal Voucher Detail', doc.name, 'entries');
|
var el = getchildren('Journal Voucher Detail', doc.name, 'entries');
|
||||||
for(var i in el) {
|
for(var i in el) {
|
||||||
td += flt(el[i].debit);
|
td += flt(el[i].debit, 2);
|
||||||
tc += flt(el[i].credit);
|
tc += flt(el[i].credit, 2);
|
||||||
}
|
}
|
||||||
var doc = locals[doc.doctype][doc.name];
|
var doc = locals[doc.doctype][doc.name];
|
||||||
doc.total_debit = td;
|
doc.total_debit = td;
|
||||||
doc.total_credit = tc;
|
doc.total_credit = tc;
|
||||||
doc.difference = flt(td - tc);
|
doc.difference = flt((td - tc), 2);
|
||||||
refresh_many(['total_debit','total_credit','difference']);
|
refresh_many(['total_debit','total_credit','difference']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -114,8 +114,8 @@ class DocType(AccountsController):
|
|||||||
debit, credit = 0.0, 0.0
|
debit, credit = 0.0, 0.0
|
||||||
debit_list, credit_list = [], []
|
debit_list, credit_list = [], []
|
||||||
for d in getlist(self.doclist, 'entries'):
|
for d in getlist(self.doclist, 'entries'):
|
||||||
debit += flt(d.debit)
|
debit += flt(d.debit, 2)
|
||||||
credit += flt(d.credit)
|
credit += flt(d.credit, 2)
|
||||||
if flt(d.debit)>0 and (d.account not in debit_list): debit_list.append(d.account)
|
if flt(d.debit)>0 and (d.account not in debit_list): debit_list.append(d.account)
|
||||||
if flt(d.credit)>0 and (d.account not in credit_list): credit_list.append(d.account)
|
if flt(d.credit)>0 and (d.account not in credit_list): credit_list.append(d.account)
|
||||||
|
|
||||||
@@ -289,32 +289,32 @@ class DocType(AccountsController):
|
|||||||
if not getlist(self.doclist,'entries'):
|
if not getlist(self.doclist,'entries'):
|
||||||
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
|
msgprint("Please enter atleast 1 entry in 'GL Entries' table")
|
||||||
else:
|
else:
|
||||||
flag, self.doc.total_debit, self.doc.total_credit = 0,0,0
|
flag, self.doc.total_debit, self.doc.total_credit = 0, 0, 0
|
||||||
diff = flt(self.doc.difference)
|
diff = flt(self.doc.difference, 2)
|
||||||
|
|
||||||
# If any row without amount, set the diff on that row
|
# If any row without amount, set the diff on that row
|
||||||
for d in getlist(self.doclist,'entries'):
|
for d in getlist(self.doclist,'entries'):
|
||||||
if not d.credit and not d.debit and flt(diff) != 0:
|
if not d.credit and not d.debit and diff != 0:
|
||||||
if diff>0:
|
if diff>0:
|
||||||
d.credit = flt(diff)
|
d.credit = diff
|
||||||
elif diff<0:
|
elif diff<0:
|
||||||
d.debit = flt(diff)
|
d.debit = diff
|
||||||
flag = 1
|
flag = 1
|
||||||
|
|
||||||
# Set the diff in a new row
|
# Set the diff in a new row
|
||||||
if flag == 0 and (flt(diff) != 0):
|
if flag == 0 and diff != 0:
|
||||||
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
|
jd = addchild(self.doc, 'entries', 'Journal Voucher Detail', self.doclist)
|
||||||
if diff>0:
|
if diff>0:
|
||||||
jd.credit = flt(abs(diff))
|
jd.credit = abs(diff)
|
||||||
elif diff<0:
|
elif diff<0:
|
||||||
jd.debit = flt(abs(diff))
|
jd.debit = abs(diff)
|
||||||
|
|
||||||
# Set the total debit, total credit and difference
|
# Set the total debit, total credit and difference
|
||||||
for d in getlist(self.doclist,'entries'):
|
for d in getlist(self.doclist,'entries'):
|
||||||
self.doc.total_debit += flt(d.debit)
|
self.doc.total_debit += flt(d.debit, 2)
|
||||||
self.doc.total_credit += flt(d.credit)
|
self.doc.total_credit += flt(d.credit, 2)
|
||||||
|
|
||||||
self.doc.difference = flt(self.doc.total_debit) - flt(self.doc.total_credit)
|
self.doc.difference = flt(self.doc.total_debit, 2) - flt(self.doc.total_credit, 2)
|
||||||
|
|
||||||
def get_outstanding_invoices(self):
|
def get_outstanding_invoices(self):
|
||||||
self.doclist = self.doc.clear_table(self.doclist, 'entries')
|
self.doclist = self.doc.clear_table(self.doclist, 'entries')
|
||||||
|
|||||||
@@ -16,30 +16,37 @@
|
|||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
import webnotes
|
import webnotes
|
||||||
|
from webnotes import msgprint, _
|
||||||
from webnotes.model import db_exists
|
from webnotes.utils import cint
|
||||||
from webnotes.model.bean import copy_doclist
|
|
||||||
from webnotes import msgprint
|
|
||||||
|
|
||||||
sql = webnotes.conn.sql
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class DocType:
|
class DocType:
|
||||||
def __init__(self,doc,doclist=[]):
|
def __init__(self,doc,doclist=[]):
|
||||||
self.doc, self.doclist = doc,doclist
|
self.doc, self.doclist = doc,doclist
|
||||||
|
|
||||||
#--------------------get naming series from sales invoice-----------------
|
|
||||||
def get_series(self):
|
def get_series(self):
|
||||||
import webnotes.model.doctype
|
import webnotes.model.doctype
|
||||||
docfield = webnotes.model.doctype.get('Sales Invoice')
|
docfield = webnotes.model.doctype.get('Sales Invoice')
|
||||||
series = [d.options for d in docfield if d.doctype == 'DocField' and d.fieldname == 'naming_series']
|
series = [d.options for d in docfield
|
||||||
|
if d.doctype == 'DocField' and d.fieldname == 'naming_series']
|
||||||
return series and series[0] or ''
|
return series and series[0] or ''
|
||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
res = sql("select name, user from `tabPOS Setting` where ifnull(user, '') = '%s' and name != '%s' and company = '%s'" % (self.doc.user, self.doc.name, self.doc.company))
|
self.check_for_duplicate()
|
||||||
|
self.validate_expense_account()
|
||||||
|
|
||||||
|
def check_for_duplicate(self):
|
||||||
|
res = webnotes.conn.sql("""select name, user from `tabPOS Setting`
|
||||||
|
where ifnull(user, '') = %s and name != %s and company = %s""",
|
||||||
|
(self.doc.user, self.doc.name, self.doc.company))
|
||||||
if res:
|
if res:
|
||||||
if res[0][1]:
|
if res[0][1]:
|
||||||
msgprint("POS Setting '%s' already created for user: '%s' and company: '%s'"%(res[0][0], res[0][1], self.doc.company), raise_exception=1)
|
msgprint("POS Setting '%s' already created for user: '%s' and company: '%s'" %
|
||||||
|
(res[0][0], res[0][1], self.doc.company), raise_exception=1)
|
||||||
else:
|
else:
|
||||||
msgprint("Global POS Setting already created - %s for this company: '%s'" % (res[0][0], self.doc.company), raise_exception=1)
|
msgprint("Global POS Setting already created - %s for this company: '%s'" %
|
||||||
|
(res[0][0], self.doc.company), raise_exception=1)
|
||||||
|
|
||||||
|
def validate_expense_account(self):
|
||||||
|
if cint(webnotes.defaults.get_global_default("auto_inventory_accounting")) \
|
||||||
|
and not self.doc.expense_account:
|
||||||
|
msgprint(_("Expense Account is mandatory"), raise_exception=1)
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
[
|
[
|
||||||
{
|
{
|
||||||
"creation": "2013-01-24 11:03:29",
|
"creation": "2013-03-26 11:03:07",
|
||||||
"docstatus": 0,
|
"docstatus": 0,
|
||||||
"modified": "2013-03-25 15:27:52",
|
"modified": "2013-03-26 12:48:18",
|
||||||
"modified_by": "Administrator",
|
"modified_by": "Administrator",
|
||||||
"owner": "Administrator"
|
"owner": "Administrator"
|
||||||
},
|
},
|
||||||
@@ -18,7 +18,8 @@
|
|||||||
"parent": "POS Setting",
|
"parent": "POS Setting",
|
||||||
"parentfield": "fields",
|
"parentfield": "fields",
|
||||||
"parenttype": "DocType",
|
"parenttype": "DocType",
|
||||||
"permlevel": 0
|
"permlevel": 0,
|
||||||
|
"read_only": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocPerm",
|
"doctype": "DocPerm",
|
||||||
@@ -141,12 +142,15 @@
|
|||||||
"reqd": 1
|
"reqd": 1
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
"depends_on": "eval:sys_defaults.auto_inventory_accounting",
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
"fieldname": "expense_account",
|
"fieldname": "expense_account",
|
||||||
"fieldtype": "Link",
|
"fieldtype": "Link",
|
||||||
|
"hidden": 0,
|
||||||
"label": "Expense Account",
|
"label": "Expense Account",
|
||||||
"options": "Account",
|
"options": "Account",
|
||||||
"reqd": 1
|
"print_hide": 1,
|
||||||
|
"reqd": 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"doctype": "DocField",
|
"doctype": "DocField",
|
||||||
|
|||||||
Reference in New Issue
Block a user