Merge pull request #30413 from frappe/mergify/bp/develop/pr-30406

fix: Rate change issue on save and mapping from other doc (backport #30406)
This commit is contained in:
Deepesh Garg 2022-03-25 14:17:48 +05:30 committed by GitHub
commit 3a639f6329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 11 deletions

View File

@ -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,

View File

@ -114,20 +114,16 @@ class calculate_taxes_and_totals(object):
for item in self.doc.get("items"):
self.doc.round_floats_in(item)
if not item.rate:
item.rate = item.price_list_rate
if item.discount_percentage == 100:
item.rate = 0.0
elif item.price_list_rate:
if item.pricing_rules or abs(item.discount_percentage) > 0:
if not item.rate or (item.pricing_rules and item.discount_percentage > 0):
item.rate = flt(item.price_list_rate *
(1.0 - (item.discount_percentage / 100.0)), item.precision("rate"))
if abs(item.discount_percentage) > 0:
item.discount_amount = item.price_list_rate * (item.discount_percentage / 100.0)
item.discount_amount = item.price_list_rate * (item.discount_percentage / 100.0)
elif item.discount_amount or item.pricing_rules:
elif item.discount_amount and item.pricing_rules:
item.rate = item.price_list_rate - item.discount_amount
if item.doctype in ['Quotation Item', 'Sales Order Item', 'Delivery Note Item', 'Sales Invoice Item',

View File

@ -1042,9 +1042,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 +1144,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);