[fix] [minor] _round function - implement round halfs to nearest even number
This commit is contained in:
parent
c46d044efe
commit
2e31e097fa
@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes import _, msgprint
|
||||
from webnotes.utils import flt
|
||||
from webnotes.utils import flt, _round
|
||||
|
||||
from buying.utils import get_item_details
|
||||
from setup.utils import get_company_currency
|
||||
@ -129,10 +129,10 @@ class BuyingController(StockController):
|
||||
self.precision("total_tax"))
|
||||
|
||||
if self.meta.get_field("rounded_total"):
|
||||
self.doc.rounded_total = round(self.doc.grand_total)
|
||||
self.doc.rounded_total = _round(self.doc.grand_total)
|
||||
|
||||
if self.meta.get_field("rounded_total_import"):
|
||||
self.doc.rounded_total_import = round(self.doc.grand_total_import)
|
||||
self.doc.rounded_total_import = _round(self.doc.grand_total_import)
|
||||
|
||||
def calculate_outstanding_amount(self):
|
||||
if self.doc.doctype == "Purchase Invoice" and self.doc.docstatus < 2:
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
from webnotes.utils import cint, flt, comma_or
|
||||
from webnotes.utils import cint, flt, comma_or, _round
|
||||
from setup.utils import get_company_currency
|
||||
from selling.utils import get_item_details
|
||||
from webnotes import msgprint, _
|
||||
@ -218,8 +218,8 @@ class SellingController(StockController):
|
||||
self.doc.other_charges_total_export = flt(self.doc.grand_total_export - self.doc.net_total_export,
|
||||
self.precision("other_charges_total_export"))
|
||||
|
||||
self.doc.rounded_total = round(self.doc.grand_total)
|
||||
self.doc.rounded_total_export = round(self.doc.grand_total_export)
|
||||
self.doc.rounded_total = _round(self.doc.grand_total)
|
||||
self.doc.rounded_total_export = _round(self.doc.grand_total_export)
|
||||
|
||||
def calculate_outstanding_amount(self):
|
||||
# NOTE:
|
||||
|
@ -4,7 +4,7 @@
|
||||
from __future__ import unicode_literals
|
||||
import webnotes
|
||||
|
||||
from webnotes.utils import add_days, cint, cstr, flt, getdate, nowdate
|
||||
from webnotes.utils import add_days, cint, cstr, flt, getdate, nowdate, _round
|
||||
from webnotes.model.doc import make_autoname
|
||||
from webnotes.model.bean import getlist
|
||||
from webnotes.model.code import get_obj
|
||||
@ -164,7 +164,7 @@ class DocType(TransactionBase):
|
||||
self.doc.gross_pay = flt(self.doc.arrear_amount) + flt(self.doc.leave_encashment_amount)
|
||||
for d in self.doclist.get({"parentfield": "earning_details"}):
|
||||
if cint(d.e_depends_on_lwp) == 1:
|
||||
d.e_modified_amount = round(flt(d.e_amount) * flt(self.doc.payment_days)
|
||||
d.e_modified_amount = _round(flt(d.e_amount) * flt(self.doc.payment_days)
|
||||
/ cint(self.doc.total_days_in_month), 2)
|
||||
elif not self.doc.payment_days:
|
||||
d.e_modified_amount = 0
|
||||
@ -176,7 +176,7 @@ class DocType(TransactionBase):
|
||||
self.doc.total_deduction = 0
|
||||
for d in getlist(self.doclist, 'deduction_details'):
|
||||
if cint(d.d_depends_on_lwp) == 1:
|
||||
d.d_modified_amount = round(flt(d.d_amount) * flt(self.doc.payment_days)
|
||||
d.d_modified_amount = _round(flt(d.d_amount) * flt(self.doc.payment_days)
|
||||
/ cint(self.doc.total_days_in_month), 2)
|
||||
elif not self.doc.payment_days:
|
||||
d.d_modified_amount = 0
|
||||
@ -189,7 +189,7 @@ class DocType(TransactionBase):
|
||||
self.calculate_earning_total()
|
||||
self.calculate_ded_total()
|
||||
self.doc.net_pay = flt(self.doc.gross_pay) - flt(self.doc.total_deduction)
|
||||
self.doc.rounded_total = round(self.doc.net_pay)
|
||||
self.doc.rounded_total = _round(self.doc.net_pay)
|
||||
|
||||
def on_submit(self):
|
||||
if(self.doc.email_check == 1):
|
||||
|
@ -13,7 +13,7 @@ def execute():
|
||||
where account = %s and voucher_type = 'Sales Invoice' and voucher_no = %s
|
||||
and ifnull(is_cancelled, 'No') = 'No' limit 1""", (r.debit_to, r.name), as_dict=1)
|
||||
if gle:
|
||||
diff = round((flt(r.grand_total) - flt(gle[0]['debit'])), 2)
|
||||
diff = flt((flt(r.grand_total) - flt(gle[0]['debit'])), 2)
|
||||
|
||||
if abs(diff) == 0.01:
|
||||
# print r.name, r.grand_total, gle[0]['debit'], diff
|
||||
|
@ -103,7 +103,7 @@ cur_frm.cscript.calc_net_total_pkg = function(doc, ps_detail) {
|
||||
net_weight_pkg += flt(item.net_weight) * flt(item.qty);
|
||||
}
|
||||
|
||||
doc.net_weight_pkg = roundNumber(net_weight_pkg, 2);
|
||||
doc.net_weight_pkg = _round(net_weight_pkg, 2);
|
||||
if(!flt(doc.gross_weight_pkg)) {
|
||||
doc.gross_weight_pkg = doc.net_weight_pkg
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user