Rounding based on smallest circulating currency fraction value

This commit is contained in:
Nabin Hait
2016-01-20 14:46:26 +05:30
parent 002fa6c1d9
commit fb0b24af78
5 changed files with 22 additions and 10 deletions

View File

@@ -5,7 +5,7 @@ from __future__ import unicode_literals
import json
import frappe
from frappe import _, scrub
from frappe.utils import cint, flt, rounded
from frappe.utils import cint, flt, round_based_on_smallest_currency_fraction
from erpnext.setup.utils import get_company_currency
from erpnext.controllers.accounts_controller import validate_conversion_rate, \
validate_taxes_and_charges, validate_inclusive_tax
@@ -319,9 +319,14 @@ class calculate_taxes_and_totals(object):
self.doc.round_floats_in(self.doc, ["grand_total", "base_grand_total"])
if self.doc.meta.get_field("rounded_total"):
self.doc.rounded_total = rounded(self.doc.grand_total)
self.doc.rounded_total = round_based_on_smallest_currency_fraction(self.doc.grand_total,
self.doc.currency, self.doc.precision("rounded_total"))
if self.doc.meta.get_field("base_rounded_total"):
self.doc.base_rounded_total = rounded(self.doc.base_grand_total)
company_currency = get_company_currency(self.doc.company)
self.doc.base_rounded_total = \
round_based_on_smallest_currency_fraction(self.doc.base_grand_total,
company_currency, self.doc.precision("base_rounded_total"))
def _cleanup(self):
for tax in self.doc.get("taxes"):