refactor(datamart): changes to customer inventory to include specific whse
This commit is contained in:
@@ -1,14 +1,23 @@
|
|||||||
import { query } from "../../sqlServer/prodSqlServer.js";
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
import { customerInvNoHold } from "../../sqlServer/querys/dataMart/customerInventoryQuerys.js";
|
import { customerInvNoHold } from "../../sqlServer/querys/dataMart/customerInventoryQuerys.js";
|
||||||
|
|
||||||
export const getCurrentCustomerInv = async (customer: any | null) => {
|
export const getCurrentCustomerInv = async (data: any | null) => {
|
||||||
|
//console.log(data.customer[0]);
|
||||||
|
|
||||||
let updatedQuery = customerInvNoHold;
|
let updatedQuery = customerInvNoHold;
|
||||||
|
|
||||||
if (customer) {
|
if (data.customer) {
|
||||||
//console.log(data.customer);
|
//console.log(data.customer);
|
||||||
updatedQuery = customerInvNoHold.replaceAll(
|
updatedQuery = customerInvNoHold.replaceAll(
|
||||||
"--and IdAdressen",
|
"--and IdAdressen",
|
||||||
`and IdAdressen = ${customer}`
|
`and IdAdressen = ${data.customer[0]}`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.whseToInclude) {
|
||||||
|
updatedQuery = updatedQuery.replaceAll(
|
||||||
|
"--and x.IdWarenlager in (14,15)",
|
||||||
|
`and x.IdWarenlager in (${data.whseToInclude[0]})`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -28,8 +28,8 @@ const current: any = [
|
|||||||
name: "getCustomerInventory",
|
name: "getCustomerInventory",
|
||||||
endpoint: "/api/datamart/getcustomerinventory",
|
endpoint: "/api/datamart/getcustomerinventory",
|
||||||
description:
|
description:
|
||||||
"Returns specific customer inventory based on there address ID.",
|
"Returns specific customer inventory based on there address ID, with optional to include warehouses, IE 36,41,5. leaving warehouse blank will just pull everything",
|
||||||
criteria: "customer",
|
criteria: "customer,whseToInclude",
|
||||||
},
|
},
|
||||||
// {
|
// {
|
||||||
// name: "getPalletLabels",
|
// name: "getPalletLabels",
|
||||||
|
|||||||
@@ -25,12 +25,12 @@ app.openapi(
|
|||||||
responses: responses(),
|
responses: responses(),
|
||||||
}),
|
}),
|
||||||
async (c) => {
|
async (c) => {
|
||||||
const customer: string = c.req.query("customer") ?? "";
|
const customerData: any = c.req.queries();
|
||||||
|
|
||||||
// make sure we have a vaid user being accessed thats really logged in
|
// make sure we have a vaid user being accessed thats really logged in
|
||||||
apiHit(c, { endpoint: "/getcustomerinventory" });
|
apiHit(c, { endpoint: "/getcustomerinventory" });
|
||||||
const { data, error } = await tryCatch(
|
const { data, error } = await tryCatch(
|
||||||
getCurrentCustomerInv(customer ? customer : null)
|
getCurrentCustomerInv(customerData ? customerData : null)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ The data below will be controlled by the user in excell by default everything wi
|
|||||||
where IdArtikelTyp = 1
|
where IdArtikelTyp = 1
|
||||||
and x.IdWarenlager not in (6, 1)
|
and x.IdWarenlager not in (6, 1)
|
||||||
--and IdAdressen
|
--and IdAdressen
|
||||||
|
--and x.IdWarenlager in (14,15)
|
||||||
|
|
||||||
|
|
||||||
group by x.IdArtikelVarianten
|
group by x.IdArtikelVarianten
|
||||||
|
|||||||
Reference in New Issue
Block a user