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
ec006924
Commit
ec006924
authored
Oct 20, 2023
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_accounting: test: fixup testSlapOSAccountingConstraint
parent
1bb9d7f8
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
23 deletions
+61
-23
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingConstraint.py
...al_components/test.erp5.testSlapOSAccountingConstraint.py
+61
-23
No files found.
master/bt5/slapos_accounting/TestTemplateItem/portal_components/test.erp5.testSlapOSAccountingConstraint.py
View file @
ec006924
...
@@ -11,7 +11,6 @@ from unittest import skip
...
@@ -11,7 +11,6 @@ from unittest import skip
import
transaction
import
transaction
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
=
'sale_trade_condition_module/slapos_aggregated_trade_condition_v3'
class
TestHostingSubscription
(
TestSlapOSConstraintMixin
):
class
TestHostingSubscription
(
TestSlapOSConstraintMixin
):
...
@@ -152,16 +151,14 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
...
@@ -152,16 +151,14 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
def
test_specialise_value
(
self
):
def
test_specialise_value
(
self
):
invoice
=
self
.
portal
.
accounting_module
.
newContent
(
invoice
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Sale Invoice Transaction'
)
portal_type
=
'Sale Invoice Transaction'
)
message
=
"Only SlapOS trade condition is allowed"
message
=
"Arity Error for Relation ['specialise'] and Type "
+
\
"('Sale Trade Condition',), arity is equal to 0 but should be at least 1"
self
.
assertTrue
(
message
in
self
.
getMessageList
(
invoice
))
self
.
assertTrue
(
message
in
self
.
getMessageList
(
invoice
))
sale_condition
=
self
.
portal
.
sale_trade_condition_module
.
newContent
(
sale_condition
=
self
.
portal
.
sale_trade_condition_module
.
newContent
(
portal_type
=
'Sale Trade Condition'
)
portal_type
=
'Sale Trade Condition'
)
invoice
.
setSpecialise
(
sale_condition
.
getRelativeUrl
())
invoice
.
setSpecialise
(
sale_condition
.
getRelativeUrl
())
self
.
assertTrue
(
message
in
self
.
getMessageList
(
invoice
))
invoice
.
setSpecialise
(
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
)
self
.
assertFalse
(
message
in
self
.
getMessageList
(
invoice
))
self
.
assertFalse
(
message
in
self
.
getMessageList
(
invoice
))
@
withAbort
@
withAbort
...
@@ -183,10 +180,35 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
...
@@ -183,10 +180,35 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
@
withAbort
@
withAbort
def
test_trade_model_match_lines
(
self
):
def
test_trade_model_match_lines
(
self
):
message
=
"Defined Trade Model does not match Lines definition"
message
=
"Defined Trade Model does not match Lines definition"
currency
=
self
.
portal
.
currency_module
.
EUR
sale_trade_condition
=
self
.
portal
.
sale_trade_condition_module
.
newContent
(
portal_type
=
"Sale Trade Condition"
,
reference
=
"Tax/payment for: %s"
%
currency
.
getRelativeUrl
(),
trade_condition_type
=
"default"
,
# XXX hardcoded
specialise
=
"business_process_module/slapos_ultimate_business_process"
,
price_currency_value
=
currency
,
payment_condition_payment_mode
=
'test-%s'
%
self
.
generateNewId
()
)
sale_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.2
,
quantity
=
1.0
,
membership_criterion_base_category
=
(
'price_currency'
,
'base_contribution'
),
membership_criterion_category
=
(
'price_currency/%s'
%
currency
.
getRelativeUrl
(),
'base_contribution/base_amount/invoicing/taxable'
)
)
sale_trade_condition
.
validate
()
invoice
=
self
.
portal
.
accounting_module
.
newContent
(
invoice
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Sale Invoice Transaction'
,
portal_type
=
'Sale Invoice Transaction'
,
price_currency
=
'currency_module/EUR'
,
price_currency
_value
=
currency
,
specialise
=
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
)
specialise
_value
=
sale_trade_condition
)
invoice
.
newContent
(
portal_type
=
'Invoice Line'
,
quantity
=
1.
,
price
=
1.
,
invoice
.
newContent
(
portal_type
=
'Invoice Line'
,
quantity
=
1.
,
price
=
1.
,
base_contribution
=
'base_amount/invoicing/taxable'
)
base_contribution
=
'base_amount/invoicing/taxable'
)
...
@@ -202,20 +224,47 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
...
@@ -202,20 +224,47 @@ class TestSaleInvoiceTransaction(TestSlapOSConstraintMixin):
@
withAbort
@
withAbort
def
test_use_trade_sale_total_price_matches_delivery_constraint
(
self
):
def
test_use_trade_sale_total_price_matches_delivery_constraint
(
self
):
message
=
"Total price does not match related Sale Packing List"
message
=
"Total price does not match related Sale Packing List"
currency
=
self
.
portal
.
currency_module
.
EUR
sale_trade_condition
=
self
.
portal
.
sale_trade_condition_module
.
newContent
(
portal_type
=
"Sale Trade Condition"
,
reference
=
"Tax/payment for: %s"
%
currency
.
getRelativeUrl
(),
trade_condition_type
=
"default"
,
# XXX hardcoded
specialise
=
"business_process_module/slapos_ultimate_business_process"
,
price_currency_value
=
currency
,
payment_condition_payment_mode
=
'test-%s'
%
self
.
generateNewId
()
)
sale_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.2
,
quantity
=
1.0
,
membership_criterion_base_category
=
(
'price_currency'
,
'base_contribution'
),
membership_criterion_category
=
(
'price_currency/%s'
%
currency
.
getRelativeUrl
(),
'base_contribution/base_amount/invoicing/taxable'
)
)
sale_trade_condition
.
validate
()
delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
delivery
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
)
portal_type
=
'Sale Packing List'
)
delivery
.
newContent
(
portal_type
=
'Sale Packing List Line'
,
delivery
.
newContent
(
portal_type
=
'Sale Packing List Line'
,
use
=
'trade/sale'
,
quantity
=
1.
,
price
=
1.
)
use
=
'trade/sale'
,
quantity
=
1.
,
price
=
1.
)
invoice
=
self
.
portal
.
accounting_module
.
newContent
(
invoice
=
self
.
portal
.
accounting_module
.
newContent
(
portal_type
=
'Sale Invoice Transaction'
,
portal_type
=
'Sale Invoice Transaction'
,
causality
=
delivery
.
getRelativeUrl
())
ledger
=
"automated"
,
specialise_value
=
sale_trade_condition
)
invoice_line
=
invoice
.
newContent
(
portal_type
=
'Invoice Line'
,
quantity
=
2.
,
invoice_line
=
invoice
.
newContent
(
portal_type
=
'Invoice Line'
,
quantity
=
2.
,
price
=
1.
,
use
=
'trade/sale'
)
price
=
1.
,
use
=
'trade/sale'
)
self
.
assertFalse
(
message
in
self
.
getMessageList
(
invoice
))
self
.
assertFalse
(
message
in
self
.
getMessageList
(
invoice
))
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
invoice
,
'confirmed'
)
self
.
portal
.
portal_workflow
.
_jumpToStateFor
(
invoice
,
'confirmed'
)
self
.
assertFalse
(
message
in
self
.
getMessageList
(
invoice
))
self
.
assertFalse
(
message
in
self
.
getMessageList
(
invoice
))
invoice
.
set
Specialise
(
AGGREGATE_SALE_TRADE_CONDITION_RELATIVE_URL
)
invoice
.
set
CausalityValue
(
delivery
)
self
.
assertTrue
(
message
in
self
.
getMessageList
(
invoice
))
self
.
assertTrue
(
message
in
self
.
getMessageList
(
invoice
))
invoice_line
.
setQuantity
(
1.
)
invoice_line
.
setQuantity
(
1.
)
self
.
assertFalse
(
message
in
self
.
getMessageList
(
invoice
))
self
.
assertFalse
(
message
in
self
.
getMessageList
(
invoice
))
...
@@ -304,9 +353,6 @@ class TestSalePackingList(TestSlapOSConstraintMixin):
...
@@ -304,9 +353,6 @@ class TestSalePackingList(TestSlapOSConstraintMixin):
def
test_source
(
self
):
def
test_source
(
self
):
self
.
_test_category_arrow
(
'source'
)
self
.
_test_category_arrow
(
'source'
)
def
test_source_section
(
self
):
self
.
_test_category_arrow
(
'source_section'
)
@
withAbort
@
withAbort
def
test_specialise
(
self
):
def
test_specialise
(
self
):
category
=
'specialise'
category
=
'specialise'
...
@@ -345,28 +391,20 @@ class TestSalePackingList(TestSlapOSConstraintMixin):
...
@@ -345,28 +391,20 @@ class TestSalePackingList(TestSlapOSConstraintMixin):
class
TestSalePackingListLine
(
TestSlapOSConstraintMixin
):
class
TestSalePackingListLine
(
TestSlapOSConstraintMixin
):
@
withAbort
@
withAbort
def
test_property_existence
(
self
):
def
test_property_existence
(
self
):
message
=
'Property existence error for property %s, this document has '
\
message_quantity
=
'No quantity defined'
'no such property or the property has never been set'
message_price
=
message
%
'price'
message_quantity
=
message
%
'quantity'
delivery_line
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
delivery_line
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
).
newContent
(
portal_type
=
'Sale Packing List'
).
newContent
(
portal_type
=
'Sale Packing List Line'
)
portal_type
=
'Sale Packing List Line'
)
self
.
assertTrue
(
message_price
in
self
.
getMessageList
(
delivery_line
))
self
.
assertTrue
(
message_quantity
in
self
.
getMessageList
(
delivery_line
))
self
.
assertTrue
(
message_quantity
in
self
.
getMessageList
(
delivery_line
))
delivery_line
.
setQuantity
(
1.0
)
delivery_line
.
setQuantity
(
1.0
)
self
.
assertTrue
(
message_price
in
self
.
getMessageList
(
delivery_line
))
self
.
assertFalse
(
message_quantity
in
self
.
getMessageList
(
delivery_line
))
delivery_line
.
setPrice
(
1.0
)
self
.
assertFalse
(
message_price
in
self
.
getMessageList
(
delivery_line
))
self
.
assertFalse
(
message_quantity
in
self
.
getMessageList
(
delivery_line
))
self
.
assertFalse
(
message_quantity
in
self
.
getMessageList
(
delivery_line
))
@
withAbort
@
withAbort
def
test_resource_arity
(
self
):
def
test_resource_arity
(
self
):
category
=
'resource'
category
=
'resource'
message
=
"Arity Error for Relation ['%s'] and Type ('Data Operation', 'Service'), arity is"
\
message
=
"Arity Error for Relation ['%s'] and Type ('Data Operation', 'Service'
, 'Software Product'
), arity is"
\
" equal to 0 but should be between 1 and 1"
%
category
" equal to 0 but should be between 1 and 1"
%
category
message_2
=
"Arity Error for Relation ['%s'] and Type ('Data Operation', 'Service'), arity is"
\
message_2
=
"Arity Error for Relation ['%s'] and Type ('Data Operation', 'Service'
, 'Software Product'
), arity is"
\
" equal to 2 but should be between 1 and 1"
%
category
" equal to 2 but should be between 1 and 1"
%
category
delivery_line
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
delivery_line
=
self
.
portal
.
sale_packing_list_module
.
newContent
(
portal_type
=
'Sale Packing List'
).
newContent
(
portal_type
=
'Sale Packing List'
).
newContent
(
...
...
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