Commit 992ce455 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: testSlapOSAccountingBuilder stop using deleted business processes

parent 525f41a2
......@@ -12,33 +12,6 @@ def convertCategoryList(base, l):
return ['%s/%s' % (base, q) for q in l]
class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
def afterSetUp(self):
super(TestSlapOSSalePackingListBuilder, self).afterSetUp()
self.expected_slapos_organisation = self.portal.organisation_module.newContent(
portal_type="Organisation",
title="testSlapOSAccountingBuilder"
).getRelativeUrl()
self.slapos_project = self.addProject()
self.slapos_trade_condition = self.portal.sale_trade_condition_module.newContent(
portal_type="Sale Trade Condition",
reference='test_trade_condition%s' % self.generateNewId(),
# XXX hardcoded
specialise="business_process_module/slapos_ultimate_business_process"
)
self.slapos_trade_condition.newContent(
portal_type="Trade Model Line",
reference="VAT",
resource="service_module/slapos_tax",
base_application="base_amount/invoicing/taxable",
trade_phase="slapos/tax",
price=0.196,
quantity=1.0,
membership_criterion_base_category=('price_currency',),
membership_criterion_category=('price_currency/currency_module/EUR',)
)
self.slapos_trade_condition.validate()
def checkSimulationMovement(self, simulation_movement):
self.assertEqual(1.0, simulation_movement.getDeliveryRatio())
......@@ -88,11 +61,15 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
self.assertEqual(expected_stop_date, delivery.getStopDate())
self.assertSameSet([
'ledger/automated',
'source/%s' % self.expected_slapos_organisation,
'source_section/%s' % self.expected_slapos_organisation,
'price_currency/currency_module/EUR',
'specialise/%s' % self.slapos_trade_condition.getRelativeUrl()] \
'ledger/automated'] \
+ convertCategoryList('price_currency',
simulation_movement.getPriceCurrencyList()) \
+ convertCategoryList('specialise',
simulation_movement.getSpecialiseList()) \
+ convertCategoryList('source',
simulation_movement.getSourceList()) \
+ convertCategoryList('source_section',
simulation_movement.getSourceSectionList()) \
+ convertCategoryList('destination',
simulation_movement.getDestinationList()) \
+ convertCategoryList('destination_section',
......@@ -105,33 +82,39 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
delivery.getCategoryList())
def test(self):
instance_tree = self.portal.instance_tree_module\
.template_instance_tree.Base_createCloneDocument(batch_mode=1)
resource, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True)
project = instance_tree.getFollowUpValue()
trade_condition = project.getSpecialiseValue()
currency = trade_condition.getPriceCurrencyValue()
source = trade_condition.getSourceSectionValue()
destination = instance_tree.getDestinationSectionValue()
business_process = trade_condition.getSpecialiseValue()
applied_rule = self.portal.portal_simulation.newContent(
portal_type='Applied Rule',
causality=instance_tree.getRelativeUrl(),
specialise='portal_rules/slapos_subscription_item_rule'
)
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
simulation_movement_kw = dict(
portal_type='Simulation Movement',
aggregate=instance_tree.getRelativeUrl(),
aggregate_value=instance_tree,
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
causality=['business_process_module/slapos_aggregated_business_process'
'/deliver', 'business_process_module/slapos_sale_business_pr'
'ocess/delivery_path'],
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
causality=[
'%s/deliver' % business_process.getRelativeUrl(),
'%s/delivery_path' % business_process.getRelativeUrl()
],
destination_value=destination,
destination_decision_value=destination,
destination_section_value=destination,
destination_project_value=project,
price_currency_value=currency,
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
resource_value=resource,
source_value=source,
source_section_value=source,
specialise_value=trade_condition,
ledger='automated',
trade_phase='slapos/delivery',
use='trade/sale',
......@@ -186,36 +169,42 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
def test(self, causality1=None, causality2=None): # pylint: disable=arguments-differ
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
resource, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True)
project = instance_tree.getFollowUpValue()
trade_condition = project.getSpecialiseValue()
currency = trade_condition.getPriceCurrencyValue()
source = trade_condition.getSourceSectionValue()
destination = instance_tree.getDestinationSectionValue()
business_process = trade_condition.getSpecialiseValue()
# Create Aggregated Packing List
delivery_kw = dict(
portal_type='Sale Packing List',
price_currency='currency_module/EUR',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
price_currency_value=currency,
source_value=source,
source_section_value=source,
specialise_value=trade_condition,
ledger='automated'
)
delivery_line_kw = dict(
portal_type='Sale Packing List Line',
resource='service_module/slapos_instance_subscription',
resource_value=resource,
use='trade/sale',
quantity_unit='unit/piece',
base_contribution_list=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
)
delivery_1 = self.portal.sale_packing_list_module.newContent(
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
destination_value=destination,
destination_decision_value=destination,
destination_section_value=destination,
destination_project_value=project,
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
causality_value=causality1,
**delivery_kw
)
# Create Applied rule and set causality
applied_rule_1 = self.portal.portal_simulation.newContent(
portal_type='Applied Rule',
......@@ -242,10 +231,10 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
# Create second delivery
delivery_2 = self.portal.sale_packing_list_module.newContent(
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
destination_value=destination,
destination_decision_value=destination,
destination_section_value=destination,
destination_project_value=project,
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
causality_value=causality2,
......@@ -272,18 +261,18 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
causality=[
'business_process_module/slapos_aggregated_business_process/deliver',
'business_process_module/slapos_sale_business_process/delivery_path'],
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
'%s/deliver' % business_process.getRelativeUrl(),
'%s/delivery_path' % business_process.getRelativeUrl()],
destination_value=destination,
destination_decision_value=destination,
destination_section_value=destination,
destination_project_value=project,
price_currency_value=currency,
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
resource_value=resource,
source_value=source,
source_section_value=source,
specialise_value=trade_condition,
trade_phase='slapos/delivery',
ledger='automated',
use='trade/sale',
......@@ -331,8 +320,8 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
invoice_movement_kw = simulation_movement_kw.copy()
invoice_movement_kw.update(
causality=[
'business_process_module/slapos_aggregated_business_process/invoice',
'business_process_module/slapos_aggregated_business_process/invoice_path'
'%s/invoice' % business_process.getRelativeUrl(),
'%s/invoice_path' % business_process.getRelativeUrl()
],
trade_phase='slapos/invoicing'
)
......@@ -403,7 +392,7 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
invoice_kw = dict(delivery_portal_type='Sale Invoice Transaction',
simulation_state='confirmed')
category_list = ['resource/currency_module/EUR', 'payment_mode/payzen']
category_list = ['resource/%s' % currency.getRelativeUrl(), 'payment_mode/payzen']
self.checkDelivery(invoice_movement_1, invoice_1,
category_list=category_list + convertCategoryList('causality',
[delivery_1.getRelativeUrl(), delivery_2.getRelativeUrl()]), **invoice_kw)
......@@ -488,6 +477,7 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
self._test_with_different_causality(causality1=causality1, causality2=causality2)
def test_with_ssingle_ausality(self):
self.portal.testromain()
causality1 = self.portal.subscription_request_module.newContent(
portal_type="Subscription Request",
)
......@@ -495,31 +485,35 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
def _test_with_different_causality(self,causality1=None, causality2=None):
resource, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True)
project = instance_tree.getFollowUpValue()
trade_condition = project.getSpecialiseValue()
currency = trade_condition.getPriceCurrencyValue()
source = trade_condition.getSourceSectionValue()
destination = instance_tree.getDestinationSectionValue()
business_process = trade_condition.getSpecialiseValue()
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
# Create Aggregated Packing List
delivery_kw = dict(
portal_type='Sale Packing List',
price_currency='currency_module/EUR',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
price_currency_value=currency,
source_value=source,
source_section_value=source,
specialise_value=trade_condition,
)
delivery_line_kw = dict(
portal_type='Sale Packing List Line',
resource='service_module/slapos_instance_subscription',
resource_value=resource,
use='trade/sale',
quantity_unit='unit/piece',
base_contribution_list=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
)
delivery_1 = self.portal.sale_packing_list_module.newContent(
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
destination_value=destination,
destination_decision_value=destination,
destination_section_value=destination,
destination_project_value=project,
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
causality_value=causality1,
......@@ -553,10 +547,10 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
# Create second delivery
delivery_2 = self.portal.sale_packing_list_module.newContent(
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
destination_value=destination,
destination_decision_value=destination,
destination_section_value=destination,
destination_project_value=project,
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
causality_value=causality2,
......@@ -584,18 +578,18 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
causality=[
'business_process_module/slapos_aggregated_business_process/deliver',
'business_process_module/slapos_sale_business_process/delivery_path'],
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
'%s/deliver' % business_process.getRelativeUrl(),
'%s/delivery_path' % business_process.getRelativeUrl()],
destination_value=destination,
destination_decision_value=destination,
destination_section_value=destination,
destination_project_value=project,
price_currency_value=currency,
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
resource_value=resource,
source_value=source,
source_section_value=source,
specialise_value=trade_condition,
trade_phase='slapos/delivery',
ledger='automated',
use='trade/sale',
......@@ -643,8 +637,8 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
invoice_movement_kw = simulation_movement_kw.copy()
invoice_movement_kw.update(
causality=[
'business_process_module/slapos_aggregated_business_process/invoice',
'business_process_module/slapos_aggregated_business_process/invoice_path'
'%s/invoice' % business_process.getRelativeUrl(),
'%s/invoice_path' % business_process.getRelativeUrl()
],
trade_phase='slapos/invoicing'
)
......@@ -714,7 +708,7 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
invoice_kw = dict(delivery_portal_type='Sale Invoice Transaction',
simulation_state='confirmed')
category_list = ['resource/currency_module/EUR', 'payment_mode/payzen']
category_list = ['resource/%s' % currency.getRelativeUrl(), 'payment_mode/payzen']
self.checkDelivery(invoice_movement_1, invoice_1,
category_list=category_list + convertCategoryList('causality',
[delivery_1.getRelativeUrl()]), **invoice_kw)
......@@ -774,30 +768,36 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
)
def test_with_different_date(self):
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
resource, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True)
project = instance_tree.getFollowUpValue()
trade_condition = project.getSpecialiseValue()
currency = trade_condition.getPriceCurrencyValue()
source = trade_condition.getSourceSectionValue()
destination = instance_tree.getDestinationSectionValue()
business_process = trade_condition.getSpecialiseValue()
# Create Aggregated Packing List
delivery_kw = dict(
portal_type='Sale Packing List',
price_currency='currency_module/EUR',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
price_currency_value=currency,
source_value=source,
source_section_value=source,
specialise_value=trade_condition,
ledger='automated'
)
delivery_line_kw = dict(
portal_type='Sale Packing List Line',
resource='service_module/slapos_instance_subscription',
resource_value=resource,
use='trade/sale',
quantity_unit='unit/piece',
base_contribution_list=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
)
delivery_1 = self.portal.sale_packing_list_module.newContent(
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
destination_value=destination,
destination_decision_value=destination,
destination_section_value=destination,
destination_project_value=project,
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
**delivery_kw
......@@ -829,10 +829,10 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
# Create second delivery
delivery_2 = self.portal.sale_packing_list_module.newContent(
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
destination_value=destination,
destination_decision_value=destination,
destination_section_value=destination,
destination_project_value=project,
start_date=DateTime('2012/02/01'),
stop_date=DateTime('2012/03/01'),
**delivery_kw
......@@ -858,18 +858,18 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
causality=[
'business_process_module/slapos_aggregated_business_process/deliver',
'business_process_module/slapos_sale_business_process/delivery_path'],
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
'%s/deliver' % business_process.getRelativeUrl(),
'%s/delivery_path' % business_process.getRelativeUrl()],
destination_value=destination,
destination_decision_value=destination,
destination_section_value=destination,
destination_project_value=project,
price_currency_value=currency,
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
resource_value=resource,
source_value=source,
source_section_value=source,
specialise_value=trade_condition,
trade_phase='slapos/delivery',
ledger='automated',
use='trade/sale',
......@@ -917,8 +917,8 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
invoice_movement_kw = simulation_movement_kw.copy()
invoice_movement_kw.update(
causality=[
'business_process_module/slapos_aggregated_business_process/invoice',
'business_process_module/slapos_aggregated_business_process/invoice_path'
'%s/invoice' % business_process.getRelativeUrl(),
'%s/invoice_path' % business_process.getRelativeUrl()
],
trade_phase='slapos/invoicing'
)
......@@ -993,7 +993,7 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
invoice_kw = dict(delivery_portal_type='Sale Invoice Transaction',
simulation_state='confirmed', expected_start_date=expected_start_date,
expected_stop_date=expected_stop_date)
category_list = ['resource/currency_module/EUR', 'payment_mode/payzen']
category_list = ['resource/%s' % currency.getRelativeUrl(), 'payment_mode/payzen']
self.checkDelivery(invoice_movement_1, invoice_1,
category_list=category_list + convertCategoryList('causality',
......@@ -1070,6 +1070,14 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
self.assertNotEqual(None, simulation_movement.getDeliveryValue())
def test(self):
resource, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True)
project = instance_tree.getFollowUpValue()
trade_condition = project.getSpecialiseValue()
currency = trade_condition.getPriceCurrencyValue()
source = trade_condition.getSourceSectionValue()
destination = instance_tree.getDestinationSectionValue()
business_process = trade_condition.getSpecialiseValue()
applied_rule_1 = self.portal.portal_simulation.newContent(
portal_type='Applied Rule',
specialise='portal_rules/slapos_delivery_root_simulation_rule'
......@@ -1078,8 +1086,7 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
portal_type='Applied Rule',
specialise='portal_rules/slapos_delivery_root_simulation_rule'
)
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
simulation_movement_1 = applied_rule_1.newContent(
portal_type='Simulation Movement'
)
......@@ -1090,18 +1097,18 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
# linked invoice
invoice_kw = dict(
portal_type='Sale Invoice Transaction',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
price_currency='currency_module/EUR',
resource='currency_module/EUR',
specialise_value=self.slapos_trade_condition,
source_value=source,
source_section_value=source,
price_currency_value=currency,
resource_value=currency,
specialise_value=trade_condition,
created_by_builder=1,
ledger='automated'
)
invoice_line_kw = dict(
portal_type='Invoice Line',
use='trade/sale',
resource='service_module/slapos_instance_subscription',
resource_value=resource,
quantity_unit='unit/piece',
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
......@@ -1116,10 +1123,10 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
invoice_1 = self.portal.accounting_module.newContent(
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
destination_project_value=self.slapos_project,
destination_value=destination,
destination_section_value=destination,
destination_decision_value=destination,
destination_project_value=project,
**invoice_kw
)
invoice_line_1 = invoice_1.newContent(
......@@ -1135,10 +1142,10 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
invoice_2 = self.portal.accounting_module.newContent(
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
destination_project_value=self.slapos_project,
destination_value=destination,
destination_section_value=destination,
destination_decision_value=destination,
destination_project_value=project,
**invoice_kw
)
invoice_line_2 = invoice_2.newContent(
......@@ -1159,8 +1166,8 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
# create new simulation movements
invoice_movement_kw = dict(
causality=[
'business_process_module/slapos_aggregated_business_process/invoice',
'business_process_module/slapos_aggregated_business_process/invoice_path'
'%s/invoice' % business_process.getRelativeUrl(),
'%s/invoice_path' % business_process.getRelativeUrl()
],
trade_phase='slapos/invoicing',
delivery_ratio=1.0,
......@@ -1168,16 +1175,16 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
portal_type='Simulation Movement',
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
destination_value=destination,
destination_section_value=destination,
destination_decision_value=destination,
destination_project_value=project,
price_currency_value=currency,
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
resource_value=resource,
source_value=source,
source_section_value=source,
specialise_value=trade_condition,
use='trade/sale',
ledger='automated'
)
......@@ -1197,15 +1204,15 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
price=.196,
delivery_ratio=1.,
delivery_error=0.,
price_currency='currency_module/EUR',
specialise_value=self.slapos_trade_condition,
price_currency_value=currency,
specialise_value=trade_condition,
resource='service_module/slapos_tax',
base_application='base_amount/invoicing/taxable',
use='trade/tax',
ledger='automated',
causality=['business_process_module/slapos_aggregated_business_process/tax',
'business_process_module/slapos_aggregated_business_process/trade_model_path',
'sale_trade_condition_module/slapos_aggregated_trade_condition/1'],
causality=['%s/tax' % business_process.getRelativeUrl(),
'%s/trade_model_path' % business_process.getRelativeUrl(),
'%s/1' % trade_condition.getRelativeUrl()],
)
trade_model_rule_1 = invoice_movement_1.newContent(
portal_type='Applied Rule',
......@@ -1261,18 +1268,17 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
)
transaction_movement_1_rec = transaction_rule_1.newContent(
portal_type='Simulation Movement',
causality=['business_process_module/slapos_aggregated_business_process/account',
'business_process_module/slapos_aggregated_business_process/account_debi'
't_path'],
causality=['%s/account' % business_process.getRelativeUrl(),
'%s/account_debit_path' % business_process.getRelativeUrl()],
destination=['account_module/payable'],
destination_decision=invoice_movement_1.getDestinationDecision(),
destination_section=invoice_movement_1.getDestinationSection(),
destination_project=invoice_movement_1.getDestinationProject(),
quantity_unit='unit/piece',
resource='currency_module/EUR',
resource_value=currency,
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
source_section_value=source,
specialise_value=trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
......@@ -1283,18 +1289,17 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
transaction_movement_1_rec_bis.edit(delivery=None, delivery_ratio=1.0)
transaction_movement_1_sal = transaction_rule_1.newContent(
portal_type='Simulation Movement',
causality=['business_process_module/slapos_aggregated_business_process/account',
'business_process_module/slapos_aggregated_business_process/account_cred'
'it_path'],
causality=['%s/account' % business_process.getRelativeUrl(),
'%s/account_credit_path' % business_process.getRelativeUrl()],
destination=['account_module/purchase'],
destination_decision=invoice_movement_1.getDestinationDecision(),
destination_section=invoice_movement_1.getDestinationSection(),
destination_project=invoice_movement_1.getDestinationProject(),
quantity_unit='unit/piece',
resource='currency_module/EUR',
resource_value=currency,
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
source_section_value=source,
specialise_value=trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
......@@ -1307,17 +1312,17 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
)
transation_model_movement_1_rec = transation_model_rule_1.newContent(
portal_type='Simulation Movement',
causality=['business_process_module/slapos_aggregated_business_process/account',
'business_process_module/slapos_aggregated_business_process/accounting_tax2'],
causality=['%s/account' % business_process.getRelativeUrl(),
'%s/accounting_tax2' % business_process.getRelativeUrl()],
destination=['account_module/payable'],
destination_decision=invoice_movement_1.getDestinationDecision(),
destination_section=invoice_movement_1.getDestinationSection(),
destination_project=invoice_movement_1.getDestinationProject(),
quantity_unit='unit/piece',
resource='currency_module/EUR',
resource_value=currency,
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
source_section_value=source,
specialise_value=trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
......@@ -1328,17 +1333,17 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
transation_model_movement_1_rec_bis.edit(delivery=None, delivery_ratio=1.0)
transation_model_movement_1_sal = transation_model_rule_1.newContent(
portal_type='Simulation Movement',
causality=['business_process_module/slapos_aggregated_business_process/account',
'business_process_module/slapos_aggregated_business_process/accounting_tax1'],
causality=['%s/account' % business_process.getRelativeUrl(),
'%s/accounting_tax1' % business_process.getRelativeUrl()],
destination=['account_module/refundable_vat'],
destination_decision=invoice_movement_1.getDestinationDecision(),
destination_section=invoice_movement_1.getDestinationSection(),
destination_project=invoice_movement_1.getDestinationProject(),
quantity_unit='unit/piece',
resource='currency_module/EUR',
resource_value=currency,
source='account_module/coll_vat',
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
source_section_value=source,
specialise_value=trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
......@@ -1351,18 +1356,17 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
)
transaction_movement_2_rec = transaction_rule_2.newContent(
portal_type='Simulation Movement',
causality=['business_process_module/slapos_aggregated_business_process/account',
'business_process_module/slapos_aggregated_business_process/account_debi'
't_path'],
causality=['%s/account' % business_process.getRelativeUrl(),
'%s/account_debit_path' % business_process.getRelativeUrl()],
destination=['account_module/payable'],
destination_decision=invoice_movement_2.getDestinationDecision(),
destination_section=invoice_movement_2.getDestinationSection(),
destination_project=invoice_movement_2.getDestinationProject(),
quantity_unit='unit/piece',
resource='currency_module/EUR',
resource_value=currency,
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
source_section_value=source,
specialise_value=trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
......@@ -1370,18 +1374,17 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
)
transaction_movement_2_sal = transaction_rule_2.newContent(
portal_type='Simulation Movement',
causality=['business_process_module/slapos_aggregated_business_process/account',
'business_process_module/slapos_aggregated_business_process/account_cred'
'it_path'],
causality=['%s/account' % business_process.getRelativeUrl(),
'%s/account_credit_path' % business_process.getRelativeUrl()],
destination=['account_module/purchase'],
destination_decision=invoice_movement_2.getDestinationDecision(),
destination_section=invoice_movement_2.getDestinationSection(),
destination_project=invoice_movement_2.getDestinationProject(),
quantity_unit='unit/piece',
resource='currency_module/EUR',
resource_value=currency,
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
source_section_value=source,
specialise_value=trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
......@@ -1394,17 +1397,17 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
)
transation_model_movement_2_rec = transation_model_rule_2.newContent(
portal_type='Simulation Movement',
causality=['business_process_module/slapos_aggregated_business_process/account',
'business_process_module/slapos_aggregated_business_process/accounting_tax2'],
causality=['%s/account' % business_process.getRelativeUrl(),
'%s/accounting_tax2' % business_process.getRelativeUrl()],
destination=['account_module/payable'],
destination_decision=invoice_movement_2.getDestinationDecision(),
destination_section=invoice_movement_2.getDestinationSection(),
destination_project=invoice_movement_2.getDestinationProject(),
quantity_unit='unit/piece',
resource='currency_module/EUR',
resource_value=currency,
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
source_section_value=source,
specialise_value=trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
......@@ -1412,17 +1415,17 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
)
transation_model_movement_2_sal = transation_model_rule_2.newContent(
portal_type='Simulation Movement',
causality=['business_process_module/slapos_aggregated_business_process/account',
'business_process_module/slapos_aggregated_business_process/accounting_tax1'],
causality=['%s/account' % business_process.getRelativeUrl(),
'%s/accounting_tax1' % business_process.getRelativeUrl()],
destination=['account_module/refundable_vat'],
destination_decision=invoice_movement_2.getDestinationDecision(),
destination_section=invoice_movement_2.getDestinationSection(),
destination_project=invoice_movement_2.getDestinationProject(),
quantity_unit='unit/piece',
resource='currency_module/EUR',
resource_value=currency,
source='account_module/coll_vat',
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
source_section_value=source,
specialise_value=trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
......@@ -1466,7 +1469,7 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
self.assertEqual('Sale Invoice Transaction Line',
transaction_line.getPortalType())
self.assertSameSet([
'resource/currency_module/EUR'] + category_list,
'resource/%s' % currency.getRelativeUrl()] + category_list,
transaction_line.getCategoryList()
)
self.assertEqual(simulation_movement.getQuantity(),
......@@ -1597,6 +1600,14 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
self.assertNotEqual(None, simulation_movement.getDeliveryValue())
def test(self):
resource, _, _, _, _, instance_tree = self.bootstrapAllocableInstanceTree(is_accountable=True)
project = instance_tree.getFollowUpValue()
trade_condition = project.getSpecialiseValue()
currency = trade_condition.getPriceCurrencyValue()
source = trade_condition.getSourceSectionValue()
destination = instance_tree.getDestinationSectionValue()
business_process = trade_condition.getSpecialiseValue()
applied_rule_1 = self.portal.portal_simulation.newContent(
portal_type='Applied Rule',
specialise='portal_rules/slapos_delivery_root_simulation_rule'
......@@ -1605,8 +1616,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
portal_type='Applied Rule',
specialise='portal_rules/slapos_delivery_root_simulation_rule'
)
person = self.portal.person_module.template_member\
.Base_createCloneDocument(batch_mode=1)
simulation_movement_1 = applied_rule_1.newContent(
portal_type='Simulation Movement'
)
......@@ -1617,11 +1627,11 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
# linked invoice
invoice_kw = dict(
portal_type='Sale Invoice Transaction',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
price_currency='currency_module/EUR',
resource='currency_module/EUR',
specialise_value=self.slapos_trade_condition,
source_value=source,
source_section_value=source,
price_currency_value=currency,
resource_value=currency,
specialise_value=trade_condition,
ledger='automated',
created_by_builder=1
)
......@@ -1629,7 +1639,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
portal_type='Invoice Line',
use='trade/sale',
ledger='automated',
resource='service_module/slapos_instance_subscription',
resource_value=resource,
quantity_unit='unit/piece',
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
......@@ -1638,10 +1648,10 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
invoice_1 = self.portal.accounting_module.newContent(
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
destination_project_value=self.slapos_project,
destination_value=destination,
destination_section_value=destination,
destination_decision_value=destination,
destination_project_value=project,
**invoice_kw
)
invoice_line_1 = invoice_1.newContent(
......@@ -1652,10 +1662,10 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
invoice_2 = self.portal.accounting_module.newContent(
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
destination_project_value=self.slapos_project,
destination_value=destination,
destination_section_value=destination,
destination_decision_value=destination,
destination_project_value=project,
**invoice_kw
)
invoice_line_2 = invoice_2.newContent(
......@@ -1680,16 +1690,16 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
portal_type='Simulation Movement',
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
destination_value=destination,
destination_decision_value=destination,
destination_section_value=destination,
destination_project_value=project,
price_currency_value=currency,
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
resource_value=resource,
source_value=source,
source_section_value=source,
specialise_value=trade_condition,
ledger='automated',
use='trade/sale',
)
......@@ -1727,11 +1737,11 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
model_movement_kw = dict(
base_application='base_amount/invoicing/taxable',
ledger='automated',
price_currency='currency_module/EUR',
price_currency_value=currency,
quantity_unit='unit/piece',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise_value=self.slapos_trade_condition,
source_value=source,
source_section_value=source,
specialise_value=trade_condition,
portal_type='Simulation Movement',
)
model_rule_1 = invoice_movement_1.newContent(
......@@ -1745,9 +1755,9 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
destination_project=invoice_movement_1.getDestinationProject(),
resource='service_module/slapos_tax',
trade_phase='slapos/tax',
causality=['business_process_module/slapos_aggregated_business_process/tax',
'business_process_module/slapos_aggregated_business_process/trade_model_path',
'sale_trade_condition_module/slapos_aggregated_trade_condition/1',
causality=['%s/tax' % business_process.getRelativeUrl(),
'%s/trade_model_path' % business_process.getRelativeUrl(),
'%s/1' % trade_condition.getRelativeUrl(),
],
price=.196,
quantity=invoice_movement_1.getTotalPrice(),
......@@ -1760,9 +1770,9 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
destination_project=invoice_movement_1.getDestinationProject(),
resource='service_module/slapos_tax',
trade_phase='slapos/tax',
causality=['business_process_module/slapos_aggregated_business_process/tax',
'business_process_module/slapos_aggregated_business_process/trade_model_path',
'sale_trade_condition_module/slapos_aggregated_trade_condition/1',
causality=['%s/tax' % business_process.getRelativeUrl(),
'%s/trade_model_path' % business_process.getRelativeUrl(),
'%s/1' % trade_condition.getRelativeUrl(),
],
price=.196,
quantity=.0,
......@@ -1780,9 +1790,9 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
destination_project=invoice_movement_2.getDestinationProject(),
resource='service_module/slapos_tax',
trade_phase='slapos/tax',
causality=['business_process_module/slapos_aggregated_business_process/tax',
'business_process_module/slapos_aggregated_business_process/trade_model_path',
'sale_trade_condition_module/slapos_aggregated_trade_condition/1',
causality=['%s/tax' % business_process.getRelativeUrl(),
'%s/trade_model_path' % business_process.getRelativeUrl(),
'%s/1' % trade_condition.getRelativeUrl(),
],
price=.196,
quantity=invoice_movement_2.getTotalPrice(),
......
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