33 lines
924 B
TypeScript
33 lines
924 B
TypeScript
import { query } from "../../sqlServer/prodSqlServer.js";
|
|
import { customerInvNoHold } from "../../sqlServer/querys/dataMart/customerInventoryQuerys.js";
|
|
|
|
export const getCurrentCustomerInv = async (customer: any | null) => {
|
|
let updatedQuery = customerInvNoHold;
|
|
|
|
if (customer) {
|
|
//console.log(data.customer);
|
|
updatedQuery = customerInvNoHold.replaceAll(
|
|
"--and IdAdressen",
|
|
`and IdAdressen = ${customer}`
|
|
);
|
|
}
|
|
try {
|
|
const inventory: any = await query(
|
|
updatedQuery,
|
|
"Get active inventory"
|
|
);
|
|
|
|
return {
|
|
success: true,
|
|
message: "All customer inventory minus holds",
|
|
data: inventory.data,
|
|
};
|
|
} catch (error) {
|
|
return {
|
|
success: false,
|
|
message: "There was an error getting the inventory",
|
|
data: error,
|
|
};
|
|
}
|
|
};
|