feat(datamart): finance price audit added
This commit is contained in:
@@ -281,6 +281,10 @@ export const runDatamartQuery = async (data: Data) => {
|
||||
: "--and pl.ArticleHumanReadableId IN ([articles])",
|
||||
);
|
||||
break;
|
||||
case "financePriceAudit":
|
||||
datamartQuery = datamartQuery.replace("[date]", `${data.options.date}`);
|
||||
|
||||
break;
|
||||
default:
|
||||
return returnFunc({
|
||||
success: false,
|
||||
|
||||
@@ -57,4 +57,12 @@ export const datamartData = [
|
||||
optionsRequired: true,
|
||||
howManyOptionsRequired: 2,
|
||||
},
|
||||
{
|
||||
name: "Finance Price Audit",
|
||||
endpoint: "financePriceAudit",
|
||||
description: `Returns all sales and purchase price for quick reference where the date is less than the one provided.`,
|
||||
options: "date",
|
||||
optionsRequired: true,
|
||||
howManyOptionsRequired: 1,
|
||||
},
|
||||
];
|
||||
|
||||
63
backend/prodSql/queries/datamart.financePriceAudit.sql
Normal file
63
backend/prodSql/queries/datamart.financePriceAudit.sql
Normal file
@@ -0,0 +1,63 @@
|
||||
use AlplaPROD_test1
|
||||
|
||||
select
|
||||
--(select wert from dbo.T_SystemParameter where Bezeichnung = 'Werkskuerzel') as Plant,
|
||||
b.IdArtikelVarianten
|
||||
,ArtikelVariantenAlias
|
||||
,ArtikelVariantenBez
|
||||
,a.Bezeichnung as articleType
|
||||
,sum(EinlagerungsMengeVPKSum) totalPal
|
||||
,sum(EinlagerungsMengeSum) totalPieces
|
||||
--,ProduktionsDatumMin
|
||||
,pp.VKPreis as salesPrice
|
||||
,sp.EKPreis as purhcasePrice
|
||||
,FORMAT(convert(date, ProduktionsDatumMin, 111), 'yyyy-MM-dd') as bookinDate
|
||||
,DATEDIFF(DAY, convert(date, ProduktionsDatumMin, 111), getdate()) as aged
|
||||
--,*
|
||||
|
||||
from dbo.V_LagerPositionenBarcodes (nolock) b
|
||||
|
||||
/* purhcase price */
|
||||
left join
|
||||
(select * from (select
|
||||
IdArtikelvarianten
|
||||
,VKPreis
|
||||
,ROW_NUMBER() OVER (PARTITION BY IdArtikelVarianten ORDER BY gueltigabDatum DESC) AS rn
|
||||
--,*
|
||||
from T_HistoryVK (nolock))c
|
||||
|
||||
where rn = 1) as pp on
|
||||
b.IdArtikelVarianten = pp.IdArtikelvarianten
|
||||
|
||||
/* sales price */
|
||||
left join
|
||||
(select * from (select
|
||||
IdArtikelvarianten
|
||||
,EKPreis
|
||||
,ROW_NUMBER() OVER (PARTITION BY IdArtikelVarianten ORDER BY gueltigabDatum DESC) AS rn
|
||||
--,*
|
||||
from T_HistoryEK (nolock) )x
|
||||
|
||||
where rn = 1) sp on
|
||||
sp.IdArtikelvarianten = b.IdArtikelVarianten
|
||||
|
||||
/* article type */
|
||||
|
||||
left join
|
||||
|
||||
T_Artikeltyp (nolock) a
|
||||
on a.IdArtikelTyp = b.IdArtikelTyp
|
||||
|
||||
where IdWarenlager not in (1,5,6)
|
||||
and ProduktionsDatumMin < '[date]' -- '2025-05-31'
|
||||
|
||||
group by b.IdArtikelVarianten
|
||||
,ArtikelVariantenAlias
|
||||
,ArtikelVariantenBez
|
||||
,convert(date, ProduktionsDatumMin, 111)
|
||||
,pp.VKPreis
|
||||
,sp.EKPreis
|
||||
,a.Bezeichnung
|
||||
|
||||
|
||||
order by IdArtikelVarianten
|
||||
Reference in New Issue
Block a user