Rounding based on smallest circulating currency fraction value
This commit is contained in:
parent
002fa6c1d9
commit
fb0b24af78
@ -5,7 +5,7 @@ from __future__ import unicode_literals
|
|||||||
import json
|
import json
|
||||||
import frappe
|
import frappe
|
||||||
from frappe import _, scrub
|
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.setup.utils import get_company_currency
|
||||||
from erpnext.controllers.accounts_controller import validate_conversion_rate, \
|
from erpnext.controllers.accounts_controller import validate_conversion_rate, \
|
||||||
validate_taxes_and_charges, validate_inclusive_tax
|
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"])
|
self.doc.round_floats_in(self.doc, ["grand_total", "base_grand_total"])
|
||||||
|
|
||||||
if self.doc.meta.get_field("rounded_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"):
|
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):
|
def _cleanup(self):
|
||||||
for tax in self.doc.get("taxes"):
|
for tax in self.doc.get("taxes"):
|
||||||
|
@ -20,6 +20,7 @@ execute:frappe.reload_doc('stock', 'doctype', 'purchase_receipt') # 2014-01-29
|
|||||||
execute:frappe.reload_doc('accounts', 'doctype', 'pos_setting') # 2014-01-29
|
execute:frappe.reload_doc('accounts', 'doctype', 'pos_setting') # 2014-01-29
|
||||||
execute:frappe.reload_doc('selling', 'doctype', 'customer') # 2014-01-29
|
execute:frappe.reload_doc('selling', 'doctype', 'customer') # 2014-01-29
|
||||||
execute:frappe.reload_doc('buying', 'doctype', 'supplier') # 2014-01-29
|
execute:frappe.reload_doc('buying', 'doctype', 'supplier') # 2014-01-29
|
||||||
|
execute:frappe.reload_doctype('Item')
|
||||||
erpnext.patches.v4_0.map_charge_to_taxes_and_charges
|
erpnext.patches.v4_0.map_charge_to_taxes_and_charges
|
||||||
execute:frappe.reload_doc('support', 'doctype', 'newsletter') # 2014-01-31
|
execute:frappe.reload_doc('support', 'doctype', 'newsletter') # 2014-01-31
|
||||||
execute:frappe.reload_doc('hr', 'doctype', 'employee') # 2014-02-03
|
execute:frappe.reload_doc('hr', 'doctype', 'employee') # 2014-02-03
|
||||||
|
@ -392,10 +392,15 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
|
|||||||
|
|
||||||
// rounded totals
|
// rounded totals
|
||||||
if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) {
|
if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total", this.frm.doc.name)) {
|
||||||
this.frm.doc.rounded_total = Math.round(this.frm.doc.grand_total);
|
this.frm.doc.rounded_total = round_based_on_smallest_currency_fraction(this.frm.doc.grand_total,
|
||||||
|
this.frm.doc.currency, precision("rounded_total"));
|
||||||
}
|
}
|
||||||
if(frappe.meta.get_docfield(this.frm.doc.doctype, "base_rounded_total", this.frm.doc.name)) {
|
if(frappe.meta.get_docfield(this.frm.doc.doctype, "base_rounded_total", this.frm.doc.name)) {
|
||||||
this.frm.doc.base_rounded_total = Math.round(this.frm.doc.base_grand_total);
|
var company_currency = this.get_company_currency();
|
||||||
|
|
||||||
|
this.frm.doc.base_rounded_total =
|
||||||
|
round_based_on_smallest_currency_fraction(this.frm.doc.base_grand_total,
|
||||||
|
company_currency, precision("base_rounded_total"));
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -416,9 +416,6 @@ erpnext.pos.PointOfSale = Class.extend({
|
|||||||
var default_mode = me.frm.doc.mode_of_payment ? me.frm.doc.mode_of_payment :
|
var default_mode = me.frm.doc.mode_of_payment ? me.frm.doc.mode_of_payment :
|
||||||
me.modes_of_payment.indexOf(__("Cash"))!==-1 ? __("Cash") : undefined;
|
me.modes_of_payment.indexOf(__("Cash"))!==-1 ? __("Cash") : undefined;
|
||||||
|
|
||||||
var smallest_currency_fraction_value = flt(frappe.model.get_value(":Currency",
|
|
||||||
me.frm.doc.currency, "smallest_currency_fraction_value"))
|
|
||||||
|
|
||||||
// show payment wizard
|
// show payment wizard
|
||||||
var dialog = new frappe.ui.Dialog({
|
var dialog = new frappe.ui.Dialog({
|
||||||
width: 400,
|
width: 400,
|
||||||
@ -439,8 +436,9 @@ erpnext.pos.PointOfSale = Class.extend({
|
|||||||
precision("paid_amount"));
|
precision("paid_amount"));
|
||||||
|
|
||||||
if (actual_change > 0) {
|
if (actual_change > 0) {
|
||||||
var rounded_change = actual_change - remainder(actual_change,
|
var rounded_change =
|
||||||
smallest_currency_fraction_value, precision("paid_amount"));
|
round_based_on_smallest_currency_fraction(actual_change,
|
||||||
|
me.frm.doc.currency, precision("paid_amount"));
|
||||||
} else {
|
} else {
|
||||||
var rounded_change = 0;
|
var rounded_change = 0;
|
||||||
}
|
}
|
||||||
|
@ -106,6 +106,7 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
mr.submit()
|
mr.submit()
|
||||||
|
|
||||||
# check if per complete is None
|
# check if per complete is None
|
||||||
|
mr.load_from_db()
|
||||||
self.assertEquals(mr.per_ordered, 0)
|
self.assertEquals(mr.per_ordered, 0)
|
||||||
self.assertEquals(mr.get("items")[0].ordered_qty, 0)
|
self.assertEquals(mr.get("items")[0].ordered_qty, 0)
|
||||||
self.assertEquals(mr.get("items")[1].ordered_qty, 0)
|
self.assertEquals(mr.get("items")[1].ordered_qty, 0)
|
||||||
@ -173,6 +174,7 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
mr.submit()
|
mr.submit()
|
||||||
|
|
||||||
# check if per complete is None
|
# check if per complete is None
|
||||||
|
mr.load_from_db()
|
||||||
self.assertEquals(mr.per_ordered, 0)
|
self.assertEquals(mr.per_ordered, 0)
|
||||||
self.assertEquals(mr.get("items")[0].ordered_qty, 0)
|
self.assertEquals(mr.get("items")[0].ordered_qty, 0)
|
||||||
self.assertEquals(mr.get("items")[1].ordered_qty, 0)
|
self.assertEquals(mr.get("items")[1].ordered_qty, 0)
|
||||||
@ -262,6 +264,7 @@ class TestMaterialRequest(unittest.TestCase):
|
|||||||
mr.submit()
|
mr.submit()
|
||||||
|
|
||||||
# check if per complete is None
|
# check if per complete is None
|
||||||
|
mr.load_from_db()
|
||||||
self.assertEquals(mr.per_ordered, 0)
|
self.assertEquals(mr.per_ordered, 0)
|
||||||
self.assertEquals(mr.get("items")[0].ordered_qty, 0)
|
self.assertEquals(mr.get("items")[0].ordered_qty, 0)
|
||||||
self.assertEquals(mr.get("items")[1].ordered_qty, 0)
|
self.assertEquals(mr.get("items")[1].ordered_qty, 0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user