feat(lstv2 move): moved lstv2 into this app to keep them combined and easier to maintain
This commit is contained in:
47
lstV2/server/services/dataMart/controller/fakeEDIUpdate.ts
Normal file
47
lstV2/server/services/dataMart/controller/fakeEDIUpdate.ts
Normal file
@@ -0,0 +1,47 @@
|
||||
import { format } from "date-fns-tz";
|
||||
import { createLog } from "../../logger/logger.js";
|
||||
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||
import { fakeEDIUpdate } from "../../sqlServer/querys/dataMart/fakeEDIUpdate.js";
|
||||
|
||||
export const getFakeEDI = async (address: string) => {
|
||||
let fakeEDI: any = [];
|
||||
|
||||
let updatedQuery = fakeEDIUpdate;
|
||||
|
||||
if (address) {
|
||||
createLog(
|
||||
"info",
|
||||
"datamart",
|
||||
"datamart",
|
||||
"The user requested a specific address."
|
||||
);
|
||||
updatedQuery = fakeEDIUpdate.replace(
|
||||
"--and IdAdresse = 14",
|
||||
`and IdAdresse = ${address}`
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
fakeEDI = await query(updatedQuery, "Gets fakeEDI orders to be fixed");
|
||||
|
||||
const correctedData = fakeEDI.data.map((n: any) => {
|
||||
return {
|
||||
...n,
|
||||
DeliveryDate: format(n.DeliveryDate, "M/d/yyyy HH:mm"),
|
||||
};
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
message: "Current open orders",
|
||||
data: correctedData,
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
return {
|
||||
success: false,
|
||||
message: "There was an error open orders",
|
||||
data: error,
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user