@flowselections/logistiek-engine 1.0.99 → 1.0.104
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/BeladingIndelingCard.d.ts.map +1 -1
- package/dist-lib/components/BeladingIndelingCard.js +5 -1
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +600 -6
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +600 -6
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/moduleClient.d.ts +600 -6
- package/dist-lib/integrations/supabase/moduleClient.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +616 -6
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/cartCoverage.functions.d.ts +600 -6
- package/dist-lib/lib/cartCoverage.functions.d.ts.map +1 -1
- package/dist-lib/lib/controlScan.server.d.ts +8 -0
- package/dist-lib/lib/controlScan.server.d.ts.map +1 -1
- package/dist-lib/lib/controlScan.server.js +86 -5
- package/dist-lib/lib/floridayCancellation.server.d.ts +15 -0
- package/dist-lib/lib/floridayCancellation.server.d.ts.map +1 -0
- package/dist-lib/lib/floridayCancellation.server.js +89 -0
- package/dist-lib/lib/floridayCancellation.test.d.ts +2 -0
- package/dist-lib/lib/floridayCancellation.test.d.ts.map +1 -0
- package/dist-lib/lib/floridayCancellation.test.js +42 -0
- package/dist-lib/lib/floridayCartCarriers.d.ts +61 -0
- package/dist-lib/lib/floridayCartCarriers.d.ts.map +1 -0
- package/dist-lib/lib/floridayCartCarriers.js +113 -0
- package/dist-lib/lib/floridayCartCarriers.test.d.ts +2 -0
- package/dist-lib/lib/floridayCartCarriers.test.d.ts.map +1 -0
- package/dist-lib/lib/floridayCartCarriers.test.js +66 -0
- package/dist-lib/lib/floridayDocuments.functions.d.ts +1800 -18
- package/dist-lib/lib/floridayDocuments.functions.d.ts.map +1 -1
- package/dist-lib/lib/floridayDocuments.server.d.ts +7 -0
- package/dist-lib/lib/floridayDocuments.server.d.ts.map +1 -1
- package/dist-lib/lib/floridayDocuments.server.js +16 -1
- package/dist-lib/lib/floridayPush.functions.d.ts +600 -6
- package/dist-lib/lib/floridayPush.functions.d.ts.map +1 -1
- package/dist-lib/lib/floridayPush.server.d.ts +2 -0
- package/dist-lib/lib/floridayPush.server.d.ts.map +1 -1
- package/dist-lib/lib/floridayPush.server.js +54 -3
- package/dist-lib/lib/layerUtilization.d.ts +2 -0
- package/dist-lib/lib/layerUtilization.d.ts.map +1 -0
- package/dist-lib/lib/layerUtilization.js +11 -0
- package/dist-lib/lib/layerUtilization.test.d.ts +2 -0
- package/dist-lib/lib/layerUtilization.test.d.ts.map +1 -0
- package/dist-lib/lib/layerUtilization.test.js +11 -0
- package/dist-lib/lib/loadCarrierPlanning.functions.d.ts +3000 -30
- package/dist-lib/lib/loadCarrierPlanning.functions.d.ts.map +1 -1
- package/dist-lib/lib/loadCarrierPlanning.server.d.ts.map +1 -1
- package/dist-lib/lib/loadCarrierPlanning.server.js +16 -4
- package/dist-lib/lib/logisticsRecalcJob.functions.d.ts +1200 -12
- package/dist-lib/lib/logisticsRecalcJob.functions.d.ts.map +1 -1
- package/dist-lib/lib/logisticsRecalculate.functions.d.ts +600 -6
- package/dist-lib/lib/logisticsRecalculate.functions.d.ts.map +1 -1
- package/dist-lib/lib/modulePrompts.d.ts.map +1 -1
- package/dist-lib/lib/modulePrompts.js +46 -0
- package/dist-lib/lib/moduleVersion.d.ts +1 -1
- package/dist-lib/lib/moduleVersion.d.ts.map +1 -1
- package/dist-lib/lib/moduleVersion.js +1 -1
- package/dist-lib/lib/plannerDiff.functions.d.ts +600 -6
- package/dist-lib/lib/plannerDiff.functions.d.ts.map +1 -1
- package/dist-lib/lib/shippingNoteQueue.server.d.ts.map +1 -1
- package/dist-lib/lib/shippingNoteQueue.server.js +40 -1
- package/package.json +4 -4
|
@@ -6,6 +6,7 @@ export declare function hashPayload(value: unknown): string;
|
|
|
6
6
|
export interface FloridayPushPayload {
|
|
7
7
|
deliveryOrderId: string;
|
|
8
8
|
fulfillmentRequestIds: string[];
|
|
9
|
+
loadCarriers: import("./floridayCartCarriers.js").LoadCarrier[];
|
|
9
10
|
}
|
|
10
11
|
export type BuildResult = {
|
|
11
12
|
ok: true;
|
|
@@ -26,6 +27,7 @@ export declare function findDeliveryOrderForSalesOrder(sb: SupabaseClient, sales
|
|
|
26
27
|
ok: true;
|
|
27
28
|
deliveryOrderId: string;
|
|
28
29
|
fulfillmentRequestIds: string[];
|
|
30
|
+
requestDetails: import("./floridayCartCarriers.js").DeliveryRequestInput[];
|
|
29
31
|
matches: number;
|
|
30
32
|
} | {
|
|
31
33
|
ok: false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floridayPush.server.d.ts","sourceRoot":"","sources":["../../src/lib/floridayPush.server.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAc/C,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUlD;
|
|
1
|
+
{"version":3,"file":"floridayPush.server.d.ts","sourceRoot":"","sources":["../../src/lib/floridayPush.server.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,2BAA2B,MAAM,CAAC;AAc/C,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAUlD;AAaD,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,EAAE,CAAC;IAChC,YAAY,EAAE,OAAO,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AAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,8EAA8E;IAC9E,OAAO,EAAE,MAAM,CAAC;CACjB;AAYD,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,cAAc,EAClB,IAAI,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAO,GACjD,OAAO,CAAC,eAAe,CAAC,CA+K1B;AAQD,wBAAsB,wBAAwB,CAAC,EAAE,EAAE,cAAc,EAAE,IAAI,SAAK,GAAG,OAAO,CAAC,IAAI,CAAC,CAS3F"}
|
|
@@ -79,10 +79,24 @@ export async function findDeliveryOrderForSalesOrder(sb, salesOrderId) {
|
|
|
79
79
|
error: `Delivery-order ${String(row["floriday_id"] ?? "")} bevat geen fulfillmentRequests voor sales-order ${salesOrderId}.`,
|
|
80
80
|
};
|
|
81
81
|
}
|
|
82
|
+
const num = (v) => (typeof v === "number" ? v : v == null || v === "" ? null : Number(v));
|
|
83
|
+
const str = (v) => (typeof v === "string" && v.trim() ? v : null);
|
|
84
|
+
const requestDetails = requests
|
|
85
|
+
.filter((r) => fulfillmentRequestIds.includes(String(r["fulfillmentRequestId"] ?? r["id"] ?? "")))
|
|
86
|
+
.map((r) => ({
|
|
87
|
+
fulfillmentRequestId: String(r["fulfillmentRequestId"] ?? r["id"] ?? ""),
|
|
88
|
+
numberOfPackages: num(r["numberOfPackages"]),
|
|
89
|
+
serviceCode: num(r["serviceCode"]),
|
|
90
|
+
packingAgentOrganizationId: str(r["packingAgentOrganizationId"]),
|
|
91
|
+
deliveryRemarks: str(r["deliveryRemarks"]),
|
|
92
|
+
commercialInvoiceReference: str(r["commercialInvoiceReference"]),
|
|
93
|
+
alternativeDisplayName: str(r["alternativeDisplayName"]),
|
|
94
|
+
}));
|
|
82
95
|
return {
|
|
83
96
|
ok: true,
|
|
84
97
|
deliveryOrderId: String(row["floriday_id"] ?? ""),
|
|
85
98
|
fulfillmentRequestIds,
|
|
99
|
+
requestDetails,
|
|
86
100
|
matches: rows.length,
|
|
87
101
|
};
|
|
88
102
|
}
|
|
@@ -121,7 +135,7 @@ export async function buildFloridayPayload(sb, orderRef) {
|
|
|
121
135
|
}
|
|
122
136
|
const { data: carts, error: cartsError } = await sb
|
|
123
137
|
.from("order_carts")
|
|
124
|
-
.select("id, cart_number, carrier_type, total_layers_used, max_layers, occupancy_pct, weight_kg, order_cart_items(product_id, product_name, crates, boxes, plants_per_crate)")
|
|
138
|
+
.select("id, cart_number, carrier_type, total_layers_used, max_layers, occupancy_pct, weight_kg, order_cart_items(product_id, product_name, crates, boxes, plants_per_crate, order_item_id)")
|
|
125
139
|
.eq("order_id", row["id"])
|
|
126
140
|
.order("cart_number", { ascending: true });
|
|
127
141
|
if (cartsError) {
|
|
@@ -132,8 +146,8 @@ export async function buildFloridayPayload(sb, orderRef) {
|
|
|
132
146
|
permanent: false,
|
|
133
147
|
};
|
|
134
148
|
}
|
|
135
|
-
const
|
|
136
|
-
|
|
149
|
+
const cartRows = (Array.isArray(carts) ? carts : []);
|
|
150
|
+
const indeling = cartRows.map((cart) => {
|
|
137
151
|
const items = Array.isArray(cart["order_cart_items"])
|
|
138
152
|
? cart["order_cart_items"]
|
|
139
153
|
: [];
|
|
@@ -150,9 +164,46 @@ export async function buildFloridayPayload(sb, orderRef) {
|
|
|
150
164
|
.sort((a, b) => String(a.productId).localeCompare(String(b.productId))),
|
|
151
165
|
};
|
|
152
166
|
});
|
|
167
|
+
// Orderregel → Floriday fulfillmentRequest (order_items.source_line_key).
|
|
168
|
+
const { data: orderItems, error: itemsError } = await sb
|
|
169
|
+
.from("order_items")
|
|
170
|
+
.select("id, source_line_key")
|
|
171
|
+
.eq("order_id", row["id"])
|
|
172
|
+
// Regels in quarantaine (Verkoop-herstel) gaan niet mee naar Floriday.
|
|
173
|
+
.is("quarantined_at", null);
|
|
174
|
+
if (itemsError) {
|
|
175
|
+
return {
|
|
176
|
+
ok: false,
|
|
177
|
+
code: "db_error_order_items",
|
|
178
|
+
error: `Orderregels niet leesbaar: ${itemsError.message}`,
|
|
179
|
+
permanent: false,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
const requestByItem = new Map();
|
|
183
|
+
for (const it of (Array.isArray(orderItems) ? orderItems : [])) {
|
|
184
|
+
const key = String(it["source_line_key"] ?? "").trim();
|
|
185
|
+
if (key)
|
|
186
|
+
requestByItem.set(String(it["id"]), key);
|
|
187
|
+
}
|
|
188
|
+
const { buildCartCarriers } = await import("./floridayCartCarriers.js");
|
|
189
|
+
const carriers = buildCartCarriers(cartRows.map((cart) => ({
|
|
190
|
+
cartNumber: cart["cart_number"] ?? null,
|
|
191
|
+
layersUsed: cart["total_layers_used"] ?? null,
|
|
192
|
+
items: (Array.isArray(cart["order_cart_items"])
|
|
193
|
+
? cart["order_cart_items"]
|
|
194
|
+
: []).map((i) => ({
|
|
195
|
+
fulfillmentRequestId: requestByItem.get(String(i["order_item_id"] ?? "")) ?? null,
|
|
196
|
+
crates: i["crates"] ?? null,
|
|
197
|
+
})),
|
|
198
|
+
})), found.requestDetails);
|
|
199
|
+
if (!carriers.ok) {
|
|
200
|
+
// Geen stille terugval op 0 lagen: zonder kloppende indeling niet versturen.
|
|
201
|
+
return { ok: false, code: carriers.code, error: carriers.error, permanent: false };
|
|
202
|
+
}
|
|
153
203
|
const payload = {
|
|
154
204
|
deliveryOrderId: found.deliveryOrderId,
|
|
155
205
|
fulfillmentRequestIds: found.fulfillmentRequestIds,
|
|
206
|
+
loadCarriers: carriers.loadCarriers,
|
|
156
207
|
};
|
|
157
208
|
// De hash bewaakt ook de karindeling, zodat een herindeling opnieuw pusht.
|
|
158
209
|
return { ok: true, payload, hash: hashPayload({ payload, indeling }) };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layerUtilization.d.ts","sourceRoot":"","sources":["../../src/lib/layerUtilization.ts"],"names":[],"mappings":"AAEA,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAM1F"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Lagen van de kar gebruikt: gebruikte lagen / lagen van de ladingdrager x 100
|
|
2
|
+
// (1 decimaal). Ontbreekt het aantal lagen van de drager, dan geen cijfer.
|
|
3
|
+
export function layerUtilizationPct(layersUsed, maxLayers) {
|
|
4
|
+
const used = Number(layersUsed);
|
|
5
|
+
const max = Number(maxLayers);
|
|
6
|
+
if (layersUsed === null || layersUsed === undefined || !Number.isFinite(used) || used < 0)
|
|
7
|
+
return null;
|
|
8
|
+
if (!Number.isFinite(max) || max <= 0)
|
|
9
|
+
return null;
|
|
10
|
+
return Math.round((1000 * used) / max) / 10;
|
|
11
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layerUtilization.test.d.ts","sourceRoot":"","sources":["../../src/lib/layerUtilization.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { layerUtilizationPct } from "./layerUtilization";
|
|
3
|
+
describe("layerUtilizationPct", () => {
|
|
4
|
+
it("1 van 5 lagen = 20%", () => expect(layerUtilizationPct(1, 5)).toBe(20));
|
|
5
|
+
it("4 van 5 lagen = 80%", () => expect(layerUtilizationPct(4, 5)).toBe(80));
|
|
6
|
+
it("drager zonder lagen geeft geen cijfer", () => {
|
|
7
|
+
expect(layerUtilizationPct(1, 0)).toBeNull();
|
|
8
|
+
expect(layerUtilizationPct(1, null)).toBeNull();
|
|
9
|
+
expect(layerUtilizationPct(null, 5)).toBeNull();
|
|
10
|
+
});
|
|
11
|
+
});
|