Pricing manual

This commit is contained in:
2026-06-11 10:49:05 +02:00
parent 9d13cfd587
commit 52459a267b
6 changed files with 84 additions and 23 deletions

View File

@@ -2820,6 +2820,45 @@ class PurchaseTradeTestCase(ModuleTestCase):
self.assertEqual(second_values['eod_price'], Decimal('106.0000'))
self.assertTrue(second_values['last'])
def test_pricing_sync_manual_values_uses_curve_last_price_for_unfixed(self):
'manual pricing rows use the component curve latest price for the unfixed leg'
Pricing = Pool().get('pricing.pricing')
currency = Mock()
unit = Mock()
sale_line = Mock(
id=10,
sale=Mock(currency=currency),
unit=unit,
)
sale_line._get_pricing_base_quantity = Mock(return_value=Decimal('10'))
component = Mock(
id=33,
auto=False,
price_source_type='curve',
price_index=Mock(),
)
component.get_price.return_value = Decimal('120')
pricing = Mock(
id=1,
price_component=component,
sale_line=sale_line,
line=None,
pricing_date=datetime.date(2026, 4, 10),
quantity=Decimal('4'),
settl_price=Decimal('100'),
)
with patch.object(Pricing, 'search', return_value=[pricing]), patch(
'trytond.modules.purchase_trade.pricing.super') as super_mock:
Pricing._sync_manual_values([pricing])
values = super_mock.return_value.write.call_args.args[1]
self.assertEqual(values['unfixed_qt_price'], Decimal('120.0000'))
self.assertEqual(values['eod_price'], Decimal('112.0000'))
component.get_price.assert_called_once_with(
datetime.date(2026, 4, 10), unit, currency, True)
def test_pricing_trigger_manual_from_to_generates_dates_without_calendar(self):
'manual pricing From/To uses calendar days when no calendar is selected'
Trigger = Pool().get('pricing.trigger')