Commit 7d0ccd72 authored by Romain Courteaud's avatar Romain Courteaud

slapos_accounting: builder test: set ledger and destination_project

Use a test trade condition
parent 791a849a
......@@ -8,8 +8,6 @@
from erp5.component.test.SlapOSTestCaseMixin import SlapOSTestCaseMixin
from DateTime import DateTime
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL = 'sale_trade_condition_module/slapos_aggregated_trade_condition_v3'
def convertCategoryList(base, l):
return ['%s/%s' % (base, q) for q in l]
......@@ -21,6 +19,27 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
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())
self.assertEqual(0.0, simulation_movement.getDeliveryError())
......@@ -69,16 +88,19 @@ 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' % AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL] \
'specialise/%s' % self.slapos_trade_condition.getRelativeUrl()] \
+ convertCategoryList('destination',
simulation_movement.getDestinationList()) \
+ convertCategoryList('destination_section',
simulation_movement.getDestinationSectionList()) \
+ convertCategoryList('destination_decision',
simulation_movement.getDestinationDecisionList()) \
+ convertCategoryList('destination_project',
simulation_movement.getDestinationProjectList()) \
+ category_list,
delivery.getCategoryList())
......@@ -100,15 +122,17 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
causality=['business_process_module/slapos_aggregated_business_process'
'/deliver', 'business_process_module/slapos_sale_business_pr'
'ocess/delivery_path'],
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
ledger='automated',
trade_phase='slapos/delivery',
use='trade/sale',
)
......@@ -158,6 +182,7 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
self.checkDelivery(simulation_movement_1, delivery_1, **delivery_kw)
self.checkDelivery(simulation_movement_2, delivery_2, **delivery_kw)
class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
def test(self, causality1=None, causality2=None): # pylint: disable=arguments-differ
......@@ -169,7 +194,8 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
price_currency='currency_module/EUR',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
ledger='automated'
)
delivery_line_kw = dict(
portal_type='Sale Packing List Line',
......@@ -180,9 +206,10 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
'base_amount/invoicing/taxable'],
)
delivery_1 = self.portal.sale_packing_list_module.newContent(
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
causality_value=causality1,
......@@ -215,9 +242,10 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
# Create second delivery
delivery_2 = self.portal.sale_packing_list_module.newContent(
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
causality_value=causality2,
......@@ -246,16 +274,18 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
causality=[
'business_process_module/slapos_aggregated_business_process/deliver',
'business_process_module/slapos_sale_business_process/delivery_path'],
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
trade_phase='slapos/delivery',
ledger='automated',
use='trade/sale',
delivery_ratio=1.0
)
......@@ -475,7 +505,7 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
price_currency='currency_module/EUR',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
specialise_value=self.slapos_trade_condition,
)
delivery_line_kw = dict(
portal_type='Sale Packing List Line',
......@@ -486,12 +516,14 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
'base_amount/invoicing/taxable'],
)
delivery_1 = self.portal.sale_packing_list_module.newContent(
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
causality_value=causality1,
ledger='automated',
**delivery_kw
)
......@@ -521,12 +553,14 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
# Create second delivery
delivery_2 = self.portal.sale_packing_list_module.newContent(
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
causality_value=causality2,
ledger='automated',
**delivery_kw
)
applied_rule_2 = self.portal.portal_simulation.newContent(
......@@ -552,16 +586,18 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
causality=[
'business_process_module/slapos_aggregated_business_process/deliver',
'business_process_module/slapos_sale_business_process/delivery_path'],
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
trade_phase='slapos/delivery',
ledger='automated',
use='trade/sale',
delivery_ratio=1.0
)
......@@ -746,7 +782,8 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
price_currency='currency_module/EUR',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
ledger='automated'
)
delivery_line_kw = dict(
portal_type='Sale Packing List Line',
......@@ -757,9 +794,10 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
'base_amount/invoicing/taxable'],
)
delivery_1 = self.portal.sale_packing_list_module.newContent(
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
**delivery_kw
......@@ -791,9 +829,10 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
# Create second delivery
delivery_2 = self.portal.sale_packing_list_module.newContent(
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
start_date=DateTime('2012/02/01'),
stop_date=DateTime('2012/03/01'),
**delivery_kw
......@@ -821,16 +860,18 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
causality=[
'business_process_module/slapos_aggregated_business_process/deliver',
'business_process_module/slapos_sale_business_process/delivery_path'],
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
trade_phase='slapos/delivery',
ledger='automated',
use='trade/sale',
delivery_ratio=1.0
)
......@@ -1053,8 +1094,9 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
source_section=self.expected_slapos_organisation,
price_currency='currency_module/EUR',
resource='currency_module/EUR',
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
created_by_builder=1
specialise_value=self.slapos_trade_condition,
created_by_builder=1,
ledger='automated'
)
invoice_line_kw = dict(
portal_type='Invoice Line',
......@@ -1074,9 +1116,10 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
invoice_1 = self.portal.accounting_module.newContent(
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
destination=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
destination_project_value=self.slapos_project,
**invoice_kw
)
invoice_line_1 = invoice_1.newContent(
......@@ -1092,9 +1135,10 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
invoice_2 = self.portal.accounting_module.newContent(
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
destination=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
destination_project_value=self.slapos_project,
**invoice_kw
)
invoice_line_2 = invoice_2.newContent(
......@@ -1124,16 +1168,18 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
portal_type='Simulation Movement',
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
use='trade/sale',
ledger='automated'
)
invoice_rule_1 = simulation_movement_1.newContent(
portal_type='Applied Rule',
......@@ -1152,10 +1198,11 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
delivery_ratio=1.,
delivery_error=0.,
price_currency='currency_module/EUR',
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_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'],
......@@ -1169,6 +1216,7 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
destination=invoice_movement_1.getDestination(),
source_section=invoice_movement_1.getSourceSection(),
destination_section=invoice_movement_1.getDestinationSection(),
destination_project=invoice_movement_1.getDestinationProject(),
quantity=invoice_movement_1.getTotalPrice(),
delivery=invoice_line_1_tax.getRelativeUrl(),
**trade_movement_kw
......@@ -1192,6 +1240,7 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
destination=invoice_movement_2.getDestination(),
source_section=invoice_movement_2.getSourceSection(),
destination_section=invoice_movement_2.getDestinationSection(),
destination_project=invoice_movement_2.getDestinationProject(),
quantity=invoice_movement_2.getTotalPrice(),
delivery=invoice_line_2_tax.getRelativeUrl(),
**trade_movement_kw
......@@ -1218,12 +1267,14 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
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',
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
quantity=invoice_movement_1.getTotalPrice() * -1,
)
......@@ -1238,12 +1289,14 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
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',
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
quantity=invoice_movement_1.getTotalPrice(),
)
......@@ -1259,12 +1312,14 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
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',
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
quantity=trade_movement_1.getTotalPrice() * -1,
)
......@@ -1278,12 +1333,14 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
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',
source='account_module/coll_vat',
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
quantity=trade_movement_1.getTotalPrice(),
)
......@@ -1300,12 +1357,14 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
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',
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
quantity=invoice_movement_2.getTotalPrice() * -1,
)
......@@ -1317,12 +1376,14 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
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',
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
quantity=invoice_movement_2.getTotalPrice(),
)
......@@ -1338,12 +1399,14 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
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',
source='account_module/receivable',
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
quantity=trade_movement_2.getTotalPrice() * -1,
)
......@@ -1354,12 +1417,14 @@ class TestSlapOSSaleInvoiceTransactionBuilder(TestSlapOSSalePackingListBuilder):
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',
source='account_module/coll_vat',
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
trade_phase='slapos/accounting',
ledger='automated',
price=1.0,
quantity=trade_movement_2.getTotalPrice(),
)
......@@ -1556,12 +1621,14 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
source_section=self.expected_slapos_organisation,
price_currency='currency_module/EUR',
resource='currency_module/EUR',
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
ledger='automated',
created_by_builder=1
)
invoice_line_kw = dict(
portal_type='Invoice Line',
use='trade/sale',
ledger='automated',
resource='service_module/slapos_instance_subscription',
quantity_unit='unit/piece',
base_contribution=['base_amount/invoicing/discounted',
......@@ -1571,9 +1638,10 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
invoice_1 = self.portal.accounting_module.newContent(
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
destination=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
destination_project_value=self.slapos_project,
**invoice_kw
)
invoice_line_1 = invoice_1.newContent(
......@@ -1584,9 +1652,10 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
invoice_2 = self.portal.accounting_module.newContent(
start_date=DateTime('2012/01/01'),
stop_date=DateTime('2012/02/01'),
destination=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_value=person,
destination_section_value=person,
destination_decision_value=person,
destination_project_value=self.slapos_project,
**invoice_kw
)
invoice_line_2 = invoice_2.newContent(
......@@ -1611,15 +1680,17 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
portal_type='Simulation Movement',
base_contribution=['base_amount/invoicing/discounted',
'base_amount/invoicing/taxable'],
destination=person.getRelativeUrl(),
destination_decision=person.getRelativeUrl(),
destination_section=person.getRelativeUrl(),
destination_value=person,
destination_decision_value=person,
destination_section_value=person,
destination_project_value=self.slapos_project,
price_currency='currency_module/EUR',
quantity_unit='unit/piece',
resource='service_module/slapos_instance_subscription',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
ledger='automated',
use='trade/sale',
)
invoice_rule_1 = simulation_movement_1.newContent(
......@@ -1630,7 +1701,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
stop_date=invoice_1.getStopDate(),
quantity=invoice_line_1.getQuantity(),
price=invoice_line_1.getPrice(),
delivery=invoice_line_1.getRelativeUrl(),
delivery_value=invoice_line_1,
**invoice_movement_kw)
invoice_rule_2 = simulation_movement_2.newContent(
......@@ -1641,7 +1712,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
stop_date=invoice_2.getStopDate(),
quantity=invoice_line_2.getQuantity(),
price=invoice_line_2.getPrice(),
delivery=invoice_line_2.getRelativeUrl(),
delivery_value=invoice_line_2,
**invoice_movement_kw)
self.tic()
......@@ -1655,11 +1726,12 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
model_movement_kw = dict(
base_application='base_amount/invoicing/taxable',
ledger='automated',
price_currency='currency_module/EUR',
quantity_unit='unit/piece',
source=self.expected_slapos_organisation,
source_section=self.expected_slapos_organisation,
specialise=AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL,
specialise_value=self.slapos_trade_condition,
portal_type='Simulation Movement',
)
model_rule_1 = invoice_movement_1.newContent(
......@@ -1670,6 +1742,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
destination=invoice_movement_1.getDestination(),
destination_section=invoice_movement_1.getDestinationSection(),
destination_decision=invoice_movement_1.getDestinationDecision(),
destination_project=invoice_movement_1.getDestinationProject(),
resource='service_module/slapos_tax',
trade_phase='slapos/tax',
causality=['business_process_module/slapos_aggregated_business_process/tax',
......@@ -1684,6 +1757,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
destination=invoice_movement_1.getDestination(),
destination_section=invoice_movement_1.getDestinationSection(),
destination_decision=invoice_movement_1.getDestinationDecision(),
destination_project=invoice_movement_1.getDestinationProject(),
resource='service_module/slapos_tax',
trade_phase='slapos/tax',
causality=['business_process_module/slapos_aggregated_business_process/tax',
......@@ -1703,6 +1777,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
destination=invoice_movement_2.getDestination(),
destination_section=invoice_movement_2.getDestinationSection(),
destination_decision=invoice_movement_2.getDestinationDecision(),
destination_project=invoice_movement_2.getDestinationProject(),
resource='service_module/slapos_tax',
trade_phase='slapos/tax',
causality=['business_process_module/slapos_aggregated_business_process/tax',
......@@ -1834,7 +1909,7 @@ class TestSlapOSSaleInvoiceTransactionTradeModelBuilder(TestSlapOSSalePackingLis
self.assertEqual(invoice_2.getRelativeUrl(),
model_line_2_tax_bis.getParentValue().getRelativeUrl())
"""
class TestSlapOSAggregatedDeliveryBuilder(SlapOSTestCaseMixin):
def emptyBuild(self, **kw):
delivery_list = self._build(**kw)
......@@ -1885,13 +1960,15 @@ class TestSlapOSAggregatedDeliveryBuilder(SlapOSTestCaseMixin):
self.assertEqual('confirmed', built_delivery.getSimulationState())
self.assertEqual('building', built_delivery.getCausalityState())
self.assertSameSet([
'ledger/automated',
'destination/%s' % person.getRelativeUrl(),
'destination_decision/%s' % person.getRelativeUrl(),
'destination_section/%s' % person.getRelativeUrl(),
'destination_project/%s' % self.slapos_project.getRelativeUrl(),
'price_currency/currency_module/EUR',
'source/%s' % self.expected_slapos_organisation,
'source_section/%s' % self.expected_slapos_organisation,
'specialise/%s' % AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL],
'specialise/%s' % self.slapos_trade_condition.getRelativeUrl()],
built_delivery.getCategoryList())
self.assertEqual(DateTime().earliestTime(), built_delivery.getStartDate())
delivery_line_list = built_delivery.contentValues(
......@@ -2015,3 +2092,4 @@ class TestSlapOSAggregatedDeliveryBuilder(SlapOSTestCaseMixin):
self.assertEqual(0.0, built_delivery_line.getPrice())
self.assertEqual(delivery_line_2.getResource(),
built_delivery_line.getResource())
"""
\ 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