Commit 5d2181dc authored by Aurel's avatar Aurel

when sending to manual validation, we must control all the document as if it's...

when sending to manual validation, we must control all the document as if it's usual way except account inventory

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@18950 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent b3e4727a
......@@ -70,11 +70,17 @@ from Products.ERP5Type.Message import Message\n
\n
txn = state_change[\'object\']\n
\n
account = txn.getDestinationPaymentValue()\n
for line in txn.contentValues(filter = {\'portal_type\' : \'Check Operation Line\'}):\n
\n
account = line.getSourcePaymentValue()\n
\n
if not account.isOverdraftFacility():\n
msg = Message(domain=\'ui\', message="Can\'t sent to manual validation because of not averdraft facility for this bank account")\n
raise ValidationFailed, (msg,)\n
if account is None:\n
msg = Message(domain=\'ui\', message="No account defined on line")\n
raise ValidationFailed, (msg,)\n
\n
if not account.isOverdraftFacility():\n
msg = Message(domain=\'ui\', message="Can\'t sent to manual validation because of not overdraft facility for this bank account")\n
raise ValidationFailed, (msg,)\n
</string> </value>
</item>
<item>
......@@ -130,8 +136,11 @@ if not account.isOverdraftFacility():\n
<string>Message</string>
<string>_getitem_</string>
<string>txn</string>
<string>_getiter_</string>
<string>_getattr_</string>
<string>line</string>
<string>account</string>
<string>None</string>
<string>msg</string>
</tuple>
</value>
......
......@@ -106,6 +106,11 @@ if transaction.getTotalPrice(fast=0, portal_type = \'Check Operation Line\') !=
msg = Message(domain=\'ui\', message="Total price doesn\'t match.")\n
raise ValidationFailed, (msg,)\n
\n
# if manual validation, check overdreaft facility\n
if state_change[\'transition\'].getId() == "wait_action":\n
context.checkAccountIsOverdraftFacility(state_change)\n
\n
\n
# Check each check operation line.\n
for check_operation_line in transaction.contentValues(filter = {\'portal_type\' : \'Check Operation Line\'}):\n
\n
......@@ -141,25 +146,26 @@ for check_operation_line in transaction.contentValues(filter = {\'portal_type\'
\n
\n
# Test if the account balance is sufficient.\n
error = context.BankAccount_checkBalance(source_bank_account.getRelativeUrl(), check_operation_line.getPrice())\n
if error[\'error_code\'] == 1:\n
msg = Message(domain=\'ui\', message="Bank account $account is not sufficient on line $line.",\n
mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
elif error[\'error_code\'] == 2:\n
msg = Message(domain=\'ui\', message="Bank account $account is not valid on $line.",\n
mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
elif error[\'error_code\'] != 0:\n
msg = Message(domain=\'ui\', message="Unknown error code.")\n
raise ValidationFailed, (msg,)\n
if state_change[\'transition\'].getId() == "plan_action":\n
error = context.BankAccount_checkBalance(source_bank_account.getRelativeUrl(), check_operation_line.getPrice())\n
if error[\'error_code\'] == 1:\n
msg = Message(domain=\'ui\', message="Bank account $account is not sufficient on line $line.",\n
mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
elif error[\'error_code\'] == 2:\n
msg = Message(domain=\'ui\', message="Bank account $account is not valid on $line.",\n
mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n
elif error[\'error_code\'] != 0:\n
msg = Message(domain=\'ui\', message="Unknown error code.")\n
raise ValidationFailed, (msg,)\n
\n
check = transaction.Base_checkCheck(bank_account=source_bank_account, reference=check_number,\n
resource=check_type)\n
if check_operation_line.getAggregate() != check.getRelativeUrl():\n
check_operation_line.edit(aggregate=check.getRelativeUrl())\n
\n
if transaction.getSimulationState() == "draft":\n
if transaction.getSimulationState() == "draft" and state_change[\'transition\'].getId() == "plan_action":\n
context.createCheckDepositLine(state_change)\n
......@@ -235,12 +241,12 @@ if transaction.getSimulationState() == "draft":\n
<string>msg</string>
<string>price</string>
<string>destination_bank_account</string>
<string>context</string>
<string>_getiter_</string>
<string>check_operation_line</string>
<string>check_number</string>
<string>check_type</string>
<string>source_bank_account</string>
<string>context</string>
<string>error</string>
<string>check</string>
</tuple>
......
......@@ -57,7 +57,7 @@
</item>
<item>
<key> <string>script_name</string> </key>
<value> <string>checkAccountIsOverdraftFacility</string> </value>
<value> <string>validateConsistency</string> </value>
</item>
<item>
<key> <string>title</string> </key>
......
365
\ No newline at end of file
369
\ 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