fix: if invoice is return then add amount in proper column

(cherry picked from commit ccb4bdbe4c)
This commit is contained in:
Sanket322
2025-02-27 13:17:57 +05:30
committed by Mergify
parent f3cafef6a7
commit 0a65217423

View File

@@ -267,6 +267,18 @@ class ReceivablePayableReport:
row.invoiced_in_account_currency += amount_in_account_currency row.invoiced_in_account_currency += amount_in_account_currency
else: else:
if self.is_invoice(ple): if self.is_invoice(ple):
# when invoice has is_return marked
if self.invoice_details.get(row.voucher_no, {}).get("is_return"):
# for Credit Note
if row.voucher_type == "Sales Invoice":
row.credit_note -= amount
row.credit_note_in_account_currency -= amount_in_account_currency
# for Debit Note
else:
row.invoiced -= amount
row.invoiced_in_account_currency -= amount_in_account_currency
return
if row.voucher_no == ple.voucher_no == ple.against_voucher_no: if row.voucher_no == ple.voucher_no == ple.against_voucher_no:
row.paid -= amount row.paid -= amount
row.paid_in_account_currency -= amount_in_account_currency row.paid_in_account_currency -= amount_in_account_currency
@@ -421,7 +433,7 @@ class ReceivablePayableReport:
# nosemgrep # nosemgrep
si_list = frappe.db.sql( si_list = frappe.db.sql(
""" """
select name, due_date, po_no select name, due_date, po_no, is_return
from `tabSales Invoice` from `tabSales Invoice`
where posting_date <= %s where posting_date <= %s
and company = %s and company = %s
@@ -453,7 +465,7 @@ class ReceivablePayableReport:
# nosemgrep # nosemgrep
for pi in frappe.db.sql( for pi in frappe.db.sql(
""" """
select name, due_date, bill_no, bill_date select name, due_date, bill_no, bill_date, is_return
from `tabPurchase Invoice` from `tabPurchase Invoice`
where where
posting_date <= %s posting_date <= %s