frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
21.17k stars 7.24k forks source link

Pricing change after change the date (reappear) #32954

Open kanedai opened 1 year ago

kanedai commented 1 year ago

Information about bug

Pre-work: 1, Multi-currency working environment 2, New Currency Exchange Date: 2022-11-13 Exchange Rate 7 Date: 2022-11-14 Exchange Rate 6 Step: 1, New Quotation 2, Use foreign currency and price list. 3, Insert some items, (some items will fetch from the price list) 4, Change price for some items. 5, Save. (So far everything is fine) 6, Change date of the quotation from 2022-11-14 to 2022-11-13, the exchange rate will be change from 7 to 6, then all item rate will re-fetch from the price list.

this issue seems totally the same as #31179

Module

selling buying accounting

Version

erpnext 13.41.1 frappe 13.43.2

Installation method

No response

Relevant log output / Stack trace / Full Error Message.

No response

kanedai commented 1 year ago

Sames as https://github.com/frappe/erpnext/pull/30990

szufisher commented 1 year ago

as temporary solution, replaced the following field events with changes as below (original file https://github.com/frappe/erpnext/blob/version-13/erpnext/public/js/controllers/transaction.js)

currency: line 1028~1035 old

            this.get_exchange_rate(transaction_date, this.frm.doc.currency, company_currency,
                function(exchange_rate) {
                    if(exchange_rate != me.frm.doc.conversion_rate) {
                        me.set_margin_amount_based_on_currency(exchange_rate);
                        me.set_actual_charges_based_on_currency(exchange_rate);
                        me.frm.set_value("conversion_rate", exchange_rate);
                    }
                });

new, changes, remark this line me.set_margin_amount_based_on_currency(exchange_rate); add new line me.calculate_taxes_and_totals();

            this.get_exchange_rate(transaction_date, this.frm.doc.currency, company_currency,
                function(exchange_rate) {
                    if(exchange_rate != me.frm.doc.conversion_rate) {
                        //me.set_margin_amount_based_on_currency(exchange_rate);
                        me.set_actual_charges_based_on_currency(exchange_rate);
                        me.frm.set_value("conversion_rate", exchange_rate);
                                                me.calculate_taxes_and_totals();
                    }
                });

conversion rate, line 1057~1062

old

        if(flt(this.frm.doc.conversion_rate)>0.0) {
            if(this.frm.doc.__onload && this.frm.doc.__onload.ignore_price_list) {
                this.calculate_taxes_and_totals();
            } else if (!this.in_apply_price_list){
                this.apply_price_list();
            }

new, changes: remark the apply_price_list line

        if(flt(this.frm.doc.conversion_rate)>0.0) {
            if(this.frm.doc.__onload && this.frm.doc.__onload.ignore_price_list) {
                this.calculate_taxes_and_totals();
            //} else if (!this.in_apply_price_list){
            //  this.apply_price_list();
            }

plc_conversion_rate, line 1156~1158

changes: remarks these lines

if(!this.in_apply_price_list) {
            this.apply_price_list(null, true);
        }
swistakm commented 1 year ago

The same problem has been reported in #29640

williamluke4 commented 11 months ago

This also seems to happen when updating the price list exchange rate in a sales order