@flowselections/logistiek-engine 1.0.90 → 1.0.98
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/FlowOrders.js +1 -1
- package/dist-lib/components/MisluktVerzendbrievenCard.d.ts +2 -0
- package/dist-lib/components/MisluktVerzendbrievenCard.d.ts.map +1 -0
- package/dist-lib/components/MisluktVerzendbrievenCard.js +50 -0
- package/dist-lib/components/RegiePage.d.ts.map +1 -1
- package/dist-lib/components/RegiePage.js +2 -1
- package/dist-lib/components/RuleEnginePage.d.ts.map +1 -1
- package/dist-lib/components/RuleEnginePage.js +3 -1
- package/dist-lib/hooks/useShippingNoteStatus.d.ts +2 -0
- package/dist-lib/hooks/useShippingNoteStatus.d.ts.map +1 -1
- package/dist-lib/hooks/useShippingNoteStatus.js +13 -1
- package/dist-lib/hooks/useShippingNoteStatus.test.d.ts +2 -0
- package/dist-lib/hooks/useShippingNoteStatus.test.d.ts.map +1 -0
- package/dist-lib/hooks/useShippingNoteStatus.test.js +20 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +415 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +415 -0
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/moduleClient.d.ts +415 -0
- package/dist-lib/integrations/supabase/moduleClient.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +423 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/cartCoverage.functions.d.ts +415 -0
- package/dist-lib/lib/cartCoverage.functions.d.ts.map +1 -1
- package/dist-lib/lib/controlScan.server.d.ts +2 -0
- package/dist-lib/lib/controlScan.server.d.ts.map +1 -1
- package/dist-lib/lib/controlScan.server.js +59 -53
- package/dist-lib/lib/floridayDocuments.functions.d.ts +1245 -0
- package/dist-lib/lib/floridayDocuments.functions.d.ts.map +1 -1
- package/dist-lib/lib/floridayPush.functions.d.ts +415 -0
- package/dist-lib/lib/floridayPush.functions.d.ts.map +1 -1
- package/dist-lib/lib/layoutPrint.server.d.ts +27 -0
- package/dist-lib/lib/layoutPrint.server.d.ts.map +1 -0
- package/dist-lib/lib/layoutPrint.server.js +48 -0
- package/dist-lib/lib/layoutPrint.test.d.ts +2 -0
- package/dist-lib/lib/layoutPrint.test.d.ts.map +1 -0
- package/dist-lib/lib/layoutPrint.test.js +47 -0
- package/dist-lib/lib/loadCarrierPlanning.functions.d.ts +2075 -0
- 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 +52 -8
- package/dist-lib/lib/logisticsRecalcJob.functions.d.ts +830 -0
- package/dist-lib/lib/logisticsRecalcJob.functions.d.ts.map +1 -1
- package/dist-lib/lib/logisticsRecalculate.functions.d.ts +415 -0
- 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 +54 -0
- package/dist-lib/lib/plannerDiff.functions.d.ts +415 -0
- package/dist-lib/lib/plannerDiff.functions.d.ts.map +1 -1
- package/dist-lib/lib/ruleEngineSchema.js +2 -2
- package/dist-lib/lib/shippingNoteQueue.server.d.ts.map +1 -1
- package/dist-lib/lib/shippingNoteQueue.server.js +40 -49
- package/package.json +1 -1
|
@@ -6,6 +6,8 @@ export interface ControlScanRun {
|
|
|
6
6
|
failed: number;
|
|
7
7
|
errors: string[];
|
|
8
8
|
}
|
|
9
|
+
/** Maximaal aantal wachtrondes op Floriday voordat de controle als mislukt stopt. */
|
|
10
|
+
export declare const CONTROL_SCAN_MAX_ATTEMPTS = 60;
|
|
9
11
|
export declare function runControlScanQueue(sb: SupabaseClient, options?: {
|
|
10
12
|
limit?: number;
|
|
11
13
|
}): Promise<ControlScanRun>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controlScan.server.d.ts","sourceRoot":"","sources":["../../src/lib/controlScan.server.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"controlScan.server.d.ts","sourceRoot":"","sources":["../../src/lib/controlScan.server.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,EAAE,CAAC;CAClB;AAcD,qFAAqF;AACrF,eAAO,MAAM,yBAAyB,KAAK,CAAC;AAwC5C,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,cAAc,EAClB,OAAO,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC/B,OAAO,CAAC,cAAc,CAAC,CAmKzB"}
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
// en dubbele scans worden al in de database geblokkeerd. Geen omgevings- of
|
|
15
15
|
// klantwaarden in deze code; de printer komt uit de werkwijze in de database.
|
|
16
16
|
// ============================================================================
|
|
17
|
+
import { printViaLayout } from "./layoutPrint.server.js";
|
|
18
|
+
/** Maximaal aantal wachtrondes op Floriday voordat de controle als mislukt stopt. */
|
|
19
|
+
export const CONTROL_SCAN_MAX_ATTEMPTS = 60;
|
|
17
20
|
function pickPdf(result) {
|
|
18
21
|
const base64 = result["pdfBase64"] ??
|
|
19
22
|
result["base64"] ??
|
|
@@ -25,12 +28,28 @@ function pickPdf(result) {
|
|
|
25
28
|
null;
|
|
26
29
|
return { base64: base64 ?? null, url: url ?? null };
|
|
27
30
|
}
|
|
28
|
-
/**
|
|
29
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Laat de controle wachten op Floriday. Pogingen blijven meetellen; na het
|
|
33
|
+
* maximum eindigt de controle als mislukt in plaats van eeuwig te wachten.
|
|
34
|
+
* Geeft true terug als de controle nu terminaal is afgesloten.
|
|
35
|
+
*/
|
|
36
|
+
async function keepWaiting(sb, row) {
|
|
37
|
+
const attempts = Number(row.attempts ?? 0);
|
|
38
|
+
if (attempts >= CONTROL_SCAN_MAX_ATTEMPTS) {
|
|
39
|
+
await sb.rpc("logistics_control_scan_finish", {
|
|
40
|
+
_id: row.id,
|
|
41
|
+
_ok: false,
|
|
42
|
+
_status: "mislukt",
|
|
43
|
+
_error_code: "wachtlimiet",
|
|
44
|
+
_error: `Na ${attempts} pogingen kende Floriday deze order nog steeds niet; de controle is gestopt. Controleer de order in Floriday en scan opnieuw.`,
|
|
45
|
+
});
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
30
48
|
await sb
|
|
31
49
|
.from("logistics_control_scan")
|
|
32
|
-
.update({ locked_until: null,
|
|
33
|
-
.eq("id", id);
|
|
50
|
+
.update({ locked_until: null, updated_at: new Date().toISOString() })
|
|
51
|
+
.eq("id", row.id);
|
|
52
|
+
return false;
|
|
34
53
|
}
|
|
35
54
|
export async function runControlScanQueue(sb, options = {}) {
|
|
36
55
|
const run = { claimed: 0, printed: 0, waiting: 0, failed: 0, errors: [] };
|
|
@@ -88,8 +107,10 @@ export async function runControlScanQueue(sb, options = {}) {
|
|
|
88
107
|
continue;
|
|
89
108
|
}
|
|
90
109
|
if (!fulfillmentOrderId) {
|
|
91
|
-
await keepWaiting(sb, row
|
|
92
|
-
|
|
110
|
+
if (await keepWaiting(sb, row))
|
|
111
|
+
run.failed++;
|
|
112
|
+
else
|
|
113
|
+
run.waiting++;
|
|
93
114
|
continue;
|
|
94
115
|
}
|
|
95
116
|
const doc = (await getFlorydayDocument(sb, {
|
|
@@ -122,54 +143,39 @@ export async function runControlScanQueue(sb, options = {}) {
|
|
|
122
143
|
run.failed++;
|
|
123
144
|
continue;
|
|
124
145
|
}
|
|
125
|
-
//
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
})
|
|
157
|
-
.select("id")
|
|
158
|
-
.maybeSingle();
|
|
159
|
-
if (jobError) {
|
|
160
|
-
await sb.rpc("logistics_control_scan_finish", {
|
|
161
|
-
_id: row.id,
|
|
162
|
-
_ok: false,
|
|
163
|
-
_status: "mislukt",
|
|
164
|
-
_fulfillment_order_id: fulfillmentOrderId,
|
|
165
|
-
_error_code: "printjob",
|
|
166
|
-
_error: `De afleverbrief kon niet worden klaargezet om te printen: ${jobError.message}`,
|
|
167
|
-
});
|
|
168
|
-
run.failed++;
|
|
169
|
-
continue;
|
|
170
|
-
}
|
|
171
|
-
jobId = job?.["id"] ?? null;
|
|
146
|
+
// Via de Layout maker; idempotent per controle.
|
|
147
|
+
const printed = await printViaLayout(sb, {
|
|
148
|
+
documenttype: "afleverbrief",
|
|
149
|
+
documentnaam: `Afleverbrief ${row.order_number}`,
|
|
150
|
+
pdfBase64: base64,
|
|
151
|
+
pdfUrl: url,
|
|
152
|
+
printPlekId: null,
|
|
153
|
+
herkomst: "floriday",
|
|
154
|
+
idempotentieSleutel: `controle-scan:${row.id}`,
|
|
155
|
+
payload: {
|
|
156
|
+
source: "controle_scan",
|
|
157
|
+
is_floriday: true,
|
|
158
|
+
order_id: row.order_id,
|
|
159
|
+
ordernummer: row.order_number,
|
|
160
|
+
order_number: row.order_number,
|
|
161
|
+
cart_id: row.cart_id,
|
|
162
|
+
fulfillment_order_id: fulfillmentOrderId,
|
|
163
|
+
control_scan_id: row.id,
|
|
164
|
+
},
|
|
165
|
+
});
|
|
166
|
+
if (!printed.ok) {
|
|
167
|
+
await sb.rpc("logistics_control_scan_finish", {
|
|
168
|
+
_id: row.id,
|
|
169
|
+
_ok: false,
|
|
170
|
+
_status: "mislukt",
|
|
171
|
+
_fulfillment_order_id: fulfillmentOrderId,
|
|
172
|
+
_error_code: printed.errorCode.toLowerCase(),
|
|
173
|
+
_error: printed.error,
|
|
174
|
+
});
|
|
175
|
+
run.failed++;
|
|
176
|
+
continue;
|
|
172
177
|
}
|
|
178
|
+
const jobId = printed.jobId;
|
|
173
179
|
await sb.rpc("logistics_control_scan_finish", {
|
|
174
180
|
_id: row.id,
|
|
175
181
|
_ok: true,
|