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 { 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 {
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user