Commit ff08a5d7 authored by Arnaud Fontaine's avatar Arnaud Fontaine

erp5_real_time_inventory_accounting: Implement Transit Accounting use case.

parent ef687d9a
......@@ -36,9 +36,58 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM
meta_type = 'ERP5 Inventory Asset Price Accounting Simulation Rule'
portal_type = 'Inventory Asset Price Accounting Simulation Rule'
## XXX: "the applicable sale/internal supply (if defined)" => even if the
## price is set to None on the PPLL/SPLL, it will be set anyway by
## Movement_getPriceCalculationOperandDict (lookup for Sale Supply)
# XXX: Copy/paste from Products.ERP5.mixin.rule to support Transit use case
def getGeneratedMovementList(self, movement_list=None, rounding=False):
"""
Returns a list of movements generated by that rule.
movement_list - optional IMovementList which can be passed explicitely
rounding - boolean argument, which controls if rounding shall be applied on
generated movements or not
NOTE:
- implement rounding appropriately (True or False seems
simplistic)
"""
# Default implementation below can be overriden by subclasses
# however it should be generic enough not to be overriden
# by most classes
# Results will be appended to result
result = []
# Build a list of movement and business path
input_movement_list = self._getInputMovementList(
movement_list=movement_list, rounding=rounding)
for input_movement in input_movement_list:
# Merge movement and business path properties (core implementation)
# Lookup Business Process through composition (NOT UNION)
business_process = input_movement.asComposedDocument()
explanation = self._applied_rule # We use applied rule as local explanation
trade_phase = self._getTradePhaseList(input_movement, business_process) # XXX-JPS not convenient to handle
update_property_dict = self._getUpdatePropertyDict(input_movement)
for movement in business_process.getTradePhaseMovementList(explanation, input_movement,
trade_phase=trade_phase, delay_mode=None,
update_property_dict=update_property_dict):
# PATCH-BEGIN
update_dict = {}
if movement.getLedger() == 'transit/entree':
update_dict['start_date'] = update_dict['stop_date'] = input_movement.getStartDate()
elif movement.getLedger() == 'transit/sortie':
update_dict['start_date'] = update_dict['stop_date'] = input_movement.getStopDate()
movement._edit(**update_dict)
input_movement.log("%r (input_movement=%r): ledger=%r, start_date=%r, stop_date=%r" %
(movement,
input_movement,
movement.getLedger(),
movement.getStartDate(),
movement.getStopDate()))
# PATCH-END
result.append(movement)
# And return list of generated movements
return result
def _getInputMovementList(self, movement_list=None, rounding=False):
simulation_movement = self._applied_rule.getParentValue()
......@@ -58,10 +107,21 @@ class InventoryAssetPriceAccountingRuleMovementGenerator(InvoiceTransactionRuleM
# XXX: Root Applied Rule?
use = input_movement.getUse()
# Site Preference => Trade => Sale/Purchase uses
#input_movement.log("%r (ledger=%r)" % (input_movement, input_movement.getLedger()))
if use == 'trade/sale':
start_date = stop_date = input_movement.getStartDate()
start_date = input_movement.getStartDate()
if input_movement.getLedger() == 'transit/sortie':
stop_date = input_movement.getStopDate()
else:
stop_date = start_date
elif use == 'trade/purchase':
start_date = stop_date = input_movement.getStopDate()
stop_date = input_movement.getStopDate()
if input_movement.getLedger() == 'transit/entree':
start_date = input_movement.getStartDate()
else:
start_date = stop_date
update_property_dict['source_section'] = input_movement.getDestinationSection()
else:
raise NotImplementedError("%s: use='%s' not handled by this Rule" %
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Trade Model Path" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>ledger</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>trade_phase/trade/inventory_accounting</string>
<string>ledger/transit/entree</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>TMP-INVENTORY-ACCOUNTING-TRANSIT-LG-IN-CREDIT</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>destination_method_id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerInCreditDestination</string> </value>
</item>
<item>
<key> <string>efficiency</string> </key>
<value> <float>-1.0</float> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>inventory_accounting_transit_ledger_in_credit_path</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>ledger</string> </key>
<value> <string>stock</string> </value>
</item>
<item>
<key> <string>payment_end_of_month</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Trade Model Path</string> </value>
</item>
<item>
<key> <string>source_method_id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerInCreditSource</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Inventory Accounting Transit Ledger In Credit</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Trade Model Path" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>ledger</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>trade_phase/trade/inventory_accounting</string>
<string>ledger/transit/entree</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>TMP-INVENTORY-ACCOUNTING-TRANSIT-LG-IN-DEBIT</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>destination_method_id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerInDebitDestination</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>inventory_accounting_transit_ledger_in_debit</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>ledger</string> </key>
<value> <string>stock</string> </value>
</item>
<item>
<key> <string>payment_end_of_month</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Trade Model Path</string> </value>
</item>
<item>
<key> <string>source_method_id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerInDebitSource</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Inventory Accounting Transit Ledger In Debit</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Trade Model Path" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>ledger</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>trade_phase/trade/inventory_accounting</string>
<string>ledger/transit/sortie</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>TMP-INVENTORY-ACCOUNTING-TRANSIT-LG-OUT-CREDIT</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>destination_method_id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerOutCreditDestination</string> </value>
</item>
<item>
<key> <string>efficiency</string> </key>
<value> <float>-1.0</float> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>inventory_accounting_transit_ledger_out_credit_path</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>ledger</string> </key>
<value> <string>stock</string> </value>
</item>
<item>
<key> <string>payment_end_of_month</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Trade Model Path</string> </value>
</item>
<item>
<key> <string>source_method_id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerOutCreditSource</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Inventory Accounting Transit Ledger Out Credit</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Trade Model Path" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_identity_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>ledger</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>string</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>trade_phase/trade/inventory_accounting</string>
<string>ledger/transit/sortie</string>
</tuple>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>TMP-INVENTORY-ACCOUNTING-TRANSIT-LG-OUT-DEBIT</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>destination_method_id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerOutDebitDestination</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>inventory_accounting_transit_ledger_out_debit_path</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>ledger</string> </key>
<value> <string>stock</string> </value>
</item>
<item>
<key> <string>payment_end_of_month</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Trade Model Path</string> </value>
</item>
<item>
<key> <string>source_method_id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerOutDebitSource</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Inventory Accounting Transit Ledger Out Debit</string> </value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -53,6 +53,24 @@
</tuple>
</value>
</item>
<item>
<key> <string>_count</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>_mt_index</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>_tree</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>transit</string> </value>
......@@ -68,4 +86,26 @@
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="Length" module="BTrees.Length"/>
</pickle>
<pickle> <int>0</int> </pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="OOBTree" module="BTrees.OOBTree"/>
</pickle>
<pickle>
<none/>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>ledger/transit/entree</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>entree</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Entrée Transit</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_folders_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Copy_or_Move_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Delete_objects_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>ledger/transit/sortie</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>sortie</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>2</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Category</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Sortie Transit</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
use = movement.getUse()
if use == 'trade/sale':
return []
elif use == 'trade/purchase':
if movement.getDestination() == 'organisation_module/supplier':
return ['source/account_module/stock_parts_transit']
else:
raise NotImplementedError
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>_params</string> </key>
<value> <string>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerInCreditDestination</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
use = movement.getUse()
if use == 'trade/sale':
if movement.getSource() == 'organisation_module/hoge':
return ['source/account_module/variation_cars']
elif use == 'trade/purchase':
return []
else:
raise NotImplementedError
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>_params</string> </key>
<value> <string>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerInCreditSource</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
use = movement.getUse()
if use == 'trade/sale':
return []
elif use == 'trade/purchase':
if movement.getDestination() == 'organisation_module/supplier':
return ['source/account_module/variation_parts']
else:
raise NotImplementedError
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>_params</string> </key>
<value> <string>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerInDebitDestination</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
use = movement.getUse()
if use == 'trade/sale':
if movement.getSource() == 'organisation_module/hoge':
return ['source/account_module/stock_car_transit']
elif use == 'trade/purchase':
return []
else:
raise NotImplementedError
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>_params</string> </key>
<value> <string>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerInDebitSource</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
use = movement.getUse()
if use == 'trade/sale':
return []
elif use == 'trade/purchase':
if movement.getDestination() == 'organisation_module/supplier':
return ['source/account_module/variation_parts']
else:
raise NotImplementedError
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>_params</string> </key>
<value> <string>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerOutCreditDestination</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
use = movement.getUse()
if use == 'trade/sale':
if movement.getSource() == 'organisation_module/hoge':
return ['source/account_module/stock_car_transit']
elif use == 'trade/purchase':
return []
else:
raise NotImplementedError
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>_params</string> </key>
<value> <string>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerOutCreditSource</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
use = movement.getUse()
if use == 'trade/sale':
return []
elif use == 'trade/purchase':
if movement.getDestination() == 'organisation_module/supplier':
return ['source/account_module/stock_parts_transit']
else:
raise NotImplementedError
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>_params</string> </key>
<value> <string>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerOutDebitDestination</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
use = movement.getUse()
if use == 'trade/sale':
if movement.getSource() == 'organisation_module/hoge':
return ['source/account_module/variation_cars']
elif use == 'trade/purchase':
return []
else:
raise NotImplementedError
return []
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </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>_params</string> </key>
<value> <string>movement</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>TradeModelPath_getInventoryAccountingTransitLedgerOutDebitSource</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -100,15 +100,15 @@ class TestRealTimeInventoryAccountingMixin:
packing_list = sequence['current_purchase_packing_list']
self._checkAndGetCausalityRelated(packing_list, 'Accounting Transaction', 0)
def stepCheckAccountingTransactionGeneratedFromSalePackingList(self, sequence=None, sequence_list=None):
def stepCheckThreeAccountingTransactionGeneratedFromSalePackingList(self, sequence=None, sequence_list=None):
packing_list = sequence['current_sale_packing_list']
accounting_transaction = self._checkAndGetCausalityRelated(packing_list, 'Accounting Transaction', 1)[0]
sequence.edit(current_accounting_transaction=accounting_transaction)
accounting_transaction_list = self._checkAndGetCausalityRelated(packing_list, 'Accounting Transaction', 3)
sequence.edit(current_accounting_transaction_list=accounting_transaction_list)
def stepCheckAccountingTransactionGeneratedFromPurchasePackingList(self, sequence=None, sequence_list=None):
def stepCheckThreeAccountingTransactionGeneratedFromPurchasePackingList(self, sequence=None, sequence_list=None):
packing_list = sequence['current_purchase_packing_list']
accounting_transaction = self._checkAndGetCausalityRelated(packing_list, 'Accounting Transaction', 1)[0]
sequence.edit(current_accounting_transaction=accounting_transaction)
accounting_transaction_list = self._checkAndGetCausalityRelated(packing_list, 'Accounting Transaction', 3)
sequence.edit(current_accounting_transaction_list=accounting_transaction_list)
def _checkDelivery(self,
delivery,
......@@ -150,8 +150,14 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc
def afterSetUp(self):
category_tool = self.portal.portal_categories
getattr(self.portal.portal_types,
'Accounting Transaction').setLedgerValueList(category_tool.ledger.contentValues())
getattr(self.portal.portal_types, 'Accounting Transaction').setLedgerValueList(
[category_tool.ledger.achat,
category_tool.ledger.preparation,
category_tool.ledger.production,
category_tool.ledger.stock,
category_tool.ledger.transit.entree,
category_tool.ledger.transit.sortie,
category_tool.ledger.vente])
if 'my_group' not in category_tool.group:
category_tool.group.newContent(portal_type='Category',
......@@ -178,6 +184,16 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc
financial_section_value=category_tool.financial_section.asset.current_assets.stock,
gap_value=category_tool.gap.fr.pcg['3']['35']['355'])
if 'stock_car_transit' not in self.portal.account_module:
self.portal.account_module.newContent(
portal_type='Account',
id='stock_car_transit',
reference='STOCK_CAR_TRANSIT',
title='Stock Transit Véhicules',
account_type_value=category_tool.account_type.asset,
financial_section_value=category_tool.financial_section.asset.current_assets.stock,
gap_value=category_tool.gap.fr.pcg['3']['35']['355'])
if 'variation_parts' not in self.portal.account_module:
self.portal.account_module.newContent(
portal_type='Account',
......@@ -198,6 +214,16 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc
financial_section_value=category_tool.financial_section.asset.current_assets.stock,
gap_value=category_tool.gap.fr.pcg['3']['32']['321'])
if 'stock_parts_transit' not in self.portal.account_module:
self.portal.account_module.newContent(
portal_type='Account',
id='stock_parts_transit',
reference='STOCK_PARTS_TRANSIT',
title='Stock Parts Transit',
account_type_value=category_tool.account_type.asset,
financial_section_value=category_tool.financial_section.asset.current_assets.stock,
gap_value=category_tool.gap.fr.pcg['3']['32']['321'])
try:
currency_eur = self.portal.currency_module.EUR
except AttributeError:
......@@ -430,14 +456,15 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc
sequence.edit(sale_packing_list_1=sale_packing_list)
def stepTestSalePackingList_checkAllAccountingTransaction(self, sequence=None, sequence_list=None):
accounting_transaction = sequence['current_accounting_transaction']
accounting_transaction_list = sequence['current_accounting_transaction_list']
for accounting_transaction in accounting_transaction_list:
self.assertEquals(accounting_transaction.getSimulationState(), 'draft')
if accounting_transaction.getLedgerValue() == self.portal.portal_categories.ledger.stock:
self._checkDelivery(
accounting_transaction,
delivery_property_dict=dict(
source_section_value=self.portal.organisation_module.hoge,
resource_value=self.portal.currency_module.DOL,
ledger_value=self.portal.portal_categories.ledger.stock,
# start_date=stop_date=SPL.start_date
start_date=DateTime('2018/01/30 00:00:00 GMT+9'),
stop_date=DateTime('2018/01/30 00:00:00 GMT+9')),
......@@ -451,6 +478,46 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc
# sum(SPLL.price)
quantity=17100)))
elif accounting_transaction.getLedgerValue() == self.portal.portal_categories.ledger.transit.entree:
self._checkDelivery(
accounting_transaction,
delivery_property_dict=dict(
source_section_value=self.portal.organisation_module.hoge,
resource_value=self.portal.currency_module.DOL,
# start_date=stop_date=SPL.start_date
start_date=DateTime('2018/01/30 00:00:00 GMT+9'),
stop_date=DateTime('2018/01/30 00:00:00 GMT+9')),
movement_property_dict_tuple=(
dict(portal_type='Accounting Transaction Line',
source_value=self.portal.account_module.variation_cars,
# sum(SPLL.price)
quantity=-17100),
dict(portal_type='Accounting Transaction Line',
source_value=self.portal.account_module.stock_car_transit,
# sum(SPLL.price)
quantity=17100)))
# ledger/transit/sortie
else:
self._checkDelivery(
accounting_transaction,
delivery_property_dict=dict(
source_section_value=self.portal.organisation_module.hoge,
resource_value=self.portal.currency_module.DOL,
ledger_value=self.portal.portal_categories.ledger.transit.sortie,
# start_date=stop_date=SPL.stop_date
start_date=DateTime('2018/01/31 00:00:00 GMT+9'),
stop_date=DateTime('2018/01/31 00:00:00 GMT+9')),
movement_property_dict_tuple=(
dict(portal_type='Accounting Transaction Line',
source_value=self.portal.account_module.stock_car_transit,
# sum(SPLL.price)
quantity=-17100),
dict(portal_type='Accounting Transaction Line',
source_value=self.portal.account_module.variation_cars,
# sum(SPLL.price)
quantity=17100)))
def testSalePackingList(self):
sequence_list = SequenceList()
sequence_str = """
......@@ -465,7 +532,7 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc
Tic
CallBuilder
Tic
CheckAccountingTransactionGeneratedFromSalePackingList
CheckThreeAccountingTransactionGeneratedFromSalePackingList
TestSalePackingList_checkAllAccountingTransaction
"""
sequence_list.addSequenceString(sequence_str)
......@@ -548,14 +615,15 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc
sequence.edit(purchase_packing_list_1=purchase_packing_list)
def stepTestPurchasePackingList_checkAllAccountingTransaction(self, sequence=None, sequence_list=None):
accounting_transaction = sequence['current_accounting_transaction']
accounting_transaction_list = sequence['current_accounting_transaction_list']
for accounting_transaction in accounting_transaction_list:
self.assertEquals(accounting_transaction.getSimulationState(), 'draft')
if accounting_transaction.getLedgerValue() == self.portal.portal_categories.ledger.stock:
self._checkDelivery(
accounting_transaction,
delivery_property_dict=dict(
source_section_value=self.portal.organisation_module.hoge,
resource_value=self.portal.currency_module.DOL,
ledger_value=self.portal.portal_categories.ledger.stock,
# start_date=stop_date=PPL.stop_date
start_date=DateTime('2018/01/10 00:00:00 GMT+9'),
stop_date=DateTime('2018/01/10 00:00:00 GMT+9')),
......@@ -569,6 +637,46 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc
# sum(PPLL.price)
quantity=14000)))
elif accounting_transaction.getLedgerValue() == self.portal.portal_categories.ledger.transit.entree:
self._checkDelivery(
accounting_transaction,
delivery_property_dict=dict(
source_section_value=self.portal.organisation_module.hoge,
resource_value=self.portal.currency_module.DOL,
# start_date=stop_date=PPL.start_date
start_date=DateTime('2018/01/09 00:00:00 GMT+9'),
stop_date=DateTime('2018/01/09 00:00:00 GMT+9')),
movement_property_dict_tuple=(
dict(portal_type='Accounting Transaction Line',
source_value=self.portal.account_module.stock_parts_transit,
# sum(PPLL.price)
quantity=-14000),
dict(portal_type='Accounting Transaction Line',
source_value=self.portal.account_module.variation_parts,
# sum(PPLL.price)
quantity=14000)))
# ledger/transit/sortie
else:
self._checkDelivery(
accounting_transaction,
delivery_property_dict=dict(
source_section_value=self.portal.organisation_module.hoge,
resource_value=self.portal.currency_module.DOL,
ledger_value=self.portal.portal_categories.ledger.transit.sortie,
# start_date=stop_date=PPL.stop_date
start_date=DateTime('2018/01/10 00:00:00 GMT+9'),
stop_date=DateTime('2018/01/10 00:00:00 GMT+9')),
movement_property_dict_tuple=(
dict(portal_type='Accounting Transaction Line',
source_value=self.portal.account_module.stock_parts_transit,
# sum(PPLL.price)
quantity=14000),
dict(portal_type='Accounting Transaction Line',
source_value=self.portal.account_module.variation_parts,
# sum(PPLL.price)
quantity=-14000)))
def testPurchasePackingList(self):
sequence_list = SequenceList()
sequence_str = """
......@@ -583,7 +691,7 @@ class TestRealTimeInventoryAccounting(ERP5TypeTestCase, TestRealTimeInventoryAcc
Tic
CallBuilder
Tic
CheckAccountingTransactionGeneratedFromPurchasePackingList
CheckThreeAccountingTransactionGeneratedFromPurchasePackingList
TestPurchasePackingList_checkAllAccountingTransaction
"""
sequence_list.addSequenceString(sequence_str)
......
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