fixed floating point issue in jv
This commit is contained in:
parent
6dcee5a1f8
commit
72d9c5b724
@ -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')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user