fix(logistics): historical issue where it was being really weird
This commit is contained in:
@@ -117,7 +117,7 @@ export const runDatamartQuery = async (data: Data) => {
|
||||
// for queries that will need to be ran on legacy until we get the plant updated need to go in here
|
||||
const doubleQueries = ["inventory"];
|
||||
const sqlQuery = sqlQuerySelector(
|
||||
`datamart.${fd.data[0].activated > 0 && doubleQueries.includes(data.name) ? data.name : `legacy.${data.name}`}`,
|
||||
`datamart.${fd.data[0].activated > 0 && !doubleQueries.includes(data.name) ? data.name : `legacy.${data.name}`}`,
|
||||
) as SqlQuery;
|
||||
|
||||
// checking if warehousing is as it will start to effect a lot of queries for plants that are not on 2.
|
||||
@@ -166,7 +166,13 @@ export const runDatamartQuery = async (data: Data) => {
|
||||
case "deliveryByDateRange":
|
||||
datamartQuery = datamartQuery
|
||||
.replace("[startDate]", `${data.options.startDate}`)
|
||||
.replace("[endDate]", `${data.options.endDate}`);
|
||||
.replace("[endDate]", `${data.options.endDate}`)
|
||||
.replace(
|
||||
"--and r.ArticleHumanReadableId in ([articles]) ",
|
||||
data.options.articles
|
||||
? `and r.ArticleHumanReadableId in (${data.options.articles})`
|
||||
: "--and r.ArticleHumanReadableId in ([articles]) ",
|
||||
);
|
||||
|
||||
break;
|
||||
case "customerInventory":
|
||||
@@ -199,19 +205,6 @@ export const runDatamartQuery = async (data: Data) => {
|
||||
"--,l.WarehouseDescription,l.LaneDescription",
|
||||
`${data.options.locations ? `,l.WarehouseDescription,l.LaneDescription` : `--,l.WarehouseDescription,l.LaneDescription`}`,
|
||||
);
|
||||
|
||||
// adding in a test for historical check.
|
||||
if (data.options.historical) {
|
||||
datamartQuery = datamartQuery
|
||||
.replace(
|
||||
"--,l.ProductionLotRunningNumber as lot,l.warehousehumanreadableid as warehouseId,l.WarehouseDescription as warehouseDescription,l.lanehumanreadableid as locationId,l.lanedescription as laneDescription",
|
||||
",l.ProductionLotRunningNumber as lot,l.warehousehumanreadableid as warehouseId,l.WarehouseDescription as warehouseDescription,l.lanehumanreadableid as locationId,l.lanedescription as laneDescription",
|
||||
)
|
||||
.replace(
|
||||
"--,l.ProductionLotRunningNumber,l.warehousehumanreadableid,l.WarehouseDescription,l.lanehumanreadableid,l.lanedescription",
|
||||
",l.ProductionLotRunningNumber,l.warehousehumanreadableid,l.WarehouseDescription,l.lanehumanreadableid,l.lanedescription",
|
||||
);
|
||||
}
|
||||
break;
|
||||
case "fakeEDIUpdate":
|
||||
datamartQuery = datamartQuery.replace(
|
||||
@@ -244,10 +237,8 @@ export const runDatamartQuery = async (data: Data) => {
|
||||
.replace("[startDate]", `${data.options.startDate}`)
|
||||
.replace("[endDate]", `${data.options.endDate}`)
|
||||
.replace(
|
||||
"and IdArtikelVarianten in ([articles])",
|
||||
data.options.articles
|
||||
? `and IdArtikelVarianten in (${data.options.articles})`
|
||||
: "--and IdArtikelVarianten in ([articles])",
|
||||
"[articles]",
|
||||
data.options.articles ? `${data.options.articles}` : "[articles]",
|
||||
);
|
||||
break;
|
||||
case "productionData":
|
||||
|
||||
@@ -66,7 +66,10 @@ const historicalInvImport = async () => {
|
||||
|
||||
const { data: inv, error: invError } = await tryCatch(
|
||||
//prodQuery(sqlQuery.query, "Inventory data"),
|
||||
runDatamartQuery({ name: "inventory", options: { historical: "x" } }),
|
||||
runDatamartQuery({
|
||||
name: "inventory",
|
||||
options: { lots: "x", locations: "x" },
|
||||
}),
|
||||
);
|
||||
|
||||
const { data: av, error: avError } = (await tryCatch(
|
||||
|
||||
@@ -21,9 +21,6 @@ ArticleHumanReadableId as article
|
||||
/** data mart include location data **/
|
||||
--,l.WarehouseDescription,l.LaneDescription
|
||||
|
||||
/** historical section **/
|
||||
--,l.ProductionLotRunningNumber as lot,l.warehousehumanreadableid as warehouseId,l.WarehouseDescription as warehouseDescription,l.lanehumanreadableid as locationId,l.lanedescription as laneDescription
|
||||
|
||||
,articleTypeName
|
||||
|
||||
FROM [warehousing].[WarehouseUnit] as l (nolock)
|
||||
@@ -58,7 +55,4 @@ ArticleTypeName
|
||||
/** data mart include location data **/
|
||||
--,l.WarehouseDescription,l.LaneDescription
|
||||
|
||||
/** historical section **/
|
||||
--,l.ProductionLotRunningNumber,l.warehousehumanreadableid,l.WarehouseDescription,l.lanehumanreadableid,l.lanedescription
|
||||
|
||||
order by ArticleHumanReadableId
|
||||
Reference in New Issue
Block a user