diff --git a/erpnext/accounts/doctype/pos_invoice/pos_invoice.json b/erpnext/accounts/doctype/pos_invoice/pos_invoice.json index 4b8aa3f8823..7fdfde944f1 100644 --- a/erpnext/accounts/doctype/pos_invoice/pos_invoice.json +++ b/erpnext/accounts/doctype/pos_invoice/pos_invoice.json @@ -664,6 +664,7 @@ "fieldname": "total_billing_amount", "fieldtype": "Currency", "label": "Total Billing Amount", + "options": "currency", "print_hide": 1, "read_only": 1 }, @@ -1531,6 +1532,7 @@ "fieldname": "amount_eligible_for_commission", "fieldtype": "Currency", "label": "Amount Eligible for Commission", + "options": "Company:company:default_currency", "read_only": 1 }, { @@ -1639,7 +1641,7 @@ "icon": "fa fa-file-text", "is_submittable": 1, "links": [], - "modified": "2026-03-30 12:15:57.253316", + "modified": "2026-05-01 02:37:30.580568", "modified_by": "Administrator", "module": "Accounts", "name": "POS Invoice", diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json index 2dc7b366b63..14e97b1c5db 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.json +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.json @@ -1150,6 +1150,7 @@ "hide_seconds": 1, "label": "Rounding Adjustment", "no_copy": 1, + "options": "Company:company:default_currency", "print_hide": 1, "read_only": 1 }, @@ -1162,6 +1163,7 @@ "label": "Rounded Total", "oldfieldname": "rounded_total", "oldfieldtype": "Currency", + "options": "Company:company:default_currency", "print_hide": 1, "read_only": 1 }, @@ -2355,7 +2357,7 @@ "link_fieldname": "consolidated_invoice" } ], - "modified": "2026-03-30 12:17:16.201016", + "modified": "2026-05-01 02:37:29.742764", "modified_by": "Administrator", "module": "Accounts", "name": "Sales Invoice", diff --git a/erpnext/public/js/controllers/transaction.js b/erpnext/public/js/controllers/transaction.js index bc22b56db11..0868c23b916 100644 --- a/erpnext/public/js/controllers/transaction.js +++ b/erpnext/public/js/controllers/transaction.js @@ -870,10 +870,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe me.apply_rule_on_other_items({ key: item }); } }, - () => { - var company_currency = me.get_company_currency(); - me.update_item_grid_labels(company_currency); - }, ]); } }, @@ -1824,63 +1820,51 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe if ( this._last_currency === this.frm.doc.currency && - this._last_price_list_currency === this.frm.doc.price_list_currency + this._last_price_list_currency === this.frm.doc.price_list_currency && + this._last_party_account_currency === this.frm.doc.party_account_currency && + this._last_company_currency === company_currency ) { return; } this._last_currency = this.frm.doc.currency; this._last_price_list_currency = this.frm.doc.price_list_currency; + this._last_party_account_currency = this.frm.doc.party_account_currency; + this._last_company_currency = company_currency; this.change_form_labels(company_currency); this.change_grid_labels(company_currency); this.frm.refresh_fields(); } + get_currency_label_options(company_currency) { + return { + currency: this.frm.doc.currency, + "Company:company:default_currency": company_currency, + party_account_currency: this.frm.doc.party_account_currency, + }; + } + + set_currency_labels_from_options(currency_options, parentfield) { + const doctype = parentfield ? this.frm.fields_dict[parentfield].grid.doctype : this.frm.doc.doctype; + const docfields = frappe.meta.get_docfields(doctype); + + Object.entries(currency_options).forEach(([options, currency]) => { + const fields = docfields + .filter((df) => df.fieldtype === "Currency" && df.options === options) + .map((df) => df.fieldname); + + this.frm.set_currency_labels(fields, currency, parentfield); + }); + } + change_form_labels(company_currency) { let me = this; + const currency_options = this.get_currency_label_options(company_currency); - this.frm.set_currency_labels( - [ - "advance_paid", - "base_total", - "base_net_total", - "base_total_taxes_and_charges", - "base_discount_amount", - "base_taxes_and_charges_added", - "base_taxes_and_charges_deducted", - "total_amount_to_pay", - "base_paid_amount", - "base_write_off_amount", - "base_change_amount", - "base_operating_cost", - "base_raw_material_cost", - "base_total_cost", - "base_secondary_items_cost", - "base_totals_section", - ], - company_currency - ); - - this.frm.set_currency_labels( - [ - "total", - "net_total", - "total_taxes_and_charges", - "discount_amount", - "taxes_and_charges_added", - "taxes_and_charges_deducted", - "tax_withholding_net_total", - "paid_amount", - "write_off_amount", - "operating_cost", - "secondary_items_cost", - "raw_material_cost", - "total_cost", - "totals_section", - ], - this.frm.doc.currency - ); + this.set_currency_labels_from_options(currency_options); + this.frm.set_currency_labels(["totals_section"], this.frm.doc.currency); + this.frm.set_currency_labels(["base_totals_section"], company_currency); this.frm.set_df_property( "conversion_rate", @@ -1956,23 +1940,25 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe change_grid_labels(company_currency) { var me = this; - - this.update_item_grid_labels(company_currency); + const currency_options = this.get_currency_label_options(company_currency); this.toggle_item_grid_columns(company_currency); - if (this.frm.doc.operations && this.frm.doc.operations.length > 0) { - this.frm.set_currency_labels( - ["operating_cost", "hour_rate"], - this.frm.doc.currency, - "operations" - ); - this.frm.set_currency_labels( - ["base_operating_cost", "base_hour_rate"], - company_currency, - "operations" - ); + for (const child_table of [ + "items", + "operations", + "secondary_items", + "taxes", + "advances", + "payment_schedule", + "sales_team", + ]) { + if (this.frm.fields_dict[child_table]) { + this.set_currency_labels_from_options(currency_options, child_table); + } + } + if (this.frm.doc.operations && this.frm.doc.operations.length > 0) { var item_grid = this.frm.fields_dict["operations"].grid; $.each(["base_operating_cost", "base_hour_rate"], function (i, fname) { if (frappe.meta.get_docfield(item_grid.doctype, fname)) @@ -1981,9 +1967,6 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe } if (this.frm.doc.secondary_items && this.frm.doc.secondary_items.length > 0) { - this.frm.set_currency_labels(["rate", "amount"], this.frm.doc.currency, "secondary_items"); - this.frm.set_currency_labels(["base_rate", "base_amount"], company_currency, "secondary_items"); - var item_grid = this.frm.fields_dict["secondary_items"].grid; $.each(["base_rate", "base_amount"], function (i, fname) { if (frappe.meta.get_docfield(item_grid.doctype, fname)) @@ -1991,74 +1974,12 @@ erpnext.TransactionController = class TransactionController extends erpnext.taxe }); } - if (this.frm.doc.taxes && this.frm.doc.taxes.length > 0) { - this.frm.set_currency_labels( - ["tax_amount", "total", "tax_amount_after_discount"], - this.frm.doc.currency, - "taxes" - ); - - this.frm.set_currency_labels( - ["base_tax_amount", "base_total", "base_tax_amount_after_discount"], - company_currency, - "taxes" - ); - } - - if (this.frm.doc.advances && this.frm.doc.advances.length > 0) { - this.frm.set_currency_labels( - ["advance_amount", "allocated_amount"], - this.frm.doc.party_account_currency, - "advances" - ); - } - this.update_payment_schedule_grid_labels(company_currency); } - update_item_grid_labels(company_currency) { - this.frm.set_currency_labels( - [ - "base_rate", - "base_net_rate", - "base_price_list_rate", - "base_amount", - "base_net_amount", - "base_rate_with_margin", - ], - company_currency, - "items" - ); - - this.frm.set_currency_labels( - [ - "rate", - "net_rate", - "price_list_rate", - "amount", - "net_amount", - "stock_uom_rate", - "rate_with_margin", - ], - this.frm.doc.currency, - "items" - ); - } - update_payment_schedule_grid_labels(company_currency) { const me = this; if (this.frm.doc.payment_schedule && this.frm.doc.payment_schedule.length > 0) { - this.frm.set_currency_labels( - ["base_payment_amount", "base_outstanding", "base_paid_amount"], - company_currency, - "payment_schedule" - ); - this.frm.set_currency_labels( - ["payment_amount", "outstanding", "paid_amount"], - this.frm.doc.currency, - "payment_schedule" - ); - var schedule_grid = this.frm.fields_dict["payment_schedule"].grid; $.each(["base_payment_amount", "base_outstanding", "base_paid_amount"], function (i, fname) { if (frappe.meta.get_docfield(schedule_grid.doctype, fname)) diff --git a/erpnext/selling/doctype/sales_order/sales_order.json b/erpnext/selling/doctype/sales_order/sales_order.json index e98fe101fbd..2e0507ab4ca 100644 --- a/erpnext/selling/doctype/sales_order/sales_order.json +++ b/erpnext/selling/doctype/sales_order/sales_order.json @@ -847,6 +847,7 @@ "hide_days": 1, "hide_seconds": 1, "label": "Loyalty Amount", + "options": "Company:company:default_currency", "print_hide": 1, "read_only": 1 }, @@ -1480,6 +1481,7 @@ "fieldname": "amount_eligible_for_commission", "fieldtype": "Currency", "label": "Amount Eligible for Commission", + "options": "Company:company:default_currency", "read_only": 1 }, { @@ -1763,7 +1765,7 @@ "idx": 105, "is_submittable": 1, "links": [], - "modified": "2026-03-30 12:19:27.522646", + "modified": "2026-05-01 02:37:30.937916", "modified_by": "Administrator", "module": "Selling", "name": "Sales Order", diff --git a/erpnext/stock/doctype/delivery_note/delivery_note.json b/erpnext/stock/doctype/delivery_note/delivery_note.json index 3729c7cc2e2..5482d12579b 100644 --- a/erpnext/stock/doctype/delivery_note/delivery_note.json +++ b/erpnext/stock/doctype/delivery_note/delivery_note.json @@ -1266,6 +1266,7 @@ "fieldname": "amount_eligible_for_commission", "fieldtype": "Currency", "label": "Amount Eligible for Commission", + "options": "Company:company:default_currency", "read_only": 1 }, { @@ -1470,7 +1471,7 @@ "idx": 146, "is_submittable": 1, "links": [], - "modified": "2026-03-30 12:19:56.889644", + "modified": "2026-05-01 02:37:31.430649", "modified_by": "Administrator", "module": "Stock", "name": "Delivery Note",