fix: Additional discount calculations in Invoices
This commit is contained in:
parent
621927d9f9
commit
f9da88cb15
@ -34,9 +34,9 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
|||||||
frappe.model.set_value(item.doctype, item.name, "rate", item_rate);
|
frappe.model.set_value(item.doctype, item.name, "rate", item_rate);
|
||||||
},
|
},
|
||||||
|
|
||||||
calculate_taxes_and_totals: function(update_paid_amount) {
|
calculate_taxes_and_totals: async function(update_paid_amount) {
|
||||||
this.discount_amount_applied = false;
|
this.discount_amount_applied = false;
|
||||||
this._calculate_taxes_and_totals();
|
await this._calculate_taxes_and_totals();
|
||||||
this.calculate_discount_amount();
|
this.calculate_discount_amount();
|
||||||
|
|
||||||
// Advance calculation applicable to Sales /Purchase Invoice
|
// Advance calculation applicable to Sales /Purchase Invoice
|
||||||
@ -72,19 +72,20 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_calculate_taxes_and_totals: function() {
|
_calculate_taxes_and_totals: async function() {
|
||||||
frappe.run_serially([
|
this.validate_conversion_rate();
|
||||||
() => this.validate_conversion_rate(),
|
this.calculate_item_values();
|
||||||
() => this.calculate_item_values(),
|
await this.update_item_tax_map();
|
||||||
() => this.update_item_tax_map(),
|
},
|
||||||
() => this.initialize_taxes(),
|
|
||||||
() => this.determine_exclusive_rate(),
|
_calculate_tax_values : function() {
|
||||||
() => this.calculate_net_total(),
|
this.initialize_taxes();
|
||||||
() => this.calculate_taxes(),
|
this.determine_exclusive_rate();
|
||||||
() => this.manipulate_grand_total_for_inclusive_tax(),
|
this.calculate_net_total();
|
||||||
() => this.calculate_totals(),
|
this.calculate_taxes();
|
||||||
() => this._cleanup()
|
this.manipulate_grand_total_for_inclusive_tax();
|
||||||
]);
|
this.calculate_totals();
|
||||||
|
this._cleanup();
|
||||||
},
|
},
|
||||||
|
|
||||||
validate_conversion_rate: function() {
|
validate_conversion_rate: function() {
|
||||||
@ -105,7 +106,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
|||||||
},
|
},
|
||||||
|
|
||||||
calculate_item_values: function() {
|
calculate_item_values: function() {
|
||||||
var me = this;
|
let me = this;
|
||||||
if (!this.discount_amount_applied) {
|
if (!this.discount_amount_applied) {
|
||||||
$.each(this.frm.doc["items"] || [], function(i, item) {
|
$.each(this.frm.doc["items"] || [], function(i, item) {
|
||||||
frappe.model.round_floats_in(item);
|
frappe.model.round_floats_in(item);
|
||||||
@ -266,7 +267,7 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
|||||||
frappe.model.round_floats_in(this.frm.doc, ["total", "base_total", "net_total", "base_net_total"]);
|
frappe.model.round_floats_in(this.frm.doc, ["total", "base_total", "net_total", "base_net_total"]);
|
||||||
},
|
},
|
||||||
|
|
||||||
update_item_tax_map: function() {
|
update_item_tax_map: async function() {
|
||||||
let me = this;
|
let me = this;
|
||||||
let item_codes = [];
|
let item_codes = [];
|
||||||
let item_rates = {};
|
let item_rates = {};
|
||||||
@ -301,6 +302,8 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
me._calculate_tax_values();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user