From 72d9c5b724449bc3a1e7be14c4f584d4454e5266 Mon Sep 17 00:00:00 2001 From: Nabin Hait Date: Tue, 26 Mar 2013 11:54:40 +0530 Subject: [PATCH] fixed floating point issue in jv --- .../journal_voucher/journal_voucher.js | 6 ++--- .../journal_voucher/journal_voucher.py | 26 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/accounts/doctype/journal_voucher/journal_voucher.js b/accounts/doctype/journal_voucher/journal_voucher.js index 82322c89ec..78956bf11e 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.js +++ b/accounts/doctype/journal_voucher/journal_voucher.js @@ -84,13 +84,13 @@ cur_frm.cscript.update_totals = function(doc) { var td=0.0; var tc =0.0; var el = getchildren('Journal Voucher Detail', doc.name, 'entries'); for(var i in el) { - td += flt(el[i].debit); - tc += flt(el[i].credit); + td += flt(el[i].debit, 2); + tc += flt(el[i].credit, 2); } var doc = locals[doc.doctype][doc.name]; doc.total_debit = td; doc.total_credit = tc; - doc.difference = flt(td - tc); + doc.difference = flt((td - tc), 2); refresh_many(['total_debit','total_credit','difference']); } diff --git a/accounts/doctype/journal_voucher/journal_voucher.py b/accounts/doctype/journal_voucher/journal_voucher.py index 812ab7d0be..8b54f0fec2 100644 --- a/accounts/doctype/journal_voucher/journal_voucher.py +++ b/accounts/doctype/journal_voucher/journal_voucher.py @@ -114,8 +114,8 @@ class DocType(AccountsController): debit, credit = 0.0, 0.0 debit_list, credit_list = [], [] for d in getlist(self.doclist, 'entries'): - debit += flt(d.debit) - credit += flt(d.credit) + debit += flt(d.debit, 2) + 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.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'): msgprint("Please enter atleast 1 entry in 'GL Entries' table") else: - flag, self.doc.total_debit, self.doc.total_credit = 0,0,0 - diff = flt(self.doc.difference) + flag, self.doc.total_debit, self.doc.total_credit = 0, 0, 0 + diff = flt(self.doc.difference, 2) # If any row without amount, set the diff on that row 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: - d.credit = flt(diff) + d.credit = diff elif diff<0: - d.debit = flt(diff) + d.debit = diff flag = 1 # 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) if diff>0: - jd.credit = flt(abs(diff)) + jd.credit = abs(diff) elif diff<0: - jd.debit = flt(abs(diff)) + jd.debit = abs(diff) # Set the total debit, total credit and difference for d in getlist(self.doclist,'entries'): - self.doc.total_debit += flt(d.debit) - self.doc.total_credit += flt(d.credit) + self.doc.total_debit += flt(d.debit, 2) + 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): self.doclist = self.doc.clear_table(self.doclist, 'entries')