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
1
Merge Requests
1
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
Romain Courteaud
slapos.core
Commits
5ce2609c
Commit
5ce2609c
authored
Mar 09, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: test that dedicated trade condition / supply are applied
parent
c9049e41
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
148 additions
and
2 deletions
+148
-2
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingSkins.py
.../portal_components/test.erp5.testSlapOSAccountingSkins.py
+148
-2
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingSkins.py
View file @
5ce2609c
...
...
@@ -849,7 +849,7 @@ class TestInstanceTree_requestUpdateOpenSaleOrder(SlapOSTestCaseMixin):
self
.
assertEqual
(
subscription
.
getCausalityState
(),
'solved'
)
self
.
assertEqual
(
open_sale_order
,
None
)
def
test_empty_InstanceTree
(
self
):
def
test_empty_InstanceTree
_ok
(
self
):
software_product
,
release_variation
,
type_variation
,
_
,
_
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_accountable
=
True
,
base_price
=
42
)
project
=
instance_tree
.
getFollowUpValue
()
person
=
instance_tree
.
getDestinationSectionValue
()
...
...
@@ -870,7 +870,7 @@ class TestInstanceTree_requestUpdateOpenSaleOrder(SlapOSTestCaseMixin):
open_sale_order
.
getPriceCurrency
(),
project
.
Project_getAccountingCurrency
()
)
sale_trade_condition
=
open_sale_order
.
getSpecialiseValue
()
sale_trade_condition
=
project
.
getSpecialiseValue
()
self
.
assertEqual
(
open_sale_order
.
getSpecialise
(),
sale_trade_condition
.
getRelativeUrl
()
...
...
@@ -969,6 +969,152 @@ class TestInstanceTree_requestUpdateOpenSaleOrder(SlapOSTestCaseMixin):
# XXX XXX Open Order start_date, stop_date, effective_date
"""
def
test_empty_InstanceTree_withDedicatedTradeConditionAndSupply
(
self
):
software_product
,
release_variation
,
type_variation
,
_
,
_
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_accountable
=
True
,
base_price
=
42
,
has_organisation
=
True
)
project
=
instance_tree
.
getFollowUpValue
()
person
=
instance_tree
.
getDestinationSectionValue
()
self
.
assertEqual
(
instance_tree
.
getCausalityState
(),
'diverged'
)
sale_trade_condition
=
project
.
getSpecialiseValue
()
# Create dedicated trade condition and supply
dedicated_sale_trade_condition
=
self
.
portal
.
sale_trade_condition_module
.
newContent
(
portal_type
=
"Sale Trade Condition"
,
reference
=
'customer_%s'
%
person
.
getTitle
(),
# XXX hardcoded
specialise_value
=
sale_trade_condition
,
destination_project_value
=
project
,
destination_section_value
=
person
)
dedicated_sale_trade_condition
.
validate
()
dedicated_sale_supply
=
self
.
portal
.
sale_supply_module
.
newContent
(
portal_type
=
"Sale Supply"
,
destination_project_value
=
project
,
destination_section_value
=
person
,
price_currency
=
project
.
Project_getAccountingCurrency
()
)
dedicated_sale_supply
.
newContent
(
portal_type
=
"Sale Supply Line"
,
base_price
=
43
,
resource_value
=
software_product
)
dedicated_sale_supply
.
validate
()
self
.
tic
()
open_sale_order
=
instance_tree
.
InstanceTree_requestUpdateOpenSaleOrder
()
self
.
assertEqual
(
instance_tree
.
getCausalityState
(),
'solved'
)
self
.
assertNotEqual
(
open_sale_order
,
None
)
self
.
assertEqual
(
'validated'
,
open_sale_order
.
getValidationState
())
self
.
tic
()
# Check Open Sale Order
self
.
assertEqual
(
open_sale_order
.
getLedger
(),
"automated"
)
self
.
assertEqual
(
open_sale_order
.
getPriceCurrency
(),
project
.
Project_getAccountingCurrency
()
)
self
.
assertEqual
(
open_sale_order
.
getSpecialise
(),
dedicated_sale_trade_condition
.
getRelativeUrl
()
)
self
.
assertEqual
(
open_sale_order
.
getSource
(),
sale_trade_condition
.
getSource
()
)
self
.
assertEqual
(
open_sale_order
.
getSourceSection
(),
sale_trade_condition
.
getSourceSection
()
)
self
.
assertEqual
(
open_sale_order
.
getDestinationProject
(),
project
.
getRelativeUrl
()
)
self
.
assertEqual
(
open_sale_order
.
getDestination
(),
person
.
getRelativeUrl
()
)
self
.
assertEqual
(
open_sale_order
.
getDestinationSection
(),
person
.
getRelativeUrl
()
)
self
.
assertEqual
(
open_sale_order
.
getDestinationDecision
(),
person
.
getRelativeUrl
()
)
# Check Open Sale Order Line
open_sale_order_line_list
=
open_sale_order
.
contentValues
(
portal_type
=
'Open Sale Order Line'
)
self
.
assertEqual
(
1
,
len
(
open_sale_order_line_list
))
line
=
open_sale_order_line_list
[
0
].
getObject
()
self
.
assertEqual
(
line
.
getResource
(),
software_product
.
getRelativeUrl
()
)
self
.
assertEqual
(
line
.
getSoftwareRelease
(),
release_variation
.
getRelativeUrl
()
)
self
.
assertEqual
(
line
.
getSoftwareType
(),
type_variation
.
getRelativeUrl
()
)
self
.
assertEqual
(
line
.
getTotalQuantity
(),
1
)
self
.
assertEqual
(
software_product
.
getQuantityUnit
(),
line
.
getQuantityUnit
()
)
self
.
assertEqual
(
software_product
.
getUse
(),
line
.
getUse
()
)
self
.
assertSameSet
(
software_product
.
getBaseContributionList
(),
line
.
getBaseContributionList
()
)
self
.
assertEqual
(
line
.
getTotalPrice
(),
43
)
self
.
assertEqual
(
line
.
getPriceCurrency
(),
project
.
Project_getAccountingCurrency
()
)
# Check Open Sale Order Cell
open_sale_order_cell_list
=
line
.
contentValues
(
portal_type
=
'Open Sale Order Cell'
)
self
.
assertEqual
(
1
,
len
(
open_sale_order_cell_list
))
cell
=
open_sale_order_cell_list
[
0
].
getObject
()
self
.
assertEqual
(
cell
.
getQuantity
(),
1
)
self
.
assertEqual
(
cell
.
getPrice
(),
43
)
hosting_subscription
=
cell
.
getAggregateValue
(
portal_type
=
"Hosting Subscription"
)
self
.
assertSameSet
(
cell
.
getAggregateList
(),
[
hosting_subscription
.
getRelativeUrl
(),
instance_tree
.
getRelativeUrl
()]
)
self
.
assertEqual
(
"validated"
,
hosting_subscription
.
getValidationState
())
"""
self.assertEqual(DateTime().earliestTime(), line.getStartDate())
self.assertEqual(min(DateTime().day(), 28),
hosting_subscription.getPeriodicityMonthDay())
start_date = addToDate(line.getStartDate(), to_add={'month': 1})
start_date = addToDate(start_date, to_add={'second': -1})
while start_date.day() >= 28:
start_date = addToDate(start_date, to_add={'day': -1})
self.assertEqual(start_date, line.getStopDate())
# XXX XXX Open Order start_date, stop_date, effective_date
"""
def
test_empty_InstanceTree_noPerson
(
self
):
_
,
_
,
_
,
_
,
_
,
instance_tree
=
self
.
bootstrapAllocableInstanceTree
(
is_accountable
=
True
,
base_price
=
42
)
instance_tree
.
setDestinationSection
(
None
)
...
...
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