diff --git a/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/CurrencySaleOrPurchase_validateVaultBalance.xml b/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/CurrencySaleOrPurchase_validateVaultBalance.xml new file mode 100644 index 0000000000000000000000000000000000000000..78dfc22f7b807a3258364fbc9e3381d2e2d71eed --- /dev/null +++ b/bt5/erp5_banking_cash/SkinTemplateItem/portal_skins/erp5_banking_cash/CurrencySaleOrPurchase_validateVaultBalance.xml @@ -0,0 +1,232 @@ +<?xml version="1.0"?> +<ZopeData> + <record id="1" aka="AAAAAAAAAAE="> + <pickle> + <tuple> + <global name="PythonScript" module="Products.PythonScripts.PythonScript"/> + <tuple/> + </tuple> + </pickle> + <pickle> + <dictionary> + <item> + <key> <string>Python_magic</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>Script_magic</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>__ac_local_roles__</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_bind_names</string> </key> + <value> + <object> + <klass> + <global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>_asgns</string> </key> + <value> + <dictionary> + <item> + <key> <string>name_container</string> </key> + <value> <string>container</string> </value> + </item> + <item> + <key> <string>name_context</string> </key> + <value> <string>context</string> </value> + </item> + <item> + <key> <string>name_m_self</string> </key> + <value> <string>script</string> </value> + </item> + <item> + <key> <string>name_subpath</string> </key> + <value> <string>traverse_subpath</string> </value> + </item> + </dictionary> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>_body</string> </key> + <value> <string encoding="cdata"><![CDATA[ + +from Products.DCWorkflow.DCWorkflow import ValidationFailed\n +from Products.ERP5Type.Message import Message\n +\n +counter_site = context.getSource()\n +# check we don\'t change of user\n +context.Baobab_checkSameUserVault(counter_site)\n +# check that we are in the good accounting date\n +context.Baobab_checkCounterDateOpen(site=counter_site,\n + date=context.getStartDate())\n +# check that the counter is open\n +context.Baobab_checkCounterOpened(counter_site)\n +\n +if is_currency_sale:\n + foreign_currency_portal_type = outgoing_portal_type\n + default_currency_portal_type = incoming_portal_type\n +else:\n + foreign_currency_portal_type = incoming_portal_type\n + default_currency_portal_type = outgoing_portal_type\n +\n +# check resource on currency fastinput\n +doc_resource = context.getResource()\n +for line in context.contentValues(portal_type=foreign_currency_portal_type):\n + if line.getResourceValue().getPriceCurrency() != doc_resource:\n + raise ValidationFailed, (Message(domain="ui",\n + message="Resource defined on document is different from currency cash."), )\n +\n +# check if an exchange rate is defined\n +if context.CurrencyPurchase_getQuantity() is None:\n + raise ValidationFailed, (Message(domain=\'ui\',\n + message="No exchange rate defined for this currency at document date."))\n +\n +# check outgoing amount\n +if is_currency_sale:\n + amount = context.getSourceTotalAssetPrice()\n +else:\n + amount = context.getQuantity()\n +if amount is None or amount <= 0:\n + msg = Message(domain="ui", message="Amount is not valid.")\n + raise ValidationFailed, (msg, )\n +\n +# Reverse error messages in cash of currency purchase\n +default_msg = "Received amount is different from input cash."\n +foreign_msg = "Return amount is different from output cash"\n +if not is_currency_sale:\n + (default_msg, foreign_msg) = (foreign_msg, default_msg)\n +\n +# Check default currency amount consistency\n +if context.getTotalPrice(portal_type=[default_currency_portal_type,\n + \'Cash Delivery Cell\'], fast=0) != context.getQuantity():\n + raise ValidationFailed, (Message(domain="ui", message=default_msg), )\n +\n +# Check foreign currency amount consistency\n +if context.getTotalPrice(portal_type=[foreign_currency_portal_type,\n + \'Cash Delivery Cell\'], fast=0) != context.getSourceTotalAssetPrice():\n + raise ValidationFailed, (Message(domain="ui", message=foreign_msg), )\n +\n +# Check outgoing inventory\n +resource_one = context.CashDelivery_checkCounterInventory(\n + portal_type=outgoing_portal_type)\n +if resource_one == 2:\n + raise ValidationFailed, (Message(domain="ui", message="No Resource."), )\n +elif resource_one == 1:\n + raise ValidationFailed, (Message(domain="ui",\n + message="Insufficient balance"), )\n + + +]]></string> </value> + </item> + <item> + <key> <string>_code</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_filepath</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_owner</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>_params</string> </key> + <value> <string>incoming_portal_type, outgoing_portal_type, is_currency_sale</string> </value> + </item> + <item> + <key> <string>errors</string> </key> + <value> + <tuple/> + </value> + </item> + <item> + <key> <string>func_code</string> </key> + <value> + <object> + <klass> + <global name="FuncCode" module="Shared.DC.Scripts.Signature"/> + </klass> + <tuple/> + <state> + <dictionary> + <item> + <key> <string>co_argcount</string> </key> + <value> <int>3</int> </value> + </item> + <item> + <key> <string>co_varnames</string> </key> + <value> + <tuple> + <string>incoming_portal_type</string> + <string>outgoing_portal_type</string> + <string>is_currency_sale</string> + <string>Products.DCWorkflow.DCWorkflow</string> + <string>ValidationFailed</string> + <string>Products.ERP5Type.Message</string> + <string>Message</string> + <string>_getattr_</string> + <string>context</string> + <string>counter_site</string> + <string>foreign_currency_portal_type</string> + <string>default_currency_portal_type</string> + <string>doc_resource</string> + <string>_getiter_</string> + <string>line</string> + <string>None</string> + <string>amount</string> + <string>msg</string> + <string>default_msg</string> + <string>foreign_msg</string> + <string>resource_one</string> + </tuple> + </value> + </item> + </dictionary> + </state> + </object> + </value> + </item> + <item> + <key> <string>func_defaults</string> </key> + <value> + <none/> + </value> + </item> + <item> + <key> <string>id</string> </key> + <value> <string>CurrencySaleOrPurchase_validateVaultBalance</string> </value> + </item> + <item> + <key> <string>warnings</string> </key> + <value> + <tuple/> + </value> + </item> + </dictionary> + </pickle> + </record> +</ZopeData> diff --git a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_purchase_workflow/scripts/validateVaultBalance.xml b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_purchase_workflow/scripts/validateVaultBalance.xml index 46331c5de80060d0165eeaae654e1b0135f65d82..97b36cb80a0954d547e5b28ba62934b7ecb5ad81 100644 --- a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_purchase_workflow/scripts/validateVaultBalance.xml +++ b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_purchase_workflow/scripts/validateVaultBalance.xml @@ -53,78 +53,12 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string encoding="cdata"><![CDATA[ - -from Products.DCWorkflow.DCWorkflow import ValidationFailed\n -from Products.ERP5Type.Message import Message\n -transaction = state_change[\'object\']\n -\n -currency = transaction.getResourceTitle()\n -encaisse_billets_et_monnaies = "/encaisse_des_billets_et_monnaies/sortante"\n -\n -\n -ressource_title = transaction.getResourceTitle().lower()\n -ressource_title = ressource_title.replace(" ", "_")\n -encaisse_devise = "/encaisse_des_devises/%s/entrante" %(ressource_title)\n -\n -#encaisse_devise = "/encaisse_des_devises/%s/entrante" %(transaction.getResourceTitle().lower())\n -\n -counter_site = transaction.getSource()\n -\n -# check we don\'t change of user\n -transaction.Baobab_checkSameUserVault(counter_site)\n -\n -incoming_destination = counter_site + encaisse_devise\n -outgoing_source = counter_site + encaisse_billets_et_monnaies\n -\n -# check again that we are in the good accounting date\n -transaction.Baobab_checkCounterDateOpen(site=outgoing_source, date=transaction.getStartDate())\n -\n -# check again that the counter is open\n -\n -context.Baobab_checkCounterOpened(counter_site)\n -base_price = transaction.getSourceTotalAssetPrice()\n -# Check the amount.\n -\n -if base_price is None or base_price <= 0:\n - msg = Message(domain="ui", message="Amount is not valid.")\n - raise ValidationFailed, (msg,)\n -\n -# Check Taxes\n -fix_montant = transaction.getDiscount()\n -pourcentage = transaction.getDiscountRatio()\n -\n -# check resource on incoming line\n -doc_resource = transaction.getResource()\n -for line in transaction.contentValues(portal_type="Incoming Cash To Currency Purchase Line"):\n - if line.getResourceValue().getPriceCurrency() != doc_resource:\n - msg = Message(domain="ui", message="Resource defined on document is different from input cash.")\n - raise ValidationFailed, (msg,)\n -\n -resource_two = transaction.CashDelivery_checkCounterInventory(outgoing_source,portal_type=\'Outgoing Cash To Currency Purchase Line\')\n -\n -billetage_entre = transaction.getTotalPrice(portal_type=[\'Incoming Cash To Currency Purchase Line\', \'Cash Delivery Cell\'],fast=0)\n -billetage_sorti = transaction.getTotalPrice(portal_type=[\'Outgoing Cash To Currency Purchase Line\', \'Cash Delivery Cell\'],fast=0)\n -\n -\n -quantity = transaction.getQuantity()\n -\n -\n -if resource_two == 2:\n - msg = Message(domain="ui", message="No Resource.")\n - raise ValidationFailed, (msg,)\n -elif billetage_entre != base_price :\n - msg = Message(domain="ui", message="Received amount is different from input cash.")\n - raise ValidationFailed, (msg,)\n -elif billetage_sorti != quantity :\n - msg = Message(domain="ui", message="Return amount is different from output cash")\n - raise ValidationFailed, (msg,) \n -elif resource_two!= 0 :\n - msg = Message(domain="ui", message="Insufficient balance")\n - raise ValidationFailed, (msg,)\n - - -]]></string> </value> + <value> <string>state_change[\'object\'].CurrencySaleOrPurchase_validateVaultBalance(\n + incoming_portal_type=\'Incoming Cash To Currency Purchase Line\',\n + outgoing_portal_type=\'Outgoing Cash To Currency Purchase Line\',\n + is_currency_sale=False,\n +)\n +</string> </value> </item> <item> <key> <string>_code</string> </key> @@ -161,33 +95,9 @@ elif resource_two!= 0 :\n <value> <tuple> <string>state_change</string> - <string>Products.DCWorkflow.DCWorkflow</string> - <string>ValidationFailed</string> - <string>Products.ERP5Type.Message</string> - <string>Message</string> - <string>_getitem_</string> - <string>transaction</string> <string>_getattr_</string> - <string>currency</string> - <string>encaisse_billets_et_monnaies</string> - <string>ressource_title</string> - <string>encaisse_devise</string> - <string>counter_site</string> - <string>incoming_destination</string> - <string>outgoing_source</string> - <string>context</string> - <string>base_price</string> - <string>None</string> - <string>msg</string> - <string>fix_montant</string> - <string>pourcentage</string> - <string>doc_resource</string> - <string>_getiter_</string> - <string>line</string> - <string>resource_two</string> - <string>billetage_entre</string> - <string>billetage_sorti</string> - <string>quantity</string> + <string>_getitem_</string> + <string>False</string> </tuple> </value> </item> diff --git a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_sale_workflow/scripts/validateVaultBalance.xml b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_sale_workflow/scripts/validateVaultBalance.xml index 621b36726d0432140ba3f26e568e899f40a6ff82..a3bc663d1aa9c316dad5d560e72296f227156266 100644 --- a/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_sale_workflow/scripts/validateVaultBalance.xml +++ b/bt5/erp5_banking_cash/WorkflowTemplateItem/portal_workflow/cash_to_currency_sale_workflow/scripts/validateVaultBalance.xml @@ -53,75 +53,11 @@ </item> <item> <key> <string>_body</string> </key> - <value> <string>from Products.DCWorkflow.DCWorkflow import ValidationFailed\n -from Products.ERP5Type.Message import Message\n -transaction = state_change[\'object\']\n -\n -currency = transaction.getResourceTitle()\n -\n -var_ressource_title = transaction.getResourceTitle().lower()\n -var_ressource_title = var_ressource_title.replace(" ", "_")\n -encaisse_devise = "/encaisse_des_devises/%s/sortante" %(var_ressource_title)\n -#encaisse_devise = "/encaisse_des_devises/%s/sortante" %(transaction.getResourceTitle().lower())\n -\n -\n -encaisse_billets_et_monnaies = "/encaisse_des_billets_et_monnaies/entrante"\n -\n -\n -# check resource on incoming line\n -doc_resource = transaction.getResource()\n -for line in transaction.contentValues(portal_type="Outgoing Cash To Currency Sale Line"):\n - if line.getResourceValue().getPriceCurrency() != doc_resource:\n - msg = Message(domain="ui", message="Resource defined on document is different from input cash.")\n - raise ValidationFailed, (msg,)\n -\n -counter_site = transaction.getSource()\n -\n -# check we don\'t change of user\n -transaction.Baobab_checkSameUserVault(counter_site)\n -\n -outgoing_source = counter_site + encaisse_devise\n -\n -# check again that we are in the good accounting date\n -transaction.Baobab_checkCounterDateOpen(site=outgoing_source, date=transaction.getStartDate())\n -\n -# check again that the counter is open\n -\n -context.Baobab_checkCounterOpened(counter_site)\n -\n -# use of the constraint : Test cash status line\n -#vliste = transaction.checkConsistency()\n -#transaction.log(\'vliste\', vliste)\n -#if len(vliste) != 0:\n -# raise ValidationFailed, (vliste[0].getMessage(),)\n -\n -\n -\n -resource_one = transaction.CashDelivery_checkCounterInventory(outgoing_source,portal_type=\'Outgoing Cash To Currency Sale Line\')\n -\n -\n -#billetage_entre = transaction.getTotalPrice(deliveryLineType=\'Incoming Cash To Currency Sale Line\')\n -billetage_entre = transaction.getTotalPrice(portal_type=[\'Incoming Cash To Currency Sale Line\',\'Cash Delivery Cell\'],fast=0)\n -#billetage_sorti = transaction.getTotalPrice(deliveryLineType=\'Outgoing Cash To Currency Sale Line\')\n -billetage_sorti = transaction.getTotalPrice(portal_type=[\'Outgoing Cash To Currency Sale Line\', \'Cash Delivery Cell\'],fast=0)\n -\n -\n -base_price = transaction.getSourceTotalAssetPrice()\n -quantity = transaction.getQuantity()\n -\n -\n -if resource_one == 2:\n - msg = Message(domain="ui", message="No Resource.")\n - raise ValidationFailed, (msg,)\n -elif billetage_entre != quantity :\n - msg = Message(domain="ui", message="Received amount is different from input cash.")\n - raise ValidationFailed, (msg,)\n -elif billetage_sorti != base_price :\n - msg = Message(domain="ui", message="Return amount is different from output cash")\n - raise ValidationFailed, (msg,) \n -elif resource_one != 0 :\n - msg = Message(domain="ui", message="Insufficient balance")\n - raise ValidationFailed, (msg,)\n + <value> <string>state_change[\'object\'].CurrencySaleOrPurchase_validateVaultBalance(\n + incoming_portal_type=\'Incoming Cash To Currency Sale Line\',\n + outgoing_portal_type=\'Outgoing Cash To Currency Sale Line\',\n + is_currency_sale=True,\n +)\n </string> </value> </item> <item> @@ -159,29 +95,9 @@ elif resource_one != 0 :\n <value> <tuple> <string>state_change</string> - <string>Products.DCWorkflow.DCWorkflow</string> - <string>ValidationFailed</string> - <string>Products.ERP5Type.Message</string> - <string>Message</string> - <string>_getitem_</string> - <string>transaction</string> <string>_getattr_</string> - <string>currency</string> - <string>var_ressource_title</string> - <string>encaisse_devise</string> - <string>encaisse_billets_et_monnaies</string> - <string>doc_resource</string> - <string>_getiter_</string> - <string>line</string> - <string>msg</string> - <string>counter_site</string> - <string>outgoing_source</string> - <string>context</string> - <string>resource_one</string> - <string>billetage_entre</string> - <string>billetage_sorti</string> - <string>base_price</string> - <string>quantity</string> + <string>_getitem_</string> + <string>True</string> </tuple> </value> </item> diff --git a/bt5/erp5_banking_cash/bt/revision b/bt5/erp5_banking_cash/bt/revision index 9084fe1a88f44196c5245586317510e602a4e3bb..633a07769901eb809dc5c81a7130887878624251 100644 --- a/bt5/erp5_banking_cash/bt/revision +++ b/bt5/erp5_banking_cash/bt/revision @@ -1 +1 @@ -684 +685 \ No newline at end of file