Commit 416b3627 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: test paying invoices

parent f84f49bd
...@@ -138,7 +138,11 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -138,7 +138,11 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
# Discount and first subscription # Discount and first subscription
self.assertEqual(first_invoice.getTotalPrice(), 24.384) self.assertEqual(first_invoice.getTotalPrice(), 24.384)
# Ensure no unexpected object has been created # Ensure no unexpected object has been created
# 1 accounting transaction
# 1 open order
# 2 assignment # 2 assignment
# 2 simulation movements
# 1 sale packing list
# 2 sale trade condition # 2 sale trade condition
# 1 subscription requests # 1 subscription requests
self.assertRelatedObjectCount(project, 10) self.assertRelatedObjectCount(project, 10)
...@@ -157,11 +161,62 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin): ...@@ -157,11 +161,62 @@ class TestSlapOSAccountingScenario(TestSlapOSVirtualMasterScenarioMixin):
self.assertEquals(amount_list[0].total_price, 125.184) self.assertEquals(amount_list[0].total_price, 125.184)
self.assertEqual(first_invoice.getSimulationState(), "stopped") self.assertEqual(first_invoice.getSimulationState(), "stopped")
# Ensure no unexpected object has been created # Ensure no unexpected object has been created
# 4 accounting transactions
# 1 open order # 1 open order
# 2 assignment # 2 assignment
# 8 simulation movements
# 4 sale packing list
# 2 sale trade condition # 2 sale trade condition
# 1 subscription requests # 1 subscription requests
self.assertRelatedObjectCount(project, 22) self.assertRelatedObjectCount(project, 22)
# Try to pay previous period
with PinnedDateTime(self, DateTime('2021/07/06')):
payment_transaction = owner_person.Entity_createPaymentTransaction(
owner_person.Entity_getOutstandingAmountList(
include_planned=False,
at_date=DateTime('2021/05/06'),
section_uid=first_invoice.getSourceSectionUid(),
resource_uid=first_invoice.getPriceCurrencyUid(),
ledger_uid=first_invoice.getLedgerUid(),
group_by_node=False
)
)
self.assertEquals(payment_transaction.AccountingTransaction_getTotalCredit(), 74.78399999999999)
self.tic()
self.assertTrue(owner_person.Entity_hasOutstandingAmount())
amount_list = owner_person.Entity_getOutstandingAmountList()
self.assertEquals(len(amount_list), 1)
self.assertEquals(amount_list[0].total_price, 100.8)
self.assertTrue(owner_person.Entity_hasOutstandingAmount(include_planned=False))
amount_list = owner_person.Entity_getOutstandingAmountList(include_planned=False)
self.assertEquals(len(amount_list), 1)
self.assertEquals(amount_list[0].total_price, 50.4)
self.assertTrue(first_invoice.SaleInvoiceTransaction_isLettered())
# Ensure no unexpected object has been created
self.assertRelatedObjectCount(project, 22)
payment_transaction = owner_person.Entity_createPaymentTransaction(
owner_person.Entity_getOutstandingAmountList(
include_planned=False,
section_uid=first_invoice.getSourceSectionUid(),
resource_uid=first_invoice.getPriceCurrencyUid(),
ledger_uid=first_invoice.getLedgerUid(),
group_by_node=False
)
)
self.assertEquals(payment_transaction.AccountingTransaction_getTotalCredit(), 50.4)
self.tic()
self.assertTrue(owner_person.Entity_hasOutstandingAmount())
amount_list = owner_person.Entity_getOutstandingAmountList()
self.assertEquals(len(amount_list), 1)
self.assertEquals(amount_list[0].total_price, 50.4)
self.assertFalse(owner_person.Entity_hasOutstandingAmount(include_planned=False))
amount_list = owner_person.Entity_getOutstandingAmountList(include_planned=False)
self.assertEquals(len(amount_list), 0)
# Ensure no unexpected object has been created
self.assertRelatedObjectCount(project, 22)
with PinnedDateTime(self, DateTime('2021/07/06')): with PinnedDateTime(self, DateTime('2021/07/06')):
self.checkERP5StateBeforeExit() self.checkERP5StateBeforeExit()
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment