Commit 9ff1462a authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: update testSlapOSAccountingRule

parent a71f8e70
......@@ -40,6 +40,7 @@ class TestDefaultInvoiceTransactionRule(SlapOSTestCaseMixin):
.Base_createCloneDocument(batch_mode=1)
destination = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
project = self.addProject()
aggregate = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
resource = self.portal.service_module.slapos_instance_subscription
......@@ -60,6 +61,7 @@ class TestDefaultInvoiceTransactionRule(SlapOSTestCaseMixin):
source_section_value=source,
destination_value=destination,
destination_section_value=destination,
destination_project_value=project,
resource_value=resource,
aggregate_value=aggregate,
start_date=start_date,
......@@ -68,6 +70,7 @@ class TestDefaultInvoiceTransactionRule(SlapOSTestCaseMixin):
'base_amount/invoicing/taxable'],
price_currency='currency_module/EUR',
use='trade/sale',
ledger='automated',
trade_phase='slapos/invoicing',
quantity_unit='unit/piece',
specialise=
......@@ -121,6 +124,8 @@ class TestDefaultInvoiceTransactionRule(SlapOSTestCaseMixin):
self.assertEqual(destination, simulation_movement.getDestination())
self.assertEqual(root_simulation_movement.getDestinationSection(),
simulation_movement.getDestinationSection())
self.assertEqual(root_simulation_movement.getDestinationProject(),
simulation_movement.getDestinationProject())
self.assertEqual(1, simulation_movement.getPrice())
self.assertEqual(root_simulation_movement.getTotalPrice() *\
quantity_sign, simulation_movement.getQuantity())
......@@ -136,6 +141,8 @@ class TestDefaultInvoiceTransactionRule(SlapOSTestCaseMixin):
self.assertEqual(None, simulation_movement.getUse())
self.assertEqual('slapos/accounting',
simulation_movement.getTradePhase())
self.assertEqual('automated',
simulation_movement.getLedger())
self.assertEqual(root_simulation_movement.getQuantityUnit(),
simulation_movement.getQuantityUnit())
self.assertEqual(root_simulation_movement.getSpecialise(),
......@@ -172,6 +179,7 @@ class TestDefaultInvoiceRule(SlapOSTestCaseMixin):
.Base_createCloneDocument(batch_mode=1)
destination = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
project = self.addProject()
resource = self.portal.service_module.slapos_account_validation
start_date = DateTime('2011/02/16')
stop_date = DateTime('2011/02/16')
......@@ -190,6 +198,7 @@ class TestDefaultInvoiceRule(SlapOSTestCaseMixin):
source_section_value=source,
destination_value=destination,
destination_section_value=destination,
destination_project_value=project,
resource_value=resource,
start_date=start_date,
stop_date=stop_date,
......@@ -198,6 +207,7 @@ class TestDefaultInvoiceRule(SlapOSTestCaseMixin):
price_currency='currency_module/EUR',
use='trade/sale',
trade_phase='slapos/invoicing',
ledger='automated',
quantity_unit='unit/piece',
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
causality_list=['business_process_module/slapos_aggregated_business_process/invoice_path',
......@@ -246,6 +256,7 @@ class TestDefaultInvoicingRule(SlapOSTestCaseMixin):
.Base_createCloneDocument(batch_mode=1)
destination = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
project = self.addProject()
aggregate = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
resource = self.portal.service_module.slapos_instance_subscription
......@@ -266,6 +277,7 @@ class TestDefaultInvoicingRule(SlapOSTestCaseMixin):
source_section_value=source,
destination_value=destination,
destination_section_value=destination,
destination_project_value=project,
resource_value=resource,
aggregate_value=aggregate,
start_date=start_date,
......@@ -275,6 +287,7 @@ class TestDefaultInvoicingRule(SlapOSTestCaseMixin):
price_currency='currency_module/EUR',
use='trade/sale',
trade_phase='slapos/delivery',
ledger='automated',
quantity_unit='unit/piece',
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
causality_list=['business_process_module/slapos_aggregated_business_process/delivery_path', 'business_process_module/slapos_aggregated_business_process/deliver'])
......@@ -313,6 +326,8 @@ class TestDefaultInvoicingRule(SlapOSTestCaseMixin):
simulation_movement.getDestination())
self.assertEqual(root_simulation_movement.getDestinationSection(),
simulation_movement.getDestinationSection())
self.assertEqual(root_simulation_movement.getDestinationProject(),
simulation_movement.getDestinationProject())
self.assertEqual(root_simulation_movement.getPrice(),
simulation_movement.getPrice())
self.assertEqual(root_simulation_movement.getQuantity(),
......@@ -333,6 +348,8 @@ class TestDefaultInvoicingRule(SlapOSTestCaseMixin):
simulation_movement.getUse())
self.assertEqual('slapos/invoicing',
simulation_movement.getTradePhase())
self.assertEqual('automated',
simulation_movement.getLedger())
self.assertEqual(root_simulation_movement.getQuantityUnit(),
simulation_movement.getQuantityUnit())
self.assertEqual(root_simulation_movement.getSpecialise(),
......@@ -366,6 +383,7 @@ class TestDefaultPaymentRule(SlapOSTestCaseMixin):
.Base_createCloneDocument(batch_mode=1)
destination = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
project = self.addProject()
resource = self.portal.currency_module.EUR
start_date = DateTime('2011/02/16')
stop_date = DateTime('2011/03/16')
......@@ -384,11 +402,13 @@ class TestDefaultPaymentRule(SlapOSTestCaseMixin):
source_section_value=source,
destination='account_module/payable',
destination_section_value=destination,
destination_project_value=project,
resource_value=resource,
start_date=start_date,
stop_date=stop_date,
use='trade/sale',
trade_phase='slapos/accounting',
ledger='automated',
quantity_unit='unit/piece',
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
causality_list=['business_process_module/slapos_aggregated_business_process/account'],
......@@ -421,18 +441,38 @@ class TestDefaultPaymentRule(SlapOSTestCaseMixin):
class TestHostingSubscriptionSimulation(SlapOSTestCaseMixin):
def _prepare(self):
"""
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
project = self.addProject()
self.instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
self.instance_tree.edit(
destination_section_value=person
destination_section_value=person,
follow_up_value=project
)
self.portal.portal_workflow._jumpToStateFor(self.instance_tree, 'validated')
"""
software_product, _, _, _, _, self.instance_tree = self.bootstrapAllocableInstanceTree()
#person = instance_tree.getDestinationSectionValue()
sale_supply = self.portal.sale_supply_module.newContent(
portal_type="Sale Supply",
destination_project_value=software_product.getFollowUpValue(),
price_currency="currency_module/EUR"
)
# XXX Put price in sale supply module
sale_supply.newContent(
portal_type="Sale Supply Line",
base_price=9,
resource_value=software_product
)
sale_supply.validate()
self.tic()
open_order = self.instance_tree.InstanceTree_requestUpdateOpenSaleOrder(
specialise="sale_trade_condition_module/default_subscription_trade_condition"
)
self.tic()
self.initial_date = DateTime('2011/02/16')
stop_date = DateTime('2011/04/16')
......@@ -443,7 +483,8 @@ class TestHostingSubscriptionSimulation(SlapOSTestCaseMixin):
self.open_order_line = open_order.contentValues(
portal_type='Open Sale Order Line'
)[0]
)[0].contentValues(portal_type='Open Sale Order Cell')[0]
self.open_order_line.edit(
start_date=self.initial_date,
stop_date=stop_date
......@@ -512,12 +553,16 @@ class TestHostingSubscriptionSimulation(SlapOSTestCaseMixin):
simulation_movement.getDestination())
self.assertEqual(self.open_order_line.getDestinationSection(),
simulation_movement.getDestinationSection())
self.assertEqual(self.open_order_line.getDestinationProject(),
simulation_movement.getDestinationProject())
self.assertEqual(self.open_order_line.getSpecialise(),
simulation_movement.getSpecialise())
self.assertEqual(self.open_order_line.getResource(),
simulation_movement.getResource())
self.assertEqual(applied_rule.getSpecialiseValue().getTradePhaseList(),
simulation_movement.getTradePhaseList())
self.assertEqual('automated',
simulation_movement.getLedger())
self.assertSameSet(self.open_order_line.getAggregateList(),
simulation_movement.getAggregateList())
self.assertEqual('planned', simulation_movement.getSimulationState())
......@@ -628,12 +673,16 @@ class TestHostingSubscriptionSimulation(SlapOSTestCaseMixin):
simulation_movement.getDestination())
self.assertEqual(self.open_order_line.getDestinationSection(),
simulation_movement.getDestinationSection())
self.assertEqual(self.open_order_line.getDestinationProject(),
simulation_movement.getDestinationProject())
self.assertEqual(self.open_order_line.getSpecialise(),
simulation_movement.getSpecialise())
self.assertEqual(self.open_order_line.getResource(),
simulation_movement.getResource())
self.assertEqual(applied_rule.getSpecialiseValue().getTradePhaseList(),
simulation_movement.getTradePhaseList())
self.assertEqual('automated',
simulation_movement.getLedger())
self.assertSameSet(self.open_order_line.getAggregateList(),
simulation_movement.getAggregateList())
self.assertEqual('planned', simulation_movement.getSimulationState())
......@@ -678,6 +727,7 @@ class TestDefaultTradeModelRule(SlapOSTestCaseMixin):
.Base_createCloneDocument(batch_mode=1)
destination = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
project = self.addProject()
aggregate = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
resource = self.portal.service_module.slapos_instance_subscription
......@@ -698,6 +748,7 @@ class TestDefaultTradeModelRule(SlapOSTestCaseMixin):
source_section_value=source,
destination_value=destination,
destination_section_value=destination,
destination_project_value=project,
resource_value=resource,
aggregate_value=aggregate,
start_date=start_date,
......@@ -707,6 +758,7 @@ class TestDefaultTradeModelRule(SlapOSTestCaseMixin):
price_currency='currency_module/EUR',
use='trade/sale',
trade_phase='slapos/invoicing',
ledger='automated',
quantity_unit='unit/piece',
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
causality_list=['business_process_module/slapos_aggregated_business_process/invoice_path', 'business_process_module/slapos_aggregated_business_process/invoice'],
......@@ -749,6 +801,8 @@ class TestDefaultTradeModelRule(SlapOSTestCaseMixin):
simulation_movement.getDestination())
self.assertEqual(root_simulation_movement.getDestinationSection(),
simulation_movement.getDestinationSection())
self.assertEqual(root_simulation_movement.getDestinationProject(),
simulation_movement.getDestinationProject())
self.assertEqual(root_simulation_movement.getTotalPrice(),
simulation_movement.getQuantity())
self.assertEqual(root_simulation_movement.getPriceCurrency(),
......@@ -771,6 +825,8 @@ class TestDefaultTradeModelRule(SlapOSTestCaseMixin):
self.assertEqual([], simulation_movement.getBaseContributionList())
self.assertEqual('slapos/tax',
simulation_movement.getTradePhase())
self.assertEqual('automated',
simulation_movement.getLedger())
self.assertEqual(root_simulation_movement.getQuantityUnit(),
simulation_movement.getQuantityUnit())
self.assertEqual(root_simulation_movement.getSpecialise(),
......@@ -785,16 +841,19 @@ class TestDefaultDeliveryRule(SlapOSTestCaseMixin):
def newArrow():
return self.portal.organisation_module.newContent(
portal_type='Organisation').getRelativeUrl()
project = self.addProject()
delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List',
source=newArrow(),
destination=newArrow(),
source_section=newArrow(),
destination_section=newArrow(),
destination_project_value=project,
price_currency='currency_module/EUR',
specialise=self.trade_condition,
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/02')
stop_date=DateTime('2012/02/02'),
ledger='automated'
)
line = delivery.newContent(portal_type='Sale Packing List Line',
resource=self.portal.service_module.newContent(
......@@ -851,6 +910,8 @@ class TestDefaultDeliveryRule(SlapOSTestCaseMixin):
simulation_movement.getDestinationList())
self.assertSameSet(delivery.getDestinationSectionList(),
simulation_movement.getDestinationSectionList())
self.assertSameSet(delivery.getDestinationProjectList(),
simulation_movement.getDestinationProjectList())
self.assertSameSet(delivery.getPriceCurrencyList(),
simulation_movement.getPriceCurrencyList())
self.assertSameSet(delivery.getSpecialiseList(),
......@@ -859,6 +920,8 @@ class TestDefaultDeliveryRule(SlapOSTestCaseMixin):
simulation_movement.getStartDate())
self.assertEqual(delivery.getStopDate(),
simulation_movement.getStopDate())
self.assertEqual('automated',
simulation_movement.getLedger())
self.assertSameSet([], [q.getSpecialiseReference()
for q in simulation_movement.contentValues(portal_type='Applied Rule')])
delivery.stop()
......@@ -872,17 +935,20 @@ class TestDefaultDeliveryRuleConsumption(SlapOSTestCaseMixin):
def newArrow():
return self.portal.organisation_module.newContent(
portal_type='Organisation').getRelativeUrl()
project = self.addProject()
delivery = self.portal.sale_packing_list_module.newContent(
portal_type='Sale Packing List',
source=newArrow(),
destination=newArrow(),
source_section=newArrow(),
destination_section=newArrow(),
destination_project_value=project,
price_currency='currency_module/EUR',
specialise='sale_trade_condition_module/slapos_consumption_trade_'
'condition',
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/02')
stop_date=DateTime('2012/02/02'),
ledger='automated'
)
delivery.newContent(portal_type='Sale Packing List Line',
resource=self.portal.service_module.newContent(
......
......@@ -6,12 +6,6 @@
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_recorded_property_dict</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>testSlapOSAccountingRule</string> </value>
......@@ -55,28 +49,13 @@
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</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>
......@@ -89,7 +68,7 @@
<item>
<key> <string>component_validation_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
</dictionary>
......@@ -98,7 +77,7 @@
</dictionary>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
......
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