@flowselections/floriday-verkoop-module 1.0.21 → 1.0.25
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/karindeling/AfmetingenTab.d.ts +6 -0
- package/dist-lib/components/karindeling/AfmetingenTab.d.ts.map +1 -0
- package/dist-lib/components/karindeling/AfmetingenTab.js +128 -0
- package/dist-lib/components/karindeling/KarindelingPage.d.ts +2 -0
- package/dist-lib/components/karindeling/KarindelingPage.d.ts.map +1 -0
- package/dist-lib/components/karindeling/KarindelingPage.js +102 -0
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.js +83 -37
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +59 -8
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts +2 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +2 -2
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.js +36 -4
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +18 -2
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +12 -1
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +2353 -374
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +2353 -374
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.js +24 -9
- package/dist-lib/integrations/supabase/client.server.d.ts +2353 -374
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +2406 -376
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.js +11 -9
- package/dist-lib/lib/cart-lock.functions.d.ts +2353 -374
- package/dist-lib/lib/cart-lock.functions.d.ts.map +1 -1
- package/dist-lib/lib/cart-planner.d.ts +9 -1
- package/dist-lib/lib/cart-planner.d.ts.map +1 -1
- package/dist-lib/lib/cart-planner.js +21 -4
- package/dist-lib/lib/cart-planning-settings.functions.d.ts +152282 -0
- package/dist-lib/lib/cart-planning-settings.functions.d.ts.map +1 -0
- package/dist-lib/lib/cart-planning-settings.functions.js +375 -0
- package/dist-lib/lib/cart-replan.functions.d.ts +18468 -651
- package/dist-lib/lib/cart-replan.functions.d.ts.map +1 -1
- package/dist-lib/lib/cart-replan.functions.js +85 -27
- package/dist-lib/lib/create-order.functions.d.ts +25367 -1619
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/cron/index.d.ts +5 -0
- package/dist-lib/lib/cron/index.d.ts.map +1 -0
- package/dist-lib/lib/cron/index.js +4 -0
- package/dist-lib/lib/cron/mirror-floriday-orders.d.ts +4 -0
- package/dist-lib/lib/cron/mirror-floriday-orders.d.ts.map +1 -0
- package/dist-lib/lib/cron/mirror-floriday-orders.js +23 -0
- package/dist-lib/lib/cron/replan-carts.d.ts +4 -0
- package/dist-lib/lib/cron/replan-carts.d.ts.map +1 -0
- package/dist-lib/lib/cron/replan-carts.js +18 -0
- package/dist-lib/lib/cron/sync-salesorders.d.ts +4 -0
- package/dist-lib/lib/cron/sync-salesorders.d.ts.map +1 -0
- package/dist-lib/lib/cron/sync-salesorders.js +18 -0
- package/dist-lib/lib/cron/sync-tradeitems.d.ts +4 -0
- package/dist-lib/lib/cron/sync-tradeitems.d.ts.map +1 -0
- package/dist-lib/lib/cron/sync-tradeitems.js +18 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts +6539 -602
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-auto-fulfillment.server.js +1 -1
- package/dist-lib/lib/floriday-central-token.server.d.ts +12 -0
- package/dist-lib/lib/floriday-central-token.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday-central-token.server.js +58 -0
- package/dist-lib/lib/floriday-gateway.server.d.ts +2 -2
- package/dist-lib/lib/floriday-gateway.server.d.ts.map +1 -1
- package/dist-lib/lib/floriday-gateway.server.js +10 -37
- package/dist-lib/lib/floriday-logistic-labels.functions.d.ts +2353 -374
- package/dist-lib/lib/floriday-logistic-labels.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-logistic-labels.functions.js +14 -4
- package/dist-lib/lib/floriday-mirror.functions.d.ts +13846 -0
- package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-mirror.functions.js +278 -0
- package/dist-lib/lib/floriday-public.functions.d.ts +14907 -1054
- package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-sync.d.ts +0 -1
- package/dist-lib/lib/floriday-sync.d.ts.map +1 -1
- package/dist-lib/lib/floriday-sync.js +1 -1
- package/dist-lib/lib/floriday-writes.functions.d.ts +10723 -828
- package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-buffers.functions.d.ts +41540 -0
- package/dist-lib/lib/order-buffers.functions.d.ts.map +1 -0
- package/dist-lib/lib/order-buffers.functions.js +244 -0
- package/dist-lib/lib/order-shipments.functions.d.ts +8631 -715
- package/dist-lib/lib/order-shipments.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-mapping.d.ts +3 -0
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.d.ts +10725 -828
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.js +129 -3
- package/dist-lib/lib/tradeitems.functions.d.ts +2353 -374
- package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.js +37 -2
- package/package.json +27 -5
|
@@ -84,6 +84,15 @@ async function runSalesOrdersSyncInternal() {
|
|
|
84
84
|
});
|
|
85
85
|
}
|
|
86
86
|
}
|
|
87
|
+
// Spiegel recent gewijzigde FO's naar de lokale orders-tabel zodat
|
|
88
|
+
// buffergroepering en gedeelde karren werken.
|
|
89
|
+
try {
|
|
90
|
+
const { mirrorFloridayOrdersFromCron } = await import("./floriday-mirror.functions");
|
|
91
|
+
await mirrorFloridayOrdersFromCron(500);
|
|
92
|
+
}
|
|
93
|
+
catch (mirrorErr) {
|
|
94
|
+
console.error("[floriday-mirror] failed", mirrorErr);
|
|
95
|
+
}
|
|
87
96
|
return { ok: results.every((r) => r.ok), results };
|
|
88
97
|
}
|
|
89
98
|
export async function runSalesOrdersSyncFromCron() {
|
|
@@ -230,7 +239,7 @@ export const getSalesOrderDetail = createServerFn({ method: "POST" })
|
|
|
230
239
|
const conn = (connRes.data ?? [])[0];
|
|
231
240
|
const sellerFallback = conn?.organization_name ?? conn?.label ?? null;
|
|
232
241
|
if (!conn?.id) {
|
|
233
|
-
return { order: null, sellerFallback, environment };
|
|
242
|
+
return { order: null, sellerFallback, environment, bufferId: null, bufferSiblings: [] };
|
|
234
243
|
}
|
|
235
244
|
// 2) De order zelf uit de cache (gerichte lookup op indexed kolom).
|
|
236
245
|
const orderRes = await supabase
|
|
@@ -244,7 +253,7 @@ export const getSalesOrderDetail = createServerFn({ method: "POST" })
|
|
|
244
253
|
}
|
|
245
254
|
const row = orderRes.data;
|
|
246
255
|
if (!row?.data) {
|
|
247
|
-
return { order: null, sellerFallback, environment };
|
|
256
|
+
return { order: null, sellerFallback, environment, bufferId: null, bufferSiblings: [] };
|
|
248
257
|
}
|
|
249
258
|
const orderData = row.data;
|
|
250
259
|
const customerOrgId = String(orderData?.customerOrganizationId ?? "");
|
|
@@ -342,7 +351,124 @@ export const getSalesOrderDetail = createServerFn({ method: "POST" })
|
|
|
342
351
|
__controlledAt: controlledAt,
|
|
343
352
|
};
|
|
344
353
|
const dto = mapJsonbToSalesOrderDTO(enrichedOrder, customerLookup, tradeItemLookup);
|
|
345
|
-
|
|
354
|
+
// 6) Buffer-siblings: zoek buffer_id via orders-tabel en verzamel alle
|
|
355
|
+
// verwante Floriday-orders. Zo werkt de detailweergave onafhankelijk
|
|
356
|
+
// van de (soms trage of gefilterde) lijst-query.
|
|
357
|
+
let bufferId = null;
|
|
358
|
+
const bufferSiblings = [];
|
|
359
|
+
try {
|
|
360
|
+
const ownRes = await supabase
|
|
361
|
+
.from("orders")
|
|
362
|
+
.select("buffer_id")
|
|
363
|
+
.eq("floriday_sales_order_id", data.id)
|
|
364
|
+
.maybeSingle();
|
|
365
|
+
bufferId = ownRes.data?.buffer_id ?? null;
|
|
366
|
+
if (bufferId) {
|
|
367
|
+
dto.bufferId = bufferId;
|
|
368
|
+
const sibRes = await supabase
|
|
369
|
+
.from("orders")
|
|
370
|
+
.select("floriday_sales_order_id")
|
|
371
|
+
.eq("buffer_id", bufferId)
|
|
372
|
+
.not("floriday_sales_order_id", "is", null);
|
|
373
|
+
const sibFoIds = (sibRes.data ?? [])
|
|
374
|
+
.map((r) => String(r.floriday_sales_order_id))
|
|
375
|
+
.filter((id) => id && id !== data.id);
|
|
376
|
+
if (sibFoIds.length > 0) {
|
|
377
|
+
const sibCacheRes = await supabase
|
|
378
|
+
.from("floriday_salesorders_cache")
|
|
379
|
+
.select("floriday_id, data, controlled_at")
|
|
380
|
+
.eq("connection_id", conn.id)
|
|
381
|
+
.in("floriday_id", sibFoIds);
|
|
382
|
+
const sibRows = (sibCacheRes.data ?? []);
|
|
383
|
+
// Verzamel extra klant/trade-item lookups voor de siblings.
|
|
384
|
+
const extraOrgIds = Array.from(new Set(sibRows
|
|
385
|
+
.map((r) => String(r?.data?.customerOrganizationId ?? ""))
|
|
386
|
+
.filter((id) => id && !customerLookup.has(id))));
|
|
387
|
+
const extraTiIds = Array.from(new Set(sibRows
|
|
388
|
+
.map((r) => String(r?.data?.tradeItemId ?? ""))
|
|
389
|
+
.filter((id) => id && !tradeItemLookup.has(id))));
|
|
390
|
+
const [extraCustLocal, extraCustCache, extraTi] = await Promise.all([
|
|
391
|
+
extraOrgIds.length
|
|
392
|
+
? supabase
|
|
393
|
+
.from("customers")
|
|
394
|
+
.select("id, company_name, commercial_name, city, postal_code, logo_url, floriday_organization_id")
|
|
395
|
+
.in("floriday_organization_id", extraOrgIds)
|
|
396
|
+
: Promise.resolve({ data: [] }),
|
|
397
|
+
extraOrgIds.length
|
|
398
|
+
? supabase
|
|
399
|
+
.from("floriday_customers_cache")
|
|
400
|
+
.select("organization_id, data")
|
|
401
|
+
.in("organization_id", extraOrgIds)
|
|
402
|
+
: Promise.resolve({ data: [] }),
|
|
403
|
+
extraTiIds.length
|
|
404
|
+
? supabase
|
|
405
|
+
.from("floriday_trade_items_cache")
|
|
406
|
+
.select("floriday_id, data")
|
|
407
|
+
.in("floriday_id", extraTiIds)
|
|
408
|
+
: Promise.resolve({ data: [] }),
|
|
409
|
+
]);
|
|
410
|
+
const localByOrg = new Map();
|
|
411
|
+
for (const c of (extraCustLocal.data ?? [])) {
|
|
412
|
+
localByOrg.set(String(c.floriday_organization_id), c);
|
|
413
|
+
}
|
|
414
|
+
for (const orgId of extraOrgIds) {
|
|
415
|
+
const localC = localByOrg.get(orgId);
|
|
416
|
+
if (localC) {
|
|
417
|
+
customerLookup.set(orgId, {
|
|
418
|
+
name: localC.commercial_name ?? localC.company_name ?? "Onbekende klant",
|
|
419
|
+
postalCode: localC.postal_code ?? "",
|
|
420
|
+
city: localC.city ?? "",
|
|
421
|
+
logoUrl: localC.logo_url ?? null,
|
|
422
|
+
raw: localC,
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
for (const c of (extraCustCache.data ?? [])) {
|
|
427
|
+
const orgId = String(c.organization_id);
|
|
428
|
+
if (customerLookup.has(orgId))
|
|
429
|
+
continue;
|
|
430
|
+
const d = c.data ?? {};
|
|
431
|
+
const addr = d.physicalAddress ?? d.mailingAddress ?? {};
|
|
432
|
+
customerLookup.set(orgId, {
|
|
433
|
+
name: d.commercialName ?? d.name ?? "Onbekende klant",
|
|
434
|
+
postalCode: addr.postalCode ?? "",
|
|
435
|
+
city: addr.city ?? "",
|
|
436
|
+
logoUrl: d.logoUrl ?? null,
|
|
437
|
+
raw: d,
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
for (const t of (extraTi.data ?? [])) {
|
|
441
|
+
const tid = String(t.floriday_id);
|
|
442
|
+
const d = t.data ?? {};
|
|
443
|
+
const photos = d.photos ?? d.images ?? d.tradeItemPhotos ?? [];
|
|
444
|
+
const firstPhotoRaw = Array.isArray(photos) && photos.length > 0
|
|
445
|
+
? (photos[0]?.url ?? photos[0]?.imageUrl ?? photos[0]?.href ?? photos[0])
|
|
446
|
+
: null;
|
|
447
|
+
tradeItemLookup.set(tid, {
|
|
448
|
+
name: pickString(d.name) ??
|
|
449
|
+
pickString(d.productName) ??
|
|
450
|
+
pickString(d.tradeItemName) ??
|
|
451
|
+
pickString(d.tradeItemTexts) ??
|
|
452
|
+
"Onbekend artikel",
|
|
453
|
+
imageUrl: pickString(firstPhotoRaw),
|
|
454
|
+
sku: pickString(d.vbnProductCode) ??
|
|
455
|
+
pickString(d.gtin) ??
|
|
456
|
+
pickString(d.articleCode),
|
|
457
|
+
raw: d,
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
for (const sr of sibRows) {
|
|
461
|
+
const sDto = mapJsonbToSalesOrderDTO({ ...sr.data, __controlledAt: sr.controlled_at ?? null }, customerLookup, tradeItemLookup);
|
|
462
|
+
sDto.bufferId = bufferId;
|
|
463
|
+
bufferSiblings.push(sDto);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
catch (err) {
|
|
469
|
+
console.warn("[getSalesOrderDetail] buffer-siblings lookup faalde:", err.message);
|
|
470
|
+
}
|
|
471
|
+
return { order: dto, sellerFallback, environment, bufferId, bufferSiblings };
|
|
346
472
|
});
|
|
347
473
|
// ─── Handmatige controle na orderpicken ───────────────────────────────────
|
|
348
474
|
const ControlInputSchema = z.object({
|