test: cr note flag to update self
diff --git a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py
index 6ff81be..a0f8af5 100644
--- a/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py
+++ b/erpnext/accounts/report/accounts_receivable/test_accounts_receivable.py
@@ -62,7 +62,7 @@
pe.insert()
pe.submit()
- def create_credit_note(self, docname):
+ def create_credit_note(self, docname, do_not_submit=False):
credit_note = create_sales_invoice(
company=self.company,
customer=self.customer,
@@ -72,6 +72,7 @@
cost_center=self.cost_center,
is_return=1,
return_against=docname,
+ do_not_submit=do_not_submit,
)
return credit_note
@@ -149,7 +150,9 @@
)
# check invoice grand total, invoiced, paid and outstanding column's value after credit note
- self.create_credit_note(si.name)
+ cr_note = self.create_credit_note(si.name, do_not_submit=True)
+ cr_note.update_outstanding_for_self = False
+ cr_note.save().submit()
report = execute(filters)
expected_data_after_credit_note = [100, 0, 0, 40, -40, self.debit_to]
@@ -167,6 +170,68 @@
],
)
+ def test_cr_note_flag_to_update_self(self):
+ filters = {
+ "company": self.company,
+ "report_date": today(),
+ "range1": 30,
+ "range2": 60,
+ "range3": 90,
+ "range4": 120,
+ "show_remarks": True,
+ }
+
+ # check invoice grand total and invoiced column's value for 3 payment terms
+ si = self.create_sales_invoice(no_payment_schedule=True)
+ name = si.name
+
+ report = execute(filters)
+
+ expected_data = [100, 100, "No Remarks"]
+
+ self.assertEqual(len(report[1]), 1)
+ row = report[1][0]
+ self.assertEqual(expected_data, [row.invoice_grand_total, row.invoiced, row.remarks])
+
+ # check invoice grand total, invoiced, paid and outstanding column's value after payment
+ self.create_payment_entry(si.name)
+ report = execute(filters)
+
+ expected_data_after_payment = [100, 100, 40, 60]
+ self.assertEqual(len(report[1]), 1)
+ row = report[1][0]
+ self.assertEqual(
+ expected_data_after_payment,
+ [row.invoice_grand_total, row.invoiced, row.paid, row.outstanding],
+ )
+
+ # check invoice grand total, invoiced, paid and outstanding column's value after credit note
+ cr_note = self.create_credit_note(si.name, do_not_submit=True)
+ cr_note.posting_date = add_days(today(), 1)
+ cr_note.update_outstanding_for_self = True
+ cr_note.save().submit()
+ report = execute(filters)
+
+ expected_data_after_credit_note = [
+ [100.0, 100.0, 40.0, 0.0, 60.0, self.debit_to],
+ [0, 0, 100.0, 0.0, -100.0, self.debit_to],
+ ]
+ self.assertEqual(len(report[1]), 2)
+ for i in range(2):
+ row = report[1][i - 1]
+ # row = report[1][0]
+ self.assertEqual(
+ expected_data_after_credit_note[i - 1],
+ [
+ row.invoice_grand_total,
+ row.invoiced,
+ row.paid,
+ row.credit_note,
+ row.outstanding,
+ row.party_account,
+ ],
+ )
+
def test_payment_againt_po_in_receivable_report(self):
"""
Payments made against Purchase Order will show up as outstanding amount