Merge branch 'version-13-pre-release' into version-13

This commit is contained in:
Nabin Hait 2021-07-22 17:05:51 +05:30
commit 338f436a1c
3 changed files with 54 additions and 59 deletions

View File

@ -5,7 +5,7 @@ import frappe
from erpnext.hooks import regional_overrides from erpnext.hooks import regional_overrides
from frappe.utils import getdate from frappe.utils import getdate
__version__ = '13.7.0' __version__ = '13.7.1'
def get_default_company(user=None): def get_default_company(user=None):
'''Get default company for user''' '''Get default company for user'''

View File

@ -75,18 +75,15 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
}, },
_calculate_taxes_and_totals: function() { _calculate_taxes_and_totals: function() {
frappe.run_serially([ this.validate_conversion_rate();
() => this.validate_conversion_rate(), this.calculate_item_values();
() => this.calculate_item_values(), this.initialize_taxes();
() => this.update_item_tax_map(), this.determine_exclusive_rate();
() => this.initialize_taxes(), this.calculate_net_total();
() => this.determine_exclusive_rate(), this.calculate_taxes();
() => this.calculate_net_total(), this.manipulate_grand_total_for_inclusive_tax();
() => this.calculate_taxes(), this.calculate_totals();
() => this.manipulate_grand_total_for_inclusive_tax(), this._cleanup();
() => this.calculate_totals(),
() => this._cleanup()
]);
}, },
validate_conversion_rate: function() { validate_conversion_rate: function() {
@ -107,7 +104,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);
@ -268,46 +265,6 @@ 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() {
let me = this;
let item_codes = [];
let item_rates = {};
let item_tax_templates = {};
$.each(this.frm.doc.items || [], function(i, item) {
if (item.item_code) {
// Use combination of name and item code in case same item is added multiple times
item_codes.push([item.item_code, item.name]);
item_rates[item.name] = item.net_rate;
item_tax_templates[item.name] = item.item_tax_template;
}
});
if (item_codes.length) {
return this.frm.call({
method: "erpnext.stock.get_item_details.get_item_tax_info",
args: {
company: me.frm.doc.company,
tax_category: cstr(me.frm.doc.tax_category),
item_codes: item_codes,
item_rates: item_rates,
item_tax_templates: item_tax_templates
},
callback: function(r) {
if (!r.exc) {
$.each(me.frm.doc.items || [], function(i, item) {
if (item.name && r.message.hasOwnProperty(item.name) && r.message[item.name].item_tax_template) {
item.item_tax_template = r.message[item.name].item_tax_template;
item.item_tax_rate = r.message[item.name].item_tax_rate;
me.add_taxes_from_item_tax_template(item.item_tax_rate);
}
});
}
}
});
}
},
add_taxes_from_item_tax_template: function(item_tax_map) { add_taxes_from_item_tax_template: function(item_tax_map) {
let me = this; let me = this;
@ -632,8 +589,6 @@ erpnext.taxes_and_totals = erpnext.payments.extend({
tax.item_wise_tax_detail = JSON.stringify(tax.item_wise_tax_detail); tax.item_wise_tax_detail = JSON.stringify(tax.item_wise_tax_detail);
}); });
} }
this.frm.refresh_fields();
}, },
set_discount_amount: function() { set_discount_amount: function() {

View File

@ -826,9 +826,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
frappe.run_serially([ frappe.run_serially([
() => me.frm.script_manager.trigger("currency"), () => me.frm.script_manager.trigger("currency"),
() => me.update_item_tax_map(),
() => me.apply_default_taxes(), () => me.apply_default_taxes(),
() => me.apply_pricing_rule(), () => me.apply_pricing_rule()
() => me.calculate_taxes_and_totals()
]); ]);
} }
} }
@ -1787,6 +1787,46 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
]); ]);
}, },
update_item_tax_map: function() {
let me = this;
let item_codes = [];
let item_rates = {};
let item_tax_templates = {};
$.each(this.frm.doc.items || [], function(i, item) {
if (item.item_code) {
// Use combination of name and item code in case same item is added multiple times
item_codes.push([item.item_code, item.name]);
item_rates[item.name] = item.net_rate;
item_tax_templates[item.name] = item.item_tax_template;
}
});
if (item_codes.length) {
return this.frm.call({
method: "erpnext.stock.get_item_details.get_item_tax_info",
args: {
company: me.frm.doc.company,
tax_category: cstr(me.frm.doc.tax_category),
item_codes: item_codes,
item_rates: item_rates,
item_tax_templates: item_tax_templates
},
callback: function(r) {
if (!r.exc) {
$.each(me.frm.doc.items || [], function(i, item) {
if (item.name && r.message.hasOwnProperty(item.name) && r.message[item.name].item_tax_template) {
item.item_tax_template = r.message[item.name].item_tax_template;
item.item_tax_rate = r.message[item.name].item_tax_rate;
me.add_taxes_from_item_tax_template(item.item_tax_rate);
}
});
}
}
});
}
},
item_tax_template: function(doc, cdt, cdn) { item_tax_template: function(doc, cdt, cdn) {
var me = this; var me = this;
if(me.frm.updating_party_details) return; if(me.frm.updating_party_details) return;