Commit
This commit is contained in:
@@ -628,7 +628,7 @@ WHERE 1=1
|
||||
AND D.Status <> 'Cancelled'
|
||||
AND D.BuyOrSell = 1 -- Purchase contracts
|
||||
AND ISNULL(D.OtherReference, '') NOT LIKE '%ACCT Matching%'
|
||||
AND B.Description LIKE '%2025%'
|
||||
AND B.Description LIKE '%2026%'
|
||||
ORDER BY 3,1
|
||||
|
||||
|
||||
@@ -831,8 +831,7 @@ WHERE 1=1
|
||||
AND D.Status <> 'Cancelled'
|
||||
AND D.BuyOrSell = -1 -- Sale contracts
|
||||
AND ISNULL(D.OtherReference, '') NOT LIKE '%ACCT Matching%'
|
||||
AND (B.Description LIKE '%2025%' OR B.Description LIKE '%2026%')
|
||||
--AND D.Reference = 2112
|
||||
AND (B.Description LIKE '%2026%')
|
||||
ORDER BY 3,1
|
||||
|
||||
|
||||
@@ -862,7 +861,7 @@ SELECT
|
||||
'Per qt' AS mode,
|
||||
ROUND (
|
||||
(IIF(PFE.Quantity IS NULL, PFE.WeightBalance / 100, 1) * PFE.OutputPriceValue),
|
||||
2 ) AS price,
|
||||
3 ) AS price,
|
||||
ER.UnitReference AS unit
|
||||
|
||||
FROM dbo.Deal AS D
|
||||
@@ -875,14 +874,42 @@ WHERE 1=1
|
||||
AND D.Status <> 'Cancelled'
|
||||
AND D.BuyOrSell = 1 -- Purchase contracts
|
||||
AND ISNULL(D.OtherReference, '') NOT LIKE '%ACCT Matching%'
|
||||
--AND (B.Description LIKE '%2025%')
|
||||
AND (B.Description LIKE '%2025%' OR B.Description LIKE '%2026%')
|
||||
AND (B.Description LIKE '%2026%')
|
||||
AND ER.FormulaGroup NOT IN (1,2) -- Not Price or MtM
|
||||
ORDER BY 1
|
||||
|
||||
|
||||
|
||||
|
||||
SELECT PC.ContractNumber
|
||||
, ER.FormulaGroup AS FormulaGroup
|
||||
, er.Formula
|
||||
, er.FormulaGroup
|
||||
, s.[Description]
|
||||
, CASE
|
||||
WHEN ER.FormulaGroup IN (1, 2) THEN ISNULL(S.Description, IIF(PFE.FormulaType='Adjustment', PFE.FormulaType, IIF(PFE.IsDiscount = 0, 'Fixed Price ', 'Discount ' + ISNULL(PFE.Comment, ''))) )
|
||||
ELSE BD.Description
|
||||
END AS CostDescription
|
||||
, (IIF(PFE.Quantity IS NULL, PFE.WeightBalance / 100, 1) * PFE.OutputPriceValue) AS Price
|
||||
, CASE
|
||||
WHEN ER.FormulaGroup = 4 THEN -1 * CASE WHEN ER.IsRevenue = 1 THEN -1 ELSE 1 END
|
||||
WHEN ER.FormulaGroup = 1 THEN -1 * CASE WHEN PFE.IsDiscount = 1 THEN -1 ELSE 1 END * PC.ContractMultiplier --Need to invert sign for the good amount vs qty
|
||||
ELSE PC.ContractMultiplier
|
||||
END * PC.CtrRemainingQty * (IIF(PFE.Quantity IS NULL, PFE.WeightBalance / 100, 1) * PFE.OutputPriceValue) AS OpenCostAmount
|
||||
FROM [singa].VW_REP_DIM_PHYSICAL_CTR PC
|
||||
INNER JOIN dbo.Deal AS D ON D.Reference = PC.ContractNumber
|
||||
INNER JOIN dbo.ExpenseRevenue AS ER ON ER.DealId = D.Id
|
||||
INNER JOIN dbo.ExpenseRevenueValue AS ERV ON ER.EstimatedId = ERV.Id
|
||||
INNER JOIN dbo.PriceFormulaElement AS PFE ON PFE.ExpenseRevenueId = ER.Id
|
||||
LEFT JOIN dbo.BaseDefinition AS BD ON ER.CostTypeId = BD.Id
|
||||
LEFT JOIN price.Maturity AS M ON PFE.MaturityId = M.Id
|
||||
LEFT JOIN price.Symbol AS S ON M.SymbolId = S.Id
|
||||
WHERE 1=1
|
||||
AND (PFE.IsManuallySet = 0 OR ER.FormulaGroup != 1 OR (S.Description IS NULL AND ER.FormulaGroup = 1)) --we want only price at contract level, so not manually set
|
||||
AND ER.FormulaGroup = 2
|
||||
|
||||
|
||||
|
||||
-- Sale contract costs
|
||||
SELECT
|
||||
|
||||
@@ -921,7 +948,7 @@ WHERE 1=1
|
||||
AND D.Status <> 'Cancelled'
|
||||
AND D.BuyOrSell <> 1 -- Sale contracts
|
||||
AND ISNULL(D.OtherReference, '') NOT LIKE '%ACCT Matching%'
|
||||
AND (B.Description LIKE '%2025%' OR B.Description LIKE '%2026%')
|
||||
AND (B.Description LIKE '%2026%')
|
||||
AND ER.FormulaGroup NOT IN (1,2) -- Not Price or MtM
|
||||
ORDER BY 1
|
||||
|
||||
@@ -957,12 +984,6 @@ AND (B.Description LIKE '%2025%' OR B.Description LIKE '%2026%')
|
||||
ORDER BY 1,2
|
||||
|
||||
|
||||
SELECT DISTINCT formulaType FROM PriceFormulaElement
|
||||
|
||||
Trigger, RangeDate
|
||||
|
||||
|
||||
|
||||
|
||||
-- Run that script to generate CSV for price_curve MTM used in physical contract in 2025 and 2026
|
||||
SELECT DISTINCT
|
||||
|
||||
Reference in New Issue
Block a user