mirror of
https://github.com/frappe/erpnext.git
synced 2026-05-26 16:34:46 +00:00
Merge pull request #46261 from frappe/mergify/bp/version-15-hotfix/pr-46172
fix: Show Credit Note amount in credit note column (backport #46172)
This commit is contained in:
@@ -38,6 +38,23 @@ class TestAccountsPayable(AccountsTestMixin, FrappeTestCase):
|
|||||||
self.assertEqual(data[1][0].get("outstanding"), 300)
|
self.assertEqual(data[1][0].get("outstanding"), 300)
|
||||||
self.assertEqual(data[1][0].get("currency"), "USD")
|
self.assertEqual(data[1][0].get("currency"), "USD")
|
||||||
|
|
||||||
|
def test_account_payable_for_debit_note(self):
|
||||||
|
pi = self.create_purchase_invoice(do_not_submit=True)
|
||||||
|
pi.is_return = 1
|
||||||
|
pi.items[0].qty = -1
|
||||||
|
pi = pi.save().submit()
|
||||||
|
|
||||||
|
filters = {
|
||||||
|
"company": self.company,
|
||||||
|
"party_type": "Supplier",
|
||||||
|
"party": [self.supplier],
|
||||||
|
"report_date": today(),
|
||||||
|
"range": "30, 60, 90, 120",
|
||||||
|
}
|
||||||
|
|
||||||
|
data = execute(filters)
|
||||||
|
self.assertEqual(data[1][0].get("invoiced"), 300)
|
||||||
|
|
||||||
def create_purchase_invoice(self, do_not_submit=False):
|
def create_purchase_invoice(self, do_not_submit=False):
|
||||||
frappe.set_user("Administrator")
|
frappe.set_user("Administrator")
|
||||||
pi = make_purchase_invoice(
|
pi = make_purchase_invoice(
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
@@ -204,7 +204,7 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase):
|
|||||||
|
|
||||||
expected_data_after_credit_note = [
|
expected_data_after_credit_note = [
|
||||||
[100.0, 100.0, 40.0, 0.0, 60.0, si.name],
|
[100.0, 100.0, 40.0, 0.0, 60.0, si.name],
|
||||||
[0, 0, 100.0, 0.0, -100.0, cr_note.name],
|
[0, 0, 0, 100.0, -100.0, cr_note.name],
|
||||||
]
|
]
|
||||||
self.assertEqual(len(report[1]), 2)
|
self.assertEqual(len(report[1]), 2)
|
||||||
si_row = next(
|
si_row = next(
|
||||||
@@ -478,13 +478,19 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase):
|
|||||||
report = execute(filters)[1]
|
report = execute(filters)[1]
|
||||||
self.assertEqual(len(report), 2)
|
self.assertEqual(len(report), 2)
|
||||||
|
|
||||||
expected_data = {sr.name: [10.0, -10.0, 0.0, -10], si.name: [100.0, 100.0, 10.0, 90.0]}
|
expected_data = {sr.name: [0.0, 10.0, -10.0, 0.0, -10], si.name: [100.0, 0.0, 100.0, 10.0, 90.0]}
|
||||||
|
|
||||||
rows = report[:2]
|
rows = report[:2]
|
||||||
for row in rows:
|
for row in rows:
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
expected_data[row.voucher_no],
|
expected_data[row.voucher_no],
|
||||||
[row.invoiced or row.paid, row.outstanding, row.remaining_balance, row.future_amount],
|
[
|
||||||
|
row.invoiced or row.paid,
|
||||||
|
row.credit_note,
|
||||||
|
row.outstanding,
|
||||||
|
row.remaining_balance,
|
||||||
|
row.future_amount,
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
pe.cancel()
|
pe.cancel()
|
||||||
|
|||||||
Reference in New Issue
Block a user