Add manual pricing

This commit is contained in:
2026-04-09 22:24:49 +02:00
parent 229b6037fb
commit 0def187750
4 changed files with 160 additions and 37 deletions

View File

@@ -246,6 +246,50 @@ class PurchaseTradeTestCase(ModuleTestCase):
self.assertEqual(pricing_model.save.call_args_list[0].args[0][0].unfixed_qt, Decimal('10'))
self.assertEqual(pricing_model.save.call_args_list[1].args[0][0].unfixed_qt, Decimal('12'))
def test_pricing_manual_fields_are_editable_except_eod(self):
'manual pricing rows can edit fixed and unfixed values while eod stays computed'
Pricing = Pool().get('pricing.pricing')
self.assertFalse(Pricing.fixed_qt.readonly)
self.assertFalse(Pricing.fixed_qt_price.readonly)
self.assertFalse(Pricing.unfixed_qt.readonly)
self.assertFalse(Pricing.unfixed_qt_price.readonly)
self.assertTrue(Pricing.eod_price.readonly)
def test_pricing_eod_uses_weighted_average_for_manual_rows(self):
'manual pricing eod uses the weighted average of fixed and unfixed legs'
Pricing = Pool().get('pricing.pricing')
pricing = Pricing()
pricing.fixed_qt = Decimal('4')
pricing.fixed_qt_price = Decimal('100')
pricing.unfixed_qt = Decimal('6')
pricing.unfixed_qt_price = Decimal('110')
self.assertEqual(pricing.compute_eod_price(), Decimal('106.0000'))
def test_sale_and_purchase_eod_use_same_weighted_formula(self):
'auto sale/purchase eod helpers use the same weighted average formula'
Pricing = Pool().get('pricing.pricing')
sale_pricing = Pricing()
sale_pricing.sale_line = Mock(quantity=Decimal('999'))
sale_pricing.fixed_qt = Decimal('4')
sale_pricing.fixed_qt_price = Decimal('100')
sale_pricing.unfixed_qt = Decimal('6')
sale_pricing.unfixed_qt_price = Decimal('110')
purchase_pricing = Pricing()
purchase_pricing.line = Mock(quantity_theorical=Decimal('999'))
purchase_pricing.fixed_qt = Decimal('4')
purchase_pricing.fixed_qt_price = Decimal('100')
purchase_pricing.unfixed_qt = Decimal('6')
purchase_pricing.unfixed_qt_price = Decimal('110')
self.assertEqual(sale_pricing.get_eod_price_sale(), Decimal('106.0000'))
self.assertEqual(
purchase_pricing.get_eod_price_purchase(), Decimal('106.0000'))
def test_sale_and_purchase_trader_operator_domains_use_explicit_categories(self):
'sale and purchase trader/operator fields are filtered by TRADER/OPERATOR categories'
Sale = Pool().get('sale.sale')