Demurrage
This commit is contained in:
@@ -9,6 +9,7 @@ from trytond.pool import Pool
|
||||
from trytond.pyson import Eval
|
||||
from trytond.tests.test_tryton import ModuleTestCase, with_transaction
|
||||
from trytond.exceptions import UserError
|
||||
from trytond.transaction import Transaction
|
||||
from trytond.modules.purchase_trade import valuation as valuation_module
|
||||
from trytond.modules.purchase_trade import lot as lot_module
|
||||
from trytond.modules.purchase_trade import purchase as purchase_module
|
||||
@@ -150,6 +151,44 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
|
||||
self.assertEqual(rate.basis, 'per_day')
|
||||
|
||||
@with_transaction()
|
||||
def test_charter_condition_role_defaults_from_context(self):
|
||||
'charter condition role defaults to the business source context'
|
||||
Condition = Pool().get('charter.condition')
|
||||
|
||||
with Transaction().set_context(charter_condition_role='sale'):
|
||||
self.assertEqual(Condition.default_party_role(), 'customer')
|
||||
condition = Condition()
|
||||
self.assertEqual(
|
||||
condition.get_party_roles(),
|
||||
[(None, ''), ('customer', 'Customer')])
|
||||
|
||||
with Transaction().set_context(charter_condition_role='purchase'):
|
||||
self.assertEqual(Condition.default_party_role(), 'supplier')
|
||||
condition = Condition()
|
||||
self.assertEqual(
|
||||
condition.get_party_roles(),
|
||||
[(None, ''), ('supplier', 'Supplier')])
|
||||
|
||||
with Transaction().set_context(charter_condition_role='charter_party'):
|
||||
self.assertEqual(Condition.default_party_role(), 'owner')
|
||||
condition = Condition()
|
||||
roles = {role for role, _ in condition.get_party_roles()}
|
||||
self.assertNotIn('supplier', roles)
|
||||
self.assertNotIn('customer', roles)
|
||||
|
||||
@with_transaction()
|
||||
def test_charter_condition_role_rejects_invalid_source_role(self):
|
||||
'charter condition role is constrained by its source'
|
||||
Condition = Pool().get('charter.condition')
|
||||
condition = Condition()
|
||||
condition.name = 'Invalid supplier condition on sale'
|
||||
condition.party_role = 'supplier'
|
||||
|
||||
with Transaction().set_context(charter_condition_role='sale'):
|
||||
with self.assertRaises(UserError):
|
||||
Condition.validate([condition])
|
||||
|
||||
@with_transaction()
|
||||
def test_sof_calculation_reads_applied_condition_rates(self):
|
||||
'sof demurrage calculation uses the selected charter condition rates'
|
||||
|
||||
Reference in New Issue
Block a user