test: show future payments allocated sales returns is considered as payment
This commit is contained in:
@@ -469,11 +469,30 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase):
|
||||
)
|
||||
|
||||
def test_future_payments(self):
|
||||
sr = self.create_sales_invoice(do_not_submit=True)
|
||||
sr.is_return = 1
|
||||
sr.items[0].qty = -1
|
||||
sr.items[0].rate = 10
|
||||
sr.calculate_taxes_and_totals()
|
||||
sr.submit()
|
||||
|
||||
si = self.create_sales_invoice()
|
||||
pe = get_payment_entry(si.doctype, si.name)
|
||||
pe.append(
|
||||
"references",
|
||||
{
|
||||
"reference_doctype": sr.doctype,
|
||||
"reference_name": sr.name,
|
||||
"due_date": sr.due_date,
|
||||
"total_amount": sr.grand_total,
|
||||
"outstanding_amount": sr.outstanding_amount,
|
||||
"allocated_amount": sr.outstanding_amount,
|
||||
},
|
||||
)
|
||||
|
||||
pe.posting_date = add_days(today(), 1)
|
||||
pe.paid_amount = 90.0
|
||||
pe.references[0].allocated_amount = 90.0
|
||||
pe.paid_amount = 80
|
||||
pe.references[0].allocated_amount = 90.0 # pe.paid_amount + sr.grand_total
|
||||
pe.save().submit()
|
||||
filters = {
|
||||
"company": self.company,
|
||||
@@ -485,16 +504,21 @@ class TestAccountsReceivable(AccountsTestMixin, FrappeTestCase):
|
||||
"show_future_payments": True,
|
||||
}
|
||||
report = execute(filters)[1]
|
||||
self.assertEqual(len(report), 1)
|
||||
self.assertEqual(len(report), 2)
|
||||
|
||||
expected_data = [100.0, 100.0, 10.0, 90.0]
|
||||
expected_data = {sr.name: [10.0, -10.0, 0.0, -10], si.name: [100.0, 100.0, 10.0, 90.0]}
|
||||
|
||||
row = report[0]
|
||||
self.assertEqual(
|
||||
expected_data, [row.invoiced, row.outstanding, row.remaining_balance, row.future_amount]
|
||||
)
|
||||
rows = report[:2]
|
||||
for row in rows:
|
||||
self.assertEqual(
|
||||
expected_data[row.voucher_no],
|
||||
[row.invoiced or row.paid, row.outstanding, row.remaining_balance, row.future_amount],
|
||||
)
|
||||
|
||||
pe.cancel()
|
||||
sr.load_from_db() # Outstanding amount is updated so a updated timestamp is needed.
|
||||
sr.cancel()
|
||||
|
||||
# full payment in future date
|
||||
pe = get_payment_entry(si.doctype, si.name)
|
||||
pe.posting_date = add_days(today(), 1)
|
||||
|
||||
Reference in New Issue
Block a user