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

@@ -392,10 +392,15 @@ erpnext.taxes_and_totals = erpnext.stock.StockController.extend({
// rounded totals
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)) {
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"));
}
},

View File

@@ -416,9 +416,6 @@ erpnext.pos.PointOfSale = Class.extend({
var default_mode = me.frm.doc.mode_of_payment ? me.frm.doc.mode_of_payment :
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
var dialog = new frappe.ui.Dialog({
width: 400,
@@ -439,8 +436,9 @@ erpnext.pos.PointOfSale = Class.extend({
precision("paid_amount"));
if (actual_change > 0) {
var rounded_change = actual_change - remainder(actual_change,
smallest_currency_fraction_value, precision("paid_amount"));
var rounded_change =
round_based_on_smallest_currency_fraction(actual_change,
me.frm.doc.currency, precision("paid_amount"));
} else {
var rounded_change = 0;
}