Skip to content

Commit

Permalink
fix: if invoice is return then add amount in proper column
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket322 committed Feb 27, 2025
1 parent fcf3749 commit ccb4bdb
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions erpnext/accounts/report/accounts_receivable/accounts_receivable.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,18 @@ def update_voucher_balance(self, ple):
row.invoiced_in_account_currency += amount_in_account_currency
else:
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:
row.paid -= amount
row.paid_in_account_currency -= amount_in_account_currency
Expand Down Expand Up @@ -421,7 +433,7 @@ def get_invoice_details(self):
# nosemgrep
si_list = frappe.db.sql(
"""
select name, due_date, po_no
select name, due_date, po_no, is_return
from `tabSales Invoice`
where posting_date <= %s
and company = %s
Expand Down Expand Up @@ -453,7 +465,7 @@ def get_invoice_details(self):
# nosemgrep
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`
where
posting_date <= %s
Expand Down

0 comments on commit ccb4bdb

Please sign in to comment.