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 { createLog } from "../../logger/logger.js";
|
||||||
import { query } from "../../sqlServer/prodSqlServer.js";
|
import { query } from "../../sqlServer/prodSqlServer.js";
|
||||||
import { fakeEDIUpdate } from "../../sqlServer/querys/dataMart/fakeEDIUpdate.js";
|
import { fakeEDIUpdate } from "../../sqlServer/querys/dataMart/fakeEDIUpdate.js";
|
||||||
@@ -23,10 +24,17 @@ export const getFakeEDI = async (address: string) => {
|
|||||||
try {
|
try {
|
||||||
fakeEDI = await query(updatedQuery, "Gets fakeEDI orders to be fixed");
|
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 {
|
return {
|
||||||
success: true,
|
success: true,
|
||||||
message: "Current open orders",
|
message: "Current open orders",
|
||||||
data: fakeEDI.data,
|
data: correctedData,
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|||||||
@@ -118,8 +118,12 @@ export const macroImportOrders = async (data: any, user: any) => {
|
|||||||
filterOrders.forEach((oo: any) => {
|
filterOrders.forEach((oo: any) => {
|
||||||
const isMatch = openOrders.some(
|
const isMatch = openOrders.some(
|
||||||
(o: any) =>
|
(o: any) =>
|
||||||
|
// check the header
|
||||||
String(o.CustomerOrderNumber).trim() ===
|
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) {
|
if (!isMatch) {
|
||||||
console.log(`ok to update: ${oo.CustomerOrderNumber}`);
|
console.log(`ok to update: ${oo.CustomerOrderNumber}`);
|
||||||
|
|||||||
@@ -109,8 +109,12 @@ export const standardOrders = async (data: any, user: any) => {
|
|||||||
filterOrders.forEach((oo: any) => {
|
filterOrders.forEach((oo: any) => {
|
||||||
const isMatch = openOrders.some(
|
const isMatch = openOrders.some(
|
||||||
(o: any) =>
|
(o: any) =>
|
||||||
|
// check the header
|
||||||
String(o.CustomerOrderNumber).trim() ===
|
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) {
|
if (!isMatch) {
|
||||||
console.log(`ok to update: ${oo.CustomerOrderNumber}`);
|
console.log(`ok to update: ${oo.CustomerOrderNumber}`);
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
export const fakeEDIUpdate = `
|
export const fakeEDIUpdate = `
|
||||||
Select LEFT(ArtikelVariantenAlias, charindex(' ', ArtikelVariantenAlias) - 1) CustomerArticleNumber,
|
Select LEFT(ArtikelVariantenAlias, charindex(' ', ArtikelVariantenAlias) - 1) CustomerArticleNumber,
|
||||||
AuftragsNummer AS CustomerOrderNumber,
|
cast(AuftragsNummer as varchar) AS CustomerOrderNumber,
|
||||||
PositionsNummer as CustomerLineNumber,
|
cast(PositionsNummer as varchar)as CustomerLineNumber,
|
||||||
AbrufNummer AS CustomerRealeaseNumber,
|
cast(AbrufNummer as varchar)AS CustomerRealeaseNumber,
|
||||||
AbrufMenge AS Quantity,
|
AbrufMenge AS Quantity,
|
||||||
' ' AS DeliveryDate,
|
AbrufLiefertermin AS DeliveryDate,
|
||||||
IdAdresse AS CustomerID,
|
IdAdresse AS CustomerID,
|
||||||
' ' AS Remark
|
' ' AS Remark
|
||||||
--,*
|
--,*
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export const orderState = `
|
export const orderState = `
|
||||||
SELECT top(10000)
|
SELECT top(10000)
|
||||||
CustomerOrderNumber
|
CustomerOrderNumber
|
||||||
|
,r.CustomerReleaseNumber
|
||||||
, OrderState
|
, OrderState
|
||||||
, r.ReleaseState
|
, r.ReleaseState
|
||||||
, h.CreatedByEdi
|
, h.CreatedByEdi
|
||||||
|
|||||||
Reference in New Issue
Block a user