diff --git a/server/services/dataMart/controller/getCustomerInventory.ts b/server/services/dataMart/controller/getCustomerInventory.ts index a7b82e5..ed22bb1 100644 --- a/server/services/dataMart/controller/getCustomerInventory.ts +++ b/server/services/dataMart/controller/getCustomerInventory.ts @@ -1,14 +1,23 @@ import { query } from "../../sqlServer/prodSqlServer.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; - if (customer) { + if (data.customer) { //console.log(data.customer); updatedQuery = customerInvNoHold.replaceAll( "--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 { diff --git a/server/services/dataMart/route/getCurrentQuerys.ts b/server/services/dataMart/route/getCurrentQuerys.ts index bc863fd..1c72276 100644 --- a/server/services/dataMart/route/getCurrentQuerys.ts +++ b/server/services/dataMart/route/getCurrentQuerys.ts @@ -28,8 +28,8 @@ const current: any = [ name: "getCustomerInventory", endpoint: "/api/datamart/getcustomerinventory", description: - "Returns specific customer inventory based on there address ID.", - criteria: "customer", + "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,whseToInclude", }, // { // name: "getPalletLabels", diff --git a/server/services/dataMart/route/getCustomerInv.ts b/server/services/dataMart/route/getCustomerInv.ts index ab39077..10655e8 100644 --- a/server/services/dataMart/route/getCustomerInv.ts +++ b/server/services/dataMart/route/getCustomerInv.ts @@ -25,12 +25,12 @@ app.openapi( responses: responses(), }), 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 apiHit(c, { endpoint: "/getcustomerinventory" }); const { data, error } = await tryCatch( - getCurrentCustomerInv(customer ? customer : null) + getCurrentCustomerInv(customerData ? customerData : null) ); if (error) { diff --git a/server/services/sqlServer/querys/dataMart/customerInventoryQuerys.ts b/server/services/sqlServer/querys/dataMart/customerInventoryQuerys.ts index 525adb5..6759495 100644 --- a/server/services/sqlServer/querys/dataMart/customerInventoryQuerys.ts +++ b/server/services/sqlServer/querys/dataMart/customerInventoryQuerys.ts @@ -32,6 +32,7 @@ The data below will be controlled by the user in excell by default everything wi where IdArtikelTyp = 1 and x.IdWarenlager not in (6, 1) --and IdAdressen +--and x.IdWarenlager in (14,15) group by x.IdArtikelVarianten