Commit a8030bc1 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting:

* serialise on business link to try grouping all user invoices movements
* destination project is not required on invoice
  Do not search with a None value
* Extend the invoice causality with the parent simulation movement explanation
* drop not needed movement group
  Previous movement group already force the same invoice
parent bf4c6295
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Category Movement Group" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>divergence_scope/category</string>
<string>collect_order_group/delivery</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>category_movement_group_on_delivery</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 Movement Group</string> </value>
</item>
<item>
<key> <string>tested_property</string> </key>
<value>
<tuple>
<string>source</string>
<string>destination</string>
<string>source_section</string>
<string>destination_section</string>
<string>source_project</string>
<string>destination_project</string>
<string>source_decision</string>
<string>destination_decision</string>
<string>source_payment</string>
<string>destination_payment</string>
<string>price_currency</string>
<string>ledger</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>category_movement_group_on_delivery</string> </value>
</item>
<item>
<key> <string>update_always</string> </key>
<value> <int>0</int> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -8,5 +8,4 @@ return [x.getObject() for x in portal.portal_catalog(
ledger__uid=portal.portal_categories.ledger.automated.getUid(),
# BEWARE: it works only in case of per-tree building
destination_section__uid=movement_list[0].getDestinationSectionUid(),
destination_project__uid=movement_list[0].getDestinationProjectUid(),
simulation_state=simulation_state) if x.getSimulationState() == simulation_state]
......@@ -3,6 +3,9 @@ the new Invoice.
"""
from Products.ERP5Type.Message import translateString
from DateTime import DateTime
portal = context.getPortalObject()
if related_simulation_movement_path_list is None:
raise RuntimeError, 'related_simulation_movement_path_list is missing. Update ERP5 Product.'
......@@ -11,17 +14,19 @@ price_currency = invoice.getPriceCurrency()
if invoice.getResource() != price_currency:
invoice.setResource(price_currency)
if invoice.getCausality(None) is None:
causality_list = []
for line in invoice.objectValues():
related_delivery = line.getDeliveryRelatedValue()
if related_delivery is not None:
root_applied_rule = related_delivery.getRootAppliedRule()
if root_applied_rule is not None:
causality = root_applied_rule.getCausality()
if causality is not None and causality not in causality_list:
causality_list.append(causality)
invoice.setCausalityList(causality_list)
# Extend the invoice causality with the parent simulation movement explanation
# usually, Sale Packing List
causality_list = invoice.getCausalityList()
for simulation_movement in related_simulation_movement_path_list:
simulation_movement = portal.restrictedTraverse(simulation_movement)
applied_rule = simulation_movement.getParentValue()
if applied_rule.getParentId() != 'portal_simulation':
causality = applied_rule.getParentValue().getExplanationValue()
if causality is not None:
causality = causality.getRelativeUrl()
if causality not in causality_list:
causality_list.append(causality)
invoice.setCausalityList(causality_list)
# Link the Invoice to the original Deposit payment
# this allow the invoice and payment to be automatilly grouped (lettering)
......
......@@ -16,6 +16,7 @@ if trade_condition is None:
lock_tag = 'build_in_progress_%s_%s' % (business_link.getUid(), trade_condition.getUid())
if context.getPortalObject().portal_activities.countMessageWithTag(lock_tag) == 0:
business_link.serialize()
business_link.build(
ledger__uid=context.getPortalObject().portal_categories.ledger.automated.getUid(),
specialise__uid=trade_condition.getUid(),
......
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