Pnl bug sh fee
This commit is contained in:
@@ -2206,6 +2206,34 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
|||||||
self.assertEqual(values[1]['quantity'], Decimal('132.00000'))
|
self.assertEqual(values[1]['quantity'], Decimal('132.00000'))
|
||||||
self.assertEqual(values[1]['amount'], Decimal('-1320.00'))
|
self.assertEqual(values[1]['amount'], Decimal('-1320.00'))
|
||||||
|
|
||||||
|
def test_shipment_fee_pnl_sums_all_shipment_lotqt(self):
|
||||||
|
'shipment fee pnl sums every lot.qt linked to the shipment'
|
||||||
|
Valuation = Pool().get('valuation.valuation')
|
||||||
|
shipment = Mock(id=70)
|
||||||
|
unit = Mock(id=2)
|
||||||
|
lot = Mock(id=5, lot_type='virtual', sale_line=None)
|
||||||
|
lot.get_current_quantity_converted.return_value = Decimal('18000')
|
||||||
|
line = Mock(id=4, unit=unit)
|
||||||
|
lot_qt_model = Mock()
|
||||||
|
lot_qt_model.search.return_value = [
|
||||||
|
Mock(id=1, lot_quantity=Decimal('5000'), lot_unit=unit,
|
||||||
|
lot_shipment_in=shipment),
|
||||||
|
Mock(id=2, lot_quantity=Decimal('6000'), lot_unit=unit,
|
||||||
|
lot_shipment_in=shipment),
|
||||||
|
Mock(id=3, lot_quantity=Decimal('7000'), lot_unit=unit,
|
||||||
|
lot_shipment_in=shipment),
|
||||||
|
]
|
||||||
|
fee = Mock(shipment_in=shipment)
|
||||||
|
|
||||||
|
segments = Valuation._fee_segments_for_fee(
|
||||||
|
fee, lot, line, lot_qt_model)
|
||||||
|
|
||||||
|
self.assertEqual(segments, [{
|
||||||
|
'quantity': Decimal('18000'),
|
||||||
|
'share': Decimal('1'),
|
||||||
|
'shipment_in': shipment.id,
|
||||||
|
}])
|
||||||
|
|
||||||
def test_snapshot_identity_prefers_sale_line_over_purchase_line(self):
|
def test_snapshot_identity_prefers_sale_line_over_purchase_line(self):
|
||||||
'valuation snapshot identity ignores purchase line when sale line exists'
|
'valuation snapshot identity ignores purchase line when sale line exists'
|
||||||
Valuation = Pool().get('valuation.valuation')
|
Valuation = Pool().get('valuation.valuation')
|
||||||
|
|||||||
@@ -1180,7 +1180,20 @@ class ValuationBase(ModelSQL):
|
|||||||
segment for segment in segments
|
segment for segment in segments
|
||||||
if segment.get('shipment_in') == shipment_id]
|
if segment.get('shipment_in') == shipment_id]
|
||||||
if selected:
|
if selected:
|
||||||
return selected
|
quantities = [
|
||||||
|
Decimal(str(segment['quantity']))
|
||||||
|
for segment in selected
|
||||||
|
if segment.get('quantity') is not None]
|
||||||
|
shares = [
|
||||||
|
Decimal(str(segment['share']))
|
||||||
|
for segment in selected
|
||||||
|
if segment.get('share') is not None]
|
||||||
|
return [{
|
||||||
|
'quantity': (
|
||||||
|
sum(quantities, Decimal(0)) if quantities else None),
|
||||||
|
'share': sum(shares, Decimal(0)) if shares else None,
|
||||||
|
'shipment_in': shipment_id,
|
||||||
|
}]
|
||||||
return [{
|
return [{
|
||||||
'quantity': None,
|
'quantity': None,
|
||||||
'share': None,
|
'share': None,
|
||||||
|
|||||||
Reference in New Issue
Block a user