Global reporting

This commit is contained in:
2026-05-24 17:25:46 +02:00
parent 96653be311
commit 6dfb12c125
6 changed files with 325 additions and 8 deletions

View File

@@ -7,9 +7,10 @@ from . import (
account,
configuration,
purchase,
sale,
global_reporting,
stock,
sale,
global_reporting,
ctrm_reporting,
stock,
derivative,
lot,
pricing,
@@ -56,8 +57,10 @@ def register():
lc.LCMT700,
lc.LCMessage,
lc.CreateLCStart,
global_reporting.GRConfiguration,
configuration.Configuration,
global_reporting.GRConfiguration,
ctrm_reporting.CTRMPhysicalPosition,
ctrm_reporting.CTRMPhysicalPositionContext,
configuration.Configuration,
pricing.ImportPricesStart,
pricing.ImportPricesResult,
module='purchase_trade', type_='model')

View File

@@ -0,0 +1,119 @@
from sql import Literal, Null
from sql.aggregate import Max, Min, Sum
from sql.functions import CurrentTimestamp
from trytond.model import ModelSQL, ModelView, fields
from trytond.pool import Pool
from trytond.transaction import Transaction
class CTRMPhysicalPositionContext(ModelView):
"CTRM Physical Position Context"
__name__ = 'ctrm.reporting.position.physical.context'
as_of = fields.Date("As of")
product = fields.Many2One('product.product', "Product")
supplier = fields.Many2One('party.party', "Supplier")
client = fields.Many2One('party.party', "Client")
currency = fields.Many2One('currency.currency', "Currency")
position_type = fields.Selection([
(None, ""),
('open', 'Open'),
('physic', 'Physic'),
('shipped', 'Shipped'),
('hedge', 'Hedge'),
('priced', 'Priced'),
], "Position Type")
@classmethod
def default_as_of(cls):
Date = Pool().get('ir.date')
return Date.today()
class CTRMPhysicalPosition(ModelSQL, ModelView):
"CTRM Physical Position"
__name__ = 'ctrm.reporting.position.physical'
product = fields.Many2One('product.product', "Product")
supplier = fields.Many2One('party.party', "Supplier")
client = fields.Many2One('party.party', "Client")
currency = fields.Many2One('currency.currency', "Currency")
uom = fields.Many2One('product.uom', "Unit")
position_type = fields.Selection([
('open', 'Open'),
('physic', 'Physic'),
('shipped', 'Shipped'),
('hedge', 'Hedge'),
('priced', 'Priced'),
], "Position Type")
physical_qty = fields.Numeric("Physical Quantity", digits=(16, 5))
hedged_qty = fields.Numeric("Hedged Quantity", digits=(16, 5))
net_exposure = fields.Numeric("Net Exposure", digits=(16, 5))
amount = fields.Numeric("Amount", digits=(16, 2))
mtm = fields.Numeric("MTM", digits=(16, 2))
pnl = fields.Numeric("P&L", digits=(16, 2))
period_start = fields.Date("Period Start")
period_end = fields.Date("Period End")
@classmethod
def table_query(cls):
OpenPosition = Pool().get('open.position')
op = OpenPosition.__table__()
context = Transaction().context
as_of = context.get('as_of')
product = context.get('product')
supplier = context.get('supplier')
client = context.get('client')
currency = context.get('currency')
position_type = context.get('position_type')
where = Literal(True)
if as_of:
where &= ((op.period_start == Null) | (op.period_start <= as_of))
where &= ((op.period_end == Null) | (op.period_end >= as_of))
if product:
where &= op.product == product
if supplier:
where &= op.supplier == supplier
if client:
where &= op.client == client
if currency:
where &= op.currency == currency
if position_type:
where &= op.type == position_type
group_by = [
op.product,
op.supplier,
op.client,
op.currency,
op.uom,
op.type,
op.period_start,
op.period_end,
]
return op.select(
Literal(0).as_('create_uid'),
CurrentTimestamp().as_('create_date'),
Literal(None).as_('write_uid'),
Literal(None).as_('write_date'),
Min(op.id).as_('id'),
op.product.as_('product'),
op.supplier.as_('supplier'),
op.client.as_('client'),
op.currency.as_('currency'),
op.uom.as_('uom'),
op.type.as_('position_type'),
Sum(op.physical_qty).as_('physical_qty'),
Sum(op.hedged_qty).as_('hedged_qty'),
Sum(op.net_exposure).as_('net_exposure'),
Sum(op.amount).as_('amount'),
Sum(op.mtm).as_('mtm'),
Sum(op.amount - op.mtm).as_('pnl'),
Max(op.period_start).as_('period_start'),
Max(op.period_end).as_('period_end'),
where=where,
group_by=group_by)

View File

@@ -0,0 +1,165 @@
<tryton>
<data>
<record model="ir.ui.view" id="ctrm_position_physical_context_view_form">
<field name="model">ctrm.reporting.position.physical.context</field>
<field name="type">form</field>
<field name="name">ctrm_position_physical_context_form</field>
</record>
<record model="ir.ui.view" id="ctrm_position_physical_view_list">
<field name="model">ctrm.reporting.position.physical</field>
<field name="type">tree</field>
<field name="name">ctrm_position_physical_list</field>
</record>
<record model="ir.action.act_window" id="act_ctrm_position_physical">
<field name="name">1.1 Physical Position</field>
<field name="res_model">ctrm.reporting.position.physical</field>
<field name="context_model">ctrm.reporting.position.physical.context</field>
</record>
<record model="ir.action.act_window.view" id="act_ctrm_position_physical_view">
<field name="sequence" eval="10"/>
<field name="view" ref="ctrm_position_physical_view_list"/>
<field name="act_window" ref="act_ctrm_position_physical"/>
</record>
<menuitem
name="1. Positions"
parent="purchase_trade.menu_global_reporting"
sequence="10"
id="menu_ctrm_positions"/>
<menuitem
name="1.1 Physical Position"
parent="menu_ctrm_positions"
sequence="10"
action="act_ctrm_position_physical"
id="menu_ctrm_position_physical"/>
<menuitem
name="1.2 Financial / Paper Position"
parent="menu_ctrm_positions"
sequence="20"
id="menu_ctrm_position_financial"/>
<menuitem
name="1.3 Net Consolidated Position"
parent="menu_ctrm_positions"
sequence="30"
id="menu_ctrm_position_net"/>
<menuitem
name="1.4 Hedge Coverage"
parent="menu_ctrm_positions"
sequence="40"
id="menu_ctrm_position_hedge"/>
<menuitem
name="2. P&amp;L"
parent="purchase_trade.menu_global_reporting"
sequence="20"
id="menu_ctrm_pnl"/>
<menuitem
name="2.1 Realized P&amp;L"
parent="menu_ctrm_pnl"
sequence="10"
id="menu_ctrm_pnl_realized"/>
<menuitem
name="2.2 Mark-to-Market"
parent="menu_ctrm_pnl"
sequence="20"
id="menu_ctrm_pnl_mtm"/>
<menuitem
name="2.3 P&amp;L Explain"
parent="menu_ctrm_pnl"
sequence="30"
id="menu_ctrm_pnl_explain"/>
<menuitem
name="2.4 P&amp;L by Dimension"
parent="menu_ctrm_pnl"
sequence="40"
id="menu_ctrm_pnl_dimension"/>
<menuitem
name="3. Risk"
parent="purchase_trade.menu_global_reporting"
sequence="30"
id="menu_ctrm_risk"/>
<menuitem
name="3.1 VaR"
parent="menu_ctrm_risk"
sequence="10"
id="menu_ctrm_risk_var"/>
<menuitem
name="3.2 Stress Tests"
parent="menu_ctrm_risk"
sequence="20"
id="menu_ctrm_risk_stress"/>
<menuitem
name="3.3 Sensitivities"
parent="menu_ctrm_risk"
sequence="30"
id="menu_ctrm_risk_sensitivities"/>
<menuitem
name="3.4 Limit Monitoring"
parent="menu_ctrm_risk"
sequence="40"
id="menu_ctrm_risk_limits"/>
<menuitem
name="3.5 Credit Exposure"
parent="menu_ctrm_risk"
sequence="50"
id="menu_ctrm_risk_credit"/>
<menuitem
name="4. Operations &amp; Logistics"
parent="purchase_trade.menu_global_reporting"
sequence="40"
id="menu_ctrm_operations"/>
<menuitem
name="4.1 Shipping / Logistics"
parent="menu_ctrm_operations"
sequence="10"
id="menu_ctrm_operations_shipping"/>
<menuitem
name="4.2 Inventory"
parent="menu_ctrm_operations"
sequence="20"
id="menu_ctrm_operations_inventory"/>
<menuitem
name="4.3 Contract Performance"
parent="menu_ctrm_operations"
sequence="30"
id="menu_ctrm_operations_contract"/>
<menuitem
name="4.4 Scheduling"
parent="menu_ctrm_operations"
sequence="40"
id="menu_ctrm_operations_scheduling"/>
<menuitem
name="5. Finance &amp; Accounting"
parent="purchase_trade.menu_global_reporting"
sequence="50"
id="menu_ctrm_finance"/>
<menuitem
name="5.1 Accruals"
parent="menu_ctrm_finance"
sequence="10"
id="menu_ctrm_finance_accruals"/>
<menuitem
name="5.2 Hedge Accounting"
parent="menu_ctrm_finance"
sequence="20"
id="menu_ctrm_finance_hedge_accounting"/>
<menuitem
name="5.3 Settlements &amp; Invoicing"
parent="menu_ctrm_finance"
sequence="30"
id="menu_ctrm_finance_settlements"/>
<menuitem
name="5.4 Cash Flow Forecast"
parent="menu_ctrm_finance"
sequence="40"
id="menu_ctrm_finance_cash_flow"/>
<menuitem
name="5.5 GL Reconciliation"
parent="menu_ctrm_finance"
sequence="50"
id="menu_ctrm_finance_gl_reconciliation"/>
</data>
</tryton>

View File

@@ -30,9 +30,10 @@ xml:
credit_risk.xml
cron.xml
party.xml
forex.xml
global_reporting.xml
derivative.xml
forex.xml
global_reporting.xml
ctrm_reporting.xml
derivative.xml
valuation.xml
weight_report.xml
dimension.xml

View File

@@ -0,0 +1,14 @@
<form>
<label name="as_of"/>
<field name="as_of"/>
<label name="product"/>
<field name="product"/>
<label name="supplier"/>
<field name="supplier"/>
<label name="client"/>
<field name="client"/>
<label name="currency"/>
<field name="currency"/>
<label name="position_type"/>
<field name="position_type"/>
</form>

View File

@@ -0,0 +1,15 @@
<tree>
<field name="product" width="140"/>
<field name="supplier" width="120"/>
<field name="client" width="120"/>
<field name="position_type" width="80"/>
<field name="physical_qty" symbol="uom" sum="1"/>
<field name="hedged_qty" symbol="uom" sum="1"/>
<field name="net_exposure" symbol="uom" sum="1"/>
<field name="currency" width="60"/>
<field name="amount" sum="1"/>
<field name="mtm" sum="1"/>
<field name="pnl" sum="1"/>
<field name="period_start"/>
<field name="period_end"/>
</tree>