fix: Rate change issue on save and mapping from other doc
(cherry picked from commit 13fcda57767c456dfca4c064c41ca4f80a1898b2)
This commit is contained in:
parent
c4854bb1b1
commit
174a6ec398
@ -399,6 +399,8 @@ def make_return_doc(doctype, source_name, target_doc=None):
|
||||
}
|
||||
}, target_doc, set_missing_values)
|
||||
|
||||
doclist.set_onload('ignore_price_list', True)
|
||||
|
||||
return doclist
|
||||
|
||||
def get_rate_for_return(voucher_type, voucher_no, item_code, return_against=None,
|
||||
|
@ -14,31 +14,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
|
||||
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);
|
||||
@ -1042,9 +1017,9 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
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) {
|
||||
@ -1144,8 +1119,8 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe
|
||||
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user