Skip to content

Commit

Permalink
test: cr note flag to update self
Browse files Browse the repository at this point in the history
  • Loading branch information
ruthra-kumar committed Mar 13, 2024
1 parent 4d0c2d8 commit ce3b1f0
Showing 1 changed file with 67 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def create_payment_entry(self, docname):
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,
Expand All @@ -72,6 +72,7 @@ def create_credit_note(self, docname):
cost_center=self.cost_center,
is_return=1,
return_against=docname,
do_not_submit=do_not_submit,
)

return credit_note
Expand Down Expand Up @@ -149,7 +150,9 @@ def test_accounts_receivable(self):
)

# 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]
Expand All @@ -167,6 +170,68 @@ def test_accounts_receivable(self):
],
)

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
Expand Down

0 comments on commit ce3b1f0

Please sign in to comment.