Commit 8daf7af2 authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_accouting: Don't split the Packing Lists with Consumption information...

slapos_accouting: Don't split the Packing Lists with Consumption information like in Subscription Request

The Consumption Information should SUM always until the packing list be stopped. The Subscription Request however should be kept separated.
parent 28326a62
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Integration Site" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Author</string>
<string>Manager</string>
<string>Owner</string>
</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>default_reference</string> </key>
<value> <string>slapos_aggregated_consumption_delivery_integration_site</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>slapos_aggregated_consumption_delivery_integration_site</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Integration Site</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>SlapOS Aggregated Consumption Delivery Integration Site</string> </value>
</item>
</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="Integration Base Category Mapping" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<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>default_destination_reference</string> </key>
<value> <string>causality</string> </value>
</item>
<item>
<key> <string>default_source_reference</string> </key>
<value> <string>Causality</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Causality</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Integration Base Category Mapping</string> </value>
</item>
</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>
......@@ -3,8 +3,8 @@
person_delivery_mapping = {}
portal = context.getPortalObject()
def newPackingList(movement, causality):
return portal.sale_packing_list_module.newContent(
def newPackingList(movement, causality, message):
delivery = portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List',
source=movement.getDestination(),
destination=movement.getDestination(),
......@@ -15,22 +15,39 @@ def newPackingList(movement, causality):
price_currency=movement.getPriceCurrency(),
causality=causality)
delivery.confirm(message)
return delivery
consumption_specialise_uid_list = [q.getUid() for q in portal.portal_catalog(
specialise_uid=portal.business_process_module.slapos_consumption_business_process.getUid(),
portal_type='Sale Trade Condition')]
for movement in movement_list:
person = movement.getDestinationValue()
causality = movement.getCausality(portal_type="Subscription Request")
specialise_uid = movement.getSpecialiseUid()
try:
delivery = person_delivery_mapping["%s---%s" % (person.getUid(), causality)]
delivery = person_delivery_mapping["%s---%s---%s" % (person.getUid(), causality, specialise_uid)]
if delivery is None:
raise KeyError
except KeyError:
delivery = person.Person_getAggregatedDelivery()
if causality is None and (delivery is None or delivery.getSimulationState() != 'confirmed'):
delivery = newPackingList(movement, causality)
delivery.confirm('New aggregated delivery.')
delivery = newPackingList(movement, causality, 'New aggregated delivery.')
person.Person_setAggregatedDelivery(delivery)
elif causality is not None:
# If causality is not None, this is a delivery from a subscription request, so
# we create a separated Sale Packing List for it.
delivery = newPackingList(movement, causality)
delivery.confirm('New aggregated delivery for subscription')
if specialise_uid in consumption_specialise_uid_list:
subscription_requestion = movement.getCausality(portal_type="Subscription Request")
delivery = subscription_requestion.SubscriptionRequest_getAggregatedConsumptionDelivery()
if delivery is None or delivery.getSimulationState() != 'confirmed':
delivery = newPackingList(movement, causality, 'New aggregated delivery for consumption')
subscription_requestion.SubscriptionRequest_setAggregatedConsumptionDelivery(delivery)
else:
# If causality is not None, this is a delivery from a subscription request, so
# we create a separated Sale Packing List for it.
delivery = newPackingList(movement, causality, 'New aggregated delivery for subscription')
person_delivery_mapping["%s---%s---%s" % (person.getUid(), causality, specialise_uid)] = delivery
person_delivery_mapping["%s---%s" % (person.getUid(), causality)] = delivery
return person_delivery_mapping.values()
integration_site = context.getPortalObject().restrictedTraverse(
'portal_integrations/slapos_aggregated_consumption_delivery_integration_site')
subscription_id = context.getId().replace('-', '_')
try:
mapping = integration_site.getCategoryFromMapping('Causality/%s' % subscription_id, create_mapping_line=True, create_mapping=True)
except ValueError:
return None
return context.restrictedTraverse(mapping)
<?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></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SubscriptionRequest_getAggregatedConsumptionDelivery</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
integration_site = context.getPortalObject().restrictedTraverse(
'portal_integrations/slapos_aggregated_delivery_integration_site')
person_id = context.getId().replace('-', '_')
integration_site.Causality[person_id].setDestinationReference(delivery.getRelativeUrl())
<?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>delivery</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SubscriptionRequest_setAggregatedConsumptionDelivery</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -49,6 +49,8 @@ portal_deliveries/slapos_sale_invoice_transaction_trade_model_builder
portal_deliveries/slapos_sale_invoice_transaction_trade_model_builder/**
portal_deliveries/slapos_sale_packing_list_builder
portal_deliveries/slapos_sale_packing_list_builder/**
portal_integrations/slapos_aggregated_consumption_delivery_integration_site
portal_integrations/slapos_aggregated_consumption_delivery_integration_site/Causality
portal_integrations/slapos_aggregated_delivery_integration_site
portal_integrations/slapos_aggregated_delivery_integration_site/Causality
portal_orders/slapos_aggregated_delivery_builder
......
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