This commit is contained in:
2026-06-07 09:47:55 +02:00
parent 4ebfbe6ddd
commit 6ffc159255
2 changed files with 129 additions and 12 deletions

View File

@@ -219,6 +219,37 @@ class PurchaseTradeTestCase(ModuleTestCase):
'planned_to_location': 20,
})
def test_lot_shipping_defaults_uniform_planned_locations(self):
'link to transport carries uniform planned locations from selection'
wizard = lot_module.LotShipping()
wizard.records = [
Mock(
r_planned_from_location=Mock(id=10),
r_planned_to_location=Mock(id=20)),
Mock(
r_planned_from_location=Mock(id=10),
r_planned_to_location=Mock(id=20)),
]
self.assertEqual(wizard.default_ship(None), {
'planned_from_location': 10,
'planned_to_location': 20,
})
def test_lot_shipping_ignores_mixed_planned_locations(self):
'link to transport does not force mixed planned locations'
wizard = lot_module.LotShipping()
wizard.records = [
Mock(
r_planned_from_location=Mock(id=10),
r_planned_to_location=Mock(id=20)),
Mock(
r_planned_from_location=Mock(id=11),
r_planned_to_location=Mock(id=21)),
]
self.assertEqual(wizard.default_ship(None), {})
def test_lot_shipping_link_creates_shipment_from_dialog_supplier(self):
'link to transport creates shipment in from dialog supplier'
wizard = lot_module.LotShipping()
@@ -271,6 +302,50 @@ class PurchaseTradeTestCase(ModuleTestCase):
with self.assertRaises(UserError):
wizard.transition_shipping()
def test_lot_shipping_scheduled_lotqt_keeps_planned_locations(self):
'scheduled lot.qt keeps the planned from and to locations'
wizard = lot_module.LotShipping()
wizard.ship = Mock(
shipment='in',
shipment_in=Mock(id=40),
shipment_out=None,
shipment_internal=None,
)
lqt = Mock(
lot_p=Mock(id=1),
lot_s=Mock(id=2),
lot_unit=Mock(id=3),
lot_av='available',
lot_status='forecast',
lot_visible=True,
planned_from_location=Mock(id=10),
planned_to_location=Mock(id=20),
planned_transport_type='vessel',
planned_from_date=datetime.date(2026, 7, 1),
planned_to_date=datetime.date(2026, 7, 5),
planned_note='POL to POD',
)
LotQt = Mock()
wizard._create_scheduled_lotqt(LotQt, lqt, Decimal('125'))
LotQt.create.assert_called_once_with([{
'lot_p': 1,
'lot_s': 2,
'lot_quantity': Decimal('125'),
'lot_unit': 3,
'lot_av': 'available',
'lot_status': 'forecast',
'lot_visible': True,
'planned_from_location': 10,
'planned_to_location': 20,
'planned_transport_type': 'vessel',
'planned_from_date': datetime.date(2026, 7, 1),
'planned_to_date': datetime.date(2026, 7, 5),
'planned_note': 'POL to POD',
'lot_shipment_in': 40,
}])
@with_transaction()
def test_get_mtm_applies_component_ratio_as_percentage(self):
'get_mtm treats component ratio as a percentage'