test: payment against partial return invoices
(cherry picked from commit 09f9764bbdec90d1b9f85ccc5a368bf85547bea1)
This commit is contained in:
parent
22b39ac4b4
commit
376e09680c
@ -1250,6 +1250,9 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
self.assertEqual(so.advance_paid, so.rounded_total)
|
self.assertEqual(so.advance_paid, so.rounded_total)
|
||||||
|
|
||||||
def test_receive_payment_from_payable_party_type(self):
|
def test_receive_payment_from_payable_party_type(self):
|
||||||
|
"""
|
||||||
|
Checks GL entries generated while receiving payments from a Payable Party Type.
|
||||||
|
"""
|
||||||
pe = create_payment_entry(
|
pe = create_payment_entry(
|
||||||
party_type="Supplier",
|
party_type="Supplier",
|
||||||
party="_Test Supplier",
|
party="_Test Supplier",
|
||||||
@ -1261,8 +1264,55 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
)
|
)
|
||||||
self.voucher_no = pe.name
|
self.voucher_no = pe.name
|
||||||
self.expected_gle = [
|
self.expected_gle = [
|
||||||
{"account": "_Test Cash - _TC", "debit": 1000.0, "credit": 0.0},
|
|
||||||
{"account": "Creditors - _TC", "debit": 0.0, "credit": 1000.0},
|
{"account": "Creditors - _TC", "debit": 0.0, "credit": 1000.0},
|
||||||
|
{"account": "_Test Cash - _TC", "debit": 1000.0, "credit": 0.0},
|
||||||
|
]
|
||||||
|
self.check_gl_entries()
|
||||||
|
|
||||||
|
def test_payment_against_partial_return_invoice(self):
|
||||||
|
"""
|
||||||
|
Checks GL entries generated for partial return invoice payments.
|
||||||
|
"""
|
||||||
|
si = create_sales_invoice(qty=10, rate=10, customer="_Test Customer")
|
||||||
|
credit_note = create_sales_invoice(
|
||||||
|
qty=-4, rate=10, customer="_Test Customer", is_return=1, return_against=si.name
|
||||||
|
)
|
||||||
|
pe = create_payment_entry(
|
||||||
|
party_type="Customer",
|
||||||
|
party="_Test Customer",
|
||||||
|
payment_type="Receive",
|
||||||
|
paid_from="Debtors - _TC",
|
||||||
|
paid_to="_Test Cash - _TC",
|
||||||
|
)
|
||||||
|
pe.set(
|
||||||
|
"references",
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"reference_doctype": "Sales Invoice",
|
||||||
|
"reference_name": si.name,
|
||||||
|
"due_date": si.get("due_date"),
|
||||||
|
"total_amount": si.grand_total,
|
||||||
|
"outstanding_amount": si.outstanding_amount,
|
||||||
|
"allocated_amount": si.outstanding_amount,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"reference_doctype": "Sales Invoice",
|
||||||
|
"reference_name": credit_note.name,
|
||||||
|
"due_date": credit_note.get("due_date"),
|
||||||
|
"total_amount": credit_note.grand_total,
|
||||||
|
"outstanding_amount": credit_note.outstanding_amount,
|
||||||
|
"allocated_amount": credit_note.outstanding_amount,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
)
|
||||||
|
pe.save()
|
||||||
|
pe.submit()
|
||||||
|
self.voucher_no = pe.name
|
||||||
|
self.expected_gle = [
|
||||||
|
{"account": "Debtors - _TC", "debit": 40.0, "credit": 0.0},
|
||||||
|
{"account": "Debtors - _TC", "debit": 0.0, "credit": 940.0},
|
||||||
|
{"account": "Debtors - _TC", "debit": 0.0, "credit": 100.0},
|
||||||
|
{"account": "_Test Cash - _TC", "debit": 1000.0, "credit": 0.0},
|
||||||
]
|
]
|
||||||
self.check_gl_entries()
|
self.check_gl_entries()
|
||||||
|
|
||||||
@ -1276,7 +1326,7 @@ class TestPaymentEntry(FrappeTestCase):
|
|||||||
gle.credit,
|
gle.credit,
|
||||||
)
|
)
|
||||||
.where((gle.voucher_no == self.voucher_no) & (gle.is_cancelled == 0))
|
.where((gle.voucher_no == self.voucher_no) & (gle.is_cancelled == 0))
|
||||||
.orderby(gle.account)
|
.orderby(gle.account, gle.debit, gle.credit, order=frappe.qb.desc)
|
||||||
).run(as_dict=True)
|
).run(as_dict=True)
|
||||||
for row in range(len(self.expected_gle)):
|
for row in range(len(self.expected_gle)):
|
||||||
for field in ["account", "debit", "credit"]:
|
for field in ["account", "debit", "credit"]:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user