Valuation
This commit is contained in:
@@ -1208,6 +1208,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
|||||||
lot = Mock(id=5, sale_line=None, lot_type='virtual')
|
lot = Mock(id=5, sale_line=None, lot_type='virtual')
|
||||||
lot.get_current_quantity_converted.return_value = Decimal('10')
|
lot.get_current_quantity_converted.return_value = Decimal('10')
|
||||||
fee = Mock(
|
fee = Mock(
|
||||||
|
id=11,
|
||||||
product=product,
|
product=product,
|
||||||
supplier=supplier,
|
supplier=supplier,
|
||||||
type='budgeted',
|
type='budgeted',
|
||||||
@@ -1241,6 +1242,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
|||||||
values = Valuation.create_pnl_fee_from_line(line)
|
values = Valuation.create_pnl_fee_from_line(line)
|
||||||
|
|
||||||
self.assertEqual(values[0]['amount'], Decimal('0'))
|
self.assertEqual(values[0]['amount'], Decimal('0'))
|
||||||
|
self.assertEqual(values[0]['fee'], fee.id)
|
||||||
|
|
||||||
def test_fee_quantity_sync_uses_physical_lots_when_present(self):
|
def test_fee_quantity_sync_uses_physical_lots_when_present(self):
|
||||||
'fee quantity sync ignores virtual lot once physical lots exist'
|
'fee quantity sync ignores virtual lot once physical lots exist'
|
||||||
@@ -1762,6 +1764,7 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
|||||||
sale_lot.get_current_quantity_converted.return_value = Decimal('220')
|
sale_lot.get_current_quantity_converted.return_value = Decimal('220')
|
||||||
sale_line.lots = [sale_lot]
|
sale_line.lots = [sale_lot]
|
||||||
fee = Mock(
|
fee = Mock(
|
||||||
|
id=12,
|
||||||
product=Mock(id=6, name='Broker commission'),
|
product=Mock(id=6, name='Broker commission'),
|
||||||
supplier=Mock(id=7),
|
supplier=Mock(id=7),
|
||||||
type='budgeted',
|
type='budgeted',
|
||||||
@@ -1802,6 +1805,8 @@ class PurchaseTradeTestCase(ModuleTestCase):
|
|||||||
values = Valuation.create_pnl_fee_from_sale_line(sale_line)
|
values = Valuation.create_pnl_fee_from_sale_line(sale_line)
|
||||||
|
|
||||||
self.assertEqual(len(values), 2)
|
self.assertEqual(len(values), 2)
|
||||||
|
self.assertEqual(values[0]['fee'], fee.id)
|
||||||
|
self.assertEqual(values[1]['fee'], fee.id)
|
||||||
self.assertEqual(values[0]['shipment_in'], shipment.id)
|
self.assertEqual(values[0]['shipment_in'], shipment.id)
|
||||||
self.assertEqual(values[0]['quantity'], Decimal('88.00000'))
|
self.assertEqual(values[0]['quantity'], Decimal('88.00000'))
|
||||||
self.assertEqual(values[0]['amount'], Decimal('-880.00'))
|
self.assertEqual(values[0]['amount'], Decimal('-880.00'))
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ class ValuationBase(ModelSQL):
|
|||||||
strategy = fields.Many2One('mtm.strategy',"Strategy")
|
strategy = fields.Many2One('mtm.strategy',"Strategy")
|
||||||
lot = fields.Many2One('lot.lot',"Lot")
|
lot = fields.Many2One('lot.lot',"Lot")
|
||||||
shipment_in = fields.Many2One('stock.shipment.in', "Shipment In")
|
shipment_in = fields.Many2One('stock.shipment.in', "Shipment In")
|
||||||
|
fee = fields.Many2One('fee.fee', "Fee")
|
||||||
base_amount = fields.Numeric("Base Amount",digits=(16,2))
|
base_amount = fields.Numeric("Base Amount",digits=(16,2))
|
||||||
rate = fields.Numeric("Rate", digits=(16,6))
|
rate = fields.Numeric("Rate", digits=(16,6))
|
||||||
|
|
||||||
@@ -337,6 +338,7 @@ class ValuationBase(ModelSQL):
|
|||||||
value.get('state'),
|
value.get('state'),
|
||||||
value.get('strategy'),
|
value.get('strategy'),
|
||||||
value.get('shipment_in'),
|
value.get('shipment_in'),
|
||||||
|
value.get('fee'),
|
||||||
value.get('mtm_curve'),
|
value.get('mtm_curve'),
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -363,6 +365,7 @@ class ValuationBase(ModelSQL):
|
|||||||
('state', '=', value.get('state')),
|
('state', '=', value.get('state')),
|
||||||
('strategy', '=', value.get('strategy')),
|
('strategy', '=', value.get('strategy')),
|
||||||
('shipment_in', '=', value.get('shipment_in')),
|
('shipment_in', '=', value.get('shipment_in')),
|
||||||
|
('fee', '=', value.get('fee')),
|
||||||
('mtm_curve', '=', value.get('mtm_curve')),
|
('mtm_curve', '=', value.get('mtm_curve')),
|
||||||
]
|
]
|
||||||
if value.get('sale_line'):
|
if value.get('sale_line'):
|
||||||
@@ -1230,6 +1233,7 @@ class ValuationBase(ModelSQL):
|
|||||||
'purchase': line.purchase.id,
|
'purchase': line.purchase.id,
|
||||||
'line': line.id,
|
'line': line.id,
|
||||||
'shipment_in': segment.get('shipment_in'),
|
'shipment_in': segment.get('shipment_in'),
|
||||||
|
'fee': sf.id,
|
||||||
'type': (
|
'type': (
|
||||||
'shipment fee' if sf.shipment_in
|
'shipment fee' if sf.shipment_in
|
||||||
else 'sale fee' if sf.sale_line
|
else 'sale fee' if sf.sale_line
|
||||||
@@ -1291,6 +1295,7 @@ class ValuationBase(ModelSQL):
|
|||||||
'sale': sale_line.sale.id,
|
'sale': sale_line.sale.id,
|
||||||
'sale_line': sale_line.id,
|
'sale_line': sale_line.id,
|
||||||
'shipment_in': segment.get('shipment_in'),
|
'shipment_in': segment.get('shipment_in'),
|
||||||
|
'fee': sf.id,
|
||||||
'type': (
|
'type': (
|
||||||
'shipment fee' if sf.shipment_in
|
'shipment fee' if sf.shipment_in
|
||||||
else 'sale fee'
|
else 'sale fee'
|
||||||
@@ -1520,6 +1525,7 @@ class ValuationDyn(ModelSQL,ModelView):
|
|||||||
r_strategy = fields.Many2One('mtm.strategy',"Strategy")
|
r_strategy = fields.Many2One('mtm.strategy',"Strategy")
|
||||||
r_lot = fields.Many2One('lot.lot',"Lot")
|
r_lot = fields.Many2One('lot.lot',"Lot")
|
||||||
r_shipment_in = fields.Many2One('stock.shipment.in', "Shipment In")
|
r_shipment_in = fields.Many2One('stock.shipment.in', "Shipment In")
|
||||||
|
r_fee = fields.Many2One('fee.fee', "Fee")
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def table_query(cls):
|
def table_query(cls):
|
||||||
@@ -1558,6 +1564,7 @@ class ValuationDyn(ModelSQL,ModelView):
|
|||||||
Max(val.strategy).as_('r_strategy'),
|
Max(val.strategy).as_('r_strategy'),
|
||||||
Max(val.lot).as_('r_lot'),
|
Max(val.lot).as_('r_lot'),
|
||||||
Max(val.shipment_in).as_('r_shipment_in'),
|
Max(val.shipment_in).as_('r_shipment_in'),
|
||||||
|
Max(val.fee).as_('r_fee'),
|
||||||
where=wh,
|
where=wh,
|
||||||
group_by=[val.type, val.counterparty, val.state, val.mtm_curve])
|
group_by=[val.type, val.counterparty, val.state, val.mtm_curve])
|
||||||
|
|
||||||
@@ -1615,6 +1622,7 @@ class ValuationReport(ValuationBase, ModelView):
|
|||||||
val.strategy.as_('strategy'),
|
val.strategy.as_('strategy'),
|
||||||
val.lot.as_('lot'),
|
val.lot.as_('lot'),
|
||||||
val.shipment_in.as_('shipment_in'),
|
val.shipment_in.as_('shipment_in'),
|
||||||
|
val.fee.as_('fee'),
|
||||||
where=wh)
|
where=wh)
|
||||||
|
|
||||||
return query
|
return query
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
<field name="purchase"/>
|
<field name="purchase"/>
|
||||||
<field name="sale"/>
|
<field name="sale"/>
|
||||||
<field name="shipment_in" optional="1"/>
|
<field name="shipment_in" optional="1"/>
|
||||||
|
<field name="fee" optional="1"/>
|
||||||
<field name="type"
|
<field name="type"
|
||||||
widget="badge"
|
widget="badge"
|
||||||
badge_colors="priced:#2563eb,Price:#2563eb,pur. priced:#1d4ed8,Pur. price:#1d4ed8,pur. efp:#38bdf8,Pur. efp:#38bdf8,sale priced:#16a34a,Sale price:#16a34a,sale efp:#86efac,Sale efp:#86efac,market:#64748b,Market:#64748b,line fee:#d97706,Line fee:#d97706,pur. fee:#f59e0b,Pur. fee:#f59e0b,sale fee:#fb923c,Sale fee:#fb923c,shipment fee:#0f766e,Shipment fee:#0f766e,derivative:#8b5cf6,Derivative:#8b5cf6,*:#94a3b8"/>
|
badge_colors="priced:#2563eb,Price:#2563eb,pur. priced:#1d4ed8,Pur. price:#1d4ed8,pur. efp:#38bdf8,Pur. efp:#38bdf8,sale priced:#16a34a,Sale price:#16a34a,sale efp:#86efac,Sale efp:#86efac,market:#64748b,Market:#64748b,line fee:#d97706,Line fee:#d97706,pur. fee:#f59e0b,Pur. fee:#f59e0b,sale fee:#fb923c,Sale fee:#fb923c,shipment fee:#0f766e,Shipment fee:#0f766e,derivative:#8b5cf6,Derivative:#8b5cf6,*:#94a3b8"/>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<tree>
|
<tree>
|
||||||
<field name="lot"/>
|
<field name="lot"/>
|
||||||
<field name="shipment_in" optional="1"/>
|
<field name="shipment_in" optional="1"/>
|
||||||
|
<field name="fee" optional="1"/>
|
||||||
<field name="type"
|
<field name="type"
|
||||||
widget="badge"
|
widget="badge"
|
||||||
badge_colors="priced:#2563eb,Price:#2563eb,pur. priced:#1d4ed8,Pur. price:#1d4ed8,pur. efp:#38bdf8,Pur. efp:#38bdf8,sale priced:#16a34a,Sale price:#16a34a,sale efp:#86efac,Sale efp:#86efac,market:#64748b,Market:#64748b,line fee:#d97706,Line fee:#d97706,pur. fee:#f59e0b,Pur. fee:#f59e0b,sale fee:#fb923c,Sale fee:#fb923c,shipment fee:#0f766e,Shipment fee:#0f766e,derivative:#8b5cf6,Derivative:#8b5cf6,*:#94a3b8"/>
|
badge_colors="priced:#2563eb,Price:#2563eb,pur. priced:#1d4ed8,Pur. price:#1d4ed8,pur. efp:#38bdf8,Pur. efp:#38bdf8,sale priced:#16a34a,Sale price:#16a34a,sale efp:#86efac,Sale efp:#86efac,market:#64748b,Market:#64748b,line fee:#d97706,Line fee:#d97706,pur. fee:#f59e0b,Pur. fee:#f59e0b,sale fee:#fb923c,Sale fee:#fb923c,shipment fee:#0f766e,Shipment fee:#0f766e,derivative:#8b5cf6,Derivative:#8b5cf6,*:#94a3b8"/>
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ this repository contains the full copyright notices and license terms. -->
|
|||||||
<tree>
|
<tree>
|
||||||
<field name="r_lot"/>
|
<field name="r_lot"/>
|
||||||
<field name="r_shipment_in" optional="1"/>
|
<field name="r_shipment_in" optional="1"/>
|
||||||
|
<field name="r_fee" optional="1"/>
|
||||||
<field name="r_type"/>
|
<field name="r_type"/>
|
||||||
<field name="r_reference"/>
|
<field name="r_reference"/>
|
||||||
<field name="r_counterparty"/>
|
<field name="r_counterparty"/>
|
||||||
|
|||||||
Reference in New Issue
Block a user