Compare commits
29 Commits
7f2e61c059
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
69d10d322b | ||
|
|
77fe2f0589 | ||
|
|
3535567376 | ||
|
|
54f2e1a934 | ||
|
|
6f29d4cf86 | ||
|
|
0d05e3b22d | ||
|
|
093be8ebdb | ||
|
|
b80385ebc0 | ||
|
|
e22fc67a3c | ||
|
|
2a8e059e3b | ||
|
|
f71ad2ac69 | ||
|
|
34b221deae | ||
|
|
089acfa5e3 | ||
|
|
2e373b2ce6 | ||
|
|
2db551c2f4 | ||
|
|
d35d88271d | ||
|
|
9facb61cae | ||
|
|
6441bbb31d | ||
|
|
092fe138c8 | ||
|
|
381197b7bb | ||
|
|
8542bfeabb | ||
|
|
0155e99815 | ||
|
|
d835f2521c | ||
|
|
bdfc7f22e0 | ||
|
|
181de17b89 | ||
|
|
452e9e2632 | ||
|
|
9e33a577e8 | ||
|
|
8cb570126a | ||
|
|
60d53b2d67 |
9
Connections/ITSA_Tradon_Prod.md
Normal file
9
Connections/ITSA_Tradon_Prod.md
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# ITSA_Tradon_Prod
|
||||||
|
|
||||||
|
## PostgreSQL Database
|
||||||
|
|
||||||
|
- Server: `72.61.163.139`
|
||||||
|
- Port: `5433`
|
||||||
|
- User name: `postgres`
|
||||||
|
- Password: `dsproject`
|
||||||
|
- Database name: `tradon`
|
||||||
BIN
ITSA/Data Reconciliation/Contracts and Costs.xlsx
Normal file
BIN
ITSA/Data Reconciliation/Contracts and Costs.xlsx
Normal file
Binary file not shown.
BIN
ITSA/Data Reconciliation/ITSA_Forward_Position_Comparison.xlsx
Normal file
BIN
ITSA/Data Reconciliation/ITSA_Forward_Position_Comparison.xlsx
Normal file
Binary file not shown.
@@ -0,0 +1,267 @@
|
|||||||
|
CREATE OR REPLACE VIEW public.vw_utility_physical_pricing_definition AS
|
||||||
|
SELECT
|
||||||
|
'Purchase'::text AS "strContractType",
|
||||||
|
pc.line AS "intContractLineId",
|
||||||
|
pc.id AS "intPricingComponentId",
|
||||||
|
pc.price_index AS "intPriceCurveId",
|
||||||
|
vpc."strPriceDescription",
|
||||||
|
vpc."strPriceIndex",
|
||||||
|
vpc."strCurrency",
|
||||||
|
vpc."strUnit",
|
||||||
|
vpc."strPriceCurveType",
|
||||||
|
vpc."strPriceArea",
|
||||||
|
vpc."strPriceCalendar",
|
||||||
|
vpc."strPricingType",
|
||||||
|
vpc."dtmPricingStartDate",
|
||||||
|
vpc."dtmPricingEndDate",
|
||||||
|
vpc."strPricingMonth"
|
||||||
|
FROM pricing_component pc
|
||||||
|
LEFT JOIN vw_utility_price_curve vpc
|
||||||
|
ON vpc."intPriceCurveId" = pc.price_index
|
||||||
|
WHERE pc.line IS NOT NULL
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'Sale'::text AS "strContractType",
|
||||||
|
pc.sale_line AS "intContractLineId",
|
||||||
|
pc.id AS "intPricingComponentId",
|
||||||
|
pc.price_index AS "intPriceCurveId",
|
||||||
|
vpc."strPriceDescription",
|
||||||
|
vpc."strPriceIndex",
|
||||||
|
vpc."strCurrency",
|
||||||
|
vpc."strUnit",
|
||||||
|
vpc."strPriceCurveType",
|
||||||
|
vpc."strPriceArea",
|
||||||
|
vpc."strPriceCalendar",
|
||||||
|
vpc."strPricingType",
|
||||||
|
vpc."dtmPricingStartDate",
|
||||||
|
vpc."dtmPricingEndDate",
|
||||||
|
vpc."strPricingMonth"
|
||||||
|
FROM pricing_component pc
|
||||||
|
LEFT JOIN vw_utility_price_curve vpc
|
||||||
|
ON vpc."intPriceCurveId" = pc.price_index
|
||||||
|
WHERE pc.sale_line IS NOT NULL;
|
||||||
|
|
||||||
|
CREATE OR REPLACE VIEW public.vw_bi_itsa_physical_open_costs_v2 AS
|
||||||
|
WITH valuation_info AS (
|
||||||
|
SELECT
|
||||||
|
pvl."intContractId",
|
||||||
|
pvl."intContractLineId",
|
||||||
|
pvl."strState",
|
||||||
|
avg(pvl."dblPrice") AS "avgPrice",
|
||||||
|
avg(pvl."dblMtmPrice")::numeric(18, 2) AS "avgMtmPrice"
|
||||||
|
FROM vw_utility_physical_valuation_line pvl
|
||||||
|
GROUP BY
|
||||||
|
pvl."intContractId",
|
||||||
|
pvl."intContractLineId",
|
||||||
|
pvl."strState"
|
||||||
|
),
|
||||||
|
utility_open_quantity AS (
|
||||||
|
SELECT
|
||||||
|
CASE
|
||||||
|
WHEN uop."strContractSide" = 'purchase'::text THEN 'Purchase'::text
|
||||||
|
WHEN uop."strContractSide" = 'sale'::text THEN 'Sale'::text
|
||||||
|
ELSE NULL::text
|
||||||
|
END AS "TradeType",
|
||||||
|
uop."intContractLineId" AS "TradeLineId",
|
||||||
|
sum(uop."dblOpenQuantity")::numeric(18, 3) AS "OpenQuantitySigned"
|
||||||
|
FROM vw_utility_open_position uop
|
||||||
|
GROUP BY
|
||||||
|
CASE
|
||||||
|
WHEN uop."strContractSide" = 'purchase'::text THEN 'Purchase'::text
|
||||||
|
WHEN uop."strContractSide" = 'sale'::text THEN 'Sale'::text
|
||||||
|
ELSE NULL::text
|
||||||
|
END,
|
||||||
|
uop."intContractLineId"
|
||||||
|
),
|
||||||
|
contract_open_quantity AS (
|
||||||
|
SELECT
|
||||||
|
'Purchase'::text AS "TradeType",
|
||||||
|
pc."intPurchaseLineId" AS "TradeLineId",
|
||||||
|
abs(COALESCE(uop."OpenQuantitySigned", 0::numeric))::numeric(18, 3) AS "OpenQuantity",
|
||||||
|
COALESCE(uop."OpenQuantitySigned", 0::numeric)::numeric(18, 3) AS "OpenQuantitySigned",
|
||||||
|
COALESCE(vi."avgMtmPrice", 0::numeric(18, 2)) AS "AvgMtmPrice",
|
||||||
|
pc."dblTheoriticalQuantity" AS "TheoriticalQuantitySigned"
|
||||||
|
FROM vw_utility_purchase_physical_contract pc
|
||||||
|
LEFT JOIN utility_open_quantity uop
|
||||||
|
ON uop."TradeType" = 'Purchase'::text
|
||||||
|
AND uop."TradeLineId" = pc."intPurchaseLineId"
|
||||||
|
LEFT JOIN valuation_info vi
|
||||||
|
ON pc."intPurchaseLineId" = vi."intContractLineId"
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'Sale'::text AS "TradeType",
|
||||||
|
pc."intSaleLineId" AS "TradeLineId",
|
||||||
|
abs(COALESCE(uop."OpenQuantitySigned", 0::numeric))::numeric(18, 3) AS "OpenQuantity",
|
||||||
|
COALESCE(uop."OpenQuantitySigned", 0::numeric)::numeric(18, 3) AS "OpenQuantitySigned",
|
||||||
|
COALESCE(vi."avgMtmPrice", 0::numeric(18, 2)) AS "AvgMtmPrice",
|
||||||
|
pc."dblTheoreticalQuantity" * '-1'::integer::numeric AS "TheoriticalQuantitySigned"
|
||||||
|
FROM vw_utility_sale_physical_contract pc
|
||||||
|
LEFT JOIN utility_open_quantity uop
|
||||||
|
ON uop."TradeType" = 'Sale'::text
|
||||||
|
AND uop."TradeLineId" = pc."intSaleLineId"
|
||||||
|
LEFT JOIN valuation_info vi
|
||||||
|
ON pc."intSaleLineId" = vi."intContractLineId"
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
1 AS "Group Order",
|
||||||
|
'Price'::text AS "Group Type",
|
||||||
|
ctr."intPurchaseLineId" AS "intTradeLineId",
|
||||||
|
CASE
|
||||||
|
WHEN ctr."strPricingType"::text = 'basis'::text THEN COALESCE(prc."strPriceDescription", 'Basis Price Curve Missing'::character varying)
|
||||||
|
ELSE 'Fixed Price'::character varying
|
||||||
|
END AS "Line Description",
|
||||||
|
pur."dblUnitPrice" AS "Price",
|
||||||
|
opq."OpenQuantitySigned" AS "Open Quantity Signed",
|
||||||
|
opq."OpenQuantitySigned" * pur."dblUnitPrice" * '-1'::integer::numeric AS "Open Cost Amount",
|
||||||
|
1 AS "intPriceGroupId",
|
||||||
|
ctr."dtmEstimatedBLDate" AS "Estimated BL Date",
|
||||||
|
opq."TheoriticalQuantitySigned" AS "Contract Quantity Signed",
|
||||||
|
'Price'::text AS "Line Group"
|
||||||
|
FROM vw_utility_dim_physical_purchase_contract ctr
|
||||||
|
JOIN vw_utility_purchase_physical_contract pur
|
||||||
|
ON ctr."intPurchaseLineId" = pur."intPurchaseLineId"
|
||||||
|
JOIN contract_open_quantity opq
|
||||||
|
ON ctr."intPurchaseLineId" = opq."TradeLineId"
|
||||||
|
AND opq."TradeType" = 'Purchase'::text
|
||||||
|
LEFT JOIN vw_utility_physical_pricing_definition prc
|
||||||
|
ON prc."strContractType" = 'Purchase'::text
|
||||||
|
AND prc."intContractLineId" = ctr."intPurchaseLineId"
|
||||||
|
WHERE
|
||||||
|
ctr."strPricingType"::text IN ('priced'::text, 'basis'::text)
|
||||||
|
AND opq."OpenQuantity" <> 0::numeric
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
2 AS "Group Order",
|
||||||
|
'MTM'::text AS "Group Type",
|
||||||
|
ctr."intPurchaseLineId" AS "intTradeLineId",
|
||||||
|
mtm."strComponentCurve" AS "Line Description",
|
||||||
|
opq."AvgMtmPrice" AS "Price",
|
||||||
|
opq."OpenQuantitySigned" AS "Open Quantity Signed",
|
||||||
|
opq."OpenQuantitySigned" * opq."AvgMtmPrice" AS "Open Cost Amount",
|
||||||
|
3 AS "intPriceGroupId",
|
||||||
|
ctr."dtmEstimatedBLDate" AS "Estimated BL Date",
|
||||||
|
opq."TheoriticalQuantitySigned" AS "Contract Quantity Signed",
|
||||||
|
'MTM'::text AS "Line Group"
|
||||||
|
FROM vw_utility_physical_mtm_definition mtm
|
||||||
|
JOIN vw_utility_dim_physical_purchase_contract ctr
|
||||||
|
ON mtm."intContractLineId" = ctr."intPurchaseLineId"
|
||||||
|
JOIN contract_open_quantity opq
|
||||||
|
ON ctr."intPurchaseLineId" = opq."TradeLineId"
|
||||||
|
AND opq."TradeType" = 'Purchase'::text
|
||||||
|
WHERE
|
||||||
|
mtm."strContractType" = 'Purchase'::text
|
||||||
|
AND opq."OpenQuantity" <> 0::numeric
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
3 AS "Group Order",
|
||||||
|
'Fee'::text AS "Group Type",
|
||||||
|
fees."intContractLineId" AS "intTradeLineId",
|
||||||
|
fees."strProduct" AS "Line Description",
|
||||||
|
fees."dblPrice" AS "Price",
|
||||||
|
opq."OpenQuantitySigned" AS "Open Quantity Signed",
|
||||||
|
CASE
|
||||||
|
WHEN fees."strPayOrRec"::text = 'pay'::text THEN 1
|
||||||
|
ELSE '-1'::integer
|
||||||
|
END::numeric * opq."OpenQuantity" * fees."dblPrice" * '-1'::integer::numeric AS "Open Cost Amount",
|
||||||
|
2 AS "intPriceGroupId",
|
||||||
|
ctr."dtmEstimatedBLDate" AS "Estimated BL Date",
|
||||||
|
opq."TheoriticalQuantitySigned" AS "Contract Quantity Signed",
|
||||||
|
fees."strProductGroup" AS "Line Group"
|
||||||
|
FROM vw_utility_contract_fees fees
|
||||||
|
JOIN vw_utility_dim_physical_purchase_contract ctr
|
||||||
|
ON fees."intContractLineId" = ctr."intPurchaseLineId"
|
||||||
|
JOIN contract_open_quantity opq
|
||||||
|
ON ctr."intPurchaseLineId" = opq."TradeLineId"
|
||||||
|
AND opq."TradeType" = 'Purchase'::text
|
||||||
|
WHERE
|
||||||
|
fees."strContractType" = 'Purchase'::text
|
||||||
|
AND opq."OpenQuantity" <> 0::numeric
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
1 AS "Group Order",
|
||||||
|
'Price'::text AS "Group Type",
|
||||||
|
ctr."intSaleLineId" AS "intTradeLineId",
|
||||||
|
CASE
|
||||||
|
WHEN ctr."strPricingType"::text = 'basis'::text THEN COALESCE(prc."strPriceDescription", 'Basis Price Curve Missing'::character varying)
|
||||||
|
ELSE 'Fixed Price'::character varying
|
||||||
|
END AS "Line Description",
|
||||||
|
sale."dblUnitPrice" AS "Price",
|
||||||
|
opq."OpenQuantitySigned" AS "Open Quantity Signed",
|
||||||
|
opq."OpenQuantitySigned" * sale."dblUnitPrice" * '-1'::integer::numeric AS "Open Cost Amount",
|
||||||
|
1 AS "intPriceGroupId",
|
||||||
|
ctr."dtmEstimatedBLDate" AS "Estimated BL Date",
|
||||||
|
opq."TheoriticalQuantitySigned" AS "Contract Quantity Signed",
|
||||||
|
'Price'::text AS "Line Group"
|
||||||
|
FROM vw_utility_dim_physical_sale_contract ctr
|
||||||
|
JOIN vw_utility_sale_physical_contract sale
|
||||||
|
ON ctr."intSaleLineId" = sale."intSaleLineId"
|
||||||
|
JOIN contract_open_quantity opq
|
||||||
|
ON ctr."intSaleLineId" = opq."TradeLineId"
|
||||||
|
AND opq."TradeType" = 'Sale'::text
|
||||||
|
LEFT JOIN vw_utility_physical_pricing_definition prc
|
||||||
|
ON prc."strContractType" = 'Sale'::text
|
||||||
|
AND prc."intContractLineId" = ctr."intSaleLineId"
|
||||||
|
WHERE
|
||||||
|
ctr."strPricingType"::text IN ('priced'::text, 'basis'::text)
|
||||||
|
AND opq."OpenQuantity" <> 0::numeric
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
2 AS "Group Order",
|
||||||
|
'MTM'::text AS "Group Type",
|
||||||
|
ctr."intSaleLineId" AS "intTradeLineId",
|
||||||
|
mtm."strComponentCurve" AS "Line Description",
|
||||||
|
opq."AvgMtmPrice" AS "Price",
|
||||||
|
opq."OpenQuantitySigned" AS "Open Quantity Signed",
|
||||||
|
opq."OpenQuantitySigned" * opq."AvgMtmPrice" AS "Open Cost Amount",
|
||||||
|
3 AS "intPriceGroupId",
|
||||||
|
ctr."dtmEstimatedBLDate" AS "Estimated BL Date",
|
||||||
|
opq."TheoriticalQuantitySigned" AS "Contract Quantity Signed",
|
||||||
|
'MTM'::text AS "Line Group"
|
||||||
|
FROM vw_utility_physical_mtm_definition mtm
|
||||||
|
JOIN vw_utility_dim_physical_sale_contract ctr
|
||||||
|
ON mtm."intContractLineId" = ctr."intSaleLineId"
|
||||||
|
JOIN contract_open_quantity opq
|
||||||
|
ON ctr."intSaleLineId" = opq."TradeLineId"
|
||||||
|
AND opq."TradeType" = 'Sale'::text
|
||||||
|
WHERE
|
||||||
|
mtm."strContractType" = 'Sale'::text
|
||||||
|
AND opq."OpenQuantity" <> 0::numeric
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
3 AS "Group Order",
|
||||||
|
'Fee'::text AS "Group Type",
|
||||||
|
fees."intContractLineId" AS "intTradeLineId",
|
||||||
|
fees."strProduct" AS "Line Description",
|
||||||
|
fees."dblPrice" AS "Price",
|
||||||
|
opq."OpenQuantitySigned" AS "Open Quantity Signed",
|
||||||
|
CASE
|
||||||
|
WHEN fees."strPayOrRec"::text = 'pay'::text THEN 1
|
||||||
|
ELSE '-1'::integer
|
||||||
|
END::numeric * opq."OpenQuantity" * fees."dblPrice" * '-1'::integer::numeric AS "Open Cost Amount",
|
||||||
|
2 AS "intPriceGroupId",
|
||||||
|
ctr."dtmEstimatedBLDate" AS "Estimated BL Date",
|
||||||
|
opq."TheoriticalQuantitySigned" AS "Contract Quantity Signed",
|
||||||
|
fees."strProductGroup" AS "Line Group"
|
||||||
|
FROM vw_utility_contract_fees fees
|
||||||
|
JOIN vw_utility_dim_physical_sale_contract ctr
|
||||||
|
ON fees."intContractLineId" = ctr."intSaleLineId"
|
||||||
|
JOIN contract_open_quantity opq
|
||||||
|
ON ctr."intSaleLineId" = opq."TradeLineId"
|
||||||
|
AND opq."TradeType" = 'Sale'::text
|
||||||
|
WHERE
|
||||||
|
fees."strContractType" = 'Sale'::text
|
||||||
|
AND opq."OpenQuantity" <> 0::numeric;
|
||||||
154
ITSA/Data Reconciliation/update_vw_utility_open_position.sql
Normal file
154
ITSA/Data Reconciliation/update_vw_utility_open_position.sql
Normal file
@@ -0,0 +1,154 @@
|
|||||||
|
CREATE OR REPLACE VIEW public.vw_utility_open_position AS
|
||||||
|
WITH physical_lot_quantity AS (
|
||||||
|
SELECT
|
||||||
|
'purchase'::text AS side,
|
||||||
|
l.line AS contract_line_id,
|
||||||
|
SUM(COALESCE(qh.quantity, 0::numeric)) AS physical_quantity
|
||||||
|
FROM lot_lot l
|
||||||
|
LEFT JOIN lot_qt_hist qh
|
||||||
|
ON qh.lot = l.id
|
||||||
|
AND qh.quantity_type = l.lot_state
|
||||||
|
WHERE
|
||||||
|
l.lot_type::text = 'physic'::text
|
||||||
|
AND l.line IS NOT NULL
|
||||||
|
GROUP BY
|
||||||
|
l.line
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'sale'::text AS side,
|
||||||
|
l.sale_line AS contract_line_id,
|
||||||
|
SUM(COALESCE(qh.quantity, 0::numeric)) AS physical_quantity
|
||||||
|
FROM lot_lot l
|
||||||
|
LEFT JOIN lot_qt_hist qh
|
||||||
|
ON qh.lot = l.id
|
||||||
|
AND qh.quantity_type = l.lot_state
|
||||||
|
WHERE
|
||||||
|
l.lot_type::text = 'physic'::text
|
||||||
|
AND l.sale_line IS NOT NULL
|
||||||
|
GROUP BY
|
||||||
|
l.sale_line
|
||||||
|
),
|
||||||
|
matched_virtual_quantity AS (
|
||||||
|
SELECT
|
||||||
|
'purchase'::text AS side,
|
||||||
|
lp.line AS contract_line_id,
|
||||||
|
SUM(lqt.lot_quantity) AS matched_quantity
|
||||||
|
FROM lot_qt lqt
|
||||||
|
JOIN lot_lot lp
|
||||||
|
ON lp.id = lqt.lot_p
|
||||||
|
WHERE
|
||||||
|
lp.lot_type::text = 'virtual'::text
|
||||||
|
AND lp.line IS NOT NULL
|
||||||
|
AND lqt.lot_s IS NOT NULL
|
||||||
|
AND lqt.lot_quantity > 0::numeric
|
||||||
|
GROUP BY
|
||||||
|
lp.line
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'sale'::text AS side,
|
||||||
|
ls.sale_line AS contract_line_id,
|
||||||
|
SUM(lqt.lot_quantity) AS matched_quantity
|
||||||
|
FROM lot_qt lqt
|
||||||
|
JOIN lot_lot ls
|
||||||
|
ON ls.id = lqt.lot_s
|
||||||
|
WHERE
|
||||||
|
ls.lot_type::text = 'virtual'::text
|
||||||
|
AND ls.sale_line IS NOT NULL
|
||||||
|
AND lqt.lot_p IS NOT NULL
|
||||||
|
AND lqt.lot_quantity > 0::numeric
|
||||||
|
GROUP BY
|
||||||
|
ls.sale_line
|
||||||
|
),
|
||||||
|
open_virtual_lots AS (
|
||||||
|
SELECT
|
||||||
|
'purchase'::text AS side,
|
||||||
|
lqt.id AS int_lot_qt_id,
|
||||||
|
lp.id AS int_lot_id,
|
||||||
|
pl.id AS int_contract_line_id,
|
||||||
|
pp.party AS int_counterparty_id,
|
||||||
|
pl.product AS int_product_id,
|
||||||
|
uom.name AS uom,
|
||||||
|
lqt.lot_quantity AS open_quantity,
|
||||||
|
pl.from_del AS period_start,
|
||||||
|
pl.to_del AS period_end,
|
||||||
|
COALESCE(plq.physical_quantity, 0::numeric) AS physical_lot_quantity,
|
||||||
|
pl.quantity_theorical - COALESCE(plq.physical_quantity, 0::numeric)
|
||||||
|
- COALESCE(mvq.matched_quantity, 0::numeric)
|
||||||
|
AS open_targeted_quantity
|
||||||
|
FROM lot_qt lqt
|
||||||
|
JOIN lot_lot lp
|
||||||
|
ON lp.id = lqt.lot_p
|
||||||
|
JOIN purchase_line pl
|
||||||
|
ON pl.id = lp.line
|
||||||
|
JOIN purchase_purchase pp
|
||||||
|
ON pp.id = pl.purchase
|
||||||
|
LEFT JOIN product_uom uom
|
||||||
|
ON uom.id = lqt.lot_unit
|
||||||
|
LEFT JOIN physical_lot_quantity plq
|
||||||
|
ON plq.side = 'purchase'::text
|
||||||
|
AND plq.contract_line_id = pl.id
|
||||||
|
LEFT JOIN matched_virtual_quantity mvq
|
||||||
|
ON mvq.side = 'purchase'::text
|
||||||
|
AND mvq.contract_line_id = pl.id
|
||||||
|
WHERE
|
||||||
|
lp.lot_type::text = 'virtual'::text
|
||||||
|
AND lqt.lot_s IS NULL
|
||||||
|
AND COALESCE(pl.finished, false) = false
|
||||||
|
AND lqt.lot_quantity > 0::numeric
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
'sale'::text AS side,
|
||||||
|
lqt.id AS int_lot_qt_id,
|
||||||
|
ls.id AS int_lot_id,
|
||||||
|
sl.id AS int_contract_line_id,
|
||||||
|
ss.party AS int_counterparty_id,
|
||||||
|
sl.product AS int_product_id,
|
||||||
|
uom.name AS uom,
|
||||||
|
-lqt.lot_quantity AS open_quantity,
|
||||||
|
sl.from_del AS period_start,
|
||||||
|
sl.to_del AS period_end,
|
||||||
|
COALESCE(plq.physical_quantity, 0::numeric) AS physical_lot_quantity,
|
||||||
|
sl.quantity_theorical - COALESCE(plq.physical_quantity, 0::numeric)
|
||||||
|
- COALESCE(mvq.matched_quantity, 0::numeric)
|
||||||
|
AS open_targeted_quantity
|
||||||
|
FROM lot_qt lqt
|
||||||
|
JOIN lot_lot ls
|
||||||
|
ON ls.id = lqt.lot_s
|
||||||
|
JOIN sale_line sl
|
||||||
|
ON sl.id = ls.sale_line
|
||||||
|
JOIN sale_sale ss
|
||||||
|
ON ss.id = sl.sale
|
||||||
|
LEFT JOIN product_uom uom
|
||||||
|
ON uom.id = lqt.lot_unit
|
||||||
|
LEFT JOIN physical_lot_quantity plq
|
||||||
|
ON plq.side = 'sale'::text
|
||||||
|
AND plq.contract_line_id = sl.id
|
||||||
|
LEFT JOIN matched_virtual_quantity mvq
|
||||||
|
ON mvq.side = 'sale'::text
|
||||||
|
AND mvq.contract_line_id = sl.id
|
||||||
|
WHERE
|
||||||
|
ls.lot_type::text = 'virtual'::text
|
||||||
|
AND lqt.lot_p IS NULL
|
||||||
|
AND COALESCE(sl.finished, false) = false
|
||||||
|
AND lqt.lot_quantity > 0::numeric
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
side AS "strContractSide",
|
||||||
|
int_lot_qt_id AS "intLotQtId",
|
||||||
|
int_lot_id AS "intLotId",
|
||||||
|
int_contract_line_id AS "intContractLineId",
|
||||||
|
int_counterparty_id AS "intCounterpartyId",
|
||||||
|
int_product_id AS "intProductId",
|
||||||
|
uom AS "strUom",
|
||||||
|
open_quantity AS "dblOpenQuantity",
|
||||||
|
period_start AS "dtmPeriodStart",
|
||||||
|
period_end AS "dtmPeriodEnd",
|
||||||
|
physical_lot_quantity AS "dblPhysicalLotQuantity",
|
||||||
|
open_targeted_quantity AS "dblOpenTargetedQuantity"
|
||||||
|
FROM open_virtual_lots;
|
||||||
@@ -0,0 +1,495 @@
|
|||||||
|
CREATE OR REPLACE VIEW public.vw_utility_shipment_fee_allocation AS
|
||||||
|
WITH physical_shipment_lots AS (
|
||||||
|
SELECT
|
||||||
|
l.lot_shipment_in AS shipment_id,
|
||||||
|
l.id AS lot_id,
|
||||||
|
l.lot_type,
|
||||||
|
l.line AS purchase_line_id,
|
||||||
|
l.sale_line AS sale_line_id,
|
||||||
|
qh.quantity AS shipment_quantity,
|
||||||
|
l.lot_unit_line AS shipment_unit_id
|
||||||
|
FROM lot_lot l
|
||||||
|
LEFT JOIN lot_qt_hist qh
|
||||||
|
ON qh.lot = l.id
|
||||||
|
AND qh.quantity_type = l.lot_state
|
||||||
|
WHERE
|
||||||
|
l.lot_type::text = 'physic'::text
|
||||||
|
AND l.lot_shipment_in IS NOT NULL
|
||||||
|
),
|
||||||
|
virtual_shipment_lots AS (
|
||||||
|
SELECT
|
||||||
|
q.lot_shipment_in AS shipment_id,
|
||||||
|
vp.id AS lot_id,
|
||||||
|
vp.lot_type,
|
||||||
|
vp.line AS purchase_line_id,
|
||||||
|
COALESCE(vp.sale_line, ps.sale_line) AS sale_line_id,
|
||||||
|
q.lot_quantity AS shipment_quantity,
|
||||||
|
q.lot_unit AS shipment_unit_id
|
||||||
|
FROM lot_qt q
|
||||||
|
JOIN lot_lot vp
|
||||||
|
ON vp.id = q.lot_p
|
||||||
|
AND vp.lot_type::text = 'virtual'::text
|
||||||
|
LEFT JOIN lot_lot ps
|
||||||
|
ON ps.id = q.lot_s
|
||||||
|
WHERE
|
||||||
|
q.lot_shipment_in IS NOT NULL
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM physical_shipment_lots pl
|
||||||
|
WHERE
|
||||||
|
pl.shipment_id = q.lot_shipment_in
|
||||||
|
AND pl.purchase_line_id = vp.line
|
||||||
|
AND (
|
||||||
|
pl.sale_line_id = COALESCE(vp.sale_line, ps.sale_line)
|
||||||
|
OR COALESCE(vp.sale_line, ps.sale_line) IS NULL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
shipment_lots AS (
|
||||||
|
SELECT
|
||||||
|
physical_shipment_lots.shipment_id,
|
||||||
|
physical_shipment_lots.lot_id,
|
||||||
|
physical_shipment_lots.lot_type,
|
||||||
|
physical_shipment_lots.purchase_line_id,
|
||||||
|
physical_shipment_lots.sale_line_id,
|
||||||
|
physical_shipment_lots.shipment_quantity,
|
||||||
|
physical_shipment_lots.shipment_unit_id
|
||||||
|
FROM physical_shipment_lots
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
virtual_shipment_lots.shipment_id,
|
||||||
|
virtual_shipment_lots.lot_id,
|
||||||
|
virtual_shipment_lots.lot_type,
|
||||||
|
virtual_shipment_lots.purchase_line_id,
|
||||||
|
virtual_shipment_lots.sale_line_id,
|
||||||
|
virtual_shipment_lots.shipment_quantity,
|
||||||
|
virtual_shipment_lots.shipment_unit_id
|
||||||
|
FROM virtual_shipment_lots
|
||||||
|
),
|
||||||
|
shipment_context AS (
|
||||||
|
SELECT
|
||||||
|
shipment_lots.shipment_id,
|
||||||
|
shipment_lots.lot_id,
|
||||||
|
shipment_lots.purchase_line_id,
|
||||||
|
shipment_lots.sale_line_id,
|
||||||
|
shipment_lots.shipment_unit_id,
|
||||||
|
sum(COALESCE(shipment_lots.shipment_quantity, 0::numeric)) AS shipment_quantity
|
||||||
|
FROM shipment_lots
|
||||||
|
WHERE shipment_lots.shipment_id IS NOT NULL
|
||||||
|
GROUP BY
|
||||||
|
shipment_lots.shipment_id,
|
||||||
|
shipment_lots.lot_id,
|
||||||
|
shipment_lots.purchase_line_id,
|
||||||
|
shipment_lots.sale_line_id,
|
||||||
|
shipment_lots.shipment_unit_id
|
||||||
|
),
|
||||||
|
shipment_base AS (
|
||||||
|
SELECT
|
||||||
|
shipment_context.shipment_id,
|
||||||
|
sum(shipment_context.shipment_quantity) AS shipment_quantity
|
||||||
|
FROM shipment_context
|
||||||
|
GROUP BY shipment_context.shipment_id
|
||||||
|
),
|
||||||
|
shipment_fee_candidates AS (
|
||||||
|
SELECT
|
||||||
|
f.id AS fee_id,
|
||||||
|
'Shipment'::text AS fee_source,
|
||||||
|
f.type AS fee_type,
|
||||||
|
CASE
|
||||||
|
WHEN f.type::text = 'ordered'::text THEN 1
|
||||||
|
WHEN f.type::text = 'scheduled'::text THEN 2
|
||||||
|
ELSE NULL::integer
|
||||||
|
END AS priority,
|
||||||
|
sb.shipment_id,
|
||||||
|
f.product AS product_id,
|
||||||
|
f.supplier AS supplier_id,
|
||||||
|
f.mode AS packaging,
|
||||||
|
f.p_r AS pay_or_rec,
|
||||||
|
f.state,
|
||||||
|
f.weight_type,
|
||||||
|
COALESCE(f.quantity, 0::numeric) AS requested_quantity,
|
||||||
|
sb.shipment_quantity,
|
||||||
|
f.price AS fee_price,
|
||||||
|
f.currency AS currency_id,
|
||||||
|
f.unit AS unit_id,
|
||||||
|
CASE
|
||||||
|
WHEN upper(f.p_r::text) = 'REC'::text THEN 1
|
||||||
|
ELSE '-1'::integer
|
||||||
|
END AS sign_multiplier,
|
||||||
|
NULL::text AS forced_cost_group
|
||||||
|
FROM shipment_base sb
|
||||||
|
JOIN fee_fee f
|
||||||
|
ON f.shipment_in = sb.shipment_id
|
||||||
|
WHERE f.type::text = ANY (ARRAY['ordered'::character varying::text, 'scheduled'::character varying::text])
|
||||||
|
),
|
||||||
|
shipment_fee_limits AS (
|
||||||
|
SELECT
|
||||||
|
c.*,
|
||||||
|
LEAST(
|
||||||
|
GREATEST(c.requested_quantity, 0::numeric),
|
||||||
|
GREATEST(
|
||||||
|
c.shipment_quantity
|
||||||
|
- COALESCE(
|
||||||
|
sum(c.requested_quantity) OVER (
|
||||||
|
PARTITION BY c.shipment_id, c.product_id, c.supplier_id
|
||||||
|
ORDER BY c.priority, c.fee_id
|
||||||
|
ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
|
||||||
|
),
|
||||||
|
0::numeric
|
||||||
|
),
|
||||||
|
0::numeric
|
||||||
|
)
|
||||||
|
) AS fee_allocatable_quantity
|
||||||
|
FROM shipment_fee_candidates c
|
||||||
|
),
|
||||||
|
shipment_fee_allocated AS (
|
||||||
|
SELECT
|
||||||
|
fl.fee_id,
|
||||||
|
fl.fee_source,
|
||||||
|
fl.fee_type,
|
||||||
|
fl.priority,
|
||||||
|
fl.shipment_id,
|
||||||
|
sc.lot_id,
|
||||||
|
sc.purchase_line_id,
|
||||||
|
sc.sale_line_id,
|
||||||
|
fl.product_id,
|
||||||
|
fl.supplier_id,
|
||||||
|
fl.packaging,
|
||||||
|
fl.pay_or_rec,
|
||||||
|
fl.state,
|
||||||
|
fl.weight_type,
|
||||||
|
fl.requested_quantity,
|
||||||
|
fl.shipment_quantity,
|
||||||
|
fl.fee_price,
|
||||||
|
fl.currency_id,
|
||||||
|
COALESCE(fl.unit_id, sc.shipment_unit_id) AS unit_id,
|
||||||
|
fl.sign_multiplier,
|
||||||
|
fl.forced_cost_group,
|
||||||
|
LEAST(
|
||||||
|
sc.shipment_quantity,
|
||||||
|
GREATEST(
|
||||||
|
fl.fee_allocatable_quantity
|
||||||
|
- COALESCE(
|
||||||
|
sum(sc.shipment_quantity) OVER (
|
||||||
|
PARTITION BY fl.fee_id
|
||||||
|
ORDER BY sc.lot_id, sc.purchase_line_id, sc.sale_line_id
|
||||||
|
ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
|
||||||
|
),
|
||||||
|
0::numeric
|
||||||
|
),
|
||||||
|
0::numeric
|
||||||
|
)
|
||||||
|
) AS allocated_quantity
|
||||||
|
FROM shipment_fee_limits fl
|
||||||
|
JOIN shipment_context sc
|
||||||
|
ON sc.shipment_id = fl.shipment_id
|
||||||
|
),
|
||||||
|
shipment_fee_coverage AS (
|
||||||
|
SELECT
|
||||||
|
shipment_fee_allocated.shipment_id,
|
||||||
|
shipment_fee_allocated.product_id,
|
||||||
|
shipment_fee_allocated.supplier_id,
|
||||||
|
max(shipment_fee_allocated.shipment_quantity) AS shipment_quantity,
|
||||||
|
sum(shipment_fee_allocated.allocated_quantity) AS allocated_quantity
|
||||||
|
FROM shipment_fee_allocated
|
||||||
|
GROUP BY
|
||||||
|
shipment_fee_allocated.shipment_id,
|
||||||
|
shipment_fee_allocated.product_id,
|
||||||
|
shipment_fee_allocated.supplier_id
|
||||||
|
),
|
||||||
|
contract_budgeted_fee_candidates AS (
|
||||||
|
SELECT
|
||||||
|
f.id AS fee_id,
|
||||||
|
'Purchase Contract'::text AS fee_source,
|
||||||
|
f.type AS fee_type,
|
||||||
|
3 AS priority,
|
||||||
|
sc.shipment_id,
|
||||||
|
sc.lot_id,
|
||||||
|
sc.purchase_line_id,
|
||||||
|
sc.sale_line_id,
|
||||||
|
f.product AS product_id,
|
||||||
|
f.supplier AS supplier_id,
|
||||||
|
f.mode AS packaging,
|
||||||
|
f.p_r AS pay_or_rec,
|
||||||
|
f.state,
|
||||||
|
f.weight_type,
|
||||||
|
sc.shipment_quantity,
|
||||||
|
f.price AS fee_price,
|
||||||
|
f.currency AS currency_id,
|
||||||
|
COALESCE(f.unit, sc.shipment_unit_id) AS unit_id,
|
||||||
|
CASE
|
||||||
|
WHEN upper(f.p_r::text) = 'REC'::text THEN '-1'::integer
|
||||||
|
ELSE 1
|
||||||
|
END AS sign_multiplier,
|
||||||
|
NULL::text AS forced_cost_group
|
||||||
|
FROM shipment_context sc
|
||||||
|
JOIN fee_fee f
|
||||||
|
ON f.line = sc.purchase_line_id
|
||||||
|
WHERE
|
||||||
|
f.type::text = 'budgeted'::text
|
||||||
|
AND sc.purchase_line_id IS NOT NULL
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
f.id AS fee_id,
|
||||||
|
'Sale Contract'::text AS fee_source,
|
||||||
|
f.type AS fee_type,
|
||||||
|
3 AS priority,
|
||||||
|
sc.shipment_id,
|
||||||
|
sc.lot_id,
|
||||||
|
sc.purchase_line_id,
|
||||||
|
sc.sale_line_id,
|
||||||
|
f.product AS product_id,
|
||||||
|
f.supplier AS supplier_id,
|
||||||
|
f.mode AS packaging,
|
||||||
|
f.p_r AS pay_or_rec,
|
||||||
|
f.state,
|
||||||
|
f.weight_type,
|
||||||
|
sc.shipment_quantity,
|
||||||
|
f.price AS fee_price,
|
||||||
|
f.currency AS currency_id,
|
||||||
|
COALESCE(f.unit, sc.shipment_unit_id) AS unit_id,
|
||||||
|
CASE
|
||||||
|
WHEN upper(f.p_r::text) = 'REC'::text THEN 1
|
||||||
|
ELSE '-1'::integer
|
||||||
|
END AS sign_multiplier,
|
||||||
|
NULL::text AS forced_cost_group
|
||||||
|
FROM shipment_context sc
|
||||||
|
JOIN fee_fee f
|
||||||
|
ON f.sale_line = sc.sale_line_id
|
||||||
|
WHERE
|
||||||
|
f.type::text = 'budgeted'::text
|
||||||
|
AND sc.sale_line_id IS NOT NULL
|
||||||
|
),
|
||||||
|
contract_budgeted_allocated AS (
|
||||||
|
SELECT
|
||||||
|
c.fee_id,
|
||||||
|
c.fee_source,
|
||||||
|
c.fee_type,
|
||||||
|
c.priority,
|
||||||
|
c.shipment_id,
|
||||||
|
c.lot_id,
|
||||||
|
c.purchase_line_id,
|
||||||
|
c.sale_line_id,
|
||||||
|
c.product_id,
|
||||||
|
c.supplier_id,
|
||||||
|
c.packaging,
|
||||||
|
c.pay_or_rec,
|
||||||
|
c.state,
|
||||||
|
c.weight_type,
|
||||||
|
c.shipment_quantity,
|
||||||
|
c.fee_price,
|
||||||
|
c.currency_id,
|
||||||
|
c.unit_id,
|
||||||
|
c.sign_multiplier,
|
||||||
|
c.forced_cost_group,
|
||||||
|
LEAST(
|
||||||
|
c.shipment_quantity,
|
||||||
|
GREATEST(
|
||||||
|
sum(c.shipment_quantity) OVER (
|
||||||
|
PARTITION BY c.shipment_id, c.product_id, c.supplier_id, c.fee_id
|
||||||
|
)
|
||||||
|
- COALESCE(fc.allocated_quantity, 0::numeric)
|
||||||
|
- COALESCE(
|
||||||
|
sum(c.shipment_quantity) OVER (
|
||||||
|
PARTITION BY c.shipment_id, c.product_id, c.supplier_id, c.fee_id
|
||||||
|
ORDER BY c.lot_id
|
||||||
|
ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
|
||||||
|
),
|
||||||
|
0::numeric
|
||||||
|
),
|
||||||
|
0::numeric
|
||||||
|
)
|
||||||
|
) AS allocated_quantity
|
||||||
|
FROM contract_budgeted_fee_candidates c
|
||||||
|
LEFT JOIN shipment_fee_coverage fc
|
||||||
|
ON fc.shipment_id = c.shipment_id
|
||||||
|
AND fc.product_id = c.product_id
|
||||||
|
AND fc.supplier_id = c.supplier_id
|
||||||
|
),
|
||||||
|
price_rows AS (
|
||||||
|
SELECT
|
||||||
|
NULL::integer AS fee_id,
|
||||||
|
'Purchase Price'::text AS fee_source,
|
||||||
|
'price'::text AS fee_type,
|
||||||
|
4 AS priority,
|
||||||
|
sc.shipment_id,
|
||||||
|
sc.lot_id,
|
||||||
|
sc.purchase_line_id,
|
||||||
|
sc.sale_line_id,
|
||||||
|
pl.product AS product_id,
|
||||||
|
NULL::integer AS supplier_id,
|
||||||
|
NULL::character varying AS packaging,
|
||||||
|
NULL::character varying AS pay_or_rec,
|
||||||
|
NULL::character varying AS state,
|
||||||
|
NULL::character varying AS weight_type,
|
||||||
|
sc.shipment_quantity AS allocated_quantity,
|
||||||
|
pl.unit_price AS fee_price,
|
||||||
|
pl.currency_ AS currency_id,
|
||||||
|
COALESCE(pl.unit, sc.shipment_unit_id) AS unit_id,
|
||||||
|
1 AS sign_multiplier,
|
||||||
|
'PurchasePrice'::text AS forced_cost_group
|
||||||
|
FROM shipment_context sc
|
||||||
|
JOIN purchase_line pl
|
||||||
|
ON pl.id = sc.purchase_line_id
|
||||||
|
WHERE sc.purchase_line_id IS NOT NULL
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
NULL::integer AS fee_id,
|
||||||
|
'Sale Price'::text AS fee_source,
|
||||||
|
'price'::text AS fee_type,
|
||||||
|
5 AS priority,
|
||||||
|
sc.shipment_id,
|
||||||
|
sc.lot_id,
|
||||||
|
sc.purchase_line_id,
|
||||||
|
sc.sale_line_id,
|
||||||
|
sl.product AS product_id,
|
||||||
|
NULL::integer AS supplier_id,
|
||||||
|
NULL::character varying AS packaging,
|
||||||
|
NULL::character varying AS pay_or_rec,
|
||||||
|
NULL::character varying AS state,
|
||||||
|
NULL::character varying AS weight_type,
|
||||||
|
sc.shipment_quantity AS allocated_quantity,
|
||||||
|
sl.unit_price AS fee_price,
|
||||||
|
ss.currency AS currency_id,
|
||||||
|
COALESCE(sl.unit, sc.shipment_unit_id) AS unit_id,
|
||||||
|
'-1'::integer AS sign_multiplier,
|
||||||
|
'SalePrice'::text AS forced_cost_group
|
||||||
|
FROM shipment_context sc
|
||||||
|
JOIN sale_line sl
|
||||||
|
ON sl.id = sc.sale_line_id
|
||||||
|
JOIN sale_sale ss
|
||||||
|
ON ss.id = sl.sale
|
||||||
|
WHERE sc.sale_line_id IS NOT NULL
|
||||||
|
),
|
||||||
|
final_fees AS (
|
||||||
|
SELECT
|
||||||
|
shipment_fee_allocated.fee_id,
|
||||||
|
shipment_fee_allocated.fee_source,
|
||||||
|
shipment_fee_allocated.fee_type,
|
||||||
|
shipment_fee_allocated.priority,
|
||||||
|
shipment_fee_allocated.shipment_id,
|
||||||
|
shipment_fee_allocated.lot_id,
|
||||||
|
shipment_fee_allocated.purchase_line_id,
|
||||||
|
shipment_fee_allocated.sale_line_id,
|
||||||
|
shipment_fee_allocated.product_id,
|
||||||
|
shipment_fee_allocated.supplier_id,
|
||||||
|
shipment_fee_allocated.packaging,
|
||||||
|
shipment_fee_allocated.pay_or_rec,
|
||||||
|
shipment_fee_allocated.state,
|
||||||
|
shipment_fee_allocated.weight_type,
|
||||||
|
shipment_fee_allocated.allocated_quantity AS fee_quantity,
|
||||||
|
shipment_fee_allocated.fee_price,
|
||||||
|
shipment_fee_allocated.currency_id,
|
||||||
|
shipment_fee_allocated.unit_id,
|
||||||
|
shipment_fee_allocated.sign_multiplier,
|
||||||
|
shipment_fee_allocated.forced_cost_group
|
||||||
|
FROM shipment_fee_allocated
|
||||||
|
WHERE shipment_fee_allocated.allocated_quantity > 0::numeric
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
contract_budgeted_allocated.fee_id,
|
||||||
|
contract_budgeted_allocated.fee_source,
|
||||||
|
contract_budgeted_allocated.fee_type,
|
||||||
|
contract_budgeted_allocated.priority,
|
||||||
|
contract_budgeted_allocated.shipment_id,
|
||||||
|
contract_budgeted_allocated.lot_id,
|
||||||
|
contract_budgeted_allocated.purchase_line_id,
|
||||||
|
contract_budgeted_allocated.sale_line_id,
|
||||||
|
contract_budgeted_allocated.product_id,
|
||||||
|
contract_budgeted_allocated.supplier_id,
|
||||||
|
contract_budgeted_allocated.packaging,
|
||||||
|
contract_budgeted_allocated.pay_or_rec,
|
||||||
|
contract_budgeted_allocated.state,
|
||||||
|
contract_budgeted_allocated.weight_type,
|
||||||
|
contract_budgeted_allocated.allocated_quantity AS fee_quantity,
|
||||||
|
contract_budgeted_allocated.fee_price,
|
||||||
|
contract_budgeted_allocated.currency_id,
|
||||||
|
contract_budgeted_allocated.unit_id,
|
||||||
|
contract_budgeted_allocated.sign_multiplier,
|
||||||
|
contract_budgeted_allocated.forced_cost_group
|
||||||
|
FROM contract_budgeted_allocated
|
||||||
|
WHERE contract_budgeted_allocated.allocated_quantity > 0::numeric
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
price_rows.fee_id,
|
||||||
|
price_rows.fee_source,
|
||||||
|
price_rows.fee_type,
|
||||||
|
price_rows.priority,
|
||||||
|
price_rows.shipment_id,
|
||||||
|
price_rows.lot_id,
|
||||||
|
price_rows.purchase_line_id,
|
||||||
|
price_rows.sale_line_id,
|
||||||
|
price_rows.product_id,
|
||||||
|
price_rows.supplier_id,
|
||||||
|
price_rows.packaging,
|
||||||
|
price_rows.pay_or_rec,
|
||||||
|
price_rows.state,
|
||||||
|
price_rows.weight_type,
|
||||||
|
price_rows.allocated_quantity AS fee_quantity,
|
||||||
|
price_rows.fee_price,
|
||||||
|
price_rows.currency_id,
|
||||||
|
price_rows.unit_id,
|
||||||
|
price_rows.sign_multiplier,
|
||||||
|
price_rows.forced_cost_group
|
||||||
|
FROM price_rows
|
||||||
|
WHERE price_rows.allocated_quantity > 0::numeric
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
f.shipment_id AS "intShipmentId",
|
||||||
|
f.lot_id AS "intLotId",
|
||||||
|
COALESCE(f.fee_id, 0) AS "intFeeId",
|
||||||
|
f.fee_source AS "strFeeSource",
|
||||||
|
f.fee_type AS "strFeeType",
|
||||||
|
f.priority AS "intPriority",
|
||||||
|
COALESCE(f.purchase_line_id, 0) AS "intPurchaseLineId",
|
||||||
|
COALESCE(f.sale_line_id, 0) AS "intSaleLineId",
|
||||||
|
COALESCE(f.product_id, 0) AS "intProductId",
|
||||||
|
COALESCE(p.code, ''::character varying) AS "strFee",
|
||||||
|
COALESCE(f.supplier_id, 0) AS "intSupplierId",
|
||||||
|
COALESCE(sup.name, ''::character varying) AS "strSupplier",
|
||||||
|
COALESCE(f.packaging, ''::character varying) AS "strPackaging",
|
||||||
|
COALESCE(f.pay_or_rec, ''::character varying) AS "strPayOrRec",
|
||||||
|
COALESCE(f.state, ''::character varying) AS "strState",
|
||||||
|
CASE
|
||||||
|
WHEN upper(f.weight_type::text) = 'BRUT'::text THEN 'Gross'::text
|
||||||
|
ELSE 'Net'::text
|
||||||
|
END AS "strWeighingType",
|
||||||
|
f.fee_quantity AS "dblQuantity",
|
||||||
|
f.fee_price AS "dblPrice",
|
||||||
|
COALESCE(cur.name, ''::character varying) AS "strCurrency",
|
||||||
|
COALESCE(uom.name, 'Mt'::character varying) AS "strUnit",
|
||||||
|
f.fee_quantity * f.fee_price AS "dblAmount",
|
||||||
|
COALESCE(
|
||||||
|
f.forced_cost_group,
|
||||||
|
CASE
|
||||||
|
WHEN upper(p.code::text) ~~ '%FREIGHT%'::text THEN 'Freight'::text
|
||||||
|
WHEN upper(p.code::text) ~~ '%PROFIT SHARING%'::text THEN 'Profit Sharing'::text
|
||||||
|
ELSE 'Other Costs'::text
|
||||||
|
END
|
||||||
|
) AS "strCostGroup",
|
||||||
|
CASE
|
||||||
|
WHEN f.pay_or_rec::text = 'pay'::text THEN - 1::numeric
|
||||||
|
WHEN f.pay_or_rec::text = 'rec'::text THEN 1::numeric
|
||||||
|
WHEN f.fee_source = 'Purchase Price'::text AND f.fee_type::text = 'price'::text THEN - 1::numeric
|
||||||
|
WHEN f.fee_source = 'Sale Price'::text AND f.fee_type::text = 'price'::text THEN 1::numeric
|
||||||
|
ELSE - 1::numeric
|
||||||
|
END AS "intSignMultiplier"
|
||||||
|
FROM final_fees f
|
||||||
|
JOIN product_product p
|
||||||
|
ON p.id = f.product_id
|
||||||
|
LEFT JOIN party_party sup
|
||||||
|
ON sup.id = f.supplier_id
|
||||||
|
LEFT JOIN currency_currency cur
|
||||||
|
ON cur.id = f.currency_id
|
||||||
|
LEFT JOIN product_uom uom
|
||||||
|
ON uom.id = f.unit_id;
|
||||||
@@ -0,0 +1,382 @@
|
|||||||
|
CREATE OR REPLACE VIEW public.vw_utility_trade_pnl_quantities AS
|
||||||
|
WITH lot_current_qty AS (
|
||||||
|
SELECT
|
||||||
|
l.id AS lot_id,
|
||||||
|
round(
|
||||||
|
COALESCE(lh.quantity, 0::numeric)
|
||||||
|
* COALESCE(lot_uom.factor, 1::double precision)::numeric
|
||||||
|
/ NULLIF(COALESCE(line_uom.factor, 1::double precision)::numeric, 0::numeric),
|
||||||
|
5
|
||||||
|
) AS pnl_quantity,
|
||||||
|
lot_uom.name AS quantity_uom
|
||||||
|
FROM lot_lot l
|
||||||
|
LEFT JOIN lot_qt_hist lh ON lh.lot = l.id AND lh.quantity_type = l.lot_state
|
||||||
|
LEFT JOIN product_uom lot_uom ON lot_uom.id = l.lot_unit_line
|
||||||
|
LEFT JOIN purchase_line pl ON pl.id = l.line
|
||||||
|
LEFT JOIN sale_line sl ON sl.id = l.sale_line
|
||||||
|
LEFT JOIN product_uom line_uom ON line_uom.id = COALESCE(pl.unit, sl.unit)
|
||||||
|
), purchase_pnl_lots AS (
|
||||||
|
SELECT
|
||||||
|
'purchase'::text AS pnl_side,
|
||||||
|
p.id AS purchase_id,
|
||||||
|
p.number AS purchase_number,
|
||||||
|
p.reference AS purchase_reference,
|
||||||
|
pl.id AS purchase_line_id,
|
||||||
|
pl.finished AS purchase_line_finished,
|
||||||
|
s.id AS sale_id,
|
||||||
|
s.number AS sale_number,
|
||||||
|
s.reference AS sale_reference,
|
||||||
|
sl.id AS sale_line_id,
|
||||||
|
sl.finished AS sale_line_finished,
|
||||||
|
l.id AS valued_lot_id,
|
||||||
|
l.lot_type AS valued_lot_type,
|
||||||
|
NULL::integer AS lot_qt_id,
|
||||||
|
lcq.pnl_quantity,
|
||||||
|
lcq.quantity_uom AS quantity_unit,
|
||||||
|
pl.product AS product_id,
|
||||||
|
COALESCE(shi.from_location, sint.from_location, sho.from_location, p.from_location) AS from_location_id,
|
||||||
|
COALESCE(shi.to_location, sint.to_location, sho.to_location, p.to_location) AS to_location_id,
|
||||||
|
shi.id AS shipment_id,
|
||||||
|
shi.bl_date,
|
||||||
|
pl.from_del AS delivery_date_from,
|
||||||
|
pl.to_del AS delivery_date_to
|
||||||
|
FROM purchase_line pl
|
||||||
|
JOIN purchase_purchase p ON p.id = pl.purchase
|
||||||
|
JOIN lot_lot l ON l.line = pl.id
|
||||||
|
JOIN lot_current_qty lcq ON lcq.lot_id = l.id
|
||||||
|
LEFT JOIN sale_line sl ON sl.id = l.sale_line
|
||||||
|
LEFT JOIN sale_sale s ON s.id = sl.sale
|
||||||
|
LEFT JOIN stock_shipment_in shi ON shi.id = l.lot_shipment_in
|
||||||
|
LEFT JOIN stock_shipment_internal sint ON sint.id = l.lot_shipment_internal
|
||||||
|
LEFT JOIN stock_shipment_out sho ON sho.id = l.lot_shipment_out
|
||||||
|
WHERE pl.type::text = 'line'::text
|
||||||
|
AND (l.lot_type::text = ANY (ARRAY['virtual'::character varying::text, 'physic'::character varying::text]))
|
||||||
|
), sale_pnl_direct_lots AS (
|
||||||
|
SELECT
|
||||||
|
'sale'::text AS pnl_side,
|
||||||
|
p.id AS purchase_id,
|
||||||
|
p.number AS purchase_number,
|
||||||
|
p.reference AS purchase_reference,
|
||||||
|
pl.id AS purchase_line_id,
|
||||||
|
pl.finished AS purchase_line_finished,
|
||||||
|
s.id AS sale_id,
|
||||||
|
s.number AS sale_number,
|
||||||
|
s.reference AS sale_reference,
|
||||||
|
sl.id AS sale_line_id,
|
||||||
|
sl.finished AS sale_line_finished,
|
||||||
|
l.id AS valued_lot_id,
|
||||||
|
l.lot_type AS valued_lot_type,
|
||||||
|
NULL::integer AS lot_qt_id,
|
||||||
|
lcq.pnl_quantity,
|
||||||
|
lcq.quantity_uom AS quantity_unit,
|
||||||
|
sl.product AS product_id,
|
||||||
|
COALESCE(shi.from_location, sint.from_location, sho.from_location, s.from_location) AS from_location_id,
|
||||||
|
COALESCE(shi.to_location, sint.to_location, sho.to_location, s.to_location) AS to_location_id,
|
||||||
|
shi.id AS shipment_id,
|
||||||
|
shi.bl_date,
|
||||||
|
sl.from_del AS delivery_date_from,
|
||||||
|
sl.to_del AS delivery_date_to
|
||||||
|
FROM purchase_line pl
|
||||||
|
JOIN purchase_purchase p ON p.id = pl.purchase
|
||||||
|
JOIN lot_lot l ON l.line = pl.id AND l.sale_line IS NOT NULL
|
||||||
|
JOIN sale_line sl ON sl.id = l.sale_line
|
||||||
|
JOIN sale_sale s ON s.id = sl.sale
|
||||||
|
JOIN lot_current_qty lcq ON lcq.lot_id = l.id
|
||||||
|
LEFT JOIN stock_shipment_in shi ON shi.id = l.lot_shipment_in
|
||||||
|
LEFT JOIN stock_shipment_internal sint ON sint.id = l.lot_shipment_internal
|
||||||
|
LEFT JOIN stock_shipment_out sho ON sho.id = l.lot_shipment_out
|
||||||
|
WHERE pl.type::text = 'line'::text
|
||||||
|
AND l.lot_type::text = 'physic'::text
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM purchase_pnl_lots ppl
|
||||||
|
WHERE ppl.valued_lot_id = l.id
|
||||||
|
AND ppl.sale_line_id = sl.id
|
||||||
|
)
|
||||||
|
), sale_pnl_matched_virtual_lots AS (
|
||||||
|
SELECT
|
||||||
|
'sale'::text AS pnl_side,
|
||||||
|
p.id AS purchase_id,
|
||||||
|
p.number AS purchase_number,
|
||||||
|
p.reference AS purchase_reference,
|
||||||
|
pl.id AS purchase_line_id,
|
||||||
|
pl.finished AS purchase_line_finished,
|
||||||
|
s.id AS sale_id,
|
||||||
|
s.number AS sale_number,
|
||||||
|
s.reference AS sale_reference,
|
||||||
|
sl.id AS sale_line_id,
|
||||||
|
sl.finished AS sale_line_finished,
|
||||||
|
sale_lot.id AS valued_lot_id,
|
||||||
|
sale_lot.lot_type AS valued_lot_type,
|
||||||
|
lqt.id AS lot_qt_id,
|
||||||
|
lcq.pnl_quantity,
|
||||||
|
lcq.quantity_uom AS quantity_unit,
|
||||||
|
sl.product AS product_id,
|
||||||
|
COALESCE(shi.from_location, sint.from_location, sho.from_location, s.from_location) AS from_location_id,
|
||||||
|
COALESCE(shi.to_location, sint.to_location, sho.to_location, s.to_location) AS to_location_id,
|
||||||
|
shi.id AS shipment_id,
|
||||||
|
shi.bl_date,
|
||||||
|
sl.from_del AS delivery_date_from,
|
||||||
|
sl.to_del AS delivery_date_to
|
||||||
|
FROM purchase_line pl
|
||||||
|
JOIN purchase_purchase p ON p.id = pl.purchase
|
||||||
|
JOIN lot_lot purchase_lot ON purchase_lot.line = pl.id
|
||||||
|
AND purchase_lot.lot_type::text = 'virtual'::text
|
||||||
|
AND purchase_lot.sale_line IS NULL
|
||||||
|
JOIN lot_qt lqt ON lqt.lot_p = purchase_lot.id
|
||||||
|
AND lqt.lot_s IS NOT NULL
|
||||||
|
AND lqt.lot_quantity > 0::numeric
|
||||||
|
JOIN lot_lot sale_lot ON sale_lot.id = lqt.lot_s
|
||||||
|
AND sale_lot.lot_type::text = 'virtual'::text
|
||||||
|
JOIN sale_line sl ON sl.id = sale_lot.sale_line
|
||||||
|
JOIN sale_sale s ON s.id = sl.sale
|
||||||
|
JOIN lot_current_qty lcq ON lcq.lot_id = sale_lot.id
|
||||||
|
LEFT JOIN stock_shipment_in shi ON shi.id = lqt.lot_shipment_in
|
||||||
|
LEFT JOIN stock_shipment_internal sint ON sint.id = lqt.lot_shipment_internal
|
||||||
|
LEFT JOIN stock_shipment_out sho ON sho.id = lqt.lot_shipment_out
|
||||||
|
WHERE pl.type::text = 'line'::text
|
||||||
|
), sale_pnl_unmatched_lots AS (
|
||||||
|
SELECT
|
||||||
|
'sale'::text AS pnl_side,
|
||||||
|
NULL::integer AS purchase_id,
|
||||||
|
NULL::character varying AS purchase_number,
|
||||||
|
NULL::character varying AS purchase_reference,
|
||||||
|
NULL::integer AS purchase_line_id,
|
||||||
|
NULL::boolean AS purchase_line_finished,
|
||||||
|
s.id AS sale_id,
|
||||||
|
s.number AS sale_number,
|
||||||
|
s.reference AS sale_reference,
|
||||||
|
sl.id AS sale_line_id,
|
||||||
|
sl.finished AS sale_line_finished,
|
||||||
|
l.id AS valued_lot_id,
|
||||||
|
l.lot_type AS valued_lot_type,
|
||||||
|
NULL::integer AS lot_qt_id,
|
||||||
|
lcq.pnl_quantity,
|
||||||
|
lcq.quantity_uom AS quantity_unit,
|
||||||
|
sl.product AS product_id,
|
||||||
|
COALESCE(shi.from_location, sint.from_location, sho.from_location, s.from_location) AS from_location_id,
|
||||||
|
COALESCE(shi.to_location, sint.to_location, sho.to_location, s.to_location) AS to_location_id,
|
||||||
|
shi.id AS shipment_id,
|
||||||
|
shi.bl_date,
|
||||||
|
sl.from_del AS delivery_date_from,
|
||||||
|
sl.to_del AS delivery_date_to
|
||||||
|
FROM sale_line sl
|
||||||
|
JOIN sale_sale s ON s.id = sl.sale
|
||||||
|
JOIN lot_lot l ON l.sale_line = sl.id
|
||||||
|
AND l.line IS NULL
|
||||||
|
AND (l.lot_type::text = ANY (ARRAY['virtual'::character varying::text, 'physic'::character varying::text]))
|
||||||
|
JOIN lot_current_qty lcq ON lcq.lot_id = l.id
|
||||||
|
LEFT JOIN stock_shipment_in shi ON shi.id = l.lot_shipment_in
|
||||||
|
LEFT JOIN stock_shipment_internal sint ON sint.id = l.lot_shipment_internal
|
||||||
|
LEFT JOIN stock_shipment_out sho ON sho.id = l.lot_shipment_out
|
||||||
|
WHERE sl.type::text = 'line'::text
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM lot_qt lqt
|
||||||
|
WHERE lqt.lot_s = l.id
|
||||||
|
AND lqt.lot_p IS NOT NULL
|
||||||
|
AND lqt.lot_quantity > 0::numeric
|
||||||
|
)
|
||||||
|
), pnl_lot_rows AS (
|
||||||
|
SELECT
|
||||||
|
purchase_pnl_lots.pnl_side,
|
||||||
|
purchase_pnl_lots.purchase_id,
|
||||||
|
purchase_pnl_lots.purchase_number,
|
||||||
|
purchase_pnl_lots.purchase_reference,
|
||||||
|
purchase_pnl_lots.purchase_line_id,
|
||||||
|
purchase_pnl_lots.purchase_line_finished,
|
||||||
|
purchase_pnl_lots.sale_id,
|
||||||
|
purchase_pnl_lots.sale_number,
|
||||||
|
purchase_pnl_lots.sale_reference,
|
||||||
|
purchase_pnl_lots.sale_line_id,
|
||||||
|
purchase_pnl_lots.sale_line_finished,
|
||||||
|
purchase_pnl_lots.valued_lot_id,
|
||||||
|
purchase_pnl_lots.valued_lot_type,
|
||||||
|
purchase_pnl_lots.lot_qt_id,
|
||||||
|
purchase_pnl_lots.pnl_quantity,
|
||||||
|
purchase_pnl_lots.quantity_unit,
|
||||||
|
purchase_pnl_lots.product_id,
|
||||||
|
purchase_pnl_lots.from_location_id,
|
||||||
|
purchase_pnl_lots.to_location_id,
|
||||||
|
purchase_pnl_lots.shipment_id,
|
||||||
|
purchase_pnl_lots.bl_date,
|
||||||
|
purchase_pnl_lots.delivery_date_from,
|
||||||
|
purchase_pnl_lots.delivery_date_to
|
||||||
|
FROM purchase_pnl_lots
|
||||||
|
UNION ALL
|
||||||
|
SELECT
|
||||||
|
sale_pnl_direct_lots.pnl_side,
|
||||||
|
sale_pnl_direct_lots.purchase_id,
|
||||||
|
sale_pnl_direct_lots.purchase_number,
|
||||||
|
sale_pnl_direct_lots.purchase_reference,
|
||||||
|
sale_pnl_direct_lots.purchase_line_id,
|
||||||
|
sale_pnl_direct_lots.purchase_line_finished,
|
||||||
|
sale_pnl_direct_lots.sale_id,
|
||||||
|
sale_pnl_direct_lots.sale_number,
|
||||||
|
sale_pnl_direct_lots.sale_reference,
|
||||||
|
sale_pnl_direct_lots.sale_line_id,
|
||||||
|
sale_pnl_direct_lots.sale_line_finished,
|
||||||
|
sale_pnl_direct_lots.valued_lot_id,
|
||||||
|
sale_pnl_direct_lots.valued_lot_type,
|
||||||
|
sale_pnl_direct_lots.lot_qt_id,
|
||||||
|
sale_pnl_direct_lots.pnl_quantity,
|
||||||
|
sale_pnl_direct_lots.quantity_unit,
|
||||||
|
sale_pnl_direct_lots.product_id,
|
||||||
|
sale_pnl_direct_lots.from_location_id,
|
||||||
|
sale_pnl_direct_lots.to_location_id,
|
||||||
|
sale_pnl_direct_lots.shipment_id,
|
||||||
|
sale_pnl_direct_lots.bl_date,
|
||||||
|
sale_pnl_direct_lots.delivery_date_from,
|
||||||
|
sale_pnl_direct_lots.delivery_date_to
|
||||||
|
FROM sale_pnl_direct_lots
|
||||||
|
UNION ALL
|
||||||
|
SELECT
|
||||||
|
sale_pnl_matched_virtual_lots.pnl_side,
|
||||||
|
sale_pnl_matched_virtual_lots.purchase_id,
|
||||||
|
sale_pnl_matched_virtual_lots.purchase_number,
|
||||||
|
sale_pnl_matched_virtual_lots.purchase_reference,
|
||||||
|
sale_pnl_matched_virtual_lots.purchase_line_id,
|
||||||
|
sale_pnl_matched_virtual_lots.purchase_line_finished,
|
||||||
|
sale_pnl_matched_virtual_lots.sale_id,
|
||||||
|
sale_pnl_matched_virtual_lots.sale_number,
|
||||||
|
sale_pnl_matched_virtual_lots.sale_reference,
|
||||||
|
sale_pnl_matched_virtual_lots.sale_line_id,
|
||||||
|
sale_pnl_matched_virtual_lots.sale_line_finished,
|
||||||
|
sale_pnl_matched_virtual_lots.valued_lot_id,
|
||||||
|
sale_pnl_matched_virtual_lots.valued_lot_type,
|
||||||
|
sale_pnl_matched_virtual_lots.lot_qt_id,
|
||||||
|
sale_pnl_matched_virtual_lots.pnl_quantity,
|
||||||
|
sale_pnl_matched_virtual_lots.quantity_unit,
|
||||||
|
sale_pnl_matched_virtual_lots.product_id,
|
||||||
|
sale_pnl_matched_virtual_lots.from_location_id,
|
||||||
|
sale_pnl_matched_virtual_lots.to_location_id,
|
||||||
|
sale_pnl_matched_virtual_lots.shipment_id,
|
||||||
|
sale_pnl_matched_virtual_lots.bl_date,
|
||||||
|
sale_pnl_matched_virtual_lots.delivery_date_from,
|
||||||
|
sale_pnl_matched_virtual_lots.delivery_date_to
|
||||||
|
FROM sale_pnl_matched_virtual_lots
|
||||||
|
UNION ALL
|
||||||
|
SELECT
|
||||||
|
sale_pnl_unmatched_lots.pnl_side,
|
||||||
|
sale_pnl_unmatched_lots.purchase_id,
|
||||||
|
sale_pnl_unmatched_lots.purchase_number,
|
||||||
|
sale_pnl_unmatched_lots.purchase_reference,
|
||||||
|
sale_pnl_unmatched_lots.purchase_line_id,
|
||||||
|
sale_pnl_unmatched_lots.purchase_line_finished,
|
||||||
|
sale_pnl_unmatched_lots.sale_id,
|
||||||
|
sale_pnl_unmatched_lots.sale_number,
|
||||||
|
sale_pnl_unmatched_lots.sale_reference,
|
||||||
|
sale_pnl_unmatched_lots.sale_line_id,
|
||||||
|
sale_pnl_unmatched_lots.sale_line_finished,
|
||||||
|
sale_pnl_unmatched_lots.valued_lot_id,
|
||||||
|
sale_pnl_unmatched_lots.valued_lot_type,
|
||||||
|
sale_pnl_unmatched_lots.lot_qt_id,
|
||||||
|
sale_pnl_unmatched_lots.pnl_quantity,
|
||||||
|
sale_pnl_unmatched_lots.quantity_unit,
|
||||||
|
sale_pnl_unmatched_lots.product_id,
|
||||||
|
sale_pnl_unmatched_lots.from_location_id,
|
||||||
|
sale_pnl_unmatched_lots.to_location_id,
|
||||||
|
sale_pnl_unmatched_lots.shipment_id,
|
||||||
|
sale_pnl_unmatched_lots.bl_date,
|
||||||
|
sale_pnl_unmatched_lots.delivery_date_from,
|
||||||
|
sale_pnl_unmatched_lots.delivery_date_to
|
||||||
|
FROM sale_pnl_unmatched_lots
|
||||||
|
), pnl_lot_rows_with_finished AS (
|
||||||
|
SELECT
|
||||||
|
pnl_lot_rows.pnl_side,
|
||||||
|
pnl_lot_rows.purchase_id,
|
||||||
|
pnl_lot_rows.purchase_number,
|
||||||
|
pnl_lot_rows.purchase_reference,
|
||||||
|
pnl_lot_rows.purchase_line_id,
|
||||||
|
pnl_lot_rows.purchase_line_finished,
|
||||||
|
pnl_lot_rows.sale_id,
|
||||||
|
pnl_lot_rows.sale_number,
|
||||||
|
pnl_lot_rows.sale_reference,
|
||||||
|
pnl_lot_rows.sale_line_id,
|
||||||
|
pnl_lot_rows.sale_line_finished,
|
||||||
|
pnl_lot_rows.valued_lot_id,
|
||||||
|
pnl_lot_rows.valued_lot_type,
|
||||||
|
pnl_lot_rows.lot_qt_id,
|
||||||
|
pnl_lot_rows.pnl_quantity,
|
||||||
|
pnl_lot_rows.quantity_unit,
|
||||||
|
pnl_lot_rows.product_id,
|
||||||
|
pnl_lot_rows.from_location_id,
|
||||||
|
pnl_lot_rows.to_location_id,
|
||||||
|
pnl_lot_rows.shipment_id,
|
||||||
|
pnl_lot_rows.bl_date,
|
||||||
|
pnl_lot_rows.delivery_date_from,
|
||||||
|
pnl_lot_rows.delivery_date_to,
|
||||||
|
CASE
|
||||||
|
WHEN pnl_lot_rows.pnl_side = 'purchase'::text THEN pnl_lot_rows.purchase_line_finished
|
||||||
|
WHEN pnl_lot_rows.pnl_side = 'sale'::text THEN pnl_lot_rows.sale_line_finished
|
||||||
|
ELSE false
|
||||||
|
END AS valued_line_finished,
|
||||||
|
CASE
|
||||||
|
WHEN pnl_lot_rows.valued_lot_type::text = 'virtual'::text
|
||||||
|
AND (
|
||||||
|
pnl_lot_rows.pnl_side = 'purchase'::text
|
||||||
|
AND pnl_lot_rows.purchase_line_finished IS TRUE
|
||||||
|
OR pnl_lot_rows.pnl_side = 'sale'::text
|
||||||
|
AND pnl_lot_rows.sale_line_finished IS TRUE
|
||||||
|
)
|
||||||
|
THEN true
|
||||||
|
ELSE false
|
||||||
|
END AS ignored_by_finished_rule
|
||||||
|
FROM pnl_lot_rows
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
pnl_side,
|
||||||
|
purchase_id,
|
||||||
|
purchase_number,
|
||||||
|
purchase_reference,
|
||||||
|
purchase_line_id,
|
||||||
|
purchase_line_finished,
|
||||||
|
sale_id,
|
||||||
|
sale_number,
|
||||||
|
sale_reference,
|
||||||
|
sale_line_id,
|
||||||
|
sale_line_finished,
|
||||||
|
valued_lot_id,
|
||||||
|
valued_lot_type,
|
||||||
|
valued_line_finished,
|
||||||
|
ignored_by_finished_rule,
|
||||||
|
sum(pnl_quantity) AS pnl_quantity_raw,
|
||||||
|
sum(
|
||||||
|
CASE
|
||||||
|
WHEN ignored_by_finished_rule THEN 0::numeric
|
||||||
|
ELSE pnl_quantity
|
||||||
|
END
|
||||||
|
) AS pnl_quantity_after_finished_rule,
|
||||||
|
quantity_unit,
|
||||||
|
product_id,
|
||||||
|
from_location_id,
|
||||||
|
to_location_id,
|
||||||
|
shipment_id,
|
||||||
|
bl_date,
|
||||||
|
delivery_date_from,
|
||||||
|
delivery_date_to
|
||||||
|
FROM pnl_lot_rows_with_finished
|
||||||
|
GROUP BY
|
||||||
|
pnl_side,
|
||||||
|
purchase_id,
|
||||||
|
purchase_number,
|
||||||
|
purchase_reference,
|
||||||
|
purchase_line_id,
|
||||||
|
purchase_line_finished,
|
||||||
|
sale_id,
|
||||||
|
sale_number,
|
||||||
|
sale_reference,
|
||||||
|
sale_line_id,
|
||||||
|
sale_line_finished,
|
||||||
|
valued_lot_type,
|
||||||
|
valued_lot_id,
|
||||||
|
valued_line_finished,
|
||||||
|
ignored_by_finished_rule,
|
||||||
|
quantity_unit,
|
||||||
|
product_id,
|
||||||
|
from_location_id,
|
||||||
|
to_location_id,
|
||||||
|
shipment_id,
|
||||||
|
bl_date,
|
||||||
|
delivery_date_from,
|
||||||
|
delivery_date_to;
|
||||||
@@ -0,0 +1,361 @@
|
|||||||
|
WITH physical_shipment_lots AS (
|
||||||
|
SELECT l.lot_shipment_in AS shipment_id,
|
||||||
|
l.id AS lot_id,
|
||||||
|
l.lot_type,
|
||||||
|
l.line AS purchase_line_id,
|
||||||
|
l.sale_line AS sale_line_id,
|
||||||
|
qh.quantity AS shipment_quantity,
|
||||||
|
l.lot_unit_line AS shipment_unit_id
|
||||||
|
FROM lot_lot l
|
||||||
|
LEFT JOIN lot_qt_hist qh ON qh.lot = l.id AND qh.quantity_type = l.lot_state
|
||||||
|
WHERE l.lot_type::text = 'physic'::text AND l.lot_shipment_in IS NOT NULL
|
||||||
|
), virtual_shipment_lots AS (
|
||||||
|
SELECT q.lot_shipment_in AS shipment_id,
|
||||||
|
vp.id AS lot_id,
|
||||||
|
vp.lot_type,
|
||||||
|
vp.line AS purchase_line_id,
|
||||||
|
COALESCE(vp.sale_line, ps.sale_line) AS sale_line_id,
|
||||||
|
q.lot_quantity AS shipment_quantity,
|
||||||
|
q.lot_unit AS shipment_unit_id
|
||||||
|
FROM lot_qt q
|
||||||
|
JOIN lot_lot vp ON vp.id = q.lot_p AND vp.lot_type::text = 'virtual'::text
|
||||||
|
LEFT JOIN lot_lot ps ON ps.id = q.lot_s
|
||||||
|
WHERE q.lot_shipment_in IS NOT NULL AND NOT (EXISTS ( SELECT 1
|
||||||
|
FROM physical_shipment_lots pl
|
||||||
|
WHERE pl.shipment_id = q.lot_shipment_in AND pl.purchase_line_id = vp.line AND (pl.sale_line_id = COALESCE(vp.sale_line, ps.sale_line) OR COALESCE(vp.sale_line, ps.sale_line) IS NULL)))
|
||||||
|
), shipment_lots AS (
|
||||||
|
SELECT physical_shipment_lots.shipment_id,
|
||||||
|
physical_shipment_lots.lot_id,
|
||||||
|
physical_shipment_lots.lot_type,
|
||||||
|
physical_shipment_lots.purchase_line_id,
|
||||||
|
physical_shipment_lots.sale_line_id,
|
||||||
|
physical_shipment_lots.shipment_quantity,
|
||||||
|
physical_shipment_lots.shipment_unit_id
|
||||||
|
FROM physical_shipment_lots
|
||||||
|
UNION ALL
|
||||||
|
SELECT virtual_shipment_lots.shipment_id,
|
||||||
|
virtual_shipment_lots.lot_id,
|
||||||
|
virtual_shipment_lots.lot_type,
|
||||||
|
virtual_shipment_lots.purchase_line_id,
|
||||||
|
virtual_shipment_lots.sale_line_id,
|
||||||
|
virtual_shipment_lots.shipment_quantity,
|
||||||
|
virtual_shipment_lots.shipment_unit_id
|
||||||
|
FROM virtual_shipment_lots
|
||||||
|
), shipment_context AS (
|
||||||
|
SELECT shipment_lots.shipment_id,
|
||||||
|
shipment_lots.lot_id,
|
||||||
|
shipment_lots.purchase_line_id,
|
||||||
|
shipment_lots.sale_line_id,
|
||||||
|
shipment_lots.shipment_unit_id,
|
||||||
|
sum(COALESCE(shipment_lots.shipment_quantity, 0::numeric)) AS shipment_quantity
|
||||||
|
FROM shipment_lots
|
||||||
|
WHERE shipment_lots.shipment_id IS NOT NULL
|
||||||
|
GROUP BY shipment_lots.shipment_id, shipment_lots.lot_id, shipment_lots.purchase_line_id, shipment_lots.sale_line_id, shipment_lots.shipment_unit_id
|
||||||
|
), shipment_base AS (
|
||||||
|
SELECT shipment_context.shipment_id,
|
||||||
|
sum(shipment_context.shipment_quantity) AS shipment_quantity
|
||||||
|
FROM shipment_context
|
||||||
|
GROUP BY shipment_context.shipment_id
|
||||||
|
), shipment_fee_candidates AS (
|
||||||
|
SELECT f_1.id AS fee_id,
|
||||||
|
'Shipment'::text AS fee_source,
|
||||||
|
f_1.type AS fee_type,
|
||||||
|
CASE
|
||||||
|
WHEN f_1.type::text = 'ordered'::text THEN 1
|
||||||
|
WHEN f_1.type::text = 'scheduled'::text THEN 2
|
||||||
|
ELSE NULL::integer
|
||||||
|
END AS priority,
|
||||||
|
sb.shipment_id,
|
||||||
|
NULL::integer AS lot_id,
|
||||||
|
NULL::integer AS purchase_line_id,
|
||||||
|
NULL::integer AS sale_line_id,
|
||||||
|
f_1.product AS product_id,
|
||||||
|
f_1.supplier AS supplier_id,
|
||||||
|
f_1.mode AS packaging,
|
||||||
|
f_1.p_r AS pay_or_rec,
|
||||||
|
f_1.state,
|
||||||
|
f_1.weight_type,
|
||||||
|
COALESCE(f_1.quantity, 0::numeric) AS requested_quantity,
|
||||||
|
sb.shipment_quantity,
|
||||||
|
f_1.price AS fee_price,
|
||||||
|
f_1.currency AS currency_id,
|
||||||
|
f_1.unit AS unit_id,
|
||||||
|
CASE
|
||||||
|
WHEN upper(f_1.p_r::text) = 'REC'::text THEN 1
|
||||||
|
ELSE '-1'::integer
|
||||||
|
END AS sign_multiplier,
|
||||||
|
NULL::text AS forced_cost_group
|
||||||
|
FROM shipment_base sb
|
||||||
|
JOIN fee_fee f_1 ON f_1.shipment_in = sb.shipment_id
|
||||||
|
WHERE f_1.type::text = ANY (ARRAY['ordered'::character varying::text, 'scheduled'::character varying::text])
|
||||||
|
), shipment_fee_allocated AS (
|
||||||
|
SELECT c.fee_id,
|
||||||
|
c.fee_source,
|
||||||
|
c.fee_type,
|
||||||
|
c.priority,
|
||||||
|
c.shipment_id,
|
||||||
|
c.lot_id,
|
||||||
|
c.purchase_line_id,
|
||||||
|
c.sale_line_id,
|
||||||
|
c.product_id,
|
||||||
|
c.supplier_id,
|
||||||
|
c.packaging,
|
||||||
|
c.pay_or_rec,
|
||||||
|
c.state,
|
||||||
|
c.weight_type,
|
||||||
|
c.requested_quantity,
|
||||||
|
c.shipment_quantity,
|
||||||
|
c.fee_price,
|
||||||
|
c.currency_id,
|
||||||
|
c.unit_id,
|
||||||
|
c.sign_multiplier,
|
||||||
|
c.forced_cost_group,
|
||||||
|
LEAST(GREATEST(c.requested_quantity, 0::numeric), GREATEST(c.shipment_quantity - COALESCE(sum(c.requested_quantity) OVER (PARTITION BY c.shipment_id, c.product_id, c.supplier_id ORDER BY c.priority, c.fee_id ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING), 0::numeric), 0::numeric)) AS allocated_quantity
|
||||||
|
FROM shipment_fee_candidates c
|
||||||
|
), shipment_fee_coverage AS (
|
||||||
|
SELECT shipment_fee_allocated.shipment_id,
|
||||||
|
shipment_fee_allocated.product_id,
|
||||||
|
shipment_fee_allocated.supplier_id,
|
||||||
|
max(shipment_fee_allocated.shipment_quantity) AS shipment_quantity,
|
||||||
|
sum(shipment_fee_allocated.allocated_quantity) AS allocated_quantity
|
||||||
|
FROM shipment_fee_allocated
|
||||||
|
GROUP BY shipment_fee_allocated.shipment_id, shipment_fee_allocated.product_id, shipment_fee_allocated.supplier_id
|
||||||
|
), contract_budgeted_fee_candidates AS (
|
||||||
|
SELECT f_1.id AS fee_id,
|
||||||
|
'Purchase Contract'::text AS fee_source,
|
||||||
|
f_1.type AS fee_type,
|
||||||
|
3 AS priority,
|
||||||
|
sc.shipment_id,
|
||||||
|
sc.lot_id,
|
||||||
|
sc.purchase_line_id,
|
||||||
|
sc.sale_line_id,
|
||||||
|
f_1.product AS product_id,
|
||||||
|
f_1.supplier AS supplier_id,
|
||||||
|
f_1.mode AS packaging,
|
||||||
|
f_1.p_r AS pay_or_rec,
|
||||||
|
f_1.state,
|
||||||
|
f_1.weight_type,
|
||||||
|
sc.shipment_quantity,
|
||||||
|
f_1.price AS fee_price,
|
||||||
|
f_1.currency AS currency_id,
|
||||||
|
COALESCE(f_1.unit, sc.shipment_unit_id) AS unit_id,
|
||||||
|
CASE
|
||||||
|
WHEN upper(f_1.p_r::text) = 'REC'::text THEN '-1'::integer
|
||||||
|
ELSE 1
|
||||||
|
END AS sign_multiplier,
|
||||||
|
NULL::text AS forced_cost_group
|
||||||
|
FROM shipment_context sc
|
||||||
|
JOIN fee_fee f_1 ON f_1.line = sc.purchase_line_id
|
||||||
|
WHERE f_1.type::text = 'budgeted'::text AND sc.purchase_line_id IS NOT NULL
|
||||||
|
UNION ALL
|
||||||
|
SELECT f_1.id AS fee_id,
|
||||||
|
'Sale Contract'::text AS fee_source,
|
||||||
|
f_1.type AS fee_type,
|
||||||
|
3 AS priority,
|
||||||
|
sc.shipment_id,
|
||||||
|
sc.lot_id,
|
||||||
|
sc.purchase_line_id,
|
||||||
|
sc.sale_line_id,
|
||||||
|
f_1.product AS product_id,
|
||||||
|
f_1.supplier AS supplier_id,
|
||||||
|
f_1.mode AS packaging,
|
||||||
|
f_1.p_r AS pay_or_rec,
|
||||||
|
f_1.state,
|
||||||
|
f_1.weight_type,
|
||||||
|
sc.shipment_quantity,
|
||||||
|
f_1.price AS fee_price,
|
||||||
|
f_1.currency AS currency_id,
|
||||||
|
COALESCE(f_1.unit, sc.shipment_unit_id) AS unit_id,
|
||||||
|
CASE
|
||||||
|
WHEN upper(f_1.p_r::text) = 'REC'::text THEN 1
|
||||||
|
ELSE '-1'::integer
|
||||||
|
END AS sign_multiplier,
|
||||||
|
NULL::text AS forced_cost_group
|
||||||
|
FROM shipment_context sc
|
||||||
|
JOIN fee_fee f_1 ON f_1.sale_line = sc.sale_line_id
|
||||||
|
WHERE f_1.type::text = 'budgeted'::text AND sc.sale_line_id IS NOT NULL
|
||||||
|
), contract_budgeted_allocated AS (
|
||||||
|
SELECT c.fee_id,
|
||||||
|
c.fee_source,
|
||||||
|
c.fee_type,
|
||||||
|
c.priority,
|
||||||
|
c.shipment_id,
|
||||||
|
c.lot_id,
|
||||||
|
c.purchase_line_id,
|
||||||
|
c.sale_line_id,
|
||||||
|
c.product_id,
|
||||||
|
c.supplier_id,
|
||||||
|
c.packaging,
|
||||||
|
c.pay_or_rec,
|
||||||
|
c.state,
|
||||||
|
c.weight_type,
|
||||||
|
c.shipment_quantity,
|
||||||
|
c.fee_price,
|
||||||
|
c.currency_id,
|
||||||
|
c.unit_id,
|
||||||
|
c.sign_multiplier,
|
||||||
|
c.forced_cost_group,
|
||||||
|
LEAST(c.shipment_quantity, GREATEST(sum(c.shipment_quantity) OVER (PARTITION BY c.shipment_id, c.product_id, c.supplier_id, c.fee_id) - COALESCE(fc.allocated_quantity, 0::numeric) - COALESCE(sum(c.shipment_quantity) OVER (PARTITION BY c.shipment_id, c.product_id, c.supplier_id, c.fee_id ORDER BY c.lot_id ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING), 0::numeric), 0::numeric)) AS allocated_quantity
|
||||||
|
FROM contract_budgeted_fee_candidates c
|
||||||
|
LEFT JOIN shipment_fee_coverage fc ON fc.shipment_id = c.shipment_id AND fc.product_id = c.product_id AND fc.supplier_id = c.supplier_id
|
||||||
|
), price_rows AS (
|
||||||
|
SELECT NULL::integer AS fee_id,
|
||||||
|
'Purchase Price'::text AS fee_source,
|
||||||
|
'price'::text AS fee_type,
|
||||||
|
4 AS priority,
|
||||||
|
sc.shipment_id,
|
||||||
|
sc.lot_id,
|
||||||
|
sc.purchase_line_id,
|
||||||
|
sc.sale_line_id,
|
||||||
|
pl.product AS product_id,
|
||||||
|
NULL::integer AS supplier_id,
|
||||||
|
NULL::character varying AS packaging,
|
||||||
|
NULL::character varying AS pay_or_rec,
|
||||||
|
NULL::character varying AS state,
|
||||||
|
NULL::character varying AS weight_type,
|
||||||
|
sc.shipment_quantity AS allocated_quantity,
|
||||||
|
pl.unit_price AS fee_price,
|
||||||
|
pl.currency_ AS currency_id,
|
||||||
|
COALESCE(pl.unit, sc.shipment_unit_id) AS unit_id,
|
||||||
|
1 AS sign_multiplier,
|
||||||
|
'PurchasePrice'::text AS forced_cost_group
|
||||||
|
FROM shipment_context sc
|
||||||
|
JOIN purchase_line pl ON pl.id = sc.purchase_line_id
|
||||||
|
WHERE sc.purchase_line_id IS NOT NULL
|
||||||
|
UNION ALL
|
||||||
|
SELECT NULL::integer AS fee_id,
|
||||||
|
'Sale Price'::text AS fee_source,
|
||||||
|
'price'::text AS fee_type,
|
||||||
|
5 AS priority,
|
||||||
|
sc.shipment_id,
|
||||||
|
sc.lot_id,
|
||||||
|
sc.purchase_line_id,
|
||||||
|
sc.sale_line_id,
|
||||||
|
sl.product AS product_id,
|
||||||
|
NULL::integer AS supplier_id,
|
||||||
|
NULL::character varying AS packaging,
|
||||||
|
NULL::character varying AS pay_or_rec,
|
||||||
|
NULL::character varying AS state,
|
||||||
|
NULL::character varying AS weight_type,
|
||||||
|
sc.shipment_quantity AS allocated_quantity,
|
||||||
|
sl.unit_price AS fee_price,
|
||||||
|
ss.currency AS currency_id,
|
||||||
|
COALESCE(sl.unit, sc.shipment_unit_id) AS unit_id,
|
||||||
|
'-1'::integer AS sign_multiplier,
|
||||||
|
'SalePrice'::text AS forced_cost_group
|
||||||
|
FROM shipment_context sc
|
||||||
|
JOIN sale_line sl ON sl.id = sc.sale_line_id
|
||||||
|
JOIN sale_sale ss ON ss.id = sl.sale
|
||||||
|
WHERE sc.sale_line_id IS NOT NULL
|
||||||
|
), final_fees AS (
|
||||||
|
SELECT shipment_fee_allocated.fee_id,
|
||||||
|
shipment_fee_allocated.fee_source,
|
||||||
|
shipment_fee_allocated.fee_type,
|
||||||
|
shipment_fee_allocated.priority,
|
||||||
|
shipment_fee_allocated.shipment_id,
|
||||||
|
shipment_fee_allocated.lot_id,
|
||||||
|
shipment_fee_allocated.purchase_line_id,
|
||||||
|
shipment_fee_allocated.sale_line_id,
|
||||||
|
shipment_fee_allocated.product_id,
|
||||||
|
shipment_fee_allocated.supplier_id,
|
||||||
|
shipment_fee_allocated.packaging,
|
||||||
|
shipment_fee_allocated.pay_or_rec,
|
||||||
|
shipment_fee_allocated.state,
|
||||||
|
shipment_fee_allocated.weight_type,
|
||||||
|
shipment_fee_allocated.allocated_quantity AS fee_quantity,
|
||||||
|
shipment_fee_allocated.fee_price,
|
||||||
|
shipment_fee_allocated.currency_id,
|
||||||
|
shipment_fee_allocated.unit_id,
|
||||||
|
shipment_fee_allocated.sign_multiplier,
|
||||||
|
shipment_fee_allocated.forced_cost_group
|
||||||
|
FROM shipment_fee_allocated
|
||||||
|
WHERE shipment_fee_allocated.allocated_quantity > 0::numeric
|
||||||
|
UNION ALL
|
||||||
|
SELECT contract_budgeted_allocated.fee_id,
|
||||||
|
contract_budgeted_allocated.fee_source,
|
||||||
|
contract_budgeted_allocated.fee_type,
|
||||||
|
contract_budgeted_allocated.priority,
|
||||||
|
contract_budgeted_allocated.shipment_id,
|
||||||
|
contract_budgeted_allocated.lot_id,
|
||||||
|
contract_budgeted_allocated.purchase_line_id,
|
||||||
|
contract_budgeted_allocated.sale_line_id,
|
||||||
|
contract_budgeted_allocated.product_id,
|
||||||
|
contract_budgeted_allocated.supplier_id,
|
||||||
|
contract_budgeted_allocated.packaging,
|
||||||
|
contract_budgeted_allocated.pay_or_rec,
|
||||||
|
contract_budgeted_allocated.state,
|
||||||
|
contract_budgeted_allocated.weight_type,
|
||||||
|
contract_budgeted_allocated.allocated_quantity AS fee_quantity,
|
||||||
|
contract_budgeted_allocated.fee_price,
|
||||||
|
contract_budgeted_allocated.currency_id,
|
||||||
|
contract_budgeted_allocated.unit_id,
|
||||||
|
contract_budgeted_allocated.sign_multiplier,
|
||||||
|
contract_budgeted_allocated.forced_cost_group
|
||||||
|
FROM contract_budgeted_allocated
|
||||||
|
WHERE contract_budgeted_allocated.allocated_quantity > 0::numeric
|
||||||
|
UNION ALL
|
||||||
|
SELECT price_rows.fee_id,
|
||||||
|
price_rows.fee_source,
|
||||||
|
price_rows.fee_type,
|
||||||
|
price_rows.priority,
|
||||||
|
price_rows.shipment_id,
|
||||||
|
price_rows.lot_id,
|
||||||
|
price_rows.purchase_line_id,
|
||||||
|
price_rows.sale_line_id,
|
||||||
|
price_rows.product_id,
|
||||||
|
price_rows.supplier_id,
|
||||||
|
price_rows.packaging,
|
||||||
|
price_rows.pay_or_rec,
|
||||||
|
price_rows.state,
|
||||||
|
price_rows.weight_type,
|
||||||
|
price_rows.allocated_quantity AS fee_quantity,
|
||||||
|
price_rows.fee_price,
|
||||||
|
price_rows.currency_id,
|
||||||
|
price_rows.unit_id,
|
||||||
|
price_rows.sign_multiplier,
|
||||||
|
price_rows.forced_cost_group
|
||||||
|
FROM price_rows
|
||||||
|
WHERE price_rows.allocated_quantity > 0::numeric
|
||||||
|
)
|
||||||
|
SELECT f.shipment_id AS "intShipmentId",
|
||||||
|
f.lot_id AS "intLotId",
|
||||||
|
COALESCE(f.fee_id, 0) AS "intFeeId",
|
||||||
|
f.fee_source AS "strFeeSource",
|
||||||
|
f.fee_type AS "strFeeType",
|
||||||
|
f.priority AS "intPriority",
|
||||||
|
COALESCE(f.purchase_line_id, 0) AS "intPurchaseLineId",
|
||||||
|
COALESCE(f.sale_line_id, 0) AS "intSaleLineId",
|
||||||
|
COALESCE(f.product_id, 0) AS "intProductId",
|
||||||
|
COALESCE(p.code, ''::character varying) AS "strFee",
|
||||||
|
COALESCE(f.supplier_id, 0) AS "intSupplierId",
|
||||||
|
COALESCE(sup.name, ''::character varying) AS "strSupplier",
|
||||||
|
COALESCE(f.packaging, ''::character varying) AS "strPackaging",
|
||||||
|
COALESCE(f.pay_or_rec, ''::character varying) AS "strPayOrRec",
|
||||||
|
COALESCE(f.state, ''::character varying) AS "strState",
|
||||||
|
CASE
|
||||||
|
WHEN upper(f.weight_type::text) = 'BRUT'::text THEN 'Gross'::text
|
||||||
|
ELSE 'Net'::text
|
||||||
|
END AS "strWeighingType",
|
||||||
|
f.fee_quantity AS "dblQuantity",
|
||||||
|
f.fee_price AS "dblPrice",
|
||||||
|
COALESCE(cur.name, ''::character varying) AS "strCurrency",
|
||||||
|
COALESCE(uom.name, 'Mt'::character varying) AS "strUnit",
|
||||||
|
f.fee_quantity * f.fee_price AS "dblAmount",
|
||||||
|
COALESCE(f.forced_cost_group,
|
||||||
|
CASE
|
||||||
|
WHEN upper(p.code::text) ~~ '%FREIGHT%'::text THEN 'Freight'::text
|
||||||
|
WHEN upper(p.code::text) ~~ '%PROFIT SHARING%'::text THEN 'Profit Sharing'::text
|
||||||
|
ELSE 'Other Costs'::text
|
||||||
|
END) AS "strCostGroup",
|
||||||
|
CASE
|
||||||
|
WHEN f.pay_or_rec::text = 'pay'::text THEN - 1::numeric
|
||||||
|
WHEN f.pay_or_rec::text = 'rec'::text THEN 1::numeric
|
||||||
|
WHEN f.fee_source = 'Purchase Price'::text AND f.fee_type::text = 'price'::text THEN - 1::numeric
|
||||||
|
WHEN f.fee_source = 'Sale Price'::text AND f.fee_type::text = 'price'::text THEN 1::numeric
|
||||||
|
ELSE - 1::numeric
|
||||||
|
END AS "intSignMultiplier"
|
||||||
|
FROM final_fees f
|
||||||
|
JOIN product_product p ON p.id = f.product_id
|
||||||
|
LEFT JOIN party_party sup ON sup.id = f.supplier_id
|
||||||
|
LEFT JOIN currency_currency cur ON cur.id = f.currency_id
|
||||||
|
LEFT JOIN product_uom uom ON uom.id = f.unit_id;
|
||||||
@@ -233,6 +233,7 @@
|
|||||||
<value>email</value>
|
<value>email</value>
|
||||||
<value>float</value>
|
<value>float</value>
|
||||||
<value>html</value>
|
<value>html</value>
|
||||||
|
<value>html_viewer</value>
|
||||||
<value>image</value>
|
<value>image</value>
|
||||||
<value>integer</value>
|
<value>integer</value>
|
||||||
<value>many2many</value>
|
<value>many2many</value>
|
||||||
|
|||||||
BIN
modules/__pycache__/__init__.cpython-314.pyc
Normal file
BIN
modules/__pycache__/__init__.cpython-314.pyc
Normal file
Binary file not shown.
@@ -1,10 +1,10 @@
|
|||||||
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
# this repository contains the full copyright notices and license terms.
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
|
||||||
from trytond.pool import Pool
|
from trytond.pool import Pool
|
||||||
|
|
||||||
from . import (
|
from . import (
|
||||||
account,
|
account,
|
||||||
purchase,
|
purchase,
|
||||||
sale,
|
sale,
|
||||||
global_reporting,
|
global_reporting,
|
||||||
@@ -32,11 +32,16 @@ from . import (
|
|||||||
dimension,
|
dimension,
|
||||||
weight_report,
|
weight_report,
|
||||||
backtoback,
|
backtoback,
|
||||||
service,
|
service,
|
||||||
invoice,
|
invoice,
|
||||||
)
|
process_documentation,
|
||||||
|
routes,
|
||||||
def register():
|
)
|
||||||
|
|
||||||
|
__all__ = ['register', 'routes']
|
||||||
|
|
||||||
|
|
||||||
|
def register():
|
||||||
Pool.register(
|
Pool.register(
|
||||||
association_tables.LCDocumentTypeProductProfile,
|
association_tables.LCDocumentTypeProductProfile,
|
||||||
association_tables.LCLetterDocumentType,
|
association_tables.LCLetterDocumentType,
|
||||||
@@ -56,6 +61,7 @@ def register():
|
|||||||
lc.LCMessage,
|
lc.LCMessage,
|
||||||
lc.CreateLCStart,
|
lc.CreateLCStart,
|
||||||
global_reporting.GRConfiguration,
|
global_reporting.GRConfiguration,
|
||||||
|
process_documentation.ProcessDocumentation,
|
||||||
pricing.ImportPricesStart,
|
pricing.ImportPricesStart,
|
||||||
pricing.ImportPricesResult,
|
pricing.ImportPricesResult,
|
||||||
module='purchase_trade', type_='model')
|
module='purchase_trade', type_='model')
|
||||||
|
|||||||
BIN
modules/purchase_trade/__pycache__/pricing.cpython-314.pyc
Normal file
BIN
modules/purchase_trade/__pycache__/pricing.cpython-314.pyc
Normal file
Binary file not shown.
@@ -4,10 +4,10 @@ Scope: code changes related only to `BR-PT-004 - Market Price Import`.
|
|||||||
|
|
||||||
## PT-BL-001 - Enforce uniqueness at model level
|
## PT-BL-001 - Enforce uniqueness at model level
|
||||||
|
|
||||||
- Status: to be tested
|
- Status: done
|
||||||
- Implementation commit: `eaae2e5`
|
- Implementation commit: `eaae2e5`
|
||||||
- Priority: high
|
- Priority: high
|
||||||
- Source: [rules/market-price-import.md](../rules/market-price-import.md)
|
- Source: [business rules/market-price-import.md](../business%20rules/market-price-import.md)
|
||||||
- Requirement: enforce uniqueness of `(price, price_date)` at model level without adding a database constraint yet.
|
- Requirement: enforce uniqueness of `(price, price_date)` at model level without adding a database constraint yet.
|
||||||
- Work done:
|
- Work done:
|
||||||
- added model-level validation on `price.price_value`
|
- added model-level validation on `price.price_value`
|
||||||
@@ -27,7 +27,7 @@ Scope: code changes related only to `BR-PT-004 - Market Price Import`.
|
|||||||
|
|
||||||
- Status: open
|
- Status: open
|
||||||
- Priority: medium
|
- Priority: medium
|
||||||
- Source: [rules/market-price-import.md](../rules/market-price-import.md)
|
- Source: [business rules/market-price-import.md](../business%20rules/market-price-import.md)
|
||||||
- Requirement: prefer the user's/default locale date format for ambiguous slash dates, then fall back to the current parsing order only if no locale preference is available.
|
- Requirement: prefer the user's/default locale date format for ambiguous slash dates, then fall back to the current parsing order only if no locale preference is available.
|
||||||
- Current behavior: `DD/MM/YYYY` is tried before `MM/DD/YYYY`.
|
- Current behavior: `DD/MM/YYYY` is tried before `MM/DD/YYYY`.
|
||||||
- Expected code impact:
|
- Expected code impact:
|
||||||
@@ -41,7 +41,7 @@ Scope: code changes related only to `BR-PT-004 - Market Price Import`.
|
|||||||
|
|
||||||
- Status: open
|
- Status: open
|
||||||
- Priority: high
|
- Priority: high
|
||||||
- Source: [rules/market-price-import.md](../rules/market-price-import.md)
|
- Source: [business rules/market-price-import.md](../business%20rules/market-price-import.md)
|
||||||
- Requirement: `price_value` is mandatory for imported rows. Missing `price_value` must be reported as a row error.
|
- Requirement: `price_value` is mandatory for imported rows. Missing `price_value` must be reported as a row error.
|
||||||
- Current behavior: empty `price_value` is imported as an empty value.
|
- Current behavior: empty `price_value` is imported as an empty value.
|
||||||
- Expected code impact:
|
- Expected code impact:
|
||||||
@@ -55,7 +55,7 @@ Scope: code changes related only to `BR-PT-004 - Market Price Import`.
|
|||||||
|
|
||||||
- Status: open
|
- Status: open
|
||||||
- Priority: high
|
- Priority: high
|
||||||
- Source: [rules/market-price-import.md](../rules/market-price-import.md)
|
- Source: [business rules/market-price-import.md](../business%20rules/market-price-import.md)
|
||||||
- Requirement: duplicate rows for the same `(price_index, price_date)` inside the same Excel file must be reported as row errors. The duplicate row must not import or update data.
|
- Requirement: duplicate rows for the same `(price_index, price_date)` inside the same Excel file must be reported as row errors. The duplicate row must not import or update data.
|
||||||
- Expected code impact:
|
- Expected code impact:
|
||||||
- `modules/purchase_trade/pricing.py`
|
- `modules/purchase_trade/pricing.py`
|
||||||
@@ -68,7 +68,7 @@ Scope: code changes related only to `BR-PT-004 - Market Price Import`.
|
|||||||
|
|
||||||
- Status: open
|
- Status: open
|
||||||
- Priority: medium
|
- Priority: medium
|
||||||
- Source: [rules/market-price-import.md](../rules/market-price-import.md)
|
- Source: [business rules/market-price-import.md](../business%20rules/market-price-import.md)
|
||||||
- Requirement: distinguish business validation errors from file, parsing, and technical errors in the import result.
|
- Requirement: distinguish business validation errors from file, parsing, and technical errors in the import result.
|
||||||
- Current behavior: row errors are grouped under one `Errors` section.
|
- Current behavior: row errors are grouped under one `Errors` section.
|
||||||
- Expected code impact:
|
- Expected code impact:
|
||||||
@@ -78,3 +78,17 @@ Scope: code changes related only to `BR-PT-004 - Market Price Import`.
|
|||||||
- result message separates business validation errors from parsing/technical errors
|
- result message separates business validation errors from parsing/technical errors
|
||||||
- invalid workbook and missing required columns remain blocking `UserError`
|
- invalid workbook and missing required columns remain blocking `UserError`
|
||||||
- row-level errors still let the import continue
|
- row-level errors still let the import continue
|
||||||
|
|
||||||
|
## PT-BL-006 - Fix missing default currency on created price index
|
||||||
|
|
||||||
|
- Status: open
|
||||||
|
- Priority: high
|
||||||
|
- Source bug: [BUG-PT-001](../bugs.md#bug-pt-001---missing-default-currency-in-price-index-automatic-creation)
|
||||||
|
- Source rule: [business rules/market-price-import.md](../business%20rules/market-price-import.md)
|
||||||
|
- Requirement: when the market price import automatically creates a missing `price.price`, the created price index must have default currency `USD`.
|
||||||
|
- Current behavior: the created price index can miss the default currency even though the import specification expects `USD`.
|
||||||
|
- Expected code impact:
|
||||||
|
- `modules/purchase_trade/pricing.py`
|
||||||
|
- Expected tests:
|
||||||
|
- automatic price index creation assigns `price_currency` to the `USD` currency record
|
||||||
|
- if the `USD` currency record cannot be found, behavior remains aligned with the rule for optional default references
|
||||||
|
|||||||
63
modules/purchase_trade/docs/bugs.md
Normal file
63
modules/purchase_trade/docs/bugs.md
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
# Bugs - Purchase Trade
|
||||||
|
|
||||||
|
This file is the bug register for `purchase_trade`.
|
||||||
|
|
||||||
|
## Workflow
|
||||||
|
|
||||||
|
1. Register every new bug in this file with a stable bug ID.
|
||||||
|
2. Create a matching backlog entry for every new bug.
|
||||||
|
3. Link the bug entry to the backlog entry.
|
||||||
|
4. When fixed, record the implementation commit in the backlog entry.
|
||||||
|
5. Keep the bug entry as history and update its status.
|
||||||
|
|
||||||
|
## Status Values
|
||||||
|
|
||||||
|
- `reported`
|
||||||
|
- `confirmed`
|
||||||
|
- `backlog-created`
|
||||||
|
- `in-progress`
|
||||||
|
- `to-be-tested`
|
||||||
|
- `done`
|
||||||
|
- `rejected`
|
||||||
|
|
||||||
|
## Bug Template
|
||||||
|
|
||||||
|
```md
|
||||||
|
### BUG-PT-001 - Short title
|
||||||
|
|
||||||
|
- Status: `reported`
|
||||||
|
- Area:
|
||||||
|
- Reported date: `YYYY-MM-DD`
|
||||||
|
- Reported by:
|
||||||
|
- Related rule:
|
||||||
|
- Backlog entry:
|
||||||
|
- Severity:
|
||||||
|
- Environment:
|
||||||
|
- Description:
|
||||||
|
- Steps to reproduce:
|
||||||
|
- Expected behavior:
|
||||||
|
- Actual behavior:
|
||||||
|
- Evidence:
|
||||||
|
- Notes:
|
||||||
|
```
|
||||||
|
|
||||||
|
## Bugs
|
||||||
|
|
||||||
|
### BUG-PT-001 - Missing default currency in Price Index automatic creation
|
||||||
|
|
||||||
|
- Status: `backlog-created`
|
||||||
|
- Area: Market Price Import
|
||||||
|
- Reported date: `2026-05-08`
|
||||||
|
- Reported by: user
|
||||||
|
- Related rule: [BR-PT-004 - Market Price Import](business%20rules/market-price-import.md)
|
||||||
|
- Backlog entry: [PT-BL-006](backlog/market-price-import-backlog.md#pt-bl-006---fix-missing-default-currency-on-created-price-index)
|
||||||
|
- Severity:
|
||||||
|
- Environment:
|
||||||
|
- Description: during market price import, if a price index should be created, then the default currency defined to USD is missing.
|
||||||
|
- Steps to reproduce:
|
||||||
|
- import market prices with `Create price index if missing` enabled
|
||||||
|
- include a `price_index` that does not already exist
|
||||||
|
- Expected behavior: the automatically created `price.price` has default currency `USD`.
|
||||||
|
- Actual behavior: the automatically created `price.price` has no default currency.
|
||||||
|
- Evidence:
|
||||||
|
- Notes:
|
||||||
@@ -0,0 +1,448 @@
|
|||||||
|
# BR-PT-005 - Shipment Fee Allocation
|
||||||
|
|
||||||
|
## Intent
|
||||||
|
|
||||||
|
Allocate shipment costs by combining shipment-level fees and contract-level budgeted fees, while avoiding double counting and keeping fee detail rows available for BI analysis.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
- Domain: `purchase_trade`
|
||||||
|
- Target: SQL view/query for shipment fee allocation
|
||||||
|
- Source tables:
|
||||||
|
- `lot_lot`
|
||||||
|
- `lot_qt`
|
||||||
|
- `lot_qt_hist`
|
||||||
|
- `fee_fee`
|
||||||
|
- `product_product`
|
||||||
|
- `party_party`
|
||||||
|
- `currency_currency`
|
||||||
|
- `product_uom`
|
||||||
|
- Fee sources:
|
||||||
|
- shipment fees linked with `fee_fee.shipment_in`
|
||||||
|
- purchase contract fees linked with `fee_fee.line`
|
||||||
|
- sale contract fees linked with `fee_fee.sale_line`
|
||||||
|
|
||||||
|
## Business Context
|
||||||
|
|
||||||
|
Every purchase contract line has a virtual lot by default. The virtual lot represents the remaining quantity of the contract line.
|
||||||
|
|
||||||
|
When physical lots are created, their quantity reduces the virtual lot quantity. Physical lots represent confirmed physical quantities, typically once the Bill of Lading quantity is known.
|
||||||
|
|
||||||
|
Before the vessel is sailing or before the exact Bill of Lading quantity is known, costs can already be ordered or scheduled at shipment level. In that case, virtual shipment quantities must still be included as forecast quantities.
|
||||||
|
|
||||||
|
## Quantity Source Rules
|
||||||
|
|
||||||
|
Shipment quantity is built directly from lot and shipment tables.
|
||||||
|
|
||||||
|
Quantity priority:
|
||||||
|
|
||||||
|
1. Use physical lots linked to the shipment when they exist.
|
||||||
|
2. Use virtual lot shipment quantities only when no physical lot exists yet for the same shipment and contract pair.
|
||||||
|
|
||||||
|
This prevents double counting:
|
||||||
|
|
||||||
|
- physical lots represent confirmed shipment quantities
|
||||||
|
- virtual lots represent forecast/open quantities until physical lots exist
|
||||||
|
|
||||||
|
## Fee Selection Rules
|
||||||
|
|
||||||
|
For each `shipment_id + product_id + supplier_id` pair:
|
||||||
|
|
||||||
|
1. Use shipment-level fees of type `ordered` first.
|
||||||
|
2. If shipment quantity remains uncovered, use shipment-level fees of type `scheduled`.
|
||||||
|
3. If shipment quantity still remains uncovered, use contract-level fees of type `budgeted`.
|
||||||
|
|
||||||
|
Contract-level fallback fees:
|
||||||
|
|
||||||
|
- purchase contract fees are eligible
|
||||||
|
- sale contract fees are eligible
|
||||||
|
- only `type = 'budgeted'` is eligible
|
||||||
|
- budgeted contract fees are applied to the remaining uncovered shipment quantity
|
||||||
|
|
||||||
|
Shipment-level fees:
|
||||||
|
|
||||||
|
- only `type IN ('ordered', 'scheduled')` are eligible
|
||||||
|
- null fee quantity is treated as `0` and does not allocate quantity
|
||||||
|
- allocated shipment fee quantity is capped to the shipment quantity
|
||||||
|
|
||||||
|
If multiple fees exist for the same product/supplier pair at the selected level, keep multiple rows. The view must preserve details for analysis.
|
||||||
|
|
||||||
|
## Sign Rules
|
||||||
|
|
||||||
|
Use the same sign logic as the existing fee utility views.
|
||||||
|
|
||||||
|
Shipment fees:
|
||||||
|
|
||||||
|
- `rec` = `+1`
|
||||||
|
- any other `p_r` value = `-1`
|
||||||
|
|
||||||
|
Purchase contract budgeted fees:
|
||||||
|
|
||||||
|
- `rec` = `-1`
|
||||||
|
- any other `p_r` value = `+1`
|
||||||
|
|
||||||
|
Sale contract budgeted fees:
|
||||||
|
|
||||||
|
- `rec` = `+1`
|
||||||
|
- any other `p_r` value = `-1`
|
||||||
|
|
||||||
|
## Expected Behavior
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
- Shipment quantity: `1000 Mt`
|
||||||
|
- Shipment ordered freight: `800 Mt` at `60 USD/Mt`
|
||||||
|
- Contract budgeted freight: `50 USD/Mt`
|
||||||
|
|
||||||
|
Expected output:
|
||||||
|
|
||||||
|
- `800 Mt` at `60 USD/Mt` from shipment ordered fee
|
||||||
|
- `200 Mt` at `50 USD/Mt` from contract budgeted fee
|
||||||
|
|
||||||
|
If a scheduled fee also exists:
|
||||||
|
|
||||||
|
- Shipment quantity: `1000 Mt`
|
||||||
|
- Ordered freight: `800 Mt` at `60 USD/Mt`
|
||||||
|
- Scheduled freight: `150 Mt` at `55 USD/Mt`
|
||||||
|
- Contract budgeted freight: `50 USD/Mt`
|
||||||
|
|
||||||
|
Expected output:
|
||||||
|
|
||||||
|
- `800 Mt` at `60 USD/Mt` from shipment ordered fee
|
||||||
|
- `150 Mt` at `55 USD/Mt` from shipment scheduled fee
|
||||||
|
- `50 Mt` at `50 USD/Mt` from contract budgeted fee
|
||||||
|
|
||||||
|
## Query Draft
|
||||||
|
|
||||||
|
```sql
|
||||||
|
WITH physical_shipment_lots AS (
|
||||||
|
SELECT
|
||||||
|
l.lot_shipment_in AS shipment_id,
|
||||||
|
l.id AS lot_id,
|
||||||
|
l.lot_type,
|
||||||
|
l.line AS purchase_line_id,
|
||||||
|
l.sale_line AS sale_line_id,
|
||||||
|
qh.quantity AS shipment_quantity,
|
||||||
|
l.lot_unit_line AS shipment_unit_id
|
||||||
|
FROM lot_lot l
|
||||||
|
LEFT JOIN lot_qt_hist qh
|
||||||
|
ON qh.lot = l.id
|
||||||
|
AND qh.quantity_type = l.lot_state
|
||||||
|
WHERE l.lot_type = 'physic'
|
||||||
|
AND l.lot_shipment_in IS NOT NULL
|
||||||
|
),
|
||||||
|
virtual_shipment_lots AS (
|
||||||
|
SELECT
|
||||||
|
q.lot_shipment_in AS shipment_id,
|
||||||
|
vp.id AS lot_id,
|
||||||
|
vp.lot_type,
|
||||||
|
vp.line AS purchase_line_id,
|
||||||
|
COALESCE(vp.sale_line, ps.sale_line) AS sale_line_id,
|
||||||
|
q.lot_quantity AS shipment_quantity,
|
||||||
|
q.lot_unit AS shipment_unit_id
|
||||||
|
FROM lot_qt q
|
||||||
|
JOIN lot_lot vp
|
||||||
|
ON vp.id = q.lot_p
|
||||||
|
AND vp.lot_type = 'virtual'
|
||||||
|
LEFT JOIN lot_lot ps
|
||||||
|
ON ps.id = q.lot_s
|
||||||
|
WHERE q.lot_shipment_in IS NOT NULL
|
||||||
|
AND NOT EXISTS (
|
||||||
|
SELECT 1
|
||||||
|
FROM physical_shipment_lots pl
|
||||||
|
WHERE pl.shipment_id = q.lot_shipment_in
|
||||||
|
AND pl.purchase_line_id = vp.line
|
||||||
|
AND (
|
||||||
|
pl.sale_line_id = COALESCE(vp.sale_line, ps.sale_line)
|
||||||
|
OR COALESCE(vp.sale_line, ps.sale_line) IS NULL
|
||||||
|
)
|
||||||
|
)
|
||||||
|
),
|
||||||
|
shipment_lots AS (
|
||||||
|
SELECT * FROM physical_shipment_lots
|
||||||
|
UNION ALL
|
||||||
|
SELECT * FROM virtual_shipment_lots
|
||||||
|
),
|
||||||
|
shipment_context AS (
|
||||||
|
SELECT
|
||||||
|
shipment_id,
|
||||||
|
purchase_line_id,
|
||||||
|
sale_line_id,
|
||||||
|
shipment_unit_id,
|
||||||
|
SUM(COALESCE(shipment_quantity, 0)) AS shipment_quantity
|
||||||
|
FROM shipment_lots
|
||||||
|
WHERE shipment_id IS NOT NULL
|
||||||
|
GROUP BY
|
||||||
|
shipment_id,
|
||||||
|
purchase_line_id,
|
||||||
|
sale_line_id,
|
||||||
|
shipment_unit_id
|
||||||
|
),
|
||||||
|
shipment_base AS (
|
||||||
|
SELECT
|
||||||
|
shipment_id,
|
||||||
|
SUM(shipment_quantity) AS shipment_quantity
|
||||||
|
FROM shipment_context
|
||||||
|
GROUP BY shipment_id
|
||||||
|
),
|
||||||
|
shipment_fee_candidates AS (
|
||||||
|
SELECT
|
||||||
|
f.id AS fee_id,
|
||||||
|
'Shipment' AS fee_source,
|
||||||
|
f.type AS fee_type,
|
||||||
|
CASE
|
||||||
|
WHEN f.type = 'ordered' THEN 1
|
||||||
|
WHEN f.type = 'scheduled' THEN 2
|
||||||
|
END AS priority,
|
||||||
|
sb.shipment_id,
|
||||||
|
NULL::integer AS purchase_line_id,
|
||||||
|
NULL::integer AS sale_line_id,
|
||||||
|
f.product AS product_id,
|
||||||
|
f.supplier AS supplier_id,
|
||||||
|
f.mode AS packaging,
|
||||||
|
f.p_r AS pay_or_rec,
|
||||||
|
f.state,
|
||||||
|
f.weight_type,
|
||||||
|
COALESCE(f.quantity, 0) AS requested_quantity,
|
||||||
|
sb.shipment_quantity,
|
||||||
|
f.price AS fee_price,
|
||||||
|
f.currency AS currency_id,
|
||||||
|
f.unit AS unit_id,
|
||||||
|
CASE
|
||||||
|
WHEN upper(f.p_r::text) = 'REC' THEN 1
|
||||||
|
ELSE -1
|
||||||
|
END AS sign_multiplier
|
||||||
|
FROM shipment_base sb
|
||||||
|
JOIN fee_fee f
|
||||||
|
ON f.shipment_in = sb.shipment_id
|
||||||
|
WHERE f.type IN ('ordered', 'scheduled')
|
||||||
|
),
|
||||||
|
shipment_fee_allocated AS (
|
||||||
|
SELECT
|
||||||
|
c.*,
|
||||||
|
LEAST(
|
||||||
|
c.requested_quantity,
|
||||||
|
GREATEST(
|
||||||
|
c.shipment_quantity
|
||||||
|
- COALESCE(
|
||||||
|
SUM(c.requested_quantity) OVER (
|
||||||
|
PARTITION BY c.shipment_id, c.product_id, c.supplier_id
|
||||||
|
ORDER BY c.priority, c.fee_id
|
||||||
|
ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING
|
||||||
|
),
|
||||||
|
0
|
||||||
|
),
|
||||||
|
0
|
||||||
|
)
|
||||||
|
) AS allocated_quantity
|
||||||
|
FROM shipment_fee_candidates c
|
||||||
|
),
|
||||||
|
shipment_fee_coverage AS (
|
||||||
|
SELECT
|
||||||
|
shipment_id,
|
||||||
|
product_id,
|
||||||
|
supplier_id,
|
||||||
|
MAX(shipment_quantity) AS shipment_quantity,
|
||||||
|
SUM(allocated_quantity) AS allocated_quantity
|
||||||
|
FROM shipment_fee_allocated
|
||||||
|
GROUP BY shipment_id, product_id, supplier_id
|
||||||
|
),
|
||||||
|
contract_budgeted_fee_candidates AS (
|
||||||
|
SELECT
|
||||||
|
f.id AS fee_id,
|
||||||
|
'Purchase Contract' AS fee_source,
|
||||||
|
f.type AS fee_type,
|
||||||
|
3 AS priority,
|
||||||
|
sc.shipment_id,
|
||||||
|
sc.purchase_line_id,
|
||||||
|
NULL::integer AS sale_line_id,
|
||||||
|
f.product AS product_id,
|
||||||
|
f.supplier AS supplier_id,
|
||||||
|
f.mode AS packaging,
|
||||||
|
f.p_r AS pay_or_rec,
|
||||||
|
f.state,
|
||||||
|
f.weight_type,
|
||||||
|
sc.shipment_quantity,
|
||||||
|
f.price AS fee_price,
|
||||||
|
f.currency AS currency_id,
|
||||||
|
COALESCE(f.unit, sc.shipment_unit_id) AS unit_id,
|
||||||
|
CASE
|
||||||
|
WHEN upper(f.p_r::text) = 'REC' THEN -1
|
||||||
|
ELSE 1
|
||||||
|
END AS sign_multiplier
|
||||||
|
FROM shipment_context sc
|
||||||
|
JOIN fee_fee f
|
||||||
|
ON f.line = sc.purchase_line_id
|
||||||
|
WHERE f.type = 'budgeted'
|
||||||
|
AND sc.purchase_line_id IS NOT NULL
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
f.id AS fee_id,
|
||||||
|
'Sale Contract' AS fee_source,
|
||||||
|
f.type AS fee_type,
|
||||||
|
3 AS priority,
|
||||||
|
sc.shipment_id,
|
||||||
|
NULL::integer AS purchase_line_id,
|
||||||
|
sc.sale_line_id,
|
||||||
|
f.product AS product_id,
|
||||||
|
f.supplier AS supplier_id,
|
||||||
|
f.mode AS packaging,
|
||||||
|
f.p_r AS pay_or_rec,
|
||||||
|
f.state,
|
||||||
|
f.weight_type,
|
||||||
|
sc.shipment_quantity,
|
||||||
|
f.price AS fee_price,
|
||||||
|
f.currency AS currency_id,
|
||||||
|
COALESCE(f.unit, sc.shipment_unit_id) AS unit_id,
|
||||||
|
CASE
|
||||||
|
WHEN upper(f.p_r::text) = 'REC' THEN 1
|
||||||
|
ELSE -1
|
||||||
|
END AS sign_multiplier
|
||||||
|
FROM shipment_context sc
|
||||||
|
JOIN fee_fee f
|
||||||
|
ON f.sale_line = sc.sale_line_id
|
||||||
|
WHERE f.type = 'budgeted'
|
||||||
|
AND sc.sale_line_id IS NOT NULL
|
||||||
|
),
|
||||||
|
contract_budgeted_allocated AS (
|
||||||
|
SELECT
|
||||||
|
c.*,
|
||||||
|
GREATEST(
|
||||||
|
c.shipment_quantity - COALESCE(fc.allocated_quantity, 0),
|
||||||
|
0
|
||||||
|
) AS allocated_quantity
|
||||||
|
FROM contract_budgeted_fee_candidates c
|
||||||
|
LEFT JOIN shipment_fee_coverage fc
|
||||||
|
ON fc.shipment_id = c.shipment_id
|
||||||
|
AND fc.product_id = c.product_id
|
||||||
|
AND fc.supplier_id = c.supplier_id
|
||||||
|
),
|
||||||
|
final_fees AS (
|
||||||
|
SELECT
|
||||||
|
fee_id,
|
||||||
|
fee_source,
|
||||||
|
fee_type,
|
||||||
|
priority,
|
||||||
|
shipment_id,
|
||||||
|
purchase_line_id,
|
||||||
|
sale_line_id,
|
||||||
|
product_id,
|
||||||
|
supplier_id,
|
||||||
|
packaging,
|
||||||
|
pay_or_rec,
|
||||||
|
state,
|
||||||
|
weight_type,
|
||||||
|
allocated_quantity AS fee_quantity,
|
||||||
|
fee_price,
|
||||||
|
currency_id,
|
||||||
|
unit_id,
|
||||||
|
sign_multiplier
|
||||||
|
FROM shipment_fee_allocated
|
||||||
|
WHERE allocated_quantity > 0
|
||||||
|
|
||||||
|
UNION ALL
|
||||||
|
|
||||||
|
SELECT
|
||||||
|
fee_id,
|
||||||
|
fee_source,
|
||||||
|
fee_type,
|
||||||
|
priority,
|
||||||
|
shipment_id,
|
||||||
|
purchase_line_id,
|
||||||
|
sale_line_id,
|
||||||
|
product_id,
|
||||||
|
supplier_id,
|
||||||
|
packaging,
|
||||||
|
pay_or_rec,
|
||||||
|
state,
|
||||||
|
weight_type,
|
||||||
|
allocated_quantity AS fee_quantity,
|
||||||
|
fee_price,
|
||||||
|
currency_id,
|
||||||
|
unit_id,
|
||||||
|
sign_multiplier
|
||||||
|
FROM contract_budgeted_allocated
|
||||||
|
WHERE allocated_quantity > 0
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
f.shipment_id AS "intShipmentId",
|
||||||
|
f.fee_id AS "intFeeId",
|
||||||
|
f.fee_source AS "Fee Source",
|
||||||
|
f.fee_type AS "Fee Type",
|
||||||
|
f.priority AS "Priority",
|
||||||
|
f.purchase_line_id AS "intPurchaseLineId",
|
||||||
|
f.sale_line_id AS "intSaleLineId",
|
||||||
|
f.product_id AS "intProductId",
|
||||||
|
p.code AS "Fee",
|
||||||
|
f.supplier_id AS "intSupplierId",
|
||||||
|
sup.name AS "Supplier",
|
||||||
|
f.packaging AS "Packaging",
|
||||||
|
f.pay_or_rec AS "Pay or Rec",
|
||||||
|
f.state AS "State",
|
||||||
|
CASE
|
||||||
|
WHEN upper(f.weight_type::text) = 'BRUT' THEN 'Gross'
|
||||||
|
ELSE 'Net'
|
||||||
|
END AS "Weighing Type",
|
||||||
|
f.fee_quantity AS "Quantity",
|
||||||
|
f.fee_price * f.sign_multiplier AS "Price",
|
||||||
|
cur.name AS "Currency",
|
||||||
|
COALESCE(uom.name, 'Mt') AS "Unit",
|
||||||
|
f.fee_quantity * f.fee_price * f.sign_multiplier AS "Amount",
|
||||||
|
CASE
|
||||||
|
WHEN upper(p.code::text) LIKE '%FREIGHT%' THEN 'Freight'
|
||||||
|
WHEN upper(p.code::text) LIKE '%PROFIT SHARING%' THEN 'Profit Sharing'
|
||||||
|
ELSE 'Other Costs'
|
||||||
|
END AS "Cost Group"
|
||||||
|
FROM final_fees f
|
||||||
|
JOIN product_product p
|
||||||
|
ON p.id = f.product_id
|
||||||
|
JOIN party_party sup
|
||||||
|
ON sup.id = f.supplier_id
|
||||||
|
LEFT JOIN currency_currency cur
|
||||||
|
ON cur.id = f.currency_id
|
||||||
|
LEFT JOIN product_uom uom
|
||||||
|
ON uom.id = f.unit_id
|
||||||
|
ORDER BY
|
||||||
|
f.shipment_id,
|
||||||
|
f.product_id,
|
||||||
|
f.supplier_id,
|
||||||
|
f.priority,
|
||||||
|
f.fee_id;
|
||||||
|
```
|
||||||
|
|
||||||
|
## Impacted Files
|
||||||
|
|
||||||
|
Expected SQL/view impact:
|
||||||
|
|
||||||
|
- BI SQL view or migration file that will materialize the shipment fee allocation query
|
||||||
|
- Existing related views for comparison:
|
||||||
|
- `vw_utility_contract_fees`
|
||||||
|
- `vw_utility_shipment_fees`
|
||||||
|
- `vw_bi_itsa_fct_contract_fees`
|
||||||
|
- `vw_bi_itsa_fct_shipment_fees`
|
||||||
|
|
||||||
|
No Python code impact is expected unless the view is generated by module migration code.
|
||||||
|
|
||||||
|
## Tests
|
||||||
|
|
||||||
|
Recommended tests:
|
||||||
|
|
||||||
|
- shipment with no ordered/scheduled fee uses full budgeted contract fee quantity
|
||||||
|
- shipment with ordered fee covering full quantity does not use budgeted fallback
|
||||||
|
- shipment with ordered fee partially covering quantity uses budgeted fallback for remaining quantity
|
||||||
|
- shipment with ordered and scheduled fees uses ordered first, scheduled second, budgeted third
|
||||||
|
- shipment fee quantity above shipment quantity is capped
|
||||||
|
- null shipment fee quantity does not allocate quantity
|
||||||
|
- multiple fees at the same priority are kept as multiple detail rows
|
||||||
|
- physical lot quantity replaces virtual forecast quantity for the same shipment/contract pair
|
||||||
|
- virtual lot quantity is used when no physical lot exists yet
|
||||||
|
|
||||||
|
## Open Questions
|
||||||
|
|
||||||
|
- Q: Should this query become a permanent PostgreSQL view?
|
||||||
|
|
||||||
|
- Q: What should the final view name be?
|
||||||
|
|
||||||
|
- Q: Should the output include both allocated quantity and original fee quantity for auditability?
|
||||||
@@ -3,8 +3,8 @@
|
|||||||
Statut: `draft`
|
Statut: `draft`
|
||||||
Version: `v0.3`
|
Version: `v0.3`
|
||||||
Derniere mise a jour: `2026-05-07`
|
Derniere mise a jour: `2026-05-07`
|
||||||
Owner metier: `a completer`
|
Owner metier: `Open Squared`
|
||||||
Owner technique: `a completer`
|
Owner technique: `Open Squared`
|
||||||
|
|
||||||
## 1) Scope
|
## 1) Scope
|
||||||
|
|
||||||
@@ -30,16 +30,17 @@ Owner technique: `a completer`
|
|||||||
|
|
||||||
| ID | Titre | Domaine | Detail |
|
| ID | Titre | Domaine | Detail |
|
||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| BR-PT-001 | Ajustement de la quantite theorique apres creation du contrat | Lot / Purchase | [rules/lot-quantity.md](rules/lot-quantity.md) |
|
| BR-PT-001 | Ajustement de la quantite theorique apres creation du contrat | Lot / Purchase | [business rules/lot-quantity.md](business%20rules/lot-quantity.md) |
|
||||||
| BR-PT-002 | Le lot physique est le pont metier entre purchase, sale et shipment | Lot / Navigation | [rules/lot-navigation.md](rules/lot-navigation.md) |
|
| BR-PT-002 | Le lot physique est le pont metier entre purchase, sale et shipment | Lot / Navigation | [business rules/lot-navigation.md](business%20rules/lot-navigation.md) |
|
||||||
| BR-PT-003 | Le freight amount des templates facture vient du fee de shipment | Invoice / Freight | [rules/invoice-freight.md](rules/invoice-freight.md) |
|
| BR-PT-003 | Le freight amount des templates facture vient du fee de shipment | Invoice / Freight | [business rules/invoice-freight.md](business%20rules/invoice-freight.md) |
|
||||||
| BR-PT-004 | Market Price Import | Pricing | [rules/market-price-import.md](rules/market-price-import.md) |
|
| BR-PT-004 | Market Price Import | Pricing | [business rules/market-price-import.md](business%20rules/market-price-import.md) |
|
||||||
|
| BR-PT-005 | Shipment Fee Allocation | Shipment / Fees | [business rules/shipment_fee_allocation.md](business%20rules/shipment_fee_allocation.md) |
|
||||||
|
|
||||||
## 4) Convention pour les nouvelles regles
|
## 4) Convention pour les nouvelles regles
|
||||||
|
|
||||||
Voir aussi [documentation-management.md](documentation-management.md) pour le workflow complet de gestion documentaire.
|
Voir aussi [documentation-management.md](documentation-management.md) pour le workflow complet de gestion documentaire.
|
||||||
|
|
||||||
Ajouter une ligne au catalogue puis creer une fiche detaillee dans `docs/rules/`.
|
Ajouter une ligne au catalogue puis creer une fiche detaillee dans `docs/business rules/`.
|
||||||
|
|
||||||
Structure recommandee:
|
Structure recommandee:
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ This guide records the documentation workflow to apply for future `purchase_trad
|
|||||||
## Rule Documentation Structure
|
## Rule Documentation Structure
|
||||||
|
|
||||||
- Keep `business-rules.md` as the entry point and rule catalog.
|
- Keep `business-rules.md` as the entry point and rule catalog.
|
||||||
- Store detailed business rules in `docs/rules/`, one file per substantial rule.
|
- Store detailed business rules in `docs/business rules/`, one file per substantial rule.
|
||||||
- Use stable business rule IDs such as `BR-PT-004`.
|
- Use stable business rule IDs such as `BR-PT-004`.
|
||||||
- Add every new detailed rule to the catalog in `business-rules.md`.
|
- Add every new detailed rule to the catalog in `business-rules.md`.
|
||||||
- Keep rule files focused on business behavior, expected outcomes, edge cases, impacted files, tests, and open questions.
|
- Keep rule files focused on business behavior, expected outcomes, edge cases, impacted files, tests, and open questions.
|
||||||
@@ -41,6 +41,8 @@ Example:
|
|||||||
- Comment: current code allows empty `price_value`. Implementing this answer requires a code change.
|
- Comment: current code allows empty `price_value`. Implementing this answer requires a code change.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Backlog From Documentation
|
## Backlog From Documentation
|
||||||
|
|
||||||
- When answered questions imply code changes, create a dedicated backlog file for the feature or rule.
|
- When answered questions imply code changes, create a dedicated backlog file for the feature or rule.
|
||||||
@@ -62,6 +64,35 @@ Example:
|
|||||||
- expected code impact
|
- expected code impact
|
||||||
- expected tests
|
- expected tests
|
||||||
|
|
||||||
|
Backlog status values:
|
||||||
|
|
||||||
|
- `open`: identified, not started yet
|
||||||
|
- `in-progress`: currently being worked on
|
||||||
|
- `blocked`: cannot progress until a dependency or question is resolved
|
||||||
|
- `implemented`: code or documentation change made, not yet validated
|
||||||
|
- `to-be-tested`: implemented and waiting for targeted validation in the right environment
|
||||||
|
- `tested`: targeted validation passed
|
||||||
|
- `done`: tested, committed, and no further action expected
|
||||||
|
- `rejected`: intentionally not implemented
|
||||||
|
|
||||||
|
Default workflow:
|
||||||
|
|
||||||
|
```text
|
||||||
|
open -> in-progress -> to-be-tested -> tested -> done
|
||||||
|
```
|
||||||
|
|
||||||
|
Use `implemented` only when the change is made but no validation attempt has happened yet. Use `to-be-tested` when validation must happen in another environment or could not be completed locally.
|
||||||
|
|
||||||
|
## Bug Management
|
||||||
|
|
||||||
|
- Register every new bug in `docs/bugs.md`.
|
||||||
|
- Use stable bug IDs such as `BUG-PT-001`.
|
||||||
|
- Every new bug must have a matching backlog entry.
|
||||||
|
- Link the bug entry to its backlog entry.
|
||||||
|
- If the bug belongs to an existing feature backlog, add it there.
|
||||||
|
- If the bug does not clearly belong to an existing feature backlog, create a dedicated backlog file under `docs/backlog/`.
|
||||||
|
- When the bug is fixed, record the implementation commit in the backlog entry and update the bug status.
|
||||||
|
|
||||||
## Review Workflow
|
## Review Workflow
|
||||||
|
|
||||||
For future development work:
|
For future development work:
|
||||||
|
|||||||
322
modules/purchase_trade/docs/documentation-structure-summary.html
Normal file
322
modules/purchase_trade/docs/documentation-structure-summary.html
Normal file
@@ -0,0 +1,322 @@
|
|||||||
|
<!doctype html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>Structure documentaire Markdown - purchase_trade</title>
|
||||||
|
<style>
|
||||||
|
@page {
|
||||||
|
size: A4;
|
||||||
|
margin: 18mm 16mm;
|
||||||
|
}
|
||||||
|
body {
|
||||||
|
color: #172033;
|
||||||
|
font-family: "Segoe UI", Arial, sans-serif;
|
||||||
|
font-size: 11px;
|
||||||
|
line-height: 1.42;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: #0f2742;
|
||||||
|
font-size: 25px;
|
||||||
|
line-height: 1.1;
|
||||||
|
margin: 0 0 6px;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
border-bottom: 2px solid #d8e2ef;
|
||||||
|
color: #18466f;
|
||||||
|
font-size: 16px;
|
||||||
|
margin: 22px 0 8px;
|
||||||
|
padding-bottom: 4px;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
color: #1f5c8f;
|
||||||
|
font-size: 13px;
|
||||||
|
margin: 13px 0 4px;
|
||||||
|
}
|
||||||
|
p {
|
||||||
|
margin: 5px 0;
|
||||||
|
}
|
||||||
|
code {
|
||||||
|
background: #eef3f8;
|
||||||
|
border-radius: 3px;
|
||||||
|
color: #0f3a5f;
|
||||||
|
font-family: Consolas, monospace;
|
||||||
|
font-size: 10px;
|
||||||
|
padding: 1px 3px;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin: 8px 0 12px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
th, td {
|
||||||
|
border: 1px solid #d4dde8;
|
||||||
|
padding: 6px 7px;
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background: #eaf2fb;
|
||||||
|
color: #14395a;
|
||||||
|
font-weight: 650;
|
||||||
|
}
|
||||||
|
ul {
|
||||||
|
margin: 5px 0 10px 18px;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
li {
|
||||||
|
margin: 3px 0;
|
||||||
|
}
|
||||||
|
.subtitle {
|
||||||
|
color: #5b6b7f;
|
||||||
|
font-size: 12px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
.callout {
|
||||||
|
background: #f4f8fc;
|
||||||
|
border-left: 4px solid #2d78b7;
|
||||||
|
margin: 9px 0 12px;
|
||||||
|
padding: 8px 10px;
|
||||||
|
}
|
||||||
|
.warning {
|
||||||
|
background: #fff7e8;
|
||||||
|
border-left-color: #d98718;
|
||||||
|
}
|
||||||
|
.ok {
|
||||||
|
background: #edf8f0;
|
||||||
|
border-left-color: #329c50;
|
||||||
|
}
|
||||||
|
.tree {
|
||||||
|
background: #f7f9fb;
|
||||||
|
border: 1px solid #dce5ee;
|
||||||
|
border-radius: 4px;
|
||||||
|
font-family: Consolas, monospace;
|
||||||
|
font-size: 10px;
|
||||||
|
padding: 9px 11px;
|
||||||
|
white-space: pre-wrap;
|
||||||
|
}
|
||||||
|
.page-break {
|
||||||
|
break-before: page;
|
||||||
|
}
|
||||||
|
.small {
|
||||||
|
color: #5b6b7f;
|
||||||
|
font-size: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Structure documentaire Markdown - purchase_trade</h1>
|
||||||
|
<p class="subtitle">Document recapitulatif de la structure mise en place pour les regles metier, bugs, backlogs et gestion documentaire.</p>
|
||||||
|
|
||||||
|
<div class="callout">
|
||||||
|
<strong>Objectif general.</strong>
|
||||||
|
La documentation est organisee pour separer les regles metier, les bugs, les backlogs d'implementation et les conventions de gestion. L'objectif est de garder un contexte lisible pour les humains et chargeable a la demande pour les agents.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>1. Arborescence Markdown</h2>
|
||||||
|
<div class="tree">modules/purchase_trade/docs/
|
||||||
|
business-rules.md
|
||||||
|
documentation-management.md
|
||||||
|
bugs.md
|
||||||
|
template-rules.md
|
||||||
|
business rules/
|
||||||
|
lot-quantity.md
|
||||||
|
lot-navigation.md
|
||||||
|
invoice-freight.md
|
||||||
|
market-price-import.md
|
||||||
|
backlog/
|
||||||
|
market-price-import-backlog.md</div>
|
||||||
|
|
||||||
|
<h2>2. Role et description des fichiers</h2>
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Fichier</th>
|
||||||
|
<th>Role</th>
|
||||||
|
<th>Description</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><code>business-rules.md</code></td>
|
||||||
|
<td>Catalogue des regles metier</td>
|
||||||
|
<td>Point d'entree des regles <code>purchase_trade</code>. Contient le scope, le glossaire, le catalogue des IDs <code>BR-PT-xxx</code> et les liens vers les fiches detaillees.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>documentation-management.md</code></td>
|
||||||
|
<td>Regles de gestion documentaire</td>
|
||||||
|
<td>Decrit le workflow: creation de regles, questions ouvertes <code>Q:</code>/<code>A:</code>, backlogs, bugs, statuts, commits de reference et discipline de scope.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>bugs.md</code></td>
|
||||||
|
<td>Registre des bugs</td>
|
||||||
|
<td>Lieu d'enregistrement initial des bugs avec ID stable <code>BUG-PT-xxx</code>. Chaque bug doit etre relie a une entree backlog.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>template-rules.md</code></td>
|
||||||
|
<td>Regles specifiques aux templates</td>
|
||||||
|
<td>Guide de correction et d'analyse des templates Relatorio/FODT, notamment les ponts Python, les placeholders XML et le cache des reports facture.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>business rules/lot-quantity.md</code></td>
|
||||||
|
<td>Regle detaillee BR-PT-001</td>
|
||||||
|
<td>Specifie l'ajustement de <code>quantity_theorical</code>, la synchronisation du lot virtuel et des quantites ouvertes <code>lot.qt</code>.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>business rules/lot-navigation.md</code></td>
|
||||||
|
<td>Regle detaillee BR-PT-002</td>
|
||||||
|
<td>Documente le lot physique comme pont stable entre purchase, sale, shipment et facture.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>business rules/invoice-freight.md</code></td>
|
||||||
|
<td>Regle detaillee BR-PT-003</td>
|
||||||
|
<td>Definit que le <code>FREIGHT VALUE</code> des factures vient du fee de shipment <code>Maritime freight</code>, via le lot physique.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>business rules/market-price-import.md</code></td>
|
||||||
|
<td>Regle detaillee BR-PT-004</td>
|
||||||
|
<td>Specifie l'import de prix marche depuis Excel: colonnes attendues, parsing, creation d'index, resultats, edge cases et questions tranchees.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>backlog/market-price-import-backlog.md</code></td>
|
||||||
|
<td>Backlog feature Market Price Import</td>
|
||||||
|
<td>Liste les travaux issus de BR-PT-004 et des bugs associes, avec statut, priorite, source, impact code, tests attendus et commit d'implementation si applicable.</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h2>3. Workflow recommande</h2>
|
||||||
|
<h3>Nouvelle regle metier</h3>
|
||||||
|
<ul>
|
||||||
|
<li>Ajouter une ligne dans <code>business-rules.md</code>.</li>
|
||||||
|
<li>Creer une fiche dediee dans <code>business rules/</code> si la regle a des impacts code, tests, edge cases ou questions.</li>
|
||||||
|
<li>Utiliser des questions <code>Q:</code> et reponses <code>A:</code>; ajouter <code>Comment:</code> si la decision implique un changement code.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Nouveau bug</h3>
|
||||||
|
<ul>
|
||||||
|
<li>Creer une entree dans <code>bugs.md</code> avec un ID stable <code>BUG-PT-xxx</code>.</li>
|
||||||
|
<li>Creer une entree backlog correspondante, soit dans un backlog existant, soit dans un nouveau fichier sous <code>backlog/</code>.</li>
|
||||||
|
<li>Lier le bug au backlog et le backlog au bug.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h3>Implementation</h3>
|
||||||
|
<ul>
|
||||||
|
<li>Passer le backlog de <code>open</code> a <code>in-progress</code>, puis <code>to-be-tested</code> apres implementation.</li>
|
||||||
|
<li>Documenter le travail realise et le statut de validation.</li>
|
||||||
|
<li>Apres commit, enregistrer le hash du commit dans l'entree backlog.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>4. Avantages</h2>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Traçabilite.</strong> Les decisions metier, bugs, backlogs, tests et commits sont relies.</li>
|
||||||
|
<li><strong>Scope clair.</strong> Un agent peut charger seulement le fichier pertinent au lieu de tout lire.</li>
|
||||||
|
<li><strong>Meilleure maintenance.</strong> Les regles lourdes vivent dans des fiches dediees; le catalogue reste court.</li>
|
||||||
|
<li><strong>Priorisation explicite.</strong> Le backlog garde statut, priorite, tests attendus et validation.</li>
|
||||||
|
<li><strong>Historique de decision.</strong> Les sections <code>Open Questions</code> gardent les arbitrages <code>Q:</code>/<code>A:</code>.</li>
|
||||||
|
<li><strong>Support bug propre.</strong> Chaque bug a un ID stable et une entree backlog obligatoire.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h2>5. Inconvenients / points de vigilance</h2>
|
||||||
|
<ul>
|
||||||
|
<li><strong>Discipline necessaire.</strong> Il faut maintenir les liens et les statuts, sinon la structure perd de sa valeur.</li>
|
||||||
|
<li><strong>Risque de fragmentation.</strong> Trop de petits fichiers peuvent ralentir la comprehension si le catalogue n'est pas tenu a jour.</li>
|
||||||
|
<li><strong>Noms avec espaces.</strong> Le dossier <code>business rules/</code> est lisible, mais les liens Markdown doivent utiliser <code>business%20rules</code> dans les URLs.</li>
|
||||||
|
<li><strong>Backlog a synchroniser.</strong> Une correction code doit etre reportee dans le backlog, notamment le statut et le commit.</li>
|
||||||
|
<li><strong>Duplication possible.</strong> Certaines informations peuvent apparaitre dans regle, bug et backlog; il faut garder chaque fichier dans son role.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<div class="page-break"></div>
|
||||||
|
<h2>6. Estimation de consommation tokens</h2>
|
||||||
|
<p>Estimation basee sur la regle pratique de l'image fournie: <strong>1 KB ≈ 200 tokens</strong>.</p>
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>Fichier</th>
|
||||||
|
<th>Taille approx.</th>
|
||||||
|
<th>Tokens approx.</th>
|
||||||
|
<th>Usage conseille</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td><code>backlog/market-price-import-backlog.md</code></td>
|
||||||
|
<td>4.70 KB</td>
|
||||||
|
<td>~939</td>
|
||||||
|
<td>Charger pour prioriser ou coder un item Market Price Import.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>bugs.md</code></td>
|
||||||
|
<td>1.67 KB</td>
|
||||||
|
<td>~333</td>
|
||||||
|
<td>Charger au moment de declarer ou suivre un bug.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>business rules/invoice-freight.md</code></td>
|
||||||
|
<td>1.49 KB</td>
|
||||||
|
<td>~298</td>
|
||||||
|
<td>Charger pour les sujets freight/facture.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>business rules/lot-navigation.md</code></td>
|
||||||
|
<td>1.84 KB</td>
|
||||||
|
<td>~369</td>
|
||||||
|
<td>Charger pour les chemins achat/vente/shipment.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>business rules/lot-quantity.md</code></td>
|
||||||
|
<td>2.87 KB</td>
|
||||||
|
<td>~574</td>
|
||||||
|
<td>Charger pour les changements de quantite theorique.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>business rules/market-price-import.md</code></td>
|
||||||
|
<td>6.21 KB</td>
|
||||||
|
<td>~1 242</td>
|
||||||
|
<td>Charger pour comprendre la specification complete de l'import.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>business-rules.md</code></td>
|
||||||
|
<td>2.21 KB</td>
|
||||||
|
<td>~441</td>
|
||||||
|
<td>Charger comme index de depart.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>documentation-management.md</code></td>
|
||||||
|
<td>4.47 KB</td>
|
||||||
|
<td>~893</td>
|
||||||
|
<td>Charger quand on gere docs, bugs, statuts ou backlog.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td><code>template-rules.md</code></td>
|
||||||
|
<td>6.14 KB</td>
|
||||||
|
<td>~1 227</td>
|
||||||
|
<td>Charger uniquement pour les sujets templates/reporting.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th>Total des 9 fichiers</th>
|
||||||
|
<th>31.58 KB</th>
|
||||||
|
<th>~6 316</th>
|
||||||
|
<th>Faible a modere si charge ensemble; meilleur en chargement a la demande.</th>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<h3>Evaluation</h3>
|
||||||
|
<div class="callout ok">
|
||||||
|
<strong>Consommation estimee: faible a moderee.</strong>
|
||||||
|
A environ 6 300 tokens pour tout le dossier Markdown <code>purchase_trade/docs</code>, la structure reste tres raisonnable par rapport a un budget conseille de 60k-80k tokens. Le risque principal n'est pas un fichier unique, mais l'accumulation avec l'historique de conversation, les diffs, les logs et les sorties de tests.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="callout warning">
|
||||||
|
<strong>Bonne pratique.</strong>
|
||||||
|
Charger <code>business-rules.md</code> comme index, puis seulement la fiche detaillee, le bug ou le backlog utile. Eviter de charger tous les fichiers docs plus de gros logs ou des diffs complets dans la meme interaction.
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h2>7. Recommandation finale</h2>
|
||||||
|
<p>La structure est pertinente et peu couteuse en tokens si elle est utilisee comme une documentation modulaire. Elle donne une bonne base pour travailler avec des agents: contexte court au depart, approfondissement a la demande, liens explicites entre bug, regle, backlog, tests et commit.</p>
|
||||||
|
|
||||||
|
<p class="small">Document genere le 2026-05-08 pour le module <code>purchase_trade</code>.</p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
BIN
modules/purchase_trade/docs/documentation-structure-summary.pdf
Normal file
BIN
modules/purchase_trade/docs/documentation-structure-summary.pdf
Normal file
Binary file not shown.
@@ -69,12 +69,20 @@ class ImportPricesStart(ModelView):
|
|||||||
"Import Prices"
|
"Import Prices"
|
||||||
__name__ = 'purchase_trade.import_prices.start'
|
__name__ = 'purchase_trade.import_prices.start'
|
||||||
|
|
||||||
|
file_structure = fields.Selection([
|
||||||
|
('historical', "Historical Prices"),
|
||||||
|
('forward', "Forward Prices"),
|
||||||
|
], "Excel file structure", required=True)
|
||||||
file_ = fields.Binary('Excel file', required=True, filename='filename')
|
file_ = fields.Binary('Excel file', required=True, filename='filename')
|
||||||
filename = fields.Char('Filename')
|
filename = fields.Char('Filename')
|
||||||
create_missing_price_index = fields.Boolean(
|
create_missing_price_index = fields.Boolean(
|
||||||
"Create price index if missing")
|
"Create price index if missing")
|
||||||
overwrite_existing_price = fields.Boolean("Overwrite existing price")
|
overwrite_existing_price = fields.Boolean("Overwrite existing price")
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_file_structure():
|
||||||
|
return 'historical'
|
||||||
|
|
||||||
|
|
||||||
class ImportPricesResult(ModelView):
|
class ImportPricesResult(ModelView):
|
||||||
"Import Prices Result"
|
"Import Prices Result"
|
||||||
@@ -112,7 +120,8 @@ class ImportPrices(Wizard):
|
|||||||
}
|
}
|
||||||
|
|
||||||
def transition_import_(self):
|
def transition_import_(self):
|
||||||
rows = self._read_xlsx(self.start.file_)
|
rows = self._read_xlsx(
|
||||||
|
self.start.file_, file_structure=self.start.file_structure)
|
||||||
stats = self._import_rows(
|
stats = self._import_rows(
|
||||||
rows,
|
rows,
|
||||||
create_missing_price_index=(
|
create_missing_price_index=(
|
||||||
@@ -142,7 +151,8 @@ class ImportPrices(Wizard):
|
|||||||
'errors': [],
|
'errors': [],
|
||||||
}
|
}
|
||||||
|
|
||||||
for row_number, row in enumerate(rows, start=2):
|
for index, row in enumerate(rows, start=2):
|
||||||
|
row_number = row.get('_row_number', index)
|
||||||
price_index = (row.get('price_index') or '').strip()
|
price_index = (row.get('price_index') or '').strip()
|
||||||
try:
|
try:
|
||||||
price_date = cls._as_date(row.get('price_date'))
|
price_date = cls._as_date(row.get('price_date'))
|
||||||
@@ -218,7 +228,7 @@ class ImportPrices(Wizard):
|
|||||||
}
|
}
|
||||||
references = [
|
references = [
|
||||||
('price_type', 'price.fixtype', [('name', '=', 'Market price')]),
|
('price_type', 'price.fixtype', [('name', '=', 'Market price')]),
|
||||||
('price_currency', 'currency.currency', [('code', '=', 'USD')]),
|
('price_currency', 'currency.currency', [('name', '=', 'USD')]),
|
||||||
('price_calendar', 'price.calendar', [('name', '=', 'Argus EU')]),
|
('price_calendar', 'price.calendar', [('name', '=', 'Argus EU')]),
|
||||||
('price_unit', 'product.uom', [('name', '=', 'Mt')]),
|
('price_unit', 'product.uom', [('name', '=', 'Mt')]),
|
||||||
]
|
]
|
||||||
@@ -341,7 +351,7 @@ class ImportPrices(Wizard):
|
|||||||
return ', '.join(parts) or 'price imported'
|
return ', '.join(parts) or 'price imported'
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def _read_xlsx(cls, data):
|
def _read_xlsx(cls, data, file_structure='historical'):
|
||||||
try:
|
try:
|
||||||
with zipfile.ZipFile(BytesIO(data)) as workbook:
|
with zipfile.ZipFile(BytesIO(data)) as workbook:
|
||||||
shared_strings = cls._read_shared_strings(workbook)
|
shared_strings = cls._read_shared_strings(workbook)
|
||||||
@@ -355,6 +365,12 @@ class ImportPrices(Wizard):
|
|||||||
if not rows:
|
if not rows:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
if file_structure == 'forward':
|
||||||
|
return cls._read_forward_price_rows(rows, shared_strings, ns)
|
||||||
|
return cls._read_historical_price_rows(rows, shared_strings, ns)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _read_historical_price_rows(cls, rows, shared_strings, ns):
|
||||||
headers = {}
|
headers = {}
|
||||||
for cell in rows[0].findall('s:c', ns):
|
for cell in rows[0].findall('s:c', ns):
|
||||||
index = cls._cell_column_index(cell.get('r'))
|
index = cls._cell_column_index(cell.get('r'))
|
||||||
@@ -381,6 +397,59 @@ class ImportPrices(Wizard):
|
|||||||
result.append(values)
|
result.append(values)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _read_forward_price_rows(cls, rows, shared_strings, ns):
|
||||||
|
headers = {}
|
||||||
|
month_terms = {}
|
||||||
|
for cell in rows[0].findall('s:c', ns):
|
||||||
|
index = cls._cell_column_index(cell.get('r'))
|
||||||
|
header = cls._cell_value(cell, shared_strings)
|
||||||
|
normalized = cls._normalize_header(header)
|
||||||
|
if index == 1 and normalized == 'priceindex':
|
||||||
|
headers[index] = 'price_index'
|
||||||
|
elif index == 2 and normalized == 'pricedate':
|
||||||
|
headers[index] = 'price_date'
|
||||||
|
elif index and index >= 3 and header not in (None, ''):
|
||||||
|
month_terms[index] = cls._as_month_term(header)
|
||||||
|
|
||||||
|
missing = []
|
||||||
|
if headers.get(1) != 'price_index':
|
||||||
|
missing.append('price_index')
|
||||||
|
if headers.get(2) != 'price_date':
|
||||||
|
missing.append('price_date')
|
||||||
|
if missing:
|
||||||
|
raise UserError(
|
||||||
|
"Missing columns in Excel file: %s" % ', '.join(missing))
|
||||||
|
if not month_terms:
|
||||||
|
raise UserError(
|
||||||
|
"Missing month term columns in Excel file.")
|
||||||
|
|
||||||
|
result = []
|
||||||
|
for excel_row_number, sheet_row in enumerate(rows[1:], start=2):
|
||||||
|
row_values = {}
|
||||||
|
for cell in sheet_row.findall('s:c', ns):
|
||||||
|
index = cls._cell_column_index(cell.get('r'))
|
||||||
|
row_values[index] = cls._cell_value(cell, shared_strings)
|
||||||
|
|
||||||
|
price_index = (row_values.get(1) or '').strip()
|
||||||
|
price_date = row_values.get(2)
|
||||||
|
if not price_index and price_date in (None, ''):
|
||||||
|
continue
|
||||||
|
|
||||||
|
for index, month_term in sorted(month_terms.items()):
|
||||||
|
price_value = row_values.get(index)
|
||||||
|
if price_value in (None, ''):
|
||||||
|
continue
|
||||||
|
result.append({
|
||||||
|
'_row_number': excel_row_number,
|
||||||
|
'price_index': (
|
||||||
|
'%s %s' % (price_index, month_term)
|
||||||
|
if price_index else ''),
|
||||||
|
'price_date': price_date,
|
||||||
|
'price_value': price_value,
|
||||||
|
})
|
||||||
|
return result
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _read_shared_strings(workbook):
|
def _read_shared_strings(workbook):
|
||||||
try:
|
try:
|
||||||
@@ -473,8 +542,20 @@ class ImportPrices(Wizard):
|
|||||||
except ValueError:
|
except ValueError:
|
||||||
pass
|
pass
|
||||||
raise UserError("Invalid price_date: %s" % text)
|
raise UserError("Invalid price_date: %s" % text)
|
||||||
|
|
||||||
class MtmScenario(ModelSQL, ModelView):
|
@classmethod
|
||||||
|
def _as_month_term(cls, value):
|
||||||
|
if isinstance(value, datetime.date):
|
||||||
|
return value.strftime('%Y-%m')
|
||||||
|
text = str(value).strip()
|
||||||
|
match = re.match(r'^(20\d{2})[-_/\. ](0[1-9]|1[0-2])$', text)
|
||||||
|
if match:
|
||||||
|
return '%s-%s' % (match.group(1), match.group(2))
|
||||||
|
if re.match(r'^\d+(\.\d+)?$', text):
|
||||||
|
return cls._as_date(text).strftime('%Y-%m')
|
||||||
|
raise UserError("Invalid month term: %s" % text)
|
||||||
|
|
||||||
|
class MtmScenario(ModelSQL, ModelView):
|
||||||
"MtM Scenario"
|
"MtM Scenario"
|
||||||
__name__ = 'mtm.scenario'
|
__name__ = 'mtm.scenario'
|
||||||
|
|
||||||
|
|||||||
314
modules/purchase_trade/process_documentation.py
Normal file
314
modules/purchase_trade/process_documentation.py
Normal file
@@ -0,0 +1,314 @@
|
|||||||
|
# This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
# this repository contains the full copyright notices and license terms.
|
||||||
|
import base64
|
||||||
|
import html
|
||||||
|
import mimetypes
|
||||||
|
import os
|
||||||
|
import posixpath
|
||||||
|
import re
|
||||||
|
from pathlib import Path
|
||||||
|
from urllib.parse import unquote
|
||||||
|
|
||||||
|
from trytond.model import ModelSingleton, ModelSQL, ModelView, fields
|
||||||
|
from trytond.transaction import Transaction
|
||||||
|
|
||||||
|
|
||||||
|
DOCUMENTATION_ROOT = Path(__file__).with_name('process_documentation')
|
||||||
|
MARKDOWN_LINK = re.compile(r'(!?)\[([^\]]*)\]\(([^)]+)\)')
|
||||||
|
HTML_IMAGE_SOURCE = re.compile(
|
||||||
|
r'(<img\b[^>]*\bsrc=)(["\'])([^"\']+)(\2)', re.IGNORECASE)
|
||||||
|
|
||||||
|
|
||||||
|
class ProcessDocumentation(ModelSingleton, ModelSQL, ModelView):
|
||||||
|
"Process Documentation"
|
||||||
|
__name__ = 'purchase_trade.process.documentation'
|
||||||
|
|
||||||
|
content = fields.Function(fields.Text('Content'), 'get_content')
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def default_content():
|
||||||
|
return _html_content()
|
||||||
|
|
||||||
|
def get_content(self, name):
|
||||||
|
return _html_content()
|
||||||
|
|
||||||
|
|
||||||
|
def _html_content():
|
||||||
|
html_file = Transaction().context.get('process_documentation_html')
|
||||||
|
if html_file:
|
||||||
|
return _html_file_content(html_file)
|
||||||
|
|
||||||
|
document = HTML_TEMPLATE % {
|
||||||
|
'content': _documentation_content(),
|
||||||
|
}
|
||||||
|
return IFRAME_TEMPLATE % {
|
||||||
|
'document': html.escape(document, quote=True),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _html_file_content(filename):
|
||||||
|
path = (DOCUMENTATION_ROOT / Path(*filename.split('/'))).resolve()
|
||||||
|
root = DOCUMENTATION_ROOT.resolve()
|
||||||
|
common_path = os.path.commonpath([str(root), str(path)])
|
||||||
|
if path != root and common_path == str(root):
|
||||||
|
if path.exists() and path.is_file() and path.suffix.lower() == '.html':
|
||||||
|
document = path.read_text(encoding='utf-8')
|
||||||
|
document = _inline_html_assets(document, _relative_name(path))
|
||||||
|
return IFRAME_TEMPLATE % {
|
||||||
|
'document': html.escape(document, quote=True),
|
||||||
|
}
|
||||||
|
return _html_error('Documentation page not found: %s' % filename)
|
||||||
|
|
||||||
|
|
||||||
|
def _inline_html_assets(document, current_file):
|
||||||
|
def replace(match):
|
||||||
|
prefix, quote, source, suffix = match.groups()
|
||||||
|
resolved = _resolve_link(current_file, source)
|
||||||
|
if resolved.startswith(('http://', 'https://', 'data:', 'mailto:')):
|
||||||
|
return match.group(0)
|
||||||
|
|
||||||
|
data_uri = _asset_data_uri(resolved)
|
||||||
|
if not data_uri:
|
||||||
|
return match.group(0)
|
||||||
|
return '%s%s%s%s' % (prefix, quote, html.escape(data_uri, quote=True),
|
||||||
|
suffix)
|
||||||
|
|
||||||
|
return HTML_IMAGE_SOURCE.sub(replace, document)
|
||||||
|
|
||||||
|
|
||||||
|
def _html_error(message):
|
||||||
|
document = HTML_TEMPLATE % {
|
||||||
|
'content': '<p>%s</p>' % html.escape(message),
|
||||||
|
}
|
||||||
|
return IFRAME_TEMPLATE % {
|
||||||
|
'document': html.escape(document, quote=True),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _documentation_content():
|
||||||
|
sections = []
|
||||||
|
index = DOCUMENTATION_ROOT / 'README.md'
|
||||||
|
if index.exists():
|
||||||
|
sections.append(_render_page(index))
|
||||||
|
|
||||||
|
for path in sorted(DOCUMENTATION_ROOT.rglob('*.md')):
|
||||||
|
if path == index:
|
||||||
|
continue
|
||||||
|
sections.append(_render_page(path))
|
||||||
|
return '\n'.join(sections)
|
||||||
|
|
||||||
|
|
||||||
|
def _render_page(path):
|
||||||
|
relative_name = _relative_name(path)
|
||||||
|
markdown = path.read_text(encoding='utf-8')
|
||||||
|
return '<section id="%s">%s</section>' % (
|
||||||
|
_anchor(relative_name), _markdown_to_html(markdown, relative_name))
|
||||||
|
|
||||||
|
|
||||||
|
def _relative_name(path):
|
||||||
|
return path.relative_to(DOCUMENTATION_ROOT.resolve()).as_posix()
|
||||||
|
|
||||||
|
|
||||||
|
def _anchor(filename):
|
||||||
|
return 'doc-' + re.sub(r'[^a-zA-Z0-9_-]+', '-', filename)
|
||||||
|
|
||||||
|
|
||||||
|
def _resolve_link(current_file, target):
|
||||||
|
if target.startswith(('#', 'http://', 'https://', 'mailto:')):
|
||||||
|
return target
|
||||||
|
target = unquote(target).replace('\\', '/')
|
||||||
|
current_dir = posixpath.dirname(current_file)
|
||||||
|
return posixpath.normpath(posixpath.join(current_dir, target)).lstrip('/')
|
||||||
|
|
||||||
|
|
||||||
|
def _asset_data_uri(filename):
|
||||||
|
path = (DOCUMENTATION_ROOT / Path(*filename.split('/'))).resolve()
|
||||||
|
root = DOCUMENTATION_ROOT.resolve()
|
||||||
|
common_path = os.path.commonpath([str(root), str(path)])
|
||||||
|
if path != root and common_path == str(root):
|
||||||
|
if path.exists() and path.is_file():
|
||||||
|
mimetype = mimetypes.guess_type(str(path))[0]
|
||||||
|
mimetype = mimetype or 'application/octet-stream'
|
||||||
|
data = base64.b64encode(path.read_bytes()).decode('ascii')
|
||||||
|
return 'data:%s;base64,%s' % (mimetype, data)
|
||||||
|
|
||||||
|
|
||||||
|
def _inline(markdown, current_file):
|
||||||
|
parts = []
|
||||||
|
last = 0
|
||||||
|
for match in MARKDOWN_LINK.finditer(markdown):
|
||||||
|
parts.append(html.escape(markdown[last:match.start()]))
|
||||||
|
is_image, label, target = match.groups()
|
||||||
|
resolved = _resolve_link(current_file, target)
|
||||||
|
label = html.escape(label)
|
||||||
|
|
||||||
|
if is_image:
|
||||||
|
source = _asset_data_uri(resolved)
|
||||||
|
if source:
|
||||||
|
parts.append('<img src="%s" alt="%s"/>' % (
|
||||||
|
html.escape(source, quote=True), label))
|
||||||
|
else:
|
||||||
|
parts.append(label)
|
||||||
|
elif resolved.endswith('.md'):
|
||||||
|
parts.append(_internal_link(_anchor(resolved), label))
|
||||||
|
elif resolved.startswith('#'):
|
||||||
|
parts.append(_internal_link(resolved.lstrip('#'), label))
|
||||||
|
elif resolved.startswith(('http://', 'https://', 'mailto:')):
|
||||||
|
parts.append('<a href="%s">%s</a>' % (
|
||||||
|
html.escape(resolved, quote=True), label))
|
||||||
|
else:
|
||||||
|
parts.append(html.escape(match.group(0)))
|
||||||
|
last = match.end()
|
||||||
|
parts.append(html.escape(markdown[last:]))
|
||||||
|
return ''.join(parts)
|
||||||
|
|
||||||
|
|
||||||
|
def _markdown_to_html(markdown, current_file):
|
||||||
|
body = []
|
||||||
|
table = []
|
||||||
|
in_list = False
|
||||||
|
|
||||||
|
def close_list():
|
||||||
|
nonlocal in_list
|
||||||
|
if in_list:
|
||||||
|
body.append('</ul>')
|
||||||
|
in_list = False
|
||||||
|
|
||||||
|
def flush_table():
|
||||||
|
nonlocal table
|
||||||
|
if table:
|
||||||
|
close_list()
|
||||||
|
body.append(_render_table(table, current_file))
|
||||||
|
table = []
|
||||||
|
|
||||||
|
for line in markdown.splitlines():
|
||||||
|
stripped = line.strip()
|
||||||
|
if stripped.startswith('|') and stripped.endswith('|'):
|
||||||
|
table.append(stripped)
|
||||||
|
continue
|
||||||
|
|
||||||
|
flush_table()
|
||||||
|
if not stripped:
|
||||||
|
close_list()
|
||||||
|
continue
|
||||||
|
|
||||||
|
if stripped.startswith('#'):
|
||||||
|
close_list()
|
||||||
|
level = len(stripped) - len(stripped.lstrip('#'))
|
||||||
|
level = min(level, 6)
|
||||||
|
title = stripped[level:].strip()
|
||||||
|
body.append('<h%d>%s</h%d>' % (
|
||||||
|
level, _inline(title, current_file), level))
|
||||||
|
elif stripped.startswith('- '):
|
||||||
|
if not in_list:
|
||||||
|
body.append('<ul>')
|
||||||
|
in_list = True
|
||||||
|
body.append('<li>%s</li>' % _inline(
|
||||||
|
stripped[2:].strip(), current_file))
|
||||||
|
else:
|
||||||
|
close_list()
|
||||||
|
body.append('<p>%s</p>' % _inline(stripped, current_file))
|
||||||
|
|
||||||
|
flush_table()
|
||||||
|
close_list()
|
||||||
|
|
||||||
|
if current_file != 'README.md':
|
||||||
|
body.insert(
|
||||||
|
0, '<p>%s</p>' % _internal_link('doc-README-md', 'Back to index'))
|
||||||
|
return '\n'.join(body)
|
||||||
|
|
||||||
|
|
||||||
|
def _internal_link(anchor, label):
|
||||||
|
anchor = html.escape(anchor, quote=True)
|
||||||
|
return '<a href="#%s" data-doc-target="%s">%s</a>' % (
|
||||||
|
anchor, anchor, label)
|
||||||
|
|
||||||
|
|
||||||
|
def _render_table(lines, current_file):
|
||||||
|
rows = [
|
||||||
|
[cell.strip() for cell in line.strip('|').split('|')]
|
||||||
|
for line in lines
|
||||||
|
]
|
||||||
|
header = rows[0] if rows else []
|
||||||
|
data = rows[1:]
|
||||||
|
if data and all(set(cell) <= {'-', ':'} for cell in data[0]):
|
||||||
|
data = data[1:]
|
||||||
|
|
||||||
|
output = ['<table>', '<thead><tr>']
|
||||||
|
for cell in header:
|
||||||
|
output.append('<th>%s</th>' % _inline(cell, current_file))
|
||||||
|
output.append('</tr></thead><tbody>')
|
||||||
|
for row in data:
|
||||||
|
output.append('<tr>')
|
||||||
|
for cell in row:
|
||||||
|
output.append('<td>%s</td>' % _inline(cell, current_file))
|
||||||
|
output.append('</tr>')
|
||||||
|
output.append('</tbody></table>')
|
||||||
|
return ''.join(output)
|
||||||
|
|
||||||
|
|
||||||
|
IFRAME_TEMPLATE = '''<iframe srcdoc="%(document)s"
|
||||||
|
style="border: 0; height: calc(100vh - 160px); min-height: 760px; width: 100%%;"
|
||||||
|
title="Tradon Processes"></iframe>
|
||||||
|
'''
|
||||||
|
|
||||||
|
|
||||||
|
HTML_TEMPLATE = '''<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8"/>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
color: #1f2933;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
line-height: 1.5;
|
||||||
|
margin: 0;
|
||||||
|
padding: 24px;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
color: #0b63ce;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
border-collapse: collapse;
|
||||||
|
margin: 16px 0;
|
||||||
|
width: 100%%;
|
||||||
|
}
|
||||||
|
th,
|
||||||
|
td {
|
||||||
|
border: 1px solid #d7dde5;
|
||||||
|
padding: 8px 10px;
|
||||||
|
text-align: left;
|
||||||
|
vertical-align: top;
|
||||||
|
}
|
||||||
|
th {
|
||||||
|
background: #f3f6f9;
|
||||||
|
}
|
||||||
|
img {
|
||||||
|
height: auto;
|
||||||
|
max-width: 100%%;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<main>%(content)s</main>
|
||||||
|
<script>
|
||||||
|
document.addEventListener('click', function(event) {
|
||||||
|
var link = event.target.closest('a[data-doc-target]');
|
||||||
|
if (!link) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var target = document.getElementById(link.dataset.docTarget);
|
||||||
|
if (!target) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
event.preventDefault();
|
||||||
|
target.scrollIntoView({block: 'start'});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
'''
|
||||||
64
modules/purchase_trade/process_documentation.xml
Normal file
64
modules/purchase_trade/process_documentation.xml
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!-- This file is part of Tryton. The COPYRIGHT file at the top level of
|
||||||
|
this repository contains the full copyright notices and license terms. -->
|
||||||
|
<tryton>
|
||||||
|
<data>
|
||||||
|
<record model="ir.ui.view" id="process_documentation_view_form">
|
||||||
|
<field name="model">purchase_trade.process.documentation</field>
|
||||||
|
<field name="type">form</field>
|
||||||
|
<field name="name">process_documentation_form</field>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<record model="ir.action.act_window" id="act_tradon_processes">
|
||||||
|
<field name="name">Tradon Processes</field>
|
||||||
|
<field name="res_model">purchase_trade.process.documentation</field>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.view"
|
||||||
|
id="act_tradon_processes_view_form">
|
||||||
|
<field name="sequence" eval="10"/>
|
||||||
|
<field name="view" ref="process_documentation_view_form"/>
|
||||||
|
<field name="act_window" ref="act_tradon_processes"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window" id="act_itsa_operations_workflow">
|
||||||
|
<field name="name">Interacid Practice Book</field>
|
||||||
|
<field name="res_model">purchase_trade.process.documentation</field>
|
||||||
|
<field name="context" eval="{
|
||||||
|
'process_documentation_html': 'ITSA/Interacid_Tradon_Practice_Book.html',
|
||||||
|
}" pyson="1"/>
|
||||||
|
</record>
|
||||||
|
<record model="ir.action.act_window.view"
|
||||||
|
id="act_itsa_operations_workflow_view_form">
|
||||||
|
<field name="sequence" eval="10"/>
|
||||||
|
<field name="view" ref="process_documentation_view_form"/>
|
||||||
|
<field name="act_window" ref="act_itsa_operations_workflow"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
name="Help & Processes"
|
||||||
|
sequence="95"
|
||||||
|
icon="tryton-public"
|
||||||
|
id="menu_help_processes"/>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
name="Tradon Processes"
|
||||||
|
parent="menu_help_processes"
|
||||||
|
action="act_tradon_processes"
|
||||||
|
sequence="10"
|
||||||
|
id="menu_tradon_processes"/>
|
||||||
|
|
||||||
|
<menuitem
|
||||||
|
name="Interacid Practice Book"
|
||||||
|
parent="menu_help_processes"
|
||||||
|
action="act_itsa_operations_workflow"
|
||||||
|
sequence="20"
|
||||||
|
id="menu_itsa_operations_workflow"/>
|
||||||
|
|
||||||
|
<record model="ir.model.access" id="access_process_documentation">
|
||||||
|
<field name="model">purchase_trade.process.documentation</field>
|
||||||
|
<field name="perm_read" eval="True"/>
|
||||||
|
<field name="perm_write" eval="False"/>
|
||||||
|
<field name="perm_create" eval="False"/>
|
||||||
|
<field name="perm_delete" eval="False"/>
|
||||||
|
</record>
|
||||||
|
</data>
|
||||||
|
</tryton>
|
||||||
@@ -0,0 +1,212 @@
|
|||||||
|
# Practice Book Generation Guideline
|
||||||
|
|
||||||
|
A reusable specification for producing **ERP "Practice Book" user manuals** for commodity
|
||||||
|
trading clients, derived from two reference documents:
|
||||||
|
|
||||||
|
- *Trading, Middle Office and Derivatives Practice Book* (front-office)
|
||||||
|
- *Shipping Practice Book v2* (operations / back-office)
|
||||||
|
|
||||||
|
Use this guideline as the blueprint when generating an equivalent document for **another
|
||||||
|
customer, another commodity set, or a different workflow** (and, where relevant, a
|
||||||
|
different ERP such as Tryton instead of iRely).
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 1. Purpose of these documents
|
||||||
|
|
||||||
|
A Practice Book is a **"to-be" operational manual**. It is *not* generic vendor software
|
||||||
|
documentation. Its job is to tell a specific client's staff **how their business is to be
|
||||||
|
run inside the configured ERP**, step by step, screen by screen.
|
||||||
|
|
||||||
|
Each book has a clear scope along the trade lifecycle:
|
||||||
|
|
||||||
|
| Book | Scope | Primary audience |
|
||||||
|
|------|-------|-----------------|
|
||||||
|
| **Trade / Middle Office / Derivatives** | Front office: contract capture, pricing, FX fixation, cost budgeting, hedging, broker reconciliation, market exposure, allocation, sales | Traders, Trader Assistants, Market Risk / Derivatives Desk, Finance |
|
||||||
|
| **Shipping / Logistics** | Back office: logistics flows, shipping instructions, load shipment, inventory receipt, vouchers, invoicing, exception handling | Operations, Logistics, Trader Assistants, Finance |
|
||||||
|
|
||||||
|
**Defining characteristics to reproduce:**
|
||||||
|
- Written in the client's own vocabulary and entity names (companies, commodities, ports, banks).
|
||||||
|
- Describes the agreed *target process*, including explicit decisions made during implementation ("we have decided to…", "for simplicity we keep…").
|
||||||
|
- Heavily screenshot-driven: every action is illustrated with an annotated capture of the real configured system.
|
||||||
|
- Honest about gaps: carries open questions, "to be confirmed", and vendor action tags inline.
|
||||||
|
- Organised lifecycle-first (follow the goods/contract from creation to settlement), not feature-first.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 2. Document structure (section template)
|
||||||
|
|
||||||
|
Reproduce this skeleton. Sections marked **[shared]** are written once and reused
|
||||||
|
verbatim across every book for the same client.
|
||||||
|
|
||||||
|
```
|
||||||
|
Title page — Client / workflow name
|
||||||
|
Contents — Auto-generated TOC with page numbers
|
||||||
|
|
||||||
|
1. Fundamentals & glossary [shared]
|
||||||
|
- Company / Location and Line of Business
|
||||||
|
- Contract pricing types (e.g. Priced vs Basis)
|
||||||
|
- Contract sequences (multi-line contracts) + any limits agreed
|
||||||
|
- Contracts budget & costs (route / cost-matrix concept)
|
||||||
|
- Contract items (product catalogue philosophy)
|
||||||
|
- Price fixations & hedging (one-liner overview)
|
||||||
|
- Hedging & broker reconciliations (overview)
|
||||||
|
- Allocations & reservations (overview)
|
||||||
|
- Logistics flows (Inbound / Outbound / Drop Ship / Transfer)
|
||||||
|
- Key process names (Shipping Instruction, Load Shipment, Inventory Receipt …)
|
||||||
|
- System-specific term mapping (e.g. "Voucher vs Invoice")
|
||||||
|
|
||||||
|
2. Main subject chapters (lifecycle-ordered)
|
||||||
|
- Each major process = a chapter
|
||||||
|
- Each chapter = intro paragraph + numbered/illustrated steps
|
||||||
|
- Field-reference tables for every data-entry screen
|
||||||
|
|
||||||
|
3. Worked scenarios
|
||||||
|
- One "base scenario" (happy path), fully illustrated end to end
|
||||||
|
- Labelled variants of the base scenario
|
||||||
|
e.g. "Variant-2 (Location: X, Commodity: Y)"
|
||||||
|
- Miscellaneous / exception flows (rejections, claims, transhipment …)
|
||||||
|
- Optionally: "Scenarios that will not happen / for later phases"
|
||||||
|
|
||||||
|
4. Appendix
|
||||||
|
- Overview diagram(s) of end-to-end flow
|
||||||
|
- Cross-reference table (e.g. helpdesk / ticket references)
|
||||||
|
- Footnotes collected from the body
|
||||||
|
```
|
||||||
|
|
||||||
|
> The two reference books deliberately **share section 1 verbatim**. Keep this discipline:
|
||||||
|
> write the fundamentals once per client and paste identically into each book so staff get
|
||||||
|
> the same grounding regardless of which manual they open.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 3. Content building blocks (the repeatable units)
|
||||||
|
|
||||||
|
### 3.1 Field-reference table
|
||||||
|
Used for every data-entry screen. The leading number ties each row to a numbered red
|
||||||
|
callout on the adjacent screenshot.
|
||||||
|
|
||||||
|
```
|
||||||
|
| # | Attribute | Description |
|
||||||
|
| - | --------- | ----------- |
|
||||||
|
| 1 | <Field> | What it is, how it is used, who fills it, defaulting rules, worked example |
|
||||||
|
```
|
||||||
|
|
||||||
|
Rules:
|
||||||
|
- Descriptions are **operational**, not just definitional — say *who* enters it, *when*, *why*, and any calculation. Long cells with embedded examples are normal and expected.
|
||||||
|
- Use a `???` / `@vendor: to complete` placeholder for fields not yet finalised rather than omitting the row.
|
||||||
|
- Keep field labels in **bold** when referenced in prose.
|
||||||
|
|
||||||
|
### 3.2 Step sequence
|
||||||
|
Process actions as a bulleted list, in execution order, each meaningful step followed by a
|
||||||
|
screenshot:
|
||||||
|
|
||||||
|
```
|
||||||
|
- Trader clicks **Insert** … [screenshot]
|
||||||
|
- A new window opens; enter the line details [field-reference table]
|
||||||
|
- Click **Save** — system allocates the number (e.g. PC- / SC- prefix)
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.3 Annotated screenshot
|
||||||
|
The dominant visual. Conventions to reproduce:
|
||||||
|
- Real captures of the *configured* system populated with the client's data.
|
||||||
|
- **Numbered red circular callouts** placed on the fields, matching `#` in the field table.
|
||||||
|
- Placed immediately after the prose/table that describes them, never front-loaded.
|
||||||
|
- For exception flows, before/after captures.
|
||||||
|
|
||||||
|
### 3.4 Notes, examples, open items
|
||||||
|
- **Note / Important Note:** bolded inline callouts for rules, warnings, responsibilities.
|
||||||
|
- *Italic worked examples* with concrete numbers (e.g. freight 4500 USD ÷ 19.2 MT = 234.38 USD/MT).
|
||||||
|
- `[@vendor: …]` inline tags for open questions, bugs, or future enhancements — kept visible in the draft.
|
||||||
|
- Footnotes (`[^n]`) for edge cases that would interrupt the main flow.
|
||||||
|
|
||||||
|
### 3.5 Worked-calculation block
|
||||||
|
For any computed value (freight, finance, insurance, FX), show the **formula then a fully
|
||||||
|
numeric example**:
|
||||||
|
|
||||||
|
```
|
||||||
|
Finance cost = Principal × Rate × Days / 365
|
||||||
|
= 87 848.77 × 2.0% × 60 / 365 = 288.82 USD
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. Formatting & style conventions
|
||||||
|
|
||||||
|
| Element | Convention |
|
||||||
|
|---------|-----------|
|
||||||
|
| Field / column names | **Bold** |
|
||||||
|
| Buttons / actions | **Bold** (e.g. click **Save**, **Insert**, **Allocate**) |
|
||||||
|
| Worked examples | *Italic*, with real numbers |
|
||||||
|
| System term being defined | **Bold** on first use |
|
||||||
|
| Open questions / vendor actions | `[@vendor: …]` inline, left in the text |
|
||||||
|
| Edge cases | Footnotes |
|
||||||
|
| Process / status names | Capitalised exactly as in the system (In-Transit, Spot, In-Store) |
|
||||||
|
| Headings | H1 = chapter, H2 = process, H3/H4 = sub-process or scenario variant |
|
||||||
|
| Voice | Future/target tense ("we will create…", "the Trader will enter…") |
|
||||||
|
|
||||||
|
Keep the **client's real master data** in every example: company/location names,
|
||||||
|
commodities, ports, incoterms, banks, grades, packaging (e.g. 69 kg bags). This grounding
|
||||||
|
is what makes the book usable and is the single most important thing to localise.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 5. How to adapt for a new customer / commodity / workflow
|
||||||
|
|
||||||
|
> **INSTRUCTION — ask before generating.** Before producing a new Practice Book, do **not**
|
||||||
|
> assume answers from the reference documents. First **ask the customer the questions
|
||||||
|
> below and wait for their answers.** Only once the answers are provided should the output
|
||||||
|
> document be generated. Pose the questions grouped as listed; where a question has a small
|
||||||
|
> fixed set of choices, offer them as selectable options, otherwise ask for free text.
|
||||||
|
|
||||||
|
**Questions to ask the customer:**
|
||||||
|
|
||||||
|
1. **Glossary entities.** What are the company/location name(s), the commodity set being
|
||||||
|
traded (e.g. coffee, cocoa, cotton, sugar, grains, iron ore, steel, copper, aluminium,
|
||||||
|
zinc/lead), and the line-of-business dimension? Are there any agreed structural limits
|
||||||
|
(e.g. maximum number of contract sequences/lines)?
|
||||||
|
|
||||||
|
2. **Pricing types.** Which pricing types does the client use — *Priced*, *Basis
|
||||||
|
(differential)*, *formula-priced*, or a combination? Which underlying markets and terms
|
||||||
|
apply (e.g. ICE, LME, SHFE, GAFTA/FOSFA references)?
|
||||||
|
|
||||||
|
3. **Cost matrix & route logic.** What are the real incoterms, typical loading and
|
||||||
|
destination places, and the cost types to budget (e.g. freight, insurance, finance,
|
||||||
|
fumigation, inland, demurrage)? Which costs are auto-calculated vs. manually entered?
|
||||||
|
|
||||||
|
4. **Logistics flows in scope.** Which flows apply — Inbound (origin → warehouse),
|
||||||
|
Outbound (warehouse → buyer), Drop Ship (direct), Transfer (location to location)? Are
|
||||||
|
the goods bagged or bulk (affecting packaging, weights, draft survey, moisture/outturn),
|
||||||
|
and is tolerance/franchise handling required for the commodity family?
|
||||||
|
|
||||||
|
5. **Hedging & FX scope.** What should the book cover — *physical only (no hedging/FX)*,
|
||||||
|
*futures hedging only*, *futures + FX hedging*, or *FX only*? Front-office and physical
|
||||||
|
mechanics must be kept in clearly separate chapters.
|
||||||
|
|
||||||
|
6. **Worked scenarios.** Which dimensions matter for this client's scenario variants
|
||||||
|
(e.g. location, commodity, contract type, packaging, exception type)? Which exception
|
||||||
|
flows must be covered (rejections, claims, transhipment …) and which are out of
|
||||||
|
scope / later phase?
|
||||||
|
|
||||||
|
7. **Screenshots.** Will annotated screenshots be supplied from the client's configured
|
||||||
|
environment, or should the document leave numbered placeholders for them? (Never reuse
|
||||||
|
another client's captures.)
|
||||||
|
|
||||||
|
8. **Target ERP.** Which ERP is the target — Tryton, iRely, or another system? If it
|
||||||
|
differs from the reference (iRely), provide the equivalent term/model mapping (e.g.
|
||||||
|
Tryton models, wizards, states) so iRely-specific terms (Voucher, Sequence, Blotter)
|
||||||
|
can be replaced. The pedagogical structure — fundamentals, field tables, illustrated
|
||||||
|
steps, worked scenarios — is ERP-agnostic and must be preserved regardless.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. Quality bar (acceptance criteria)
|
||||||
|
|
||||||
|
A generated Practice Book is "done" when:
|
||||||
|
- A new staff member could execute each process end-to-end using only the book.
|
||||||
|
- Every data-entry screen has a matching numbered field table + annotated screenshot.
|
||||||
|
- Every computed figure shows its formula and a numeric worked example.
|
||||||
|
- All examples use the client's real master data.
|
||||||
|
- Open items are visibly tagged, not silently dropped.
|
||||||
|
- The fundamentals chapter is identical across the client's set of books.
|
||||||
|
- Scope boundaries (what is in / out / later phase) are stated explicitly.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Customer master data management
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Credit management & credit limit assessment
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Sales enquiry & quotation management
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Sales order creation & confirmation
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Order scheduling & promising
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Contract management
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Pricing & discount management
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Inventory reservation & availability check
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Pick, pack & ship (outbound logistics)
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Delivery note & shipping documentation
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Customer invoicing & billing
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Revenue recognition
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Accounts receivable management
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Collections management & dunning
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Cash application & payment matching
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Customer dispute & deduction management
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Customer returns & credit notes
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Bad debt provisioning & write-off
|
||||||
|
|
||||||
|
Parent process: Order to Cash (O2C) / Sales to Collection
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Vendor master data management
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Spend category management
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Purchase requisition
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Sourcing & RFQ/RFP management
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Supplier evaluation & selection
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Purchase order creation & approval
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Contract & framework agreement management
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Goods receipt & inspection (inbound logistics)
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Service entry sheet / service confirmation
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Invoice receipt & verification (3-way match)
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Accounts payable management
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Payment run & disbursement
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Early payment discounts & supply chain finance
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Vendor dispute management
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Goods returns & debit notes
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Vendor performance management
|
||||||
|
|
||||||
|
Parent process: Purchase to Pay (P2P) / Procure to Disbursement
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Demand planning & forecasting
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Master production scheduling (MPS)
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Material requirements planning (MRP)
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Capacity planning & work centre management
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Bill of materials (BOM) management
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Routing & work instruction management
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Production order creation & release
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Shop floor execution & work-in-progress tracking
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Material issue to production
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Quality control & inspection during production
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Production confirmation & yield reporting
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Co-product & by-product handling
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Production order settlement & costing
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Scrap & rework management
|
||||||
|
|
||||||
|
Parent process: Plan to Produce / Make to Stock / Make to Order
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Warehouse structure & location management
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Goods receipt processing
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Put-away & storage management
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Inventory transfers & stock movements
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Pick, pack & goods issue
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Batch & serial number management
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Lot traceability & expiry management
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Physical inventory counting & reconciliation
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Inventory adjustments & write-offs
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Stock valuation & costing
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Bonded warehouse & customs management
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Cold chain & temperature management
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# 3PL / outsourced warehouse management
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Warehouse KPI & performance management
|
||||||
|
|
||||||
|
Parent process: Inventory & Warehouse Management
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Chart of accounts management
|
||||||
|
|
||||||
|
Parent process: Record to Report (R2R) / Accounting to Financial Statements
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Journal entry & period-end accruals
|
||||||
|
|
||||||
|
Parent process: Record to Report (R2R) / Accounting to Financial Statements
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Fixed asset accounting (acquisition, depreciation, disposal)
|
||||||
|
|
||||||
|
Parent process: Record to Report (R2R) / Accounting to Financial Statements
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Bank reconciliation
|
||||||
|
|
||||||
|
Parent process: Record to Report (R2R) / Accounting to Financial Statements
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Intercompany accounting & elimination
|
||||||
|
|
||||||
|
Parent process: Record to Report (R2R) / Accounting to Financial Statements
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Cost centre & profit centre accounting
|
||||||
|
|
||||||
|
Parent process: Record to Report (R2R) / Accounting to Financial Statements
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Project accounting
|
||||||
|
|
||||||
|
Parent process: Record to Report (R2R) / Accounting to Financial Statements
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Inventory accounting & COGS
|
||||||
|
|
||||||
|
Parent process: Record to Report (R2R) / Accounting to Financial Statements
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Tax accounting (VAT, corporate tax, withholding tax)
|
||||||
|
|
||||||
|
Parent process: Record to Report (R2R) / Accounting to Financial Statements
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Month-end & year-end close
|
||||||
|
|
||||||
|
Parent process: Record to Report (R2R) / Accounting to Financial Statements
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
# Financial statement preparation (P&L, balance sheet, cash flow)
|
||||||
|
|
||||||
|
Parent process: Record to Report (R2R) / Accounting to Financial Statements
|
||||||
|
|
||||||
|
## Purpose
|
||||||
|
|
||||||
|
Describe the objective of this subprocess and its expected control outcome in Tradon.
|
||||||
|
|
||||||
|
## Tradon / Tryton execution
|
||||||
|
|
||||||
|
- Screens and menu entries: to be completed.
|
||||||
|
- Models, fields and reports: to be completed.
|
||||||
|
- Operating steps: to be completed.
|
||||||
|
|
||||||
|
## COSO control considerations
|
||||||
|
|
||||||
|
- Control environment: to be completed.
|
||||||
|
- Risk assessment: to be completed.
|
||||||
|
- Control activities: to be completed.
|
||||||
|
- Information and communication: to be completed.
|
||||||
|
- Monitoring: to be completed.
|
||||||
|
|
||||||
|
## Evidence and records
|
||||||
|
|
||||||
|
- Documents, approvals, audit trail or reports: to be completed.
|
||||||
|
|
||||||
|
## Open points
|
||||||
|
|
||||||
|
- To be completed.
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user