fix: Rate change issue on save and mapping from other doc
(cherry picked from commit 13fcda5776)
This commit is contained in:
committed by
mergify-bot
parent
a5b29c1722
commit
8ff47999ab
@@ -14,31 +14,6 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
|
||||
frappe.model.round_floats_in(item, ["rate", "price_list_rate"]);
|
||||
|
||||
if(item.price_list_rate) {
|
||||
if(item.rate > item.price_list_rate && has_margin_field) {
|
||||
// if rate is greater than price_list_rate, set margin
|
||||
// or set discount
|
||||
item.discount_percentage = 0;
|
||||
item.margin_type = 'Amount';
|
||||
item.margin_rate_or_amount = flt(item.rate - item.price_list_rate,
|
||||
precision("margin_rate_or_amount", item));
|
||||
item.rate_with_margin = item.rate;
|
||||
} else {
|
||||
item.discount_percentage = flt((1 - item.rate / item.price_list_rate) * 100.0,
|
||||
precision("discount_percentage", item));
|
||||
item.discount_amount = flt(item.price_list_rate) - flt(item.rate);
|
||||
item.margin_type = '';
|
||||
item.margin_rate_or_amount = 0;
|
||||
item.rate_with_margin = 0;
|
||||
}
|
||||
} else {
|
||||
item.discount_percentage = 0.0;
|
||||
item.margin_type = '';
|
||||
item.margin_rate_or_amount = 0;
|
||||
item.rate_with_margin = 0;
|
||||
}
|
||||
item.base_rate_with_margin = item.rate_with_margin * flt(frm.doc.conversion_rate);
|
||||
|
||||
cur_frm.cscript.set_gross_profit(item);
|
||||
cur_frm.cscript.calculate_taxes_and_totals();
|
||||
cur_frm.cscript.calculate_stock_uom_rate(frm, cdt, cdn);
|
||||
@@ -1021,9 +996,9 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
var me = this;
|
||||
this.set_dynamic_labels();
|
||||
var company_currency = this.get_company_currency();
|
||||
// Added `ignore_pricing_rule` to determine if document is loading after mapping from another doc
|
||||
// Added `ignore_price_list` to determine if document is loading after mapping from another doc
|
||||
if(this.frm.doc.currency && this.frm.doc.currency !== company_currency
|
||||
&& !this.frm.doc.ignore_pricing_rule) {
|
||||
&& !this.frm.doc.__onload.ignore_price_list) {
|
||||
|
||||
this.get_exchange_rate(transaction_date, this.frm.doc.currency, company_currency,
|
||||
function(exchange_rate) {
|
||||
@@ -1123,8 +1098,8 @@ erpnext.TransactionController = erpnext.taxes_and_totals.extend({
|
||||
this.set_dynamic_labels();
|
||||
|
||||
var company_currency = this.get_company_currency();
|
||||
// Added `ignore_pricing_rule` to determine if document is loading after mapping from another doc
|
||||
if(this.frm.doc.price_list_currency !== company_currency && !this.frm.doc.ignore_pricing_rule) {
|
||||
// Added `ignore_price_list` to determine if document is loading after mapping from another doc
|
||||
if(this.frm.doc.price_list_currency !== company_currency && !this.frm.doc.__onload.ignore_price_list) {
|
||||
this.get_exchange_rate(this.frm.doc.posting_date, this.frm.doc.price_list_currency, company_currency,
|
||||
function(exchange_rate) {
|
||||
me.frm.set_value("plc_conversion_rate", exchange_rate);
|
||||
|
||||
Reference in New Issue
Block a user