net_total and grand_total mismatch issue
This commit is contained in:
parent
e0ce9407cb
commit
5e13e0c316
@ -209,26 +209,17 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
|
|
||||||
calculate_totals: function() {
|
calculate_totals: function() {
|
||||||
var tax_count = this.frm.tax_doclist.length;
|
var tax_count = this.frm.tax_doclist.length;
|
||||||
this.frm.doc.grand_total = flt(tax_count ?
|
this.frm.doc.grand_total = flt(tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total);
|
||||||
this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total);
|
|
||||||
this.frm.doc.grand_total_import = flt(tax_count ?
|
|
||||||
flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate) : this.frm.doc.net_total_import);
|
|
||||||
|
|
||||||
this.frm.doc.total_tax = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
|
this.frm.doc.total_tax = flt(this.frm.doc.grand_total - this.frm.doc.net_total, precision("total_tax"));
|
||||||
precision("total_tax"));
|
|
||||||
|
|
||||||
this.frm.doc.grand_total = flt(this.frm.doc.grand_total, precision("grand_total"));
|
this.frm.doc.grand_total = flt(this.frm.doc.grand_total, precision("grand_total"));
|
||||||
this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total_import, precision("grand_total_import"));
|
|
||||||
|
|
||||||
// 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 = Math.round(this.frm.doc.grand_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total_import", this.frm.doc.name)) {
|
|
||||||
this.frm.doc.rounded_total_import = Math.round(this.frm.doc.grand_total_import);
|
|
||||||
}
|
|
||||||
|
|
||||||
// other charges added/deducted
|
// other charges added/deducted
|
||||||
this.frm.doc.other_charges_added = 0.0
|
this.frm.doc.other_charges_added = 0.0
|
||||||
this.frm.doc.other_charges_deducted = 0.0
|
this.frm.doc.other_charges_deducted = 0.0
|
||||||
@ -246,6 +237,16 @@ erpnext.buying.BuyingController = erpnext.TransactionController.extend({
|
|||||||
frappe.model.round_floats_in(this.frm.doc,
|
frappe.model.round_floats_in(this.frm.doc,
|
||||||
["other_charges_added", "other_charges_deducted"]);
|
["other_charges_added", "other_charges_deducted"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.frm.doc.grand_total_import = flt((this.frm.doc.other_charges_added || this.frm.doc.other_charges_deducted) ?
|
||||||
|
flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate) : this.frm.doc.net_total_import);
|
||||||
|
|
||||||
|
this.frm.doc.grand_total_import = flt(this.frm.doc.grand_total_import, precision("grand_total_import"));
|
||||||
|
|
||||||
|
if(frappe.meta.get_docfield(this.frm.doc.doctype, "rounded_total_import", this.frm.doc.name)) {
|
||||||
|
this.frm.doc.rounded_total_import = Math.round(this.frm.doc.grand_total_import);
|
||||||
|
}
|
||||||
|
|
||||||
this.frm.doc.other_charges_added_import = flt(this.frm.doc.other_charges_added /
|
this.frm.doc.other_charges_added_import = flt(this.frm.doc.other_charges_added /
|
||||||
this.frm.doc.conversion_rate, precision("other_charges_added_import"));
|
this.frm.doc.conversion_rate, precision("other_charges_added_import"));
|
||||||
this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted /
|
this.frm.doc.other_charges_deducted_import = flt(this.frm.doc.other_charges_deducted /
|
||||||
|
|||||||
@ -91,8 +91,7 @@ class BuyingController(StockController):
|
|||||||
item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
|
item.rate = flt(item.price_list_rate * (1.0 - (item.discount_percentage / 100.0)),
|
||||||
self.precision("rate", item))
|
self.precision("rate", item))
|
||||||
|
|
||||||
item.amount = flt(item.rate * item.qty,
|
item.amount = flt(item.rate * item.qty, self.precision("amount", item))
|
||||||
self.precision("amount", item))
|
|
||||||
item.item_tax_amount = 0.0;
|
item.item_tax_amount = 0.0;
|
||||||
|
|
||||||
self._set_in_company_currency(item, "amount", "base_amount")
|
self._set_in_company_currency(item, "amount", "base_amount")
|
||||||
@ -111,20 +110,14 @@ class BuyingController(StockController):
|
|||||||
|
|
||||||
def calculate_totals(self):
|
def calculate_totals(self):
|
||||||
self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist else self.net_total)
|
self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist else self.net_total)
|
||||||
self.grand_total_import = flt(self.grand_total / self.conversion_rate) \
|
|
||||||
if self.tax_doclist else self.net_total_import
|
|
||||||
|
|
||||||
self.total_tax = flt(self.grand_total - self.net_total, self.precision("total_tax"))
|
self.total_tax = flt(self.grand_total - self.net_total, self.precision("total_tax"))
|
||||||
|
|
||||||
self.grand_total = flt(self.grand_total, self.precision("grand_total"))
|
self.grand_total = flt(self.grand_total, self.precision("grand_total"))
|
||||||
self.grand_total_import = flt(self.grand_total_import, self.precision("grand_total_import"))
|
|
||||||
|
|
||||||
if self.meta.get_field("rounded_total"):
|
if self.meta.get_field("rounded_total"):
|
||||||
self.rounded_total = rounded(self.grand_total)
|
self.rounded_total = rounded(self.grand_total)
|
||||||
|
|
||||||
if self.meta.get_field("rounded_total_import"):
|
|
||||||
self.rounded_total_import = rounded(self.grand_total_import)
|
|
||||||
|
|
||||||
if self.meta.get_field("other_charges_added"):
|
if self.meta.get_field("other_charges_added"):
|
||||||
self.other_charges_added = flt(sum([flt(d.tax_amount) for d in self.tax_doclist
|
self.other_charges_added = flt(sum([flt(d.tax_amount) for d in self.tax_doclist
|
||||||
if d.add_deduct_tax=="Add" and d.category in ["Valuation and Total", "Total"]]),
|
if d.add_deduct_tax=="Add" and d.category in ["Valuation and Total", "Total"]]),
|
||||||
@ -135,6 +128,14 @@ class BuyingController(StockController):
|
|||||||
if d.add_deduct_tax=="Deduct" and d.category in ["Valuation and Total", "Total"]]),
|
if d.add_deduct_tax=="Deduct" and d.category in ["Valuation and Total", "Total"]]),
|
||||||
self.precision("other_charges_deducted"))
|
self.precision("other_charges_deducted"))
|
||||||
|
|
||||||
|
self.grand_total_import = flt(self.grand_total / self.conversion_rate) \
|
||||||
|
if (self.other_charges_added or self.other_charges_deducted) else self.net_total_import
|
||||||
|
|
||||||
|
self.grand_total_import = flt(self.grand_total_import, self.precision("grand_total_import"))
|
||||||
|
|
||||||
|
if self.meta.get_field("rounded_total_import"):
|
||||||
|
self.rounded_total_import = rounded(self.grand_total_import)
|
||||||
|
|
||||||
if self.meta.get_field("other_charges_added_import"):
|
if self.meta.get_field("other_charges_added_import"):
|
||||||
self.other_charges_added_import = flt(self.other_charges_added /
|
self.other_charges_added_import = flt(self.other_charges_added /
|
||||||
self.conversion_rate, self.precision("other_charges_added_import"))
|
self.conversion_rate, self.precision("other_charges_added_import"))
|
||||||
|
|||||||
@ -218,10 +218,11 @@ class SellingController(StockController):
|
|||||||
def calculate_totals(self):
|
def calculate_totals(self):
|
||||||
self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist else self.net_total)
|
self.grand_total = flt(self.tax_doclist[-1].total if self.tax_doclist else self.net_total)
|
||||||
|
|
||||||
self.grand_total_export = flt(self.grand_total / self.conversion_rate)
|
|
||||||
|
|
||||||
self.other_charges_total = flt(self.grand_total - self.net_total, self.precision("other_charges_total"))
|
self.other_charges_total = flt(self.grand_total - self.net_total, self.precision("other_charges_total"))
|
||||||
|
|
||||||
|
self.grand_total_export = flt(self.grand_total / self.conversion_rate) \
|
||||||
|
if (self.other_charges_total or self.discount_amount) else self.net_total_export
|
||||||
|
|
||||||
self.other_charges_total_export = flt(self.grand_total_export - self.net_total_export +
|
self.other_charges_total_export = flt(self.grand_total_export - self.net_total_export +
|
||||||
flt(self.discount_amount), self.precision("other_charges_total_export"))
|
flt(self.discount_amount), self.precision("other_charges_total_export"))
|
||||||
|
|
||||||
|
|||||||
@ -342,10 +342,13 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
var tax_count = this.frm.tax_doclist.length;
|
var tax_count = this.frm.tax_doclist.length;
|
||||||
|
|
||||||
this.frm.doc.grand_total = flt(tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total);
|
this.frm.doc.grand_total = flt(tax_count ? this.frm.tax_doclist[tax_count - 1].total : this.frm.doc.net_total);
|
||||||
this.frm.doc.grand_total_export = flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate);
|
|
||||||
|
|
||||||
this.frm.doc.other_charges_total = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
|
this.frm.doc.other_charges_total = flt(this.frm.doc.grand_total - this.frm.doc.net_total,
|
||||||
precision("other_charges_total"));
|
precision("other_charges_total"));
|
||||||
|
|
||||||
|
this.frm.doc.grand_total_export = (this.frm.doc.other_charges_total || this.frm.doc.discount_amount) ?
|
||||||
|
flt(this.frm.doc.grand_total / this.frm.doc.conversion_rate) : this.frm.doc.net_total_export;
|
||||||
|
|
||||||
this.frm.doc.other_charges_total_export = flt(this.frm.doc.grand_total_export -
|
this.frm.doc.other_charges_total_export = flt(this.frm.doc.grand_total_export -
|
||||||
this.frm.doc.net_total_export + flt(this.frm.doc.discount_amount),
|
this.frm.doc.net_total_export + flt(this.frm.doc.discount_amount),
|
||||||
precision("other_charges_total_export"));
|
precision("other_charges_total_export"));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user