Commit cff90edc authored by Sebastien Robin's avatar Sebastien Robin

make sure it is impossible to remove two validate in the same time two...

make sure it is impossible to remove two validate in the same time two operations wich decrease the value of a vault

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@13950 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 19a0e85c
...@@ -62,7 +62,13 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin, ...@@ -62,7 +62,13 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin,
to debit two times the same account if the amount on the account is to debit two times the same account if the amount on the account is
too short. too short.
We must make sure that future incoming movements will not be
taken into account
We will by the way check the way counter dates are working. We will by the way check the way counter dates are working.
Also, we must make sure it is not possible to deliver two check
payments by the same time (due to tag on counter)
""" """
login = PortalTestCase.login login = PortalTestCase.login
...@@ -157,33 +163,13 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin, ...@@ -157,33 +163,13 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin,
Make sure we can not close the counter date Make sure we can not close the counter date
when there is still some operations remaining when there is still some operations remaining
""" """
# Before the test, we need to input the inventory
inventory_dict_line_1 = {'id' : 'inventory_line_1',
'resource': self.billet_10000,
'variation_id': ('emission_letter', 'cash_status', 'variation'),
'variation_value': ('emission_letter/p', 'cash_status/valid') + self.variation_list,
'quantity': {'variation/2003': 0, 'variation/1992': 0}}
inventory_dict_line_2 = {'id' : 'inventory_line_2',
'resource': self.billet_200,
'variation_id': ('emission_letter', 'cash_status', 'variation'),
'variation_value': ('emission_letter/p', 'cash_status/valid') + self.variation_list,
'quantity': {'variation/2003': 0, 'variation/1992': 0}}
inventory_dict_line_3 = {'id' : 'inventory_line_3',
'resource':self.billet_5000 ,
'variation_id': ('emission_letter', 'cash_status', 'variation'),
'variation_value': ('emission_letter/p', 'cash_status/valid') + self.variation_list,
'quantity': {'variation/2003': 0, 'variation/1992': 0}}
line_list = [inventory_dict_line_1, inventory_dict_line_2, inventory_dict_line_3]
self.line_list = line_list
bi_counter = self.paris.surface.banque_interne bi_counter = self.paris.surface.banque_interne
bi_counter_vault = bi_counter.guichet_1.encaisse_des_billets_et_monnaies.entrante bi_counter_vault = bi_counter.guichet_1.encaisse_des_billets_et_monnaies.entrante
self.createCashInventory(source=None, destination=bi_counter_vault, currency=self.currency_1, line_list = self.line_list
self.resetInventory(source=None, destination=bi_counter_vault, currency=self.currency_1,
line_list=line_list,extra_id='_reset_in') line_list=line_list,extra_id='_reset_in')
bi_counter_vault = bi_counter.guichet_1.encaisse_des_billets_et_monnaies.sortante bi_counter_vault = bi_counter.guichet_1.encaisse_des_billets_et_monnaies.sortante
self.createCashInventory(source=None, destination=bi_counter_vault, currency=self.currency_1, self.resetInventory(source=None, destination=bi_counter_vault, currency=self.currency_1,
line_list=line_list,extra_id='_reset_out') line_list=line_list,extra_id='_reset_out')
def stepCheckRightStockBeforeClosingDate(self, def stepCheckRightStockBeforeClosingDate(self,
...@@ -201,9 +187,9 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin, ...@@ -201,9 +187,9 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin,
""" """
self.simulation_tool = self.getSimulationTool() self.simulation_tool = self.getSimulationTool()
# check the inventory of the bank account # check the inventory of the bank account
self.assertEqual(self.currency_1.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 100000) self.assertEqual(self.currency_1.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 30000)
self.assertEqual(self.currency_1.getAvailableInventory(payment=self.bank_account_1.getRelativeUrl()), 100000) self.assertEqual(self.currency_1.getAvailableInventory(payment=self.bank_account_1.getRelativeUrl()), 30000)
self.assertEqual(self.currency_1.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 100000) self.assertEqual(self.currency_1.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 30000)
def stepCheckAccountConfirmedInventory(self, sequence=None, sequence_list=None, **kwd): def stepCheckAccountConfirmedInventory(self, sequence=None, sequence_list=None, **kwd):
""" """
...@@ -211,9 +197,9 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin, ...@@ -211,9 +197,9 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin,
""" """
self.simulation_tool = self.getSimulationTool() self.simulation_tool = self.getSimulationTool()
# check the final inventory of the bank account # check the final inventory of the bank account
self.assertEqual(self.currency_1.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 100000) self.assertEqual(self.currency_1.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 30000)
self.assertEqual(self.currency_1.getAvailableInventory(payment=self.bank_account_1.getRelativeUrl()), 80000) self.assertEqual(self.currency_1.getAvailableInventory(payment=self.bank_account_1.getRelativeUrl()), 10000)
self.assertEqual(self.currency_1.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 100000) self.assertEqual(self.currency_1.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 30000)
def stepCheckAccountFinalInventory(self, sequence=None, sequence_list=None, **kwd): def stepCheckAccountFinalInventory(self, sequence=None, sequence_list=None, **kwd):
""" """
...@@ -221,9 +207,9 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin, ...@@ -221,9 +207,9 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin,
""" """
self.simulation_tool = self.getSimulationTool() self.simulation_tool = self.getSimulationTool()
# check the final inventory of the bank account # check the final inventory of the bank account
self.assertEqual(self.currency_1.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 100000) self.assertEqual(self.currency_1.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 30000)
self.assertEqual(self.currency_1.getAvailableInventory(payment=self.bank_account_1.getRelativeUrl()), 100000) self.assertEqual(self.currency_1.getAvailableInventory(payment=self.bank_account_1.getRelativeUrl()), 30000)
self.assertEqual(self.currency_1.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 100000) self.assertEqual(self.currency_1.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 30000)
def test_01_ERP5BankingAvailabeInventory(self, quiet=QUIET, run=RUN_ALL_TEST): def test_01_ERP5BankingAvailabeInventory(self, quiet=QUIET, run=RUN_ALL_TEST):
...@@ -250,7 +236,8 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin, ...@@ -250,7 +236,8 @@ class TestERP5BankingAvailableInventory(TestERP5BankingCheckPaymentMixin,
'MoneyDepositInputCashDetails Tic ' \ 'MoneyDepositInputCashDetails Tic ' \
'DeliverMoneyDeposit Tic ' \ 'DeliverMoneyDeposit Tic ' \
'ValidateAnotherCheckPaymentWorksAgain Tic ' \ 'ValidateAnotherCheckPaymentWorksAgain Tic ' \
'Pay Tic ' \ 'Pay PayAnotherCheckPaymentFails ' \
'Tic ' \
'CheckAccountFinalInventory ' \ 'CheckAccountFinalInventory ' \
'CheckBadStockBeforeClosingDate ' \ 'CheckBadStockBeforeClosingDate ' \
'ResetInventory Tic ' \ 'ResetInventory Tic ' \
......
...@@ -118,7 +118,7 @@ class TestERP5BankingCheckPaymentMixin: ...@@ -118,7 +118,7 @@ class TestERP5BankingCheckPaymentMixin:
self.bank_account_1 = self.createBankAccount(person=self.person_1, self.bank_account_1 = self.createBankAccount(person=self.person_1,
account_id='bank_account_1', account_id='bank_account_1',
currency=self.currency_1, currency=self.currency_1,
amount=100000) amount=30000)
# now we need to create a user as Manager to do the test # now we need to create a user as Manager to do the test
# in order to have an assigment defined which is used to do transition # in order to have an assigment defined which is used to do transition
...@@ -162,6 +162,9 @@ class TestERP5BankingCheckPaymentMixin: ...@@ -162,6 +162,9 @@ class TestERP5BankingCheckPaymentMixin:
self.check_5 = self.createCheck(id='check_5', self.check_5 = self.createCheck(id='check_5',
reference='54', reference='54',
checkbook=self.checkbook_1) checkbook=self.checkbook_1)
self.check_5 = self.createCheck(id='check_6',
reference='56',
checkbook=self.checkbook_1)
self.non_existant_check_reference = '55' self.non_existant_check_reference = '55'
self.createCheckbookModel(id='checkbook_model') self.createCheckbookModel(id='checkbook_model')
...@@ -193,8 +196,8 @@ class TestERP5BankingCheckPaymentMixin: ...@@ -193,8 +196,8 @@ class TestERP5BankingCheckPaymentMixin:
self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 24.0) self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 24.0)
self.assertEqual(self.simulation_tool.getFutureInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 24.0) self.assertEqual(self.simulation_tool.getFutureInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 24.0)
# check the inventory of the bank account # check the inventory of the bank account
self.assertEqual(self.simulation_tool.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 100000) self.assertEqual(self.simulation_tool.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 30000)
self.assertEqual(self.simulation_tool.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 100000) self.assertEqual(self.simulation_tool.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 30000)
def stepCreateCheckPayment(self, sequence=None, sequence_list=None, **kwd): def stepCreateCheckPayment(self, sequence=None, sequence_list=None, **kwd):
...@@ -235,19 +238,29 @@ class TestERP5BankingCheckPaymentMixin: ...@@ -235,19 +238,29 @@ class TestERP5BankingCheckPaymentMixin:
""" Make sure we can validate another check payment """ """ Make sure we can validate another check payment """
self.createAnotherCheckPayment(sequence=sequence,will_fail=0,number="51") self.createAnotherCheckPayment(sequence=sequence,will_fail=0,number="51")
def stepPayAnotherCheckPaymentFails(self, sequence=None, sequence_list=None, **kwd):
""" Make sure we can validate another check payment """
self.createAnotherCheckPayment(sequence=sequence,
check_pay_will_fail=1, number="56")
def stepValidateAnotherCheckPaymentWorksAgain(self, sequence=None, sequence_list=None, **kwd): def stepValidateAnotherCheckPaymentWorksAgain(self, sequence=None, sequence_list=None, **kwd):
""" Make sure we can validate another check payment """ """ Make sure we can validate another check payment """
self.createAnotherCheckPayment(sequence=sequence,will_fail=0,number="54") self.createAnotherCheckPayment(sequence=sequence,
will_fail=0, number="54")
def stepValidateAnotherCheckPaymentFails(self, sequence=None, sequence_list=None, **kwd): def stepValidateAnotherCheckPaymentFails(self, sequence=None, sequence_list=None, **kwd):
""" Make sure that we can not validate another check payment """ """ Make sure that we can not validate another check payment """
self.createAnotherCheckPayment(sequence=sequence,will_fail=1,number="52") self.createAnotherCheckPayment(sequence=sequence, will_fail=1,
pending_account=1, number="52")
def stepValidateAnotherCheckPaymentFailsAgain(self, sequence=None, sequence_list=None, **kwd): def stepValidateAnotherCheckPaymentFailsAgain(self, sequence=None, sequence_list=None, **kwd):
""" Make sure that we can not validate another check payment """ """ Make sure that we can not validate another check payment """
self.createAnotherCheckPayment(sequence=sequence,will_fail=1,number="53") self.createAnotherCheckPayment(sequence=sequence, will_fail=1,
insuffisient_balance=1, number="53")
def createAnotherCheckPayment(self, will_fail=0, sequence=None, number=None,**kwd): def createAnotherCheckPayment(self, will_fail=0, check_pay_will_fail=0, sequence=None,
number=None, pending_account=0,
insuffisient_balance=0, **kwd):
new_payment = self.check_payment_module.newContent(portal_type = 'Check Payment', new_payment = self.check_payment_module.newContent(portal_type = 'Check Payment',
destination_payment_value = self.bank_account_1, destination_payment_value = self.bank_account_1,
# aggregate_value = self.check_1, # aggregate_value = self.check_1,
...@@ -255,16 +268,20 @@ class TestERP5BankingCheckPaymentMixin: ...@@ -255,16 +268,20 @@ class TestERP5BankingCheckPaymentMixin:
aggregate_free_text = number, aggregate_free_text = number,
# source_value = self.bi_counter, # source_value = self.bi_counter,
start_date = DateTime().Date(), start_date = DateTime().Date(),
source_total_asset_price = 90000.0) source_total_asset_price = 20000.0)
new_payment._setSource(self.bi_counter.getRelativeUrl()) new_payment._setSource(self.bi_counter.getRelativeUrl())
self.workflow_tool.doActionFor(new_payment, 'plan_action', self.workflow_tool.doActionFor(new_payment, 'plan_action',
wf_id='check_payment_workflow') wf_id='check_payment_workflow')
self.assertEqual(new_payment.getSimulationState(), 'planned') self.assertEqual(new_payment.getSimulationState(), 'planned')
get_transaction().commit() get_transaction().commit()
if will_fail: if will_fail:
self.assertRaises(ValidationFailed,self.workflow_tool.doActionFor, message = self.assertWorkflowTransitionFails(new_payment,
new_payment, 'confirm_action', 'check_payment_workflow','confirm_action')
wf_id='check_payment_workflow') LOG('self.assertWorkflowTransitionFails message',0,message)
if pending_account:
self.failUnless(message.find('There are operations pending for this account')>=0)
if insuffisient_balance:
self.failUnless(message.find('Bank account is not sufficient')>=0)
self.assertEqual(new_payment.getSimulationState(), 'planned') self.assertEqual(new_payment.getSimulationState(), 'planned')
get_transaction().commit() get_transaction().commit()
self.workflow_tool.doActionFor(new_payment, 'cancel_action', self.workflow_tool.doActionFor(new_payment, 'cancel_action',
...@@ -275,6 +292,12 @@ class TestERP5BankingCheckPaymentMixin: ...@@ -275,6 +292,12 @@ class TestERP5BankingCheckPaymentMixin:
wf_id='check_payment_workflow') wf_id='check_payment_workflow')
self.assertEqual(new_payment.getSimulationState(), 'confirmed') self.assertEqual(new_payment.getSimulationState(), 'confirmed')
get_transaction().commit() get_transaction().commit()
if check_pay_will_fail:
self.stepInputCashDetails(check_payment=new_payment)
message = self.assertWorkflowTransitionFails(new_payment,
'check_payment_workflow','deliver_action')
LOG('self.assertWorkflowTransitionFails message',0,message)
self.failUnless(message.find('There are operations pending for this vault')>=0)
self.workflow_tool.doActionFor(new_payment, 'cancel_action', self.workflow_tool.doActionFor(new_payment, 'cancel_action',
wf_id='check_payment_workflow') wf_id='check_payment_workflow')
...@@ -354,25 +377,28 @@ class TestERP5BankingCheckPaymentMixin: ...@@ -354,25 +377,28 @@ class TestERP5BankingCheckPaymentMixin:
self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 24.0) self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 24.0)
self.assertEqual(self.simulation_tool.getFutureInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 24.0) self.assertEqual(self.simulation_tool.getFutureInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 24.0)
# check the inventory of the bank account, must be planned to be decrease by 20000 # check the inventory of the bank account, must be planned to be decrease by 20000
self.assertEqual(self.simulation_tool.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 100000) self.assertEqual(self.simulation_tool.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 30000)
self.assertEqual(self.simulation_tool.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 80000) self.assertEqual(self.simulation_tool.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 10000)
def stepInputCashDetails(self, sequence=None, sequence_list=None, **kwd): def stepInputCashDetails(self, sequence=None, check_payment=None,
sequence_list=None, **kwd):
""" """
Input cash details Input cash details
""" """
self.addCashLineToDelivery(self.check_payment, 'line_1', 'Cash Delivery Line', self.billet_10000, if check_payment is None:
check_payment = self.check_payment
self.addCashLineToDelivery(check_payment, 'line_1', 'Cash Delivery Line', self.billet_10000,
('emission_letter', 'cash_status', 'variation'), ('emission_letter', 'cash_status', 'variation'),
('emission_letter/p', 'cash_status/valid') + self.variation_list[1:], ('emission_letter/p', 'cash_status/valid') + self.variation_list[1:],
{self.variation_list[1] : 1}) {self.variation_list[1] : 1})
self.assertEqual(self.check_payment.line_1.getPrice(), 10000) self.assertEqual(check_payment.line_1.getPrice(), 10000)
self.addCashLineToDelivery(self.check_payment, 'line_2', 'Cash Delivery Line', self.billet_5000, self.addCashLineToDelivery(check_payment, 'line_2', 'Cash Delivery Line', self.billet_5000,
('emission_letter', 'cash_status', 'variation'), ('emission_letter', 'cash_status', 'variation'),
('emission_letter/p', 'cash_status/valid') + self.variation_list[1:], ('emission_letter/p', 'cash_status/valid') + self.variation_list[1:],
{self.variation_list[1] : 2}) {self.variation_list[1] : 2})
self.assertEqual(self.check_payment.line_2.getPrice(), 5000) self.assertEqual(check_payment.line_2.getPrice(), 5000)
def stepPay(self, sequence=None, sequence_list=None, **kwd): def stepPay(self, sequence=None, sequence_list=None, **kwd):
""" """
...@@ -401,8 +427,8 @@ class TestERP5BankingCheckPaymentMixin: ...@@ -401,8 +427,8 @@ class TestERP5BankingCheckPaymentMixin:
self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 22.0) self.assertEqual(self.simulation_tool.getCurrentInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 22.0)
self.assertEqual(self.simulation_tool.getFutureInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 22.0) self.assertEqual(self.simulation_tool.getFutureInventory(node=self.bi_counter_vault.getRelativeUrl(), resource = self.billet_5000.getRelativeUrl()), 22.0)
# check the final inventory of the bank account # check the final inventory of the bank account
self.assertEqual(self.simulation_tool.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 80000) self.assertEqual(self.simulation_tool.getCurrentInventory(payment=self.bank_account_1.getRelativeUrl()), 10000)
self.assertEqual(self.simulation_tool.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 80000) self.assertEqual(self.simulation_tool.getFutureInventory(payment=self.bank_account_1.getRelativeUrl()), 10000)
def stepCleanup(self, sequence=None, sequence_list=None, **kwd): def stepCleanup(self, sequence=None, sequence_list=None, **kwd):
""" """
......
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