Commit 5a509cb7 authored by Aurel's avatar Aurel

emission date must not be older than 3 years for check

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@15039 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 7c6cfa90
...@@ -69,6 +69,7 @@ ...@@ -69,6 +69,7 @@
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
from Products.ERP5Type.Message import Message\n from Products.ERP5Type.Message import Message\n
from Products.ERP5Type.DateUtils import getIntervalBetweenDates\n
\n \n
transaction = state_change[\'object\']\n transaction = state_change[\'object\']\n
\n \n
...@@ -102,31 +103,41 @@ for check_operation_line in transaction.contentValues(filter = {\'portal_type\' ...@@ -102,31 +103,41 @@ for check_operation_line in transaction.contentValues(filter = {\'portal_type\'
check_number = check_operation_line.getAggregateFreeText()\n check_number = check_operation_line.getAggregateFreeText()\n
if not check_number:\n if not check_number:\n
msg = Message(domain=\'ui\', message=\'Check is not defined on line $line.\'\n msg = Message(domain=\'ui\', message=\'Check is not defined on line $line.\'\n
, mapping={"line" : line.getId()})\n , mapping={"line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n raise ValidationFailed, (msg,)\n
\n \n
check_type = check_operation_line.getAggregateResource()\n check_type = check_operation_line.getAggregateResource()\n
if check_type is None:\n if check_type is None:\n
msg = Message(domain=\'ui\', message=\'Check type is not defined on line $line.\'\n msg = Message(domain=\'ui\', message=\'Check type is not defined on line $line.\'\n
, mapping={"line" : line.getId()})\n , mapping={"line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n raise ValidationFailed, (msg,)\n
\n \n
\n \n
source_bank_account = check_operation_line.getSourcePaymentValue()\n source_bank_account = check_operation_line.getSourcePaymentValue()\n
if source_bank_account is None:\n if source_bank_account is None:\n
msg = Message(domain=\'ui\', message=\'Bank account not defined on line $line.\'\n msg = Message(domain=\'ui\', message=\'Bank account not defined on line $line.\'\n
, mapping={"line" : line.getId()})\n , mapping={"line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n raise ValidationFailed, (msg,)\n
\n \n
# Test check is valid based on date\n
if \'compte\' in check_operation_line.getAggregateResourceTitle():\n
interval = getIntervalBetweenDates(check_operation_line.getStartDate(), check_operation_line.getStopDate())\n
if interval[\'year\'] >= 3:\n
if interval[\'month\'] > 0 or interval["day"] > 0:\n
msg = Message(domain=\'ui\', message="Check $s is more than 3 years old.",\n
mapping={"check" : check_operation_line.getAggregateFreeText()})\n
raise ValidationFailed, (msg,)\n
\n
\n
# Test if the account balance is sufficient.\n # Test if the account balance is sufficient.\n
error = context.BankAccount_checkBalance(source_bank_account.getRelativeUrl(), check_operation_line.getPrice())\n error = context.BankAccount_checkBalance(source_bank_account.getRelativeUrl(), check_operation_line.getPrice())\n
if error[\'error_code\'] == 1:\n if error[\'error_code\'] == 1:\n
msg = Message(domain=\'ui\', message="Bank account $account is not sufficient on line $line.",\n msg = Message(domain=\'ui\', message="Bank account $account is not sufficient on line $line.",\n
mapping={"account": source_bank_account.getInternalBankAccountNumber, "line" : line.getId()})\n mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n raise ValidationFailed, (msg,)\n
elif error[\'error_code\'] == 2:\n elif error[\'error_code\'] == 2:\n
msg = Message(domain=\'ui\', message="Bank account $account is not valid on $line.",\n msg = Message(domain=\'ui\', message="Bank account $account is not valid on $line.",\n
mapping={"account": source_bank_account.getInternalBankAccountNumber, "line" : line.getId()})\n mapping={"account": source_bank_account.getInternalBankAccountNumber(), "line" : check_operation_line.getId()})\n
raise ValidationFailed, (msg,)\n raise ValidationFailed, (msg,)\n
elif error[\'error_code\'] != 0:\n elif error[\'error_code\'] != 0:\n
msg = Message(domain=\'ui\', message="Unknown error code.")\n msg = Message(domain=\'ui\', message="Unknown error code.")\n
...@@ -202,6 +213,8 @@ if transaction.getSimulationState() == "draft":\n ...@@ -202,6 +213,8 @@ if transaction.getSimulationState() == "draft":\n
<string>ValidationFailed</string> <string>ValidationFailed</string>
<string>Products.ERP5Type.Message</string> <string>Products.ERP5Type.Message</string>
<string>Message</string> <string>Message</string>
<string>Products.ERP5Type.DateUtils</string>
<string>getIntervalBetweenDates</string>
<string>_getitem_</string> <string>_getitem_</string>
<string>transaction</string> <string>transaction</string>
<string>_getattr_</string> <string>_getattr_</string>
...@@ -214,9 +227,9 @@ if transaction.getSimulationState() == "draft":\n ...@@ -214,9 +227,9 @@ if transaction.getSimulationState() == "draft":\n
<string>_getiter_</string> <string>_getiter_</string>
<string>check_operation_line</string> <string>check_operation_line</string>
<string>check_number</string> <string>check_number</string>
<string>line</string>
<string>check_type</string> <string>check_type</string>
<string>source_bank_account</string> <string>source_bank_account</string>
<string>interval</string>
<string>context</string> <string>context</string>
<string>error</string> <string>error</string>
<string>check</string> <string>check</string>
......
289 291
\ No newline at end of file \ 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