fix(fakeedi updates): corrected an issue where multi orders would not update if 1 release was used
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
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";
|
||||
@@ -23,10 +24,17 @@ export const getFakeEDI = async (address: string) => {
|
||||
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: fakeEDI.data,
|
||||
data: correctedData,
|
||||
};
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
|
||||
@@ -118,8 +118,12 @@ export const macroImportOrders = async (data: any, user: any) => {
|
||||
filterOrders.forEach((oo: any) => {
|
||||
const isMatch = openOrders.some(
|
||||
(o: any) =>
|
||||
// check the header
|
||||
String(o.CustomerOrderNumber).trim() ===
|
||||
String(oo.CustomerOrderNumber).trim()
|
||||
String(oo.CustomerOrderNumber).trim() &&
|
||||
// and check the customer release is not in here.
|
||||
String(o.CustomerRealeaseNumber).trim() ===
|
||||
String(oo.CustomerRealeaseNumber).trim()
|
||||
);
|
||||
if (!isMatch) {
|
||||
console.log(`ok to update: ${oo.CustomerOrderNumber}`);
|
||||
|
||||
@@ -109,8 +109,12 @@ export const standardOrders = async (data: any, user: any) => {
|
||||
filterOrders.forEach((oo: any) => {
|
||||
const isMatch = openOrders.some(
|
||||
(o: any) =>
|
||||
// check the header
|
||||
String(o.CustomerOrderNumber).trim() ===
|
||||
String(oo.CustomerOrderNumber).trim()
|
||||
String(oo.CustomerOrderNumber).trim() &&
|
||||
// and check the customer release is not in here.
|
||||
String(o.CustomerRealeaseNumber).trim() ===
|
||||
String(oo.CustomerRealeaseNumber).trim()
|
||||
);
|
||||
if (!isMatch) {
|
||||
console.log(`ok to update: ${oo.CustomerOrderNumber}`);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
export const fakeEDIUpdate = `
|
||||
Select LEFT(ArtikelVariantenAlias, charindex(' ', ArtikelVariantenAlias) - 1) CustomerArticleNumber,
|
||||
AuftragsNummer AS CustomerOrderNumber,
|
||||
PositionsNummer as CustomerLineNumber,
|
||||
AbrufNummer AS CustomerRealeaseNumber,
|
||||
cast(AuftragsNummer as varchar) AS CustomerOrderNumber,
|
||||
cast(PositionsNummer as varchar)as CustomerLineNumber,
|
||||
cast(AbrufNummer as varchar)AS CustomerRealeaseNumber,
|
||||
AbrufMenge AS Quantity,
|
||||
' ' AS DeliveryDate,
|
||||
AbrufLiefertermin AS DeliveryDate,
|
||||
IdAdresse AS CustomerID,
|
||||
' ' AS Remark
|
||||
--,*
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
export const orderState = `
|
||||
SELECT top(10000)
|
||||
CustomerOrderNumber
|
||||
,r.CustomerReleaseNumber
|
||||
, OrderState
|
||||
, r.ReleaseState
|
||||
, h.CreatedByEdi
|
||||
|
||||
Reference in New Issue
Block a user