From f16f249a3839ac5143da7573a186ab5db9067490 Mon Sep 17 00:00:00 2001 From: Vishnu Priya Baskaran <145791817+ervishnucs@users.noreply.github.com> Date: Wed, 2 Sep 2026 12:22:24 +0530 Subject: [PATCH] fix(pos): use company-currency change amount when netting pos gl entries (#58599) --- .../sales_invoice/services/gl_composer.py | 2 +- .../sales_invoice/test_sales_invoice.py | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/erpnext/accounts/doctype/sales_invoice/services/gl_composer.py b/erpnext/accounts/doctype/sales_invoice/services/gl_composer.py index ee9635af5a1..abc136f431a 100644 --- a/erpnext/accounts/doctype/sales_invoice/services/gl_composer.py +++ b/erpnext/accounts/doctype/sales_invoice/services/gl_composer.py @@ -476,7 +476,7 @@ class SalesInvoiceGLComposer(BaseGLComposer): for payment_mode in doc.payments: if skip_change_gl_entries and payment_mode.account == doc.account_for_change_amount: - payment_mode.base_amount -= flt(doc.change_amount) + payment_mode.base_amount -= flt(doc.base_change_amount) if payment_mode.base_amount: # POS, make payment entries diff --git a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py index a6ddf05c45e..4eb27964e8f 100644 --- a/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/test_sales_invoice.py @@ -1583,6 +1583,35 @@ class TestSalesInvoice(ERPNextTestSuite): frappe.db.set_single_value("POS Settings", "post_change_gl_entries", 1) + def test_pos_change_amount_multi_currency_gl_entry(self): + from erpnext.accounts.doctype.sales_invoice.services.gl_composer import SalesInvoiceGLComposer + + frappe.db.set_single_value("POS Settings", "post_change_gl_entries", 0) + + si = create_sales_invoice(do_not_save=True) + si.is_pos = 1 + si.currency = "USD" + si.conversion_rate = 50 + si.party_account_currency = "USD" + si.account_for_change_amount = "Cash - _TC" + si.change_amount = 50 + si.base_change_amount = 2500 + si.append( + "payments", + {"mode_of_payment": "Cash", "account": "Cash - _TC", "amount": 150, "base_amount": 7500}, + ) + + gl_entries = [] + SalesInvoiceGLComposer(si).make_pos_gl_entries(gl_entries) + + debtors_entry = next(entry for entry in gl_entries if entry["account"] == si.debit_to) + cash_entry = next(entry for entry in gl_entries if entry["account"] == "Cash - _TC") + + self.assertEqual(flt(debtors_entry["credit"]), 5000.0) + self.assertEqual(flt(cash_entry["debit"]), 5000.0) + + frappe.db.set_single_value("POS Settings", "post_change_gl_entries", 1) + def test_stock_delivered_but_not_billed_gl_on_invoice(self): company = "_Test SDBNB Company" from erpnext.stock.doctype.delivery_note.test_delivery_note import create_delivery_note