Commit 9628376b authored by Sebastien Robin's avatar Sebastien Robin

check stock values in checkbook vault transfer and checkbook delivery

git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@14000 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent ebb82ecc
...@@ -65,9 +65,7 @@ ...@@ -65,9 +65,7 @@
</item> </item>
<item> <item>
<key> <string>_body</string> </key> <key> <string>_body</string> </key>
<value> <string encoding="cdata"><![CDATA[ <value> <string># XXX: This script is only kept in case it must be added back as a "Before" script on "_action" transition.\n
# XXX: This script is only kept in case it must be added back as a "Before" script on "_action" transition.\n
# But it is not used any longer at the moment.\n # But it is not used any longer at the moment.\n
\n \n
from Products.DCWorkflow.DCWorkflow import ValidationFailed\n from Products.DCWorkflow.DCWorkflow import ValidationFailed\n
...@@ -75,62 +73,6 @@ from Products.ERP5Type.Message import Message\n ...@@ -75,62 +73,6 @@ from Products.ERP5Type.Message import Message\n
\n \n
transaction = state_change[\'object\']\n transaction = state_change[\'object\']\n
\n \n
# First we have to look if we have some checks with some prices,\n
# if so, this means that we are saling such kinds of check, thus\n
# we must change the position of the customer account\n
movement_list = transaction.getMovementList()\n
total_debit = 0\n
for movement in movement_list:\n
aggregate_value_list = movement.getAggregateValueList()\n
for item in aggregate_value_list:\n
if item.getPortalType()==\'Check\':\n
if item.getPrice() is not None:\n
# then we must calculate the exchange value\n
base_price = movement.CurrencyExchange_getExchangeRateList()[0]\n
if base_price is None:\n
msg = Message(domain = "ui", message="Sorry, no valid price was found for this currency")\n
raise ValidationFailed, (msg,)\n
total_debit += base_price*item.getPrice()\n
if total_debit>0:\n
total_debit = round(total_debit+0.5)\n
# Source and destination will be updated automaticaly based on the category of bank account\n
# The default account chosen should act as some kind of *temp* account or *parent* account\n
movement = transaction.get(\'movement\',None)\n
if movement is None:\n
movement = transaction.newContent(portal_type=\'Banking Operation Line\',\n
id=\'movement\',\n
source=\'account_module/bank_account\', # Set default source\n
destination=\'account_module/bank_account\', # Set default destination\n
)\n
movement.setSourceDebit(total_debit)\n
transaction.setSourceTotalAssetPrice(total_debit)\n
\n
line = transaction.movement\n
bank_account = transaction.getDestinationPaymentValue()\n
price = total_debit\n
\n
# this prevents multiple transactions from being committed at the same time for this bank account.\n
bank_account.serialize()\n
\n
# Make sure there are no other operations pending for this account\n
if context.BankAccount_isMessagePending(bank_account):\n
msg = Message(domain=\'ui\', message="There are operations pending for this account that prevent form calculating its position. Please try again later.")\n
raise ValidationFailed, (msg,)\n
\n
# Index the banking operation line so it impacts account position\n
context.BankingOperationLine_index(line)\n
\n
# Test if the account balance is sufficient.\n
error = context.BankAccount_checkBalance(bank_account.getRelativeUrl(), price)\n
if error[\'error_code\'] == 1:\n
msg = Message(domain=\'ui\', message="Bank account is not sufficient.")\n
raise ValidationFailed, (msg,)\n
elif error[\'error_code\'] == 2:\n
msg = Message(domain=\'ui\', message="Bank account is not valid.")\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 \n
date = transaction.getStartDate()\n date = transaction.getStartDate()\n
source = transaction.getSource(None)\n source = transaction.getSource(None)\n
...@@ -138,6 +80,9 @@ if source is None:\n ...@@ -138,6 +80,9 @@ if source is None:\n
msg = Message(domain=\'ui\', message=\'No counter defined.\')\n msg = Message(domain=\'ui\', message=\'No counter defined.\')\n
raise ValidationFailed, (msg,)\n raise ValidationFailed, (msg,)\n
\n \n
at_date = transaction.getStartDate()\n
transaction.CheckbookDelivery_checkAggregateStockList(at_date=at_date, node_url = source)\n
\n
# check we are in an opened accounting day\n # check we are in an opened accounting day\n
if not transaction.Baobab_checkCounterDateOpen(site=source, date=date):\n if not transaction.Baobab_checkCounterDateOpen(site=source, date=date):\n
msg = Message(domain = "ui", message="Counter Date is not opened")\n msg = Message(domain = "ui", message="Counter Date is not opened")\n
...@@ -149,9 +94,7 @@ if \'guichet\' in site.getVaultType():\n ...@@ -149,9 +94,7 @@ if \'guichet\' in site.getVaultType():\n
if not context.Baobab_checkCounterOpened(site):\n if not context.Baobab_checkCounterOpened(site):\n
msg = Message(domain = "ui", message="Counter is not opened")\n msg = Message(domain = "ui", message="Counter is not opened")\n
raise ValidationFailed, (msg,)\n raise ValidationFailed, (msg,)\n
</string> </value>
]]></string> </value>
</item> </item>
<item> <item>
<key> <string>_code</string> </key> <key> <string>_code</string> </key>
...@@ -202,24 +145,13 @@ if \'guichet\' in site.getVaultType():\n ...@@ -202,24 +145,13 @@ if \'guichet\' in site.getVaultType():\n
<string>_getitem_</string> <string>_getitem_</string>
<string>transaction</string> <string>transaction</string>
<string>_getattr_</string> <string>_getattr_</string>
<string>movement_list</string>
<string>total_debit</string>
<string>_getiter_</string>
<string>movement</string>
<string>aggregate_value_list</string>
<string>item</string>
<string>None</string>
<string>base_price</string>
<string>msg</string>
<string>round</string>
<string>line</string>
<string>bank_account</string>
<string>price</string>
<string>context</string>
<string>error</string>
<string>date</string> <string>date</string>
<string>None</string>
<string>source</string> <string>source</string>
<string>msg</string>
<string>at_date</string>
<string>site</string> <string>site</string>
<string>context</string>
</tuple> </tuple>
</value> </value>
</item> </item>
...@@ -236,7 +168,7 @@ if \'guichet\' in site.getVaultType():\n ...@@ -236,7 +168,7 @@ if \'guichet\' in site.getVaultType():\n
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
<value> <string>validatePositionAccounting</string> </value> <value> <string>checkConsistency</string> </value>
</item> </item>
<item> <item>
<key> <string>warnings</string> </key> <key> <string>warnings</string> </key>
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
</item> </item>
<item> <item>
<key> <string>script_name</string> </key> <key> <string>script_name</string> </key>
<value> <string></string> </value> <value> <string>checkConsistency</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
...@@ -73,11 +73,8 @@ ...@@ -73,11 +73,8 @@
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="Guard" module="Products.DCWorkflow.Guard"/>
<string>Products.DCWorkflow.Guard</string> <tuple/>
<string>Guard</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
......
...@@ -80,6 +80,9 @@ line_list = transaction.objectValues()\n ...@@ -80,6 +80,9 @@ line_list = transaction.objectValues()\n
if len(line_list)==0:\n if len(line_list)==0:\n
msg = Message(domain="ui", message="Sorry, you must select at least one check or checkbook")\n msg = Message(domain="ui", message="Sorry, you must select at least one check or checkbook")\n
\n \n
at_date = transaction.getStartDate()\n
transaction.CheckbookDelivery_checkAggregateStockList(at_date=at_date, node_url = baobab_source)\n
\n
if msg is not None:\n if msg is not None:\n
raise ValidationFailed, (msg,)\n raise ValidationFailed, (msg,)\n
</string> </value> </string> </value>
...@@ -137,6 +140,8 @@ if msg is not None:\n ...@@ -137,6 +140,8 @@ if msg is not None:\n
<string>msg</string> <string>msg</string>
<string>line_list</string> <string>line_list</string>
<string>len</string> <string>len</string>
<string>at_date</string>
<string>baobab_source</string>
</tuple> </tuple>
</value> </value>
</item> </item>
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</item> </item>
<item> <item>
<key> <string>script_name</string> </key> <key> <string>script_name</string> </key>
<value> <string>validateSourceAndDestination</string> </value> <value> <string>validateCheckbookVaultTransferConsistency</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
...@@ -67,11 +67,8 @@ ...@@ -67,11 +67,8 @@
<record id="2" aka="AAAAAAAAAAI="> <record id="2" aka="AAAAAAAAAAI=">
<pickle> <pickle>
<tuple> <tuple>
<tuple> <global name="Guard" module="Products.DCWorkflow.Guard"/>
<string>Products.DCWorkflow.Guard</string> <tuple/>
<string>Guard</string>
</tuple>
<none/>
</tuple> </tuple>
</pickle> </pickle>
<pickle> <pickle>
......
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
</item> </item>
<item> <item>
<key> <string>script_name</string> </key> <key> <string>script_name</string> </key>
<value> <string></string> </value> <value> <string>validateSourceAndDestination</string> </value>
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
......
156 158
\ 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