Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Lisa Casino
slapos.core
Commits
bbf94fa7
Commit
bbf94fa7
authored
Mar 05, 2021
by
Rafael Monnerat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: Update Movement Group to not merge based on SPL causality
extend test to diff movement
parent
7a04d633
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
878 additions
and
24 deletions
+878
-24
master/bt5/slapos_accounting/DocumentTemplateItem/portal_components/document.erp5.RootAppliedRuleCausalityCausalityMovementGroup.py
...nt.erp5.RootAppliedRuleCausalityCausalityMovementGroup.py
+11
-1
master/bt5/slapos_accounting/DocumentTemplateItem/portal_components/document.erp5_slapos.RootAppliedRuleCausalityMovementGroup.py
...ment.erp5_slapos.RootAppliedRuleCausalityMovementGroup.py
+50
-0
master/bt5/slapos_accounting/DocumentTemplateItem/portal_components/document.erp5_slapos.RootAppliedRuleCausalityMovementGroup.xml
...ent.erp5_slapos.RootAppliedRuleCausalityMovementGroup.xml
+133
-0
master/bt5/slapos_accounting/PathTemplateItem/portal_deliveries/slapos_sale_invoice_builder/category_movement_group_on_line.xml
..._sale_invoice_builder/category_movement_group_on_line.xml
+1
-1
master/bt5/slapos_accounting/PathTemplateItem/portal_deliveries/slapos_sale_invoice_builder/root_applied_rule_causality_causality_movement_group_on_delivery.xml
...d_rule_causality_causality_movement_group_on_delivery.xml
+2
-1
master/bt5/slapos_accounting/PathTemplateItem/portal_deliveries/slapos_sale_invoice_builder/root_applied_rule_causality_movement_group_on_line.xml
...er/root_applied_rule_causality_movement_group_on_line.xml
+43
-0
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_simulation/SaleInvoiceTransaction_postSlapOSGeneration.py
...simulation/SaleInvoiceTransaction_postSlapOSGeneration.py
+4
-2
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingBuilder.py
...ortal_components/test.erp5.testSlapOSAccountingBuilder.py
+632
-18
master/bt5/slapos_accounting/bt/template_document_id_list
master/bt5/slapos_accounting/bt/template_document_id_list
+2
-1
No files found.
master/bt5/slapos_accounting/DocumentTemplateItem/portal_components/document.erp5.RootAppliedRuleCausalityCausalityMovementGroup.py
View file @
bbf94fa7
...
@@ -45,8 +45,18 @@ class RootAppliedRuleCausalityCausalityMovementGroup(MovementGroup):
...
@@ -45,8 +45,18 @@ class RootAppliedRuleCausalityCausalityMovementGroup(MovementGroup):
return
property_dict
return
property_dict
def
test
(
self
,
movement
,
property_dict
,
**
kw
):
def
test
(
self
,
movement
,
property_dict
,
**
kw
):
if
'root_causality_causality_value_list'
in
property_dict
:
root_causality_causality_value_list
=
property_dict
[
'root_causality_causality_value_list'
]
if
root_causality_causality_value_list
[
0
]
is
None
and
not
movement
.
getCausalityValueList
():
return
True
,
property_dict
for
causality
in
movement
.
getCausalityValueList
():
test_root_causality_causality_value
=
causality
.
getCausalityValue
()
if
test_root_causality_causality_value
==
root_causality_causality_value_list
[
0
]:
return
True
,
property_dict
# We can always update
# We can always update
return
Tru
e
,
property_dict
return
Fals
e
,
property_dict
def
_getRootCausalityCausalityValue
(
self
,
movement
):
def
_getRootCausalityCausalityValue
(
self
,
movement
):
""" Get the causality value of the causality of the root applied rule for a movement """
""" Get the causality value of the causality of the root applied rule for a movement """
...
...
master/bt5/slapos_accounting/DocumentTemplateItem/portal_components/document.erp5_slapos.RootAppliedRuleCausalityMovementGroup.py
0 → 100644
View file @
bbf94fa7
##############################################################################
#
# Copyright (c) 2008 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly adviced to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from
erp5.component.document.erp5_version.RootAppliedRuleCausalityMovementGroup
\
import
RootAppliedRuleCausalityMovementGroup
as
ERP5RootAppliedRuleCausalityMovementGroup
class
RootAppliedRuleCausalityMovementGroup
(
ERP5RootAppliedRuleCausalityMovementGroup
):
"""
The purpose of MovementGroup is to define how movements are grouped,
and how values are updated from simulation movements.
This movement group is used to group movements whose root apply rule
has the same causality.
This overwrites the default for not always update, but check the information.
"""
def
test
(
self
,
movement
,
property_dict
,
**
kw
):
if
'root_causality_value_list'
in
property_dict
:
root_causality_value_list
=
property_dict
[
'root_causality_value_list'
]
for
simulation_movement
in
movement
.
getDeliveryRelatedValueList
():
if
self
.
_getRootCausalityValue
(
simulation_movement
)
==
root_causality_value_list
[
0
]:
return
True
,
property_dict
# No don't update
return
False
,
property_dict
\ No newline at end of file
master/bt5/slapos_accounting/DocumentTemplateItem/portal_components/document.erp5_slapos.RootAppliedRuleCausalityMovementGroup.xml
0 → 100644
View file @
bbf94fa7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Document Component"
module=
"erp5.portal_type"
/>
</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>
RootAppliedRuleCausalityMovementGroup
</string>
</value>
</item>
<item>
<key>
<string>
default_source_reference
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
document.erp5_slapos.RootAppliedRuleCausalityMovementGroup
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Document Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5_slapos
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</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>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.Workflow"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_log
</string>
</key>
<value>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/PathTemplateItem/portal_deliveries/slapos_sale_invoice_builder/category_movement_group_on_line.xml
View file @
bbf94fa7
...
@@ -27,7 +27,7 @@
...
@@ -27,7 +27,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
int_index
</string>
</key>
<key>
<string>
int_index
</string>
</key>
<value>
<int>
1
</int>
</value>
<value>
<int>
3
</int>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
portal_type
</string>
</key>
<key>
<string>
portal_type
</string>
</key>
...
...
master/bt5/slapos_accounting/PathTemplateItem/portal_deliveries/slapos_sale_invoice_builder/root_applied_rule_causality_causality_movement_group_on_delivery.xml
View file @
bbf94fa7
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
<value>
<value>
<tuple>
<tuple>
<string>
collect_order_group/delivery
</string>
<string>
collect_order_group/delivery
</string>
<string>
divergence_scope/category
</string>
</tuple>
</tuple>
</value>
</value>
</item>
</item>
...
@@ -26,7 +27,7 @@
...
@@ -26,7 +27,7 @@
</item>
</item>
<item>
<item>
<key>
<string>
int_index
</string>
</key>
<key>
<string>
int_index
</string>
</key>
<value>
<int>
3
</int>
</value>
<value>
<int>
2
</int>
</value>
</item>
</item>
<item>
<item>
<key>
<string>
portal_type
</string>
</key>
<key>
<string>
portal_type
</string>
</key>
...
...
master/bt5/slapos_accounting/PathTemplateItem/portal_deliveries/slapos_sale_invoice_builder/root_applied_rule_causality_movement_group_on_line.xml
0 → 100644
View file @
bbf94fa7
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Root Applied Rule Causality Movement Group"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
categories
</string>
</key>
<value>
<tuple>
<string>
collect_order_group/line
</string>
<string>
divergence_scope/category
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
root_applied_rule_causality_movement_group_on_line
</string>
</value>
</item>
<item>
<key>
<string>
int_index
</string>
</key>
<value>
<int>
1
</int>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Root Applied Rule Causality Movement Group
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string>
root_applied_rule_causality_movement_group_on_line
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_accounting/SkinTemplateItem/portal_skins/slapos_simulation/SaleInvoiceTransaction_postSlapOSGeneration.py
View file @
bbf94fa7
...
@@ -48,10 +48,12 @@ if context.getStartDate() is None:
...
@@ -48,10 +48,12 @@ if context.getStartDate() is None:
max_stop_date
=
DateTime
().
earliestTime
()
max_stop_date
=
DateTime
().
earliestTime
()
context
.
setStopDate
(
max_stop_date
)
context
.
setStopDate
(
max_stop_date
)
if
context
.
getCausalityState
()
==
'draft'
:
context
.
startBuilding
()
comment
=
translateString
(
'Initialised by Delivery Builder.'
)
comment
=
translateString
(
'Initialised by Delivery Builder.'
)
if
invoice
.
getCausalityState
()
==
'draft'
:
invoice
.
startBuilding
(
comment
=
comment
)
if
invoice
.
portal_workflow
.
isTransitionPossible
(
invoice
,
'plan'
):
if
invoice
.
portal_workflow
.
isTransitionPossible
(
invoice
,
'plan'
):
invoice
.
plan
(
comment
=
comment
)
invoice
.
plan
(
comment
=
comment
)
if
invoice
.
portal_workflow
.
isTransitionPossible
(
invoice
,
'confirm'
):
if
invoice
.
portal_workflow
.
isTransitionPossible
(
invoice
,
'confirm'
):
...
...
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingBuilder.py
View file @
bbf94fa7
...
@@ -44,16 +44,21 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
...
@@ -44,16 +44,21 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
portal_type
=
'Simulation Movement'
))
portal_type
=
'Simulation Movement'
))
def
checkDelivery
(
self
,
simulation_movement
,
delivery
,
delivery_portal_type
,
def
checkDelivery
(
self
,
simulation_movement
,
delivery
,
delivery_portal_type
,
category_list
,
simulation_state
=
'delivered'
,
already_solved
=
False
):
category_list
,
simulation_state
=
'delivered'
,
already_solved
=
False
,
expected_start_date
=
None
,
expected_stop_date
=
None
):
self
.
assertEqual
(
delivery_portal_type
,
delivery
.
getPortalType
())
self
.
assertEqual
(
delivery_portal_type
,
delivery
.
getPortalType
())
self
.
assertEqual
(
simulation_state
,
delivery
.
getSimulationState
())
self
.
assertEqual
(
simulation_state
,
delivery
.
getSimulationState
())
self
.
assertEqual
(
'building'
,
delivery
.
getCausalityState
())
self
.
assertEqual
(
'building'
,
delivery
.
getCausalityState
())
delivery
.
updateCausalityState
(
solve_automatically
=
False
)
delivery
.
updateCausalityState
(
solve_automatically
=
False
)
self
.
assertEqual
(
'solved'
,
delivery
.
getCausalityState
())
self
.
assertEqual
(
'solved'
,
delivery
.
getCausalityState
())
self
.
assertEqual
(
simulation_movement
.
getStartDate
(),
if
expected_start_date
is
None
:
delivery
.
getStartDate
())
expected_start_date
=
simulation_movement
.
getStartDate
()
self
.
assertEqual
(
simulation_movement
.
getStopDate
(),
self
.
assertEqual
(
expected_start_date
,
delivery
.
getStartDate
())
delivery
.
getStopDate
())
if
expected_stop_date
is
None
:
expected_stop_date
=
simulation_movement
.
getStopDate
()
self
.
assertEqual
(
expected_stop_date
,
delivery
.
getStopDate
())
self
.
assertSameSet
([
self
.
assertSameSet
([
'source/%s'
%
self
.
expected_slapos_organisation
,
'source/%s'
%
self
.
expected_slapos_organisation
,
'source_section/%s'
%
self
.
expected_slapos_organisation
,
'source_section/%s'
%
self
.
expected_slapos_organisation
,
...
@@ -114,7 +119,6 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
...
@@ -114,7 +119,6 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
)
)
self
.
tic
()
self
.
tic
()
self
.
portal
.
portal_deliveries
.
slapos_sale_packing_list_builder
.
build
(
self
.
portal
.
portal_deliveries
.
slapos_sale_packing_list_builder
.
build
(
path
=
'%s/%%'
%
applied_rule
.
getPath
())
path
=
'%s/%%'
%
applied_rule
.
getPath
())
self
.
tic
()
self
.
tic
()
...
@@ -146,9 +150,10 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
...
@@ -146,9 +150,10 @@ class TestSlapOSSalePackingListBuilder(SlapOSTestCaseMixin):
self
.
checkDelivery
(
simulation_movement_2
,
delivery_2
,
**
delivery_kw
)
self
.
checkDelivery
(
simulation_movement_2
,
delivery_2
,
**
delivery_kw
)
class
TestSlapOSSaleInvoiceBuilder
(
TestSlapOSSalePackingListBuilder
):
class
TestSlapOSSaleInvoiceBuilder
(
TestSlapOSSalePackingListBuilder
):
def
test
(
self
):
def
test
(
self
,
causality1
=
None
,
causality2
=
None
):
# pylint: disable=arguments-differ
person
=
self
.
portal
.
person_module
.
template_member
\
person
=
self
.
portal
.
person_module
.
template_member
\
.
Base_createCloneDocument
(
batch_mode
=
1
)
.
Base_createCloneDocument
(
batch_mode
=
1
)
# Create Aggregated Packing List
delivery_kw
=
dict
(
delivery_kw
=
dict
(
portal_type
=
'Sale Packing List'
,
portal_type
=
'Sale Packing List'
,
price_currency
=
'currency_module/EUR'
,
price_currency
=
'currency_module/EUR'
,
...
@@ -170,8 +175,11 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
...
@@ -170,8 +175,11 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
destination_section
=
person
.
getRelativeUrl
(),
destination_section
=
person
.
getRelativeUrl
(),
start_date
=
DateTime
(
'2012/01/01'
),
start_date
=
DateTime
(
'2012/01/01'
),
stop_date
=
DateTime
(
'2012/02/01'
),
stop_date
=
DateTime
(
'2012/02/01'
),
causality_value
=
causality1
,
**
delivery_kw
**
delivery_kw
)
)
# Create Applied rule and set causality
applied_rule_1
=
self
.
portal
.
portal_simulation
.
newContent
(
applied_rule_1
=
self
.
portal
.
portal_simulation
.
newContent
(
portal_type
=
'Applied Rule'
,
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_delivery_root_simulation_rule'
,
specialise
=
'portal_rules/slapos_delivery_root_simulation_rule'
,
...
@@ -179,6 +187,10 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
...
@@ -179,6 +187,10 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
)
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_1
,
'delivered'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_1
,
'delivered'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_1
,
'calculating'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_1
,
'calculating'
)
if
delivery_1
.
getCausalityState
()
==
'draft'
:
# There are more them one workflow that has calculating state
delivery_1
.
startBuilding
()
delivery_line_1
=
delivery_1
.
newContent
(
delivery_line_1
=
delivery_1
.
newContent
(
quantity
=
1.2
,
quantity
=
1.2
,
price
=
3.4
,
price
=
3.4
,
...
@@ -190,12 +202,15 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
...
@@ -190,12 +202,15 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
price
=
0.0
,
price
=
0.0
,
resource
=
'service_module/slapos_instance_setup'
resource
=
'service_module/slapos_instance_setup'
)
)
# Create second delivery
delivery_2
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
delivery_2
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
destination
=
person
.
getRelativeUrl
(),
destination
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
destination_section
=
person
.
getRelativeUrl
(),
destination_section
=
person
.
getRelativeUrl
(),
start_date
=
DateTime
(
'2012/01/01'
),
start_date
=
DateTime
(
'2012/01/01'
),
stop_date
=
DateTime
(
'2012/02/01'
),
stop_date
=
DateTime
(
'2012/02/01'
),
causality_value
=
causality2
,
**
delivery_kw
**
delivery_kw
)
)
applied_rule_2
=
self
.
portal
.
portal_simulation
.
newContent
(
applied_rule_2
=
self
.
portal
.
portal_simulation
.
newContent
(
...
@@ -205,6 +220,10 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
...
@@ -205,6 +220,10 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
)
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_2
,
'delivered'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_2
,
'delivered'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_2
,
'calculating'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_2
,
'calculating'
)
if
delivery_2
.
getCausalityState
()
==
'draft'
:
# There are more them one workflow that has calculating state
delivery_2
.
startBuilding
()
delivery_line_2
=
delivery_2
.
newContent
(
delivery_line_2
=
delivery_2
.
newContent
(
quantity
=
5.6
,
quantity
=
5.6
,
price
=
7.8
,
price
=
7.8
,
...
@@ -214,9 +233,9 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
...
@@ -214,9 +233,9 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
portal_type
=
'Simulation Movement'
,
portal_type
=
'Simulation Movement'
,
base_contribution
=
[
'base_amount/invoicing/discounted'
,
base_contribution
=
[
'base_amount/invoicing/discounted'
,
'base_amount/invoicing/taxable'
],
'base_amount/invoicing/taxable'
],
causality
=
[
'business_process_module/slapos_aggregated_business_process'
causality
=
[
'/deliver'
,
'business_process_module/slapos_sale_business_pr'
'business_process_module/slapos_aggregated_business_process/deliver'
,
'
ocess/delivery_path'
],
'business_process_module/slapos_sale_business_pr
ocess/delivery_path'
],
destination
=
person
.
getRelativeUrl
(),
destination
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
destination_section
=
person
.
getRelativeUrl
(),
destination_section
=
person
.
getRelativeUrl
(),
...
@@ -257,6 +276,9 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
...
@@ -257,6 +276,9 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
)
)
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
'calculating'
,
delivery_1
.
getCausalityState
())
self
.
assertEqual
(
'calculating'
,
delivery_2
.
getCausalityState
())
delivery_1
.
updateCausalityState
(
solve_automatically
=
False
)
delivery_1
.
updateCausalityState
(
solve_automatically
=
False
)
delivery_2
.
updateCausalityState
(
solve_automatically
=
False
)
delivery_2
.
updateCausalityState
(
solve_automatically
=
False
)
self
.
tic
()
self
.
tic
()
...
@@ -307,9 +329,8 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
...
@@ -307,9 +329,8 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
self
.
tic
()
self
.
tic
()
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
path
=
'%s/%%'
%
applied_rule_1
.
getPath
())
path
=
[
'%s/%%'
%
applied_rule_1
.
getPath
(),
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
'%s/%%'
%
applied_rule_2
.
getPath
()])
path
=
'%s/%%'
%
applied_rule_2
.
getPath
())
self
.
tic
()
self
.
tic
()
self
.
checkSimulationMovement
(
invoice_movement_1
)
self
.
checkSimulationMovement
(
invoice_movement_1
)
...
@@ -336,7 +357,8 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
...
@@ -336,7 +357,8 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
invoice_1
=
invoice_line_1
.
getParentValue
()
invoice_1
=
invoice_line_1
.
getParentValue
()
invoice_2
=
invoice_line_2
.
getParentValue
()
invoice_2
=
invoice_line_2
.
getParentValue
()
self
.
assertNotEqual
(
invoice_1
.
getRelativeUrl
(),
# The invoices are merged since they are from the same user.
self
.
assertEqual
(
invoice_1
.
getRelativeUrl
(),
invoice_2
.
getRelativeUrl
())
invoice_2
.
getRelativeUrl
())
invoice_kw
=
dict
(
delivery_portal_type
=
'Sale Invoice Transaction'
,
invoice_kw
=
dict
(
delivery_portal_type
=
'Sale Invoice Transaction'
,
...
@@ -344,16 +366,21 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
...
@@ -344,16 +366,21 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
category_list
=
[
'resource/currency_module/EUR'
,
'payment_mode/payzen'
]
category_list
=
[
'resource/currency_module/EUR'
,
'payment_mode/payzen'
]
self
.
checkDelivery
(
invoice_movement_1
,
invoice_1
,
self
.
checkDelivery
(
invoice_movement_1
,
invoice_1
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
[
delivery_1
.
getRelativeUrl
()]),
**
invoice_kw
)
[
delivery_1
.
getRelativeUrl
(),
delivery_2
.
getRelativeUrl
()]),
**
invoice_kw
)
# Start building and check again, remember invoice_1 and invoice_2
invoice_1
.
startBuilding
()
self
.
checkDelivery
(
invoice_movement_2
,
invoice_2
,
self
.
checkDelivery
(
invoice_movement_2
,
invoice_2
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
[
delivery_2
.
getRelativeUrl
()]),
**
invoice_kw
)
[
delivery_
1
.
getRelativeUrl
(),
delivery_
2
.
getRelativeUrl
()]),
**
invoice_kw
)
# check delivering of movement later
# check delivering of movement later
delivery_line_2_bis
=
delivery_line_2
.
Base_createCloneDocument
(
delivery_line_2_bis
=
delivery_line_2
.
Base_createCloneDocument
(
batch_mode
=
1
)
batch_mode
=
1
)
delivery_line_2_bis
.
edit
(
delivery_line_2_bis
.
edit
(
price
=
0.0
,
# Keep price different else this line will be merged with delivery_line_1_bis
# on the invoice side
price
=
1.1
,
resource
=
'service_module/slapos_instance_setup'
resource
=
'service_module/slapos_instance_setup'
)
)
simulation_movement_2_bis
=
applied_rule_2
.
newContent
(
simulation_movement_2_bis
=
applied_rule_2
.
newContent
(
...
@@ -381,10 +408,13 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
...
@@ -381,10 +408,13 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
self
.
tic
()
self
.
tic
()
self
.
assertEqual
(
'solved'
,
delivery_2
.
getCausalityState
())
self
.
assertEqual
(
'solved'
,
delivery_2
.
getCausalityState
())
self
.
assertEqual
(
invoice_movement_2_bis
.
getDeliveryValue
(),
None
)
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
path
=
'%s/%%'
%
applied_rule_1
.
getPath
())
path
=
'%s/%%'
%
applied_rule_1
.
getPath
())
self
.
assertEqual
(
invoice_movement_2_bis
.
getDeliveryValue
(),
None
)
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
path
=
'%s/%%'
%
applied_rule_2
.
getPath
())
path
=
'%s/%%'
%
applied_rule_2
.
getPath
())
self
.
tic
()
self
.
tic
()
self
.
checkSimulationMovement
(
invoice_movement_2_bis
)
self
.
checkSimulationMovement
(
invoice_movement_2_bis
)
...
@@ -395,9 +425,593 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
...
@@ -395,9 +425,593 @@ class TestSlapOSSaleInvoiceBuilder(TestSlapOSSalePackingListBuilder):
self
.
checkDeliveryLine
(
invoice_movement_2_bis
,
invoice_line_2_bis
,
self
.
checkDeliveryLine
(
invoice_movement_2_bis
,
invoice_line_2_bis
,
**
line_kw
)
**
line_kw
)
self
.
checkDelivery
(
invoice_movement_2_bis
,
invoice_2
,
self
.
checkDelivery
(
invoice_movement_2_bis
,
invoice_2
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
[
delivery_1
.
getRelativeUrl
(),
delivery_2
.
getRelativeUrl
()]),
**
invoice_kw
)
self
.
assertEqual
(
invoice_line_2
.
getParentValue
(),
invoice_line_1
.
getParentValue
()
)
def
test_with_same_causality
(
self
):
causality1
=
self
.
portal
.
subscription_request_module
.
newContent
(
portal_type
=
"Subscription Request"
,
)
self
.
test
(
causality1
=
causality1
,
causality2
=
causality1
)
def
test_with_different_causality
(
self
):
causality1
=
self
.
portal
.
subscription_request_module
.
newContent
(
portal_type
=
"Subscription Request"
,
)
causality2
=
self
.
portal
.
subscription_request_module
.
newContent
(
portal_type
=
"Subscription Request"
,
)
self
.
_test_with_different_causality
(
causality1
=
causality1
,
causality2
=
causality2
)
def
test_with_ssingle_ausality
(
self
):
causality1
=
self
.
portal
.
subscription_request_module
.
newContent
(
portal_type
=
"Subscription Request"
,
)
self
.
_test_with_different_causality
(
causality1
=
causality1
,
causality2
=
None
)
def
_test_with_different_causality
(
self
,
causality1
=
None
,
causality2
=
None
):
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
=
'sale_trade_condition_module/slapos_aggregated_trade_condition'
)
delivery_line_kw
=
dict
(
portal_type
=
'Sale Packing List Line'
,
resource
=
'service_module/slapos_instance_subscription'
,
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
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
destination_section
=
person
.
getRelativeUrl
(),
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'
,
specialise
=
'portal_rules/slapos_delivery_root_simulation_rule'
,
causality
=
delivery_1
.
getRelativeUrl
()
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_1
,
'delivered'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_1
,
'calculating'
)
if
delivery_1
.
getCausalityState
()
==
'draft'
:
# There are more them one workflow that has calculating state
delivery_1
.
startBuilding
()
delivery_line_1
=
delivery_1
.
newContent
(
quantity
=
1.2
,
price
=
3.4
,
**
delivery_line_kw
)
delivery_line_1_bis
=
delivery_line_1
.
Base_createCloneDocument
(
batch_mode
=
1
)
delivery_line_1_bis
.
edit
(
price
=
0.0
,
resource
=
'service_module/slapos_instance_setup'
)
# Create second delivery
delivery_2
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
destination
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
destination_section
=
person
.
getRelativeUrl
(),
start_date
=
DateTime
(
'2012/01/01'
),
stop_date
=
DateTime
(
'2012/02/01'
),
causality_value
=
causality2
,
**
delivery_kw
)
applied_rule_2
=
self
.
portal
.
portal_simulation
.
newContent
(
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_delivery_root_simulation_rule'
,
causality
=
delivery_2
.
getRelativeUrl
()
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_2
,
'delivered'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_2
,
'calculating'
)
if
delivery_2
.
getCausalityState
()
==
'draft'
:
# There are more them one workflow that has calculating state
delivery_2
.
startBuilding
()
delivery_line_2
=
delivery_2
.
newContent
(
quantity
=
5.6
,
price
=
7.8
,
**
delivery_line_kw
)
simulation_movement_kw
=
dict
(
portal_type
=
'Simulation Movement'
,
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
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
destination_section
=
person
.
getRelativeUrl
(),
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
=
'sale_trade_condition_module/slapos_aggregated_trade_condition'
,
trade_phase
=
'slapos/delivery'
,
use
=
'trade/sale'
,
delivery_ratio
=
1.0
)
simulation_movement_1
=
applied_rule_1
.
newContent
(
quantity
=
delivery_line_1
.
getQuantity
(),
price
=
delivery_line_1
.
getPrice
(),
start_date
=
delivery_1
.
getStartDate
(),
stop_date
=
delivery_1
.
getStopDate
(),
delivery
=
delivery_line_1
.
getRelativeUrl
(),
**
simulation_movement_kw
)
simulation_movement_1_bis
=
applied_rule_1
.
newContent
(
quantity
=
delivery_line_1_bis
.
getQuantity
(),
price
=
delivery_line_1_bis
.
getPrice
(),
start_date
=
delivery_1
.
getStartDate
(),
stop_date
=
delivery_1
.
getStopDate
(),
delivery
=
delivery_line_1_bis
.
getRelativeUrl
(),
**
simulation_movement_kw
)
simulation_movement_1_bis
.
edit
(
resource
=
delivery_line_1_bis
.
getResource
())
simulation_movement_2
=
applied_rule_2
.
newContent
(
quantity
=
delivery_line_2
.
getQuantity
(),
price
=
delivery_line_2
.
getPrice
(),
start_date
=
delivery_2
.
getStartDate
(),
stop_date
=
delivery_2
.
getStopDate
(),
delivery
=
delivery_line_2
.
getRelativeUrl
(),
**
simulation_movement_kw
)
self
.
tic
()
self
.
assertEqual
(
'calculating'
,
delivery_1
.
getCausalityState
())
self
.
assertEqual
(
'calculating'
,
delivery_2
.
getCausalityState
())
delivery_1
.
updateCausalityState
(
solve_automatically
=
False
)
delivery_2
.
updateCausalityState
(
solve_automatically
=
False
)
self
.
tic
()
# test the test
self
.
assertEqual
(
'solved'
,
delivery_1
.
getCausalityState
())
self
.
assertEqual
(
'solved'
,
delivery_2
.
getCausalityState
())
# create new simulation movements
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'
],
trade_phase
=
'slapos/invoicing'
)
invoice_rule_1
=
simulation_movement_1
.
newContent
(
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_invoice_simulation_rule'
)
invoice_movement_1
=
invoice_rule_1
.
newContent
(
start_date
=
delivery_1
.
getStartDate
(),
stop_date
=
delivery_1
.
getStopDate
(),
quantity
=
delivery_line_1
.
getQuantity
(),
price
=
delivery_line_1
.
getPrice
(),
**
invoice_movement_kw
)
invoice_rule_1_bis
=
simulation_movement_1_bis
.
newContent
(
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_invoice_simulation_rule'
)
invoice_movement_1_bis
=
invoice_rule_1_bis
.
newContent
(
start_date
=
delivery_1
.
getStartDate
(),
stop_date
=
delivery_1
.
getStopDate
(),
quantity
=
delivery_line_1_bis
.
getQuantity
(),
price
=
delivery_line_1_bis
.
getPrice
(),
**
invoice_movement_kw
)
invoice_movement_1_bis
.
edit
(
resource
=
delivery_line_1_bis
.
getResource
())
invoice_rule_2
=
simulation_movement_2
.
newContent
(
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_invoice_simulation_rule'
)
invoice_movement_2
=
invoice_rule_2
.
newContent
(
start_date
=
delivery_2
.
getStartDate
(),
stop_date
=
delivery_2
.
getStopDate
(),
quantity
=
delivery_line_2
.
getQuantity
(),
price
=
delivery_line_2
.
getPrice
(),
**
invoice_movement_kw
)
self
.
tic
()
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
path
=
[
'%s/%%'
%
applied_rule_1
.
getPath
(),
'%s/%%'
%
applied_rule_2
.
getPath
()])
self
.
tic
()
self
.
checkSimulationMovement
(
invoice_movement_1
)
self
.
checkSimulationMovement
(
invoice_movement_1_bis
)
self
.
checkSimulationMovement
(
invoice_movement_2
)
invoice_line_1
=
invoice_movement_1
.
getDeliveryValue
()
invoice_line_1_bis
=
invoice_movement_1_bis
.
getDeliveryValue
()
invoice_line_2
=
invoice_movement_2
.
getDeliveryValue
()
self
.
assertNotEqual
(
invoice_line_1
.
getRelativeUrl
(),
invoice_line_2
.
getRelativeUrl
())
self
.
assertNotEqual
(
invoice_line_1
,
invoice_line_1_bis
)
self
.
assertEqual
(
invoice_line_1
.
getParentValue
(),
invoice_line_1_bis
.
getParentValue
())
line_kw
=
dict
(
line_portal_type
=
'Invoice Line'
,
cell_portal_type
=
'Invoice Cell'
,
has_date_on_line
=
True
)
self
.
checkDeliveryLine
(
invoice_movement_1
,
invoice_line_1
,
**
line_kw
)
self
.
checkDeliveryLine
(
invoice_movement_1_bis
,
invoice_line_1_bis
,
**
line_kw
)
self
.
checkDeliveryLine
(
invoice_movement_2
,
invoice_line_2
,
**
line_kw
)
invoice_1
=
invoice_line_1
.
getParentValue
()
invoice_2
=
invoice_line_2
.
getParentValue
()
self
.
assertNotEqual
(
invoice_1
.
getRelativeUrl
(),
invoice_2
.
getRelativeUrl
())
invoice_kw
=
dict
(
delivery_portal_type
=
'Sale Invoice Transaction'
,
simulation_state
=
'confirmed'
)
category_list
=
[
'resource/currency_module/EUR'
,
'payment_mode/payzen'
]
self
.
checkDelivery
(
invoice_movement_1
,
invoice_1
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
[
delivery_1
.
getRelativeUrl
()]),
**
invoice_kw
)
self
.
checkDelivery
(
invoice_movement_2
,
invoice_2
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
[
delivery_2
.
getRelativeUrl
()]),
**
invoice_kw
)
[
delivery_2
.
getRelativeUrl
()]),
**
invoice_kw
)
# check delivering of movement later
delivery_line_2_bis
=
delivery_line_2
.
Base_createCloneDocument
(
batch_mode
=
1
)
delivery_line_2_bis
.
edit
(
price
=
0.0
,
resource
=
'service_module/slapos_instance_setup'
)
simulation_movement_2_bis
=
applied_rule_2
.
newContent
(
quantity
=
delivery_line_2_bis
.
getQuantity
(),
price
=
delivery_line_2_bis
.
getPrice
(),
start_date
=
delivery_2
.
getStartDate
(),
stop_date
=
delivery_2
.
getStopDate
(),
delivery
=
delivery_line_2_bis
.
getRelativeUrl
(),
**
simulation_movement_kw
)
simulation_movement_2_bis
.
edit
(
resource
=
delivery_line_2_bis
.
getResource
())
invoice_rule_2_bis
=
simulation_movement_2_bis
.
newContent
(
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_invoice_simulation_rule'
)
invoice_movement_2_bis
=
invoice_rule_2_bis
.
newContent
(
start_date
=
delivery_2
.
getStartDate
(),
stop_date
=
delivery_2
.
getStopDate
(),
quantity
=
delivery_line_2_bis
.
getQuantity
(),
price
=
delivery_line_2_bis
.
getPrice
(),
**
invoice_movement_kw
)
invoice_movement_2_bis
.
edit
(
resource
=
delivery_line_2_bis
.
getResource
())
self
.
tic
()
# test the test
delivery_2
.
updateCausalityState
(
solve_automatically
=
False
)
self
.
tic
()
self
.
assertEqual
(
'solved'
,
delivery_2
.
getCausalityState
())
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
path
=
[
'%s/%%'
%
applied_rule_1
.
getPath
(),
'%s/%%'
%
applied_rule_2
.
getPath
()])
self
.
tic
()
self
.
checkSimulationMovement
(
invoice_movement_2_bis
)
invoice_line_2_bis
=
invoice_movement_2_bis
.
getDeliveryValue
()
self
.
assertNotEqual
(
invoice_line_2
,
invoice_line_2_bis
)
self
.
assertEqual
(
invoice_line_2
.
getParentValue
(),
invoice_line_2_bis
.
getParentValue
())
self
.
checkDeliveryLine
(
invoice_movement_2_bis
,
invoice_line_2_bis
,
**
line_kw
)
self
.
checkDelivery
(
invoice_movement_2_bis
,
invoice_2
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
[
delivery_2
.
getRelativeUrl
()]),
**
invoice_kw
)
self
.
assertNotEqual
(
invoice_line_2
.
getParentValue
(),
invoice_line_1
.
getParentValue
()
)
def
test_with_different_date
(
self
):
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
=
'sale_trade_condition_module/slapos_aggregated_trade_condition'
,
)
delivery_line_kw
=
dict
(
portal_type
=
'Sale Packing List Line'
,
resource
=
'service_module/slapos_instance_subscription'
,
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
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
destination_section
=
person
.
getRelativeUrl
(),
start_date
=
DateTime
(
'2012/01/01'
),
stop_date
=
DateTime
(
'2012/02/01'
),
**
delivery_kw
)
# Create Applied rule and set causality
applied_rule_1
=
self
.
portal
.
portal_simulation
.
newContent
(
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_delivery_root_simulation_rule'
,
causality
=
delivery_1
.
getRelativeUrl
()
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_1
,
'delivered'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_1
,
'calculating'
)
if
delivery_1
.
getCausalityState
()
==
'draft'
:
# There are more them one workflow that has calculating state
delivery_1
.
startBuilding
()
delivery_line_1
=
delivery_1
.
newContent
(
quantity
=
1.2
,
price
=
3.4
,
**
delivery_line_kw
)
delivery_line_1_bis
=
delivery_line_1
.
Base_createCloneDocument
(
batch_mode
=
1
)
delivery_line_1_bis
.
edit
(
price
=
0.0
,
resource
=
'service_module/slapos_instance_setup'
)
# Create second delivery
delivery_2
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
destination
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
destination_section
=
person
.
getRelativeUrl
(),
start_date
=
DateTime
(
'2012/02/01'
),
stop_date
=
DateTime
(
'2012/03/01'
),
**
delivery_kw
)
applied_rule_2
=
self
.
portal
.
portal_simulation
.
newContent
(
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_delivery_root_simulation_rule'
,
causality
=
delivery_2
.
getRelativeUrl
()
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_2
,
'delivered'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
delivery_2
,
'calculating'
)
if
delivery_2
.
getCausalityState
()
==
'draft'
:
# There are more them one workflow that has calculating state
delivery_2
.
startBuilding
()
delivery_line_2
=
delivery_2
.
newContent
(
quantity
=
5.6
,
price
=
7.8
,
**
delivery_line_kw
)
simulation_movement_kw
=
dict
(
portal_type
=
'Simulation Movement'
,
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
=
person
.
getRelativeUrl
(),
destination_decision
=
person
.
getRelativeUrl
(),
destination_section
=
person
.
getRelativeUrl
(),
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
=
'sale_trade_condition_module/slapos_aggregated_trade_condition'
,
trade_phase
=
'slapos/delivery'
,
use
=
'trade/sale'
,
delivery_ratio
=
1.0
)
simulation_movement_1
=
applied_rule_1
.
newContent
(
quantity
=
delivery_line_1
.
getQuantity
(),
price
=
delivery_line_1
.
getPrice
(),
start_date
=
delivery_1
.
getStartDate
(),
stop_date
=
delivery_1
.
getStopDate
(),
delivery
=
delivery_line_1
.
getRelativeUrl
(),
**
simulation_movement_kw
)
simulation_movement_1_bis
=
applied_rule_1
.
newContent
(
quantity
=
delivery_line_1_bis
.
getQuantity
(),
price
=
delivery_line_1_bis
.
getPrice
(),
start_date
=
delivery_1
.
getStartDate
(),
stop_date
=
delivery_1
.
getStopDate
(),
delivery
=
delivery_line_1_bis
.
getRelativeUrl
(),
**
simulation_movement_kw
)
simulation_movement_1_bis
.
edit
(
resource
=
delivery_line_1_bis
.
getResource
())
simulation_movement_2
=
applied_rule_2
.
newContent
(
quantity
=
delivery_line_2
.
getQuantity
(),
price
=
delivery_line_2
.
getPrice
(),
start_date
=
delivery_2
.
getStartDate
(),
stop_date
=
delivery_2
.
getStopDate
(),
delivery
=
delivery_line_2
.
getRelativeUrl
(),
**
simulation_movement_kw
)
self
.
tic
()
self
.
assertEqual
(
'calculating'
,
delivery_1
.
getCausalityState
())
self
.
assertEqual
(
'calculating'
,
delivery_2
.
getCausalityState
())
delivery_1
.
updateCausalityState
(
solve_automatically
=
False
)
delivery_2
.
updateCausalityState
(
solve_automatically
=
False
)
self
.
tic
()
# test the test
self
.
assertEqual
(
'solved'
,
delivery_1
.
getCausalityState
())
self
.
assertEqual
(
'solved'
,
delivery_2
.
getCausalityState
())
# create new simulation movements
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'
],
trade_phase
=
'slapos/invoicing'
)
invoice_rule_1
=
simulation_movement_1
.
newContent
(
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_invoice_simulation_rule'
)
invoice_movement_1
=
invoice_rule_1
.
newContent
(
start_date
=
delivery_1
.
getStartDate
(),
stop_date
=
delivery_1
.
getStopDate
(),
quantity
=
delivery_line_1
.
getQuantity
(),
price
=
delivery_line_1
.
getPrice
(),
**
invoice_movement_kw
)
invoice_rule_1_bis
=
simulation_movement_1_bis
.
newContent
(
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_invoice_simulation_rule'
)
invoice_movement_1_bis
=
invoice_rule_1_bis
.
newContent
(
start_date
=
delivery_1
.
getStartDate
(),
stop_date
=
delivery_1
.
getStopDate
(),
quantity
=
delivery_line_1_bis
.
getQuantity
(),
price
=
delivery_line_1_bis
.
getPrice
(),
**
invoice_movement_kw
)
invoice_movement_1_bis
.
edit
(
resource
=
delivery_line_1_bis
.
getResource
())
invoice_rule_2
=
simulation_movement_2
.
newContent
(
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_invoice_simulation_rule'
)
invoice_movement_2
=
invoice_rule_2
.
newContent
(
start_date
=
delivery_2
.
getStartDate
(),
stop_date
=
delivery_2
.
getStopDate
(),
quantity
=
delivery_line_2
.
getQuantity
(),
price
=
delivery_line_2
.
getPrice
(),
**
invoice_movement_kw
)
self
.
tic
()
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
path
=
[
'%s/%%'
%
applied_rule_1
.
getPath
(),
'%s/%%'
%
applied_rule_2
.
getPath
()])
self
.
tic
()
self
.
checkSimulationMovement
(
invoice_movement_1
)
self
.
checkSimulationMovement
(
invoice_movement_1_bis
)
self
.
checkSimulationMovement
(
invoice_movement_2
)
invoice_line_1
=
invoice_movement_1
.
getDeliveryValue
()
invoice_line_1_bis
=
invoice_movement_1_bis
.
getDeliveryValue
()
invoice_line_2
=
invoice_movement_2
.
getDeliveryValue
()
self
.
assertNotEqual
(
invoice_line_1
.
getRelativeUrl
(),
invoice_line_2
.
getRelativeUrl
())
self
.
assertNotEqual
(
invoice_line_1
,
invoice_line_1_bis
)
self
.
assertEqual
(
invoice_line_1
.
getParentValue
(),
invoice_line_1_bis
.
getParentValue
())
line_kw
=
dict
(
line_portal_type
=
'Invoice Line'
,
cell_portal_type
=
'Invoice Cell'
,
has_date_on_line
=
True
)
self
.
checkDeliveryLine
(
invoice_movement_1
,
invoice_line_1
,
**
line_kw
)
self
.
checkDeliveryLine
(
invoice_movement_1_bis
,
invoice_line_1_bis
,
**
line_kw
)
self
.
checkDeliveryLine
(
invoice_movement_2
,
invoice_line_2
,
**
line_kw
)
invoice_1
=
invoice_line_1
.
getParentValue
()
invoice_2
=
invoice_line_2
.
getParentValue
()
# The invoices are merged since they are from the same user.
self
.
assertEqual
(
invoice_1
.
getRelativeUrl
(),
invoice_2
.
getRelativeUrl
())
expected_start_date
=
delivery_1
.
getStartDate
()
expected_stop_date
=
delivery_2
.
getStopDate
()
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'
]
self
.
checkDelivery
(
invoice_movement_1
,
invoice_1
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
[
delivery_1
.
getRelativeUrl
(),
delivery_2
.
getRelativeUrl
()]),
**
invoice_kw
)
# Start building and check again, remember invoice_1 and invoice_2
invoice_1
.
startBuilding
()
self
.
checkDelivery
(
invoice_movement_2
,
invoice_2
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
[
delivery_1
.
getRelativeUrl
(),
delivery_2
.
getRelativeUrl
()]),
**
invoice_kw
)
# check delivering of movement later
delivery_line_2_bis
=
delivery_line_2
.
Base_createCloneDocument
(
batch_mode
=
1
)
delivery_line_2_bis
.
edit
(
# Keep price different else this line will be merged with delivery_line_1_bis
# on the invoice side
price
=
1.1
,
resource
=
'service_module/slapos_instance_setup'
)
simulation_movement_2_bis
=
applied_rule_2
.
newContent
(
quantity
=
delivery_line_2_bis
.
getQuantity
(),
price
=
delivery_line_2_bis
.
getPrice
(),
start_date
=
delivery_2
.
getStartDate
(),
stop_date
=
delivery_2
.
getStopDate
(),
delivery
=
delivery_line_2_bis
.
getRelativeUrl
(),
**
simulation_movement_kw
)
simulation_movement_2_bis
.
edit
(
resource
=
delivery_line_2_bis
.
getResource
())
invoice_rule_2_bis
=
simulation_movement_2_bis
.
newContent
(
portal_type
=
'Applied Rule'
,
specialise
=
'portal_rules/slapos_invoice_simulation_rule'
)
invoice_movement_2_bis
=
invoice_rule_2_bis
.
newContent
(
start_date
=
delivery_2
.
getStartDate
(),
stop_date
=
delivery_2
.
getStopDate
(),
quantity
=
delivery_line_2_bis
.
getQuantity
(),
price
=
delivery_line_2_bis
.
getPrice
(),
**
invoice_movement_kw
)
invoice_movement_2_bis
.
edit
(
resource
=
delivery_line_2_bis
.
getResource
())
self
.
tic
()
# test the test
delivery_2
.
updateCausalityState
(
solve_automatically
=
False
)
self
.
tic
()
self
.
assertEqual
(
'solved'
,
delivery_2
.
getCausalityState
())
self
.
assertEqual
(
invoice_movement_2_bis
.
getDeliveryValue
(),
None
)
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
path
=
'%s/%%'
%
applied_rule_1
.
getPath
())
self
.
assertEqual
(
invoice_movement_2_bis
.
getDeliveryValue
(),
None
)
self
.
portal
.
portal_deliveries
.
slapos_sale_invoice_builder
.
build
(
path
=
'%s/%%'
%
applied_rule_2
.
getPath
())
self
.
tic
()
self
.
checkSimulationMovement
(
invoice_movement_2_bis
)
invoice_line_2_bis
=
invoice_movement_2_bis
.
getDeliveryValue
()
self
.
assertNotEqual
(
invoice_line_2
,
invoice_line_2_bis
)
self
.
assertEqual
(
invoice_line_2
.
getParentValue
(),
invoice_line_2_bis
.
getParentValue
())
self
.
checkDeliveryLine
(
invoice_movement_2_bis
,
invoice_line_2_bis
,
**
line_kw
)
self
.
checkDelivery
(
invoice_movement_2_bis
,
invoice_2
,
category_list
=
category_list
+
convertCategoryList
(
'causality'
,
[
delivery_1
.
getRelativeUrl
(),
delivery_2
.
getRelativeUrl
()]),
**
invoice_kw
)
self
.
assertEqual
(
invoice_line_2
.
getParentValue
(),
invoice_line_1
.
getParentValue
()
)
class
TestSlapOSSaleInvoiceTransactionBuilder
(
TestSlapOSSalePackingListBuilder
):
class
TestSlapOSSaleInvoiceTransactionBuilder
(
TestSlapOSSalePackingListBuilder
):
def
checkSimulationMovement
(
self
,
simulation_movement
):
def
checkSimulationMovement
(
self
,
simulation_movement
):
self
.
assertNotEqual
(
0.0
,
simulation_movement
.
getDeliveryRatio
())
self
.
assertNotEqual
(
0.0
,
simulation_movement
.
getDeliveryRatio
())
...
...
master/bt5/slapos_accounting/bt/template_document_id_list
View file @
bbf94fa7
document.erp5.SlapOSAccountingQuantityUpdatingOrderBuilder
document.erp5.SlapOSAccountingQuantityUpdatingOrderBuilder
document.erp5.SubscriptionItemRootSimulationRule
document.erp5.SubscriptionItemRootSimulationRule
document.erp5.RootAppliedRuleCausalityCausalityMovementGroup
document.erp5.RootAppliedRuleCausalityCausalityMovementGroup
\ No newline at end of file
document.erp5_slapos.RootAppliedRuleCausalityMovementGroup
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment