From a0155279e0674de130d188febfc05c608712f314 Mon Sep 17 00:00:00 2001 From: ljain112 Date: Tue, 28 Jan 2025 17:54:16 +0530 Subject: [PATCH] fix: update voucher outstanding from payment ledger (cherry picked from commit dd7707035148b4d8a2d36c57f0f5dbc476707734) --- .../purchase_invoice/purchase_invoice.py | 15 ++++++------- .../doctype/sales_invoice/sales_invoice.py | 22 +++++++++++-------- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py index e131b01f9f36..045e754734d2 100644 --- a/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py +++ b/erpnext/accounts/doctype/purchase_invoice/purchase_invoice.py @@ -10,7 +10,6 @@ import erpnext from erpnext.accounts.deferred_revenue import validate_service_stop_date -from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt from erpnext.accounts.doctype.repost_accounting_ledger.repost_accounting_ledger import ( validate_docs_for_deferred_accounting, validate_docs_for_voucher_types, @@ -33,7 +32,7 @@ merge_similar_entries, ) from erpnext.accounts.party import get_due_date, get_party_account -from erpnext.accounts.utils import get_account_currency, get_fiscal_year +from erpnext.accounts.utils import get_account_currency, get_fiscal_year, update_voucher_outstanding from erpnext.assets.doctype.asset.asset import is_cwip_accounting_enabled from erpnext.assets.doctype.asset_category.asset_category import get_asset_category_account from erpnext.buying.utils import check_on_hold_or_closed_status @@ -661,12 +660,12 @@ def cancel_provisional_entries(self): def update_supplier_outstanding(self, update_outstanding): if update_outstanding == "No": - update_outstanding_amt( - self.credit_to, - "Supplier", - self.supplier, - self.doctype, - self.return_against if cint(self.is_return) and self.return_against else self.name, + update_voucher_outstanding( + voucher_type=self.doctype, + voucher_no=self.return_against if cint(self.is_return) and self.return_against else self.name, + account=self.credit_to, + party_type="Supplier", + party=self.supplier, ) def get_gl_entries(self, warehouse_account=None): diff --git a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py index b3ef8e239855..2d96cb5ff8d0 100644 --- a/erpnext/accounts/doctype/sales_invoice/sales_invoice.py +++ b/erpnext/accounts/doctype/sales_invoice/sales_invoice.py @@ -24,7 +24,11 @@ ) from erpnext.accounts.general_ledger import get_round_off_account_and_cost_center from erpnext.accounts.party import get_due_date, get_party_account, get_party_details -from erpnext.accounts.utils import cancel_exchange_gain_loss_journal, get_account_currency +from erpnext.accounts.utils import ( + cancel_exchange_gain_loss_journal, + get_account_currency, + update_voucher_outstanding, +) from erpnext.assets.doctype.asset.depreciation import ( depreciate_asset, get_disposal_account_and_cost_center, @@ -1019,14 +1023,14 @@ def make_gl_entries(self, gl_entries=None, from_repost=False): make_reverse_gl_entries(voucher_type=self.doctype, voucher_no=self.name) if update_outstanding == "No": - from erpnext.accounts.doctype.gl_entry.gl_entry import update_outstanding_amt - - update_outstanding_amt( - self.debit_to, - "Customer", - self.customer, - self.doctype, - self.return_against if cint(self.is_return) and self.return_against else self.name, + update_voucher_outstanding( + voucher_type=self.doctype, + voucher_no=self.return_against + if cint(self.is_return) and self.return_against + else self.name, + account=self.debit_to, + party_type="Customer", + party=self.customer, ) elif self.docstatus == 2 and cint(self.update_stock) and cint(auto_accounting_for_stock):