ICT bug padding + template
This commit is contained in:
@@ -355,6 +355,29 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
self.assertEqual(fee.quantity, Decimal('40.00000'))
|
||||
save.assert_called_once_with([fee])
|
||||
|
||||
def test_fee_ppack_auto_sync_keeps_auto_quantity(self):
|
||||
'per packing auto fee keeps the on-change quantity on save'
|
||||
Fee = Pool().get('fee.fee')
|
||||
fee = Fee()
|
||||
fee.id = 1
|
||||
fee.mode = 'ppack'
|
||||
fee.auto_calculation = True
|
||||
fee.quantity = Decimal('3')
|
||||
fee.unit = Mock()
|
||||
lot = Mock(lot_type='physic', lot_qt=Decimal('990'))
|
||||
fee_lots = Mock()
|
||||
fee_lots.search.return_value = [Mock(lot=lot)]
|
||||
|
||||
with patch(
|
||||
'trytond.modules.purchase_trade.fee.Pool'
|
||||
) as PoolMock, patch.object(Fee, 'save') as save:
|
||||
PoolMock.return_value.get.return_value = fee_lots
|
||||
|
||||
fee.sync_quantity_from_lots()
|
||||
|
||||
self.assertEqual(fee.quantity, Decimal('3'))
|
||||
save.assert_not_called()
|
||||
|
||||
def test_fee_pnl_regeneration_uses_shipment_lotqt_purchase_line(self):
|
||||
'fee pnl regeneration follows shipment lot.qt back to purchase line'
|
||||
Fee = Pool().get('fee.fee')
|
||||
@@ -4206,6 +4229,106 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
||||
invoice.report_quantity_lines,
|
||||
'950.00 LBS (950.00 LBS)')
|
||||
|
||||
def test_invoice_report_weights_prefer_invoice_line_snapshot(self):
|
||||
'invoice report weights use the invoicing snapshot when available'
|
||||
Invoice = Pool().get('account.invoice')
|
||||
|
||||
unit = Mock(rec_name='LBS', symbol='LBS')
|
||||
lot = Mock(lot_unit_line=unit)
|
||||
lot.get_hist_quantity.return_value = (
|
||||
Decimal('950'),
|
||||
Decimal('980'),
|
||||
)
|
||||
snapshot = Mock(
|
||||
net_quantity=Decimal('900'),
|
||||
gross_quantity=Decimal('920'),
|
||||
unit=unit,
|
||||
)
|
||||
line = Mock(
|
||||
type='line',
|
||||
quantity=Decimal('1000'),
|
||||
lot=lot,
|
||||
unit=Mock(rec_name='MT'),
|
||||
lot_weight_snapshots=[snapshot],
|
||||
)
|
||||
invoice = Invoice()
|
||||
invoice.lines = [line]
|
||||
|
||||
self.assertEqual(invoice.report_net, Decimal('900'))
|
||||
self.assertEqual(invoice.report_gross, Decimal('920'))
|
||||
self.assertEqual(invoice.report_weight_unit_upper, 'LBS')
|
||||
self.assertEqual(
|
||||
invoice.report_quantity_lines,
|
||||
'900.00 LBS (900.00 LBS)')
|
||||
|
||||
def test_invoice_report_proforma_snapshot_adds_sale_padding(self):
|
||||
'ICT provisional report displays snapshot weights plus sale padding'
|
||||
Invoice = Pool().get('account.invoice')
|
||||
|
||||
unit = Mock(id=1, rec_name='LBS', symbol='LBS')
|
||||
lot = Mock(lot_unit_line=unit, sale_invoice_padding=Decimal('10'))
|
||||
snapshot = Mock(
|
||||
net_quantity=Decimal('900'),
|
||||
gross_quantity=Decimal('920'),
|
||||
unit=unit,
|
||||
)
|
||||
line = Mock(
|
||||
type='line',
|
||||
description='Pro forma',
|
||||
invoice_type='out',
|
||||
quantity=Decimal('1010'),
|
||||
lot=lot,
|
||||
unit=unit,
|
||||
lot_weight_snapshots=[snapshot],
|
||||
)
|
||||
invoice = Invoice()
|
||||
invoice.lines = [line]
|
||||
|
||||
self.assertEqual(invoice.report_net, Decimal('910'))
|
||||
self.assertEqual(invoice.report_gross, Decimal('930'))
|
||||
self.assertEqual(
|
||||
invoice.report_quantity_lines,
|
||||
'910.00 LBS (910.00 LBS)')
|
||||
|
||||
def test_invoice_validation_creates_weight_snapshot_for_proforma_lines(self):
|
||||
'invoice validation snapshots lot weights for pro forma invoice lines'
|
||||
Invoice = Pool().get('account.invoice')
|
||||
|
||||
lot_ref = Mock(id=10)
|
||||
lot = Mock(id=10)
|
||||
proforma = Mock(
|
||||
type='line',
|
||||
description='Pro forma',
|
||||
quantity=Decimal('1000'),
|
||||
lot=lot_ref,
|
||||
)
|
||||
final = Mock(
|
||||
type='line',
|
||||
description='Final',
|
||||
quantity=Decimal('1000'),
|
||||
lot=lot_ref,
|
||||
)
|
||||
invoice = Invoice()
|
||||
invoice.lines = [proforma, final]
|
||||
|
||||
snapshot_model = Mock()
|
||||
lot_model = Mock(return_value=lot)
|
||||
|
||||
def get_model(name):
|
||||
if name == 'account.invoice.line.lot.weight':
|
||||
return snapshot_model
|
||||
if name == 'lot.lot':
|
||||
return lot_model
|
||||
raise AssertionError(name)
|
||||
|
||||
with patch('trytond.modules.purchase_trade.invoice.Pool') as PoolMock:
|
||||
PoolMock.return_value.get.side_effect = get_model
|
||||
|
||||
invoice._create_lot_weight_snapshots()
|
||||
|
||||
snapshot_model.create_for_invoice_line.assert_called_once_with(
|
||||
proforma, lot)
|
||||
|
||||
def test_invoice_report_lbs_converts_kilogram_to_lbs(self):
|
||||
'invoice lbs helper converts kilogram quantities with the proper uom ratio'
|
||||
Invoice = Pool().get('account.invoice')
|
||||
|
||||
Reference in New Issue
Block a user