From 653c0b886a98766795db8c03ba5002d2ce1c549b Mon Sep 17 00:00:00 2001 From: marination Date: Wed, 12 Jun 2024 12:59:58 +0200 Subject: [PATCH] test: Multiple ECs against a BT --- .../test_bank_reconciliation_tool_beta.py | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/banking/klarna_kosma_integration/doctype/bank_reconciliation_tool_beta/test_bank_reconciliation_tool_beta.py b/banking/klarna_kosma_integration/doctype/bank_reconciliation_tool_beta/test_bank_reconciliation_tool_beta.py index d98701ad..86e65f13 100644 --- a/banking/klarna_kosma_integration/doctype/bank_reconciliation_tool_beta/test_bank_reconciliation_tool_beta.py +++ b/banking/klarna_kosma_integration/doctype/bank_reconciliation_tool_beta/test_bank_reconciliation_tool_beta.py @@ -329,33 +329,57 @@ def test_unpaid_voucher_and_jv_against_transaction(self): self.assertEqual(bt.status, "Reconciled") self.assertEqual(bt.unallocated_amount, 0) - def test_unpaid_expense_claim_fully_reconcile(self): + def test_unpaid_expense_claims_fully_reconcile(self): + """ + Test if 2 unpaid expense claims fully reconcile against a Bank Transaction. + Test if they are paid and then the PE is reconciled. + """ bt = create_bank_transaction( - withdrawal=200, reference_no="expense-cl-001234", bank_account=self.bank_account + withdrawal=300, reference_no="expense-cl-001234", bank_account=self.bank_account ) expense_claim = make_expense_claim( payable_account=frappe.db.get_value( "Company", bt.company, "default_payable_account" ), - amount=300, + amount=200, sanctioned_amount=200, company=bt.company, account="Travel Expenses - _TC", ) + expense_claim_2 = make_expense_claim( + payable_account=frappe.db.get_value( + "Company", bt.company, "default_payable_account" + ), + amount=100, + sanctioned_amount=100, + company=bt.company, + account="Travel Expenses - _TC", + ) reconcile_vouchers( bt.name, json.dumps( - [{"payment_doctype": "Expense Claim", "payment_name": expense_claim.name}] + [ + {"payment_doctype": "Expense Claim", "payment_name": expense_claim.name}, + {"payment_doctype": "Expense Claim", "payment_name": expense_claim_2.name}, + ] ), ) bt.reload() expense_claim.reload() - self.assertEqual(bt.payment_entries[0].allocated_amount, 200) + expense_claim_2.reload() + self.assertEqual( + bt.payment_entries[0].allocated_amount, 300 + ) # one PE against 2 expense claims self.assertEqual(len(bt.payment_entries), 1) self.assertEqual(bt.unallocated_amount, 0) + self.assertEqual(expense_claim.total_amount_reimbursed, 200) - self.assertEqual(expense_claim.total_claimed_amount, 300) + self.assertEqual(expense_claim_2.total_amount_reimbursed, 100) + + pe = get_pe_references([expense_claim.name, expense_claim_2.name]) + self.assertEqual(pe[0].allocated_amount, 200) + self.assertEqual(pe[1].allocated_amount, 100) def get_pe_references(vouchers: list):