From 79f6e6111f2044b29a6d54c2681d1355122c465a Mon Sep 17 00:00:00 2001 From: "AzureAD\\SylvainDUVERNAY" Date: Thu, 23 Apr 2026 09:21:55 +0200 Subject: [PATCH] Commit --- Reference Data/Euclid_Queries.sql | 47 +- .../__pycache__/config.cpython-314.pyc | Bin 3212 -> 3179 bytes .../python_project/helpers/config.py | 6 +- .../python_project/loaders/Prices.csv | 2223 +---------------- .../python_project/loaders/Prices_2.csv | 1109 -------- .../python_project/loaders/Prices_3.csv | 1039 -------- .../python_project/loaders/Prices_4.csv | 53 - .../python_project/loaders/Prices_5.csv | 559 ----- .../python_project/loaders/Prices_6.csv | 406 --- .../Purchase_Contracts_with_mapping.csv | 76 +- .../loaders/Sale_Contracts_with_mapping.csv | 8 +- SQL/Contracts with MTM info.sql | 2 - ...ete price_price_value after 2026-04-09.sql | 3 + SQL/Update stock_location country.sql | 101 + 14 files changed, 210 insertions(+), 5422 deletions(-) delete mode 100644 Reference Data/python_project/loaders/Prices_2.csv delete mode 100644 Reference Data/python_project/loaders/Prices_3.csv delete mode 100644 Reference Data/python_project/loaders/Prices_4.csv delete mode 100644 Reference Data/python_project/loaders/Prices_5.csv delete mode 100644 Reference Data/python_project/loaders/Prices_6.csv create mode 100644 SQL/Delete price_price_value after 2026-04-09.sql create mode 100644 SQL/Update stock_location country.sql diff --git a/Reference Data/Euclid_Queries.sql b/Reference Data/Euclid_Queries.sql index e33c647..86912bf 100644 --- a/Reference Data/Euclid_Queries.sql +++ b/Reference Data/Euclid_Queries.sql @@ -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 diff --git a/Reference Data/python_project/helpers/__pycache__/config.cpython-314.pyc b/Reference Data/python_project/helpers/__pycache__/config.cpython-314.pyc index 13bd18de8df80e615e5b722b13dd55d03dcc0b0b..37baa6027e06cc447a9f1a9fbbf3ea9716cb2468 100644 GIT binary patch delta 118 zcmeB?d@aGN&Bx2d00fQC?`E=YFLbuj4=qkDD%KCK%qdIE%yS71a}DxyjMVop zNX=6SE-XzfN=?z9{Etn{Q$Hlg(Z%0S!85lYCp9-UuOzV~Ge1w?GbGqiKPWXVwJ0?& zIaR?Wu_RHypt2+*KQF$ZC_gJTxkNuFKQRSlM?h&&az '2026-04-09' + AND "active" = true; diff --git a/SQL/Update stock_location country.sql b/SQL/Update stock_location country.sql new file mode 100644 index 0000000..4ca6bf9 --- /dev/null +++ b/SQL/Update stock_location country.sql @@ -0,0 +1,101 @@ +-- Update stock_location.country based on port/city name identification +-- Skipped: root nodes (Customer, Supplier, Warehouse, Drop, Lost and Found), +-- generic entries (ANY PORT, To be defined, Transit, Input/Output/Storage Zone), +-- ambiguous entries (Limas - geography uncertain) + +UPDATE stock_location SET country = 9 WHERE id = 1254; -- Adelaide -> Australia +UPDATE stock_location SET country = 9 WHERE id = 1260; -- Gladstone -> Australia +UPDATE stock_location SET country = 9 WHERE id = 1276; -- Port Hedland -> Australia + +UPDATE stock_location SET country = 17 WHERE id = 1221; -- Antwerpen -> Belgium + +UPDATE stock_location SET country = 24 WHERE id = 1278; -- Rio Grande -> Brazil + +UPDATE stock_location SET country = 32 WHERE id = 1288; -- Vancouver -> Canada + +UPDATE stock_location SET country = 35 WHERE id = 1257; -- Barquito -> Chile +UPDATE stock_location SET country = 35 WHERE id = 1272; -- Mejillones -> Chile + +UPDATE stock_location SET country = 36 WHERE id = 1225; -- Fangcheng -> China +UPDATE stock_location SET country = 36 WHERE id = 1232; -- Laizhou -> China +UPDATE stock_location SET country = 36 WHERE id = 1234; -- Longkou -> China +UPDATE stock_location SET country = 36 WHERE id = 1237; -- Ningde -> China +UPDATE stock_location SET country = 36 WHERE id = 1242; -- Putian -> China +UPDATE stock_location SET country = 36 WHERE id = 1243; -- Qingdao -> China +UPDATE stock_location SET country = 36 WHERE id = 1244; -- Rizhao -> China +UPDATE stock_location SET country = 36 WHERE id = 1246; -- Rugao -> China +UPDATE stock_location SET country = 36 WHERE id = 1252; -- YIZHENG -> China +UPDATE stock_location SET country = 36 WHERE id = 1253; -- Zhangjiagang -> China + +UPDATE stock_location SET country = 59 WHERE id = 1241; -- Pori (Supplier) -> Finland +UPDATE stock_location SET country = 59 WHERE id = 1286; -- Pori (Customer) -> Finland + +UPDATE stock_location SET country = 60 WHERE id = 1119; -- STORAGE - ROUEN -> France + +UPDATE stock_location SET country = 64 WHERE id = 1226; -- Hamburg -> Germany + +UPDATE stock_location SET country = 65 WHERE id = 1282; -- Tema -> Ghana + +UPDATE stock_location SET country = 76 WHERE id = 1259; -- Budge Budge -> India +UPDATE stock_location SET country = 76 WHERE id = 1227; -- Hazira -> India +UPDATE stock_location SET country = 76 WHERE id = 1266; -- Kakinada -> India +UPDATE stock_location SET country = 76 WHERE id = 1267; -- Kandla -> India +UPDATE stock_location SET country = 76 WHERE id = 1273; -- New Mangalore -> India +UPDATE stock_location SET country = 76 WHERE id = 1275; -- Paradip -> India +UPDATE stock_location SET country = 76 WHERE id = 1283; -- Tuticorin -> India +UPDATE stock_location SET country = 76 WHERE id = 1284; -- Visakhapatnam -> India + +UPDATE stock_location SET country = 77 WHERE id = 1255; -- BAHODOPI-POSO -> Indonesia +UPDATE stock_location SET country = 77 WHERE id = 1262; -- Gresik -> Indonesia +UPDATE stock_location SET country = 77 WHERE id = 1269; -- LHOKSEUMAWE -> Indonesia + +UPDATE stock_location SET country = 84 WHERE id = 1228; -- Hibi -> Japan +UPDATE stock_location SET country = 84 WHERE id = 1231; -- Japan -> Japan +UPDATE stock_location SET country = 84 WHERE id = 1235; -- Naoshima -> Japan +UPDATE stock_location SET country = 84 WHERE id = 1236; -- Niihama -> Japan +UPDATE stock_location SET country = 84 WHERE id = 1239; -- Onahama -> Japan +UPDATE stock_location SET country = 84 WHERE id = 1247; -- Saganoseki -> Japan + +UPDATE stock_location SET country = 102 WHERE id = 1116; -- PORT KELANG FREE ZONE -> Malaysia +UPDATE stock_location SET country = 102 WHERE id = 1115; -- STORAGE - PORT KELANG -> Malaysia +UPDATE stock_location SET country = 102 WHERE id = 1268; -- Kemaman -> Malaysia + +UPDATE stock_location SET country = 109 WHERE id = 1233; -- Lazaro Cardenas -> Mexico + +UPDATE stock_location SET country = 115 WHERE id = 1265; -- Jorf Lasfar -> Morocco + +UPDATE stock_location SET country = 128 WHERE id = 1238; -- Odda -> Norway + +UPDATE stock_location SET country = 135 WHERE id = 1223; -- Callao -> Peru +UPDATE stock_location SET country = 135 WHERE id = 1230; -- Ilo -> Peru + +UPDATE stock_location SET country = 136 WHERE id = 1264; -- Isabel -> Philippines + +UPDATE stock_location SET country = 149 WHERE id = 1277; -- Ras Al Khair -> Saudi Arabia + +UPDATE stock_location SET country = 160 WHERE id = 1224; -- Donghae -> South Korea +UPDATE stock_location SET country = 160 WHERE id = 1240; -- Onsan -> South Korea +UPDATE stock_location SET country = 160 WHERE id = 1250; -- Ulsan -> South Korea +UPDATE stock_location SET country = 160 WHERE id = 1251; -- Yeosu -> South Korea + +UPDATE stock_location SET country = 162 WHERE id = 1229; -- Huelva -> Spain + +UPDATE stock_location SET country = 166 WHERE id = 1245; -- Ronnskar -> Sweden + +UPDATE stock_location SET country = 169 WHERE id = 1248; -- Taichung -> Taiwan + +UPDATE stock_location SET country = 172 WHERE id = 1256; -- Bangkok -> Thailand +UPDATE stock_location SET country = 172 WHERE id = 1271; -- Map Ta Phut -> Thailand +UPDATE stock_location SET country = 172 WHERE id = 1279; -- Samut Prakan -> Thailand + +UPDATE stock_location SET country = 177 WHERE id = 1222; -- Bandirma -> Turkey + +UPDATE stock_location SET country = 184 WHERE id = 1258; -- Beaumont -> United States +UPDATE stock_location SET country = 184 WHERE id = 1274; -- New Orleans -> United States +UPDATE stock_location SET country = 184 WHERE id = 1280; -- San Juan -> United States (Puerto Rico) +UPDATE stock_location SET country = 184 WHERE id = 1281; -- Stockton -> United States +UPDATE stock_location SET country = 184 WHERE id = 1249; -- Tampa (Customer) -> United States +UPDATE stock_location SET country = 184 WHERE id = 1285; -- Tampa (Supplier) -> United States + +UPDATE stock_location SET country = 189 WHERE id = 1261; -- Go Dau -> Vietnam +UPDATE stock_location SET country = 189 WHERE id = 1263; -- Hai Phong -> Vietnam