manipulate grand total for inclusive tax
This commit is contained in:
parent
4944fb33ce
commit
d6822ddd7c
@ -185,6 +185,7 @@ class AccountsController(TransactionBase):
|
|||||||
|
|
||||||
self.calculate_net_total()
|
self.calculate_net_total()
|
||||||
self.calculate_taxes()
|
self.calculate_taxes()
|
||||||
|
self.manipulate_grand_total_for_inclusive_tax()
|
||||||
self.calculate_totals()
|
self.calculate_totals()
|
||||||
self._cleanup()
|
self._cleanup()
|
||||||
|
|
||||||
@ -353,6 +354,19 @@ class AccountsController(TransactionBase):
|
|||||||
self.precision(base_field, item))
|
self.precision(base_field, item))
|
||||||
item.set(base_field, value_in_company_currency)
|
item.set(base_field, value_in_company_currency)
|
||||||
|
|
||||||
|
def manipulate_grand_total_for_inclusive_tax(self):
|
||||||
|
# if fully inclusive taxes and diff
|
||||||
|
if (self.meta.get_field("net_total_export") and self.tax_doclist
|
||||||
|
and all(cint(t.included_in_print_rate) for t in self.tax_doclist)):
|
||||||
|
|
||||||
|
last_tax = self.tax_doclist[-1]
|
||||||
|
|
||||||
|
diff = self.net_total_export - flt(last_tax.total / self.conversion_rate,
|
||||||
|
self.precision("grand_total_export"))
|
||||||
|
|
||||||
|
if diff:
|
||||||
|
last_tax.total = last_tax.total + flt(diff * self.conversion_rate, self.precision("total", last_tax))
|
||||||
|
|
||||||
def calculate_total_advance(self, parenttype, advance_parentfield):
|
def calculate_total_advance(self, parenttype, advance_parentfield):
|
||||||
if self.doctype == parenttype and self.docstatus < 2:
|
if self.doctype == parenttype and self.docstatus < 2:
|
||||||
sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv))
|
sum_of_allocated_amount = sum([flt(adv.allocated_amount, self.precision("allocated_amount", adv))
|
||||||
|
@ -632,6 +632,7 @@ erpnext.TransactionController = erpnext.stock.StockController.extend({
|
|||||||
this.determine_exclusive_rate && this.determine_exclusive_rate();
|
this.determine_exclusive_rate && this.determine_exclusive_rate();
|
||||||
this.calculate_net_total();
|
this.calculate_net_total();
|
||||||
this.calculate_taxes();
|
this.calculate_taxes();
|
||||||
|
this.manipulate_grand_total_for_inclusive_tax && this.manipulate_grand_total_for_inclusive_tax();
|
||||||
this.calculate_totals();
|
this.calculate_totals();
|
||||||
this._cleanup();
|
this._cleanup();
|
||||||
|
|
||||||
|
@ -458,6 +458,26 @@ erpnext.selling.SellingController = erpnext.TransactionController.extend({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
manipulate_grand_total_for_inclusive_tax: function() {
|
||||||
|
// if fully inclusive taxes and diff
|
||||||
|
if (this.frm.tax_doclist.length) {
|
||||||
|
var all_inclusive = frappe.utils.all(this.frm.tax_doclist.map(function(d) {
|
||||||
|
return cint(d.included_in_print_rate);
|
||||||
|
}));
|
||||||
|
|
||||||
|
if (all_inclusive) {
|
||||||
|
var last_tax = this.frm.tax_doclist.slice(-1)[0];
|
||||||
|
|
||||||
|
var diff = this.frm.doc.net_total_export
|
||||||
|
- flt(last_tax.total / this.frm.doc.conversion_rate, precision("grand_total_export"));
|
||||||
|
|
||||||
|
if (diff) {
|
||||||
|
last_tax.total += flt(diff * this.frm.doc.conversion_rate, precision("total", last_tax));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_cleanup: function() {
|
_cleanup: function() {
|
||||||
this._super();
|
this._super();
|
||||||
this.frm.doc.in_words = this.frm.doc.in_words_export = "";
|
this.frm.doc.in_words = this.frm.doc.in_words_export = "";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user