Commit 1b3f2e35 authored by Łukasz Nowak's avatar Łukasz Nowak

Extend aggregated invoice constraints.

Its total price related with use/trade/sale shall match related packing list
total price.
parent 2988be8c
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="TALES Constraint" 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>_range_criterion</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>expression</string> </key>
<value> <string>python: context.SaleInvoiceTransaction_isTotalPriceMatchingSalePackingList()</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>use_trade_sale_total_price_matches_delivery_constraint</string> </value>
</item>
<item>
<key> <string>int_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>membership_criterion_category</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>message_expression_false</string> </key>
<value> <string>Total price does not match related Sale Packing List</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>TALES Constraint</string> </value>
</item>
<item>
<key> <string>string_index</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>test_method_id</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>test_tales_expression</string> </key>
<value> <string>python: context.getSpecialise() == context.getPortalObject().portal_preferences.getPreferredAggregatedSaleTradeCondition()</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="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>_body</string> </key>
<value> <string>invoice = context\n
specialise = context.getPortalObject().portal_preferences.getPreferredAggregatedSaleTradeCondition()\n
if invoice.getSpecialise() != specialise:\n
raise TypeError(\'Only invoice specialised by %s shall be checked\' % specialise)\n
\n
delivery_list = invoice.getCausalityValueList(portal_type=\'Sale Packing List\')\n
amount = len(delivery_list)\n
if amount != 1:\n
raise TypeError(\'Wrong amount %s of related packing lists\' % amount)\n
delivery = delivery_list[0]\n
\n
return delivery.getTotalPrice(use=\'use/trade/sale\') == context.getTotalPrice(use=\'use/trade/sale\')\n
</string> </value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>SaleInvoiceTransaction_isTotalPriceMatchingSalePackingList</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -195,3 +195,27 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
use='trade/tax',
)
self.assertFalse(message in self.getMessageList(invoice))
@withAbort
def test_use_trade_sale_total_price_matches_delivery_constraint(self):
message = "Total price does not match related Sale Packing List"
delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List')
delivery.newContent(portal_type='Sale Packing List Line',
use='trade/sale', quantity=1., price=1.)
invoice = self.portal.accounting_module.newContent(
portal_type='Sale Invoice Transaction',
causality=delivery.getRelativeUrl())
invoice_line = invoice.newContent(portal_type='Invoice Line', quantity=2.,
price=1., use='trade/sale')
self.assertFalse(message in self.getMessageList(invoice))
self.portal.portal_workflow._jumpToStateFor(invoice, 'confirmed')
self.assertFalse(message in self.getMessageList(invoice))
invoice.setSpecialise('sale_trade_condition_module/slapos_aggregated_trade_condition')
self.assertTrue(message in self.getMessageList(invoice))
invoice_line.setQuantity(1.)
self.assertFalse(message in self.getMessageList(invoice))
invoice.newContent(portal_type='Invoice Line', quantity=2.,
price=1.)
self.assertFalse(message in self.getMessageList(invoice))
162
\ No newline at end of file
163
\ No newline at end of file
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