Commit ebcef705 authored by Sebastien Robin's avatar Sebastien Robin

invoicing: invoice transaction builders should find corresponding deliveries...

invoicing: invoice transaction builders should find corresponding deliveries only through explanations

What happened before :
- user confirm sale invoice
- activity for building vat invoice lines is created
- user change destination_section
- since builder was expecting having same destination_section on delivery
and simulation movements, it was failing

Now, the builder does not look at source/destination or other categories, it only looks
for common explanation. This can be done this way only because transaction lines should
go inside the same delivery as invoice lines with standard invoicing.
parent db7ddc30
<?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>3</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_section</string>
<string>destination_section</string>
<string>source_payment</string>
<string>destination_payment</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>category_movement_group_on_delivery</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Causality Movement Group" module="erp5.portal_type"/>
<global name="Parent Explanation Movement Group" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
......@@ -22,19 +22,19 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>causality_movement_group_on_delivery</string> </value>
<value> <string>parent_explanation_movement_group_on_delivery</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>3</int> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Causality Movement Group</string> </value>
<value> <string>Parent Explanation Movement Group</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>causality_movement_group_on_delivery</string> </value>
<value> <string>parent_explanation_movement_group_on_delivery</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Movement Group" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>divergence_scope/property</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>property_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>Property Movement Group</string> </value>
</item>
<item>
<key> <string>tested_property</string> </key>
<value>
<tuple>
<string>start_date</string>
<string>stop_date</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>property_movement_group_on_delivery</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>delivery_mode</string>
<string>incoterm</string>
<string>source</string>
<string>destination</string>
<string>source_section</string>
<string>destination_section</string>
<string>source_decision</string>
<string>destination_decision</string>
<string>source_administration</string>
<string>destination_administration</string>
<string>source_project</string>
<string>destination_project</string>
<string>source_payment</string>
<string>destination_payment</string>
<string>price_currency</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>category_movement_group_on_delivery</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Causality Movement Group" module="erp5.portal_type"/>
<global name="Parent Explanation Movement Group" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
......@@ -22,19 +22,19 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>causality_movement_group_on_delivery</string> </value>
<value> <string>parent_explanation_movement_group_on_delivery</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value> <int>3</int> </value>
<value> <int>1</int> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Causality Movement Group</string> </value>
<value> <string>Parent Explanation Movement Group</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>causality_movement_group_on_delivery</string> </value>
<value> <string>parent_explanation_movement_group_on_delivery</string> </value>
</item>
</dictionary>
</pickle>
......
<?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>3</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_section</string>
<string>destination_section</string>
<string>source_payment</string>
<string>destination_payment</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>category_movement_group_on_delivery</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="First Causality Movement Group" module="erp5.portal_type"/>
<global name="Parent Explanation Movement Group" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
......@@ -16,11 +16,13 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string>BPM modification - used instead of Causality Movement Group to group orphaned parent movements coming from invoice</string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>causality_movement_group_on_delivery</string> </value>
<value> <string>parent_explanation_movement_group_on_delivery</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
......@@ -28,11 +30,11 @@
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>First Causality Movement Group</string> </value>
<value> <string>Parent Explanation Movement Group</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>First Causality Movement Group</string> </value>
<value> <string>parent_explanation_movement_group_on_delivery</string> </value>
</item>
</dictionary>
</pickle>
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Property Movement Group" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>divergence_scope/property</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>property_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>Property Movement Group</string> </value>
</item>
<item>
<key> <string>tested_property</string> </key>
<value>
<tuple>
<string>start_date</string>
<string>stop_date</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>property_movement_group_on_delivery</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?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>delivery_mode</string>
<string>incoterm</string>
<string>source</string>
<string>destination</string>
<string>source_section</string>
<string>destination_section</string>
<string>source_decision</string>
<string>destination_decision</string>
<string>source_administration</string>
<string>destination_administration</string>
<string>source_project</string>
<string>destination_project</string>
<string>source_payment</string>
<string>destination_payment</string>
<string>price_currency</string>
</tuple>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>category_movement_group_on_delivery</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -2,7 +2,7 @@
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="First Causality Movement Group" module="erp5.portal_type"/>
<global name="Parent Explanation Movement Group" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
......@@ -16,11 +16,13 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string>BPM modification - used instead of Causality Movement Group to group orphaned parent movements coming from invoice</string> </value>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>causality_movement_group_on_delivery</string> </value>
<value> <string>parent_explanation_movement_group_on_delivery</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
......@@ -28,11 +30,11 @@
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>First Causality Movement Group</string> </value>
<value> <string>Parent Explanation Movement Group</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>First Causality Movement Group</string> </value>
<value> <string>parent_explanation_movement_group_on_delivery</string> </value>
</item>
</dictionary>
</pickle>
......
......@@ -753,31 +753,6 @@ class TestInvoiceMixin(TestPackingListMixin):
new_invoice.edit(start_date=self.datetime,
stop_date=self.datetime+1)
def stepRemoveDateMovementGroupForTransactionBuilder(self, sequence=None,
sequence_list=None, **kw):
"""
Remove DateMovementGroup
"""
portal = self.getPortal()
builder = portal.portal_deliveries.sale_invoice_transaction_builder
delivery_movement_group_list = builder.getDeliveryMovementGroupList()
uf = self.getPortal().acl_users
uf._doAddUser('admin', '', ['Manager'], [])
user = uf.getUserById('admin').__of__(uf)
newSecurityManager(None, user)
for movement_group in delivery_movement_group_list:
if movement_group.getPortalType() == 'Property Movement Group':
# it contains 'start_date' and 'stop_date' only, so we remove
# movement group itself.
builder.deleteContent(movement_group.getId())
builder.newContent(
portal_type = 'Parent Explanation Movement Group',
collect_order_group='delivery',
int_index=len(delivery_movement_group_list)+1
)
user = uf.getUserById('test_invoice_user').__of__(uf)
newSecurityManager(None, user)
def stepEditInvoice(self, sequence=None, sequence_list=None, **kw):
"""Edit the current invoice, to trigger updateSimulation."""
invoice = sequence.get('invoice')
......@@ -2698,7 +2673,6 @@ class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase):
stepInvoiceBuilderAlarm
stepTic
stepCheckTwoInvoices
stepRemoveDateMovementGroupForTransactionBuilder
stepStartTwoInvoices
stepTic
stepInvoiceBuilderAlarm
......@@ -3600,6 +3574,43 @@ class TestSaleInvoice(TestSaleInvoiceMixin, TestInvoice, ERP5TypeTestCase):
self.assertEqual('solved', packing_list.getCausalityState())
self.assertEqual('solved', invoice.getCausalityState())
def test_19_SimpleInvoiceModifyArrow(self):
"""
Check we can modify arrow on an invoice without having building issues
of transaction lines
"""
sequence_list = SequenceList()
for base_sequence in (self.PACKING_LIST_DEFAULT_SEQUENCE, ) :
sequence_list.addSequenceString(
base_sequence +
"""
stepSetReadyPackingList
stepTic
stepStartPackingList
stepCheckInvoicingRule
stepTic
stepInvoiceBuilderAlarm
stepTic
stepCheckInvoiceBuilding
""")
sequence_list.play(self)
sequence = sequence_list.getSequenceList()[0]
invoice = sequence.get("invoice")
self.assertEqual("confirmed", invoice.getSimulationState())
self.assertEqual("solved", invoice.getCausalityState())
self.portal.portal_workflow.doActionFor(invoice, "start_action")
other_client = sequence.get("organisation3")
invoice.setDestinationSectionValue(other_client)
self.tic()
self.assertEqual("diverged", invoice.getCausalityState())
self.assertEqual(set([("411", -65714.22),
("44571", 10769.22),
("70712", 54945.00)]),
set([(x.getSourceValue().getGapId(),
x.getQuantity()) for x in \
invoice.objectValues(
portal_type="Sale Invoice Transaction Line")]))
class TestPurchaseInvoice(TestInvoice, ERP5TypeTestCase):
"""Tests for purchase invoice.
"""
......
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