From dd1020ccfbc3fd432bec8fff95cc19348b3c5b57 Mon Sep 17 00:00:00 2001 From: ruthra kumar Date: Wed, 4 Jun 2025 14:26:15 +0530 Subject: [PATCH] refactor: call procedures based on config (cherry picked from commit e90c6a33bd81227e610f051c3558bf29b6d979d9) # Conflicts: # erpnext/accounts/report/accounts_receivable/accounts_receivable.py --- .../accounts_receivable.py | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py index 46424fcae11..eb5f480f5fe 100644 --- a/erpnext/accounts/report/accounts_receivable/accounts_receivable.py +++ b/erpnext/accounts/report/accounts_receivable/accounts_receivable.py @@ -114,10 +114,15 @@ class ReceivablePayableReport: self.fetch_ple_in_buffered_cursor() elif self.ple_fetch_method == "UnBuffered Cursor": self.fetch_ple_in_unbuffered_cursor() +<<<<<<< HEAD <<<<<<< HEAD ======= self.init_and_run_sql_procedures() +======= + elif self.ple_fetch_method == "Raw SQL": + self.init_and_run_sql_procedures() +>>>>>>> e90c6a33bd (refactor: call procedures based on config) # Build delivery note map against all sales invoices self.build_delivery_note_map() @@ -343,24 +348,40 @@ class ReceivablePayableReport: voucher_type, voucher_no, party, - party_account, + party_account `account`, posting_date, account_currency, - sum(invoiced), - sum(paid), - sum(credit_note), - sum(invoiced) - sum(paid) - sum(credit_note), - sum(invoiced_in_account_currency), - sum(paid_in_account_currency), - sum(credit_note_in_account_currency), - sum(invoiced_in_account_currency) - sum(paid_in_account_currency) - sum(credit_note_in_account_currency) - from `{self.proc._voucher_balance_name}` group by name;""" + sum(invoiced) `invoiced`, + sum(paid) `paid`, + sum(credit_note) `credit_note`, + sum(invoiced) - sum(paid) - sum(credit_note) `outstanding`, + sum(invoiced_in_account_currency) `invoiced_in_account_currency`, + sum(paid_in_account_currency) `paid_in_account_currency`, + sum(credit_note_in_account_currency) `credit_note_in_account_currency`, + sum(invoiced_in_account_currency) - sum(paid_in_account_currency) - sum(credit_note_in_account_currency) `outstanding_in_account_currency` + from `{self.proc._voucher_balance_name}` group by name;""", + as_dict=True, ) - self.printv(res) - - def printv(self, res): for x in res: - print(x) + if self.filters.get("ignore_accounts"): + key = (x.voucher_type, x.voucher_no, x.party) + else: + key = (x.account, x.voucher_type, x.voucher_no, x.party) + + _d = self.build_voucher_dict(x) + for field in [ + "invoiced", + "paid", + "credit_note", + "outstanding", + "invoiced_in_account_currency", + "paid_in_account_currency", + "credit_note_in_account_currency", + "outstanding_in_account_currency", + ]: + _d[field] = x.get(field) + + self.voucher_balance[key] = _d def update_sub_total_row(self, row, party): total_row = self.total_row_map.get(party)