@flowselections/floriday-verkoop-module 1.0.32 → 1.0.34
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.js +1 -1
- package/dist-lib/components/karindeling/KarindelingPage.js +11 -2
- package/dist-lib/components/verkoop/CreateOrderPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.js +65 -15
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +6 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +6 -0
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +6 -0
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +6 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/cart-lock.functions.d.ts +6 -0
- package/dist-lib/lib/cart-lock.functions.d.ts.map +1 -1
- package/dist-lib/lib/cart-planning-settings.functions.d.ts +70 -0
- package/dist-lib/lib/cart-planning-settings.functions.d.ts.map +1 -1
- package/dist-lib/lib/cart-planning-settings.functions.js +38 -5
- package/dist-lib/lib/cart-replan.functions.d.ts +18 -0
- package/dist-lib/lib/cart-replan.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.d.ts +13913 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +121 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts +18 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-logistic-labels.functions.d.ts +6 -0
- package/dist-lib/lib/floriday-logistic-labels.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.functions.d.ts +6 -0
- package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-public.functions.d.ts +42 -0
- package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-writes.functions.d.ts +30 -0
- package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-buffers.functions.d.ts +18 -0
- package/dist-lib/lib/order-buffers.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-shipments.functions.d.ts +24 -0
- package/dist-lib/lib/order-shipments.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.d.ts +30 -0
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/tradeitems.functions.d.ts +6 -0
- package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -426,6 +426,127 @@ export const listCarriersForCreateOrder = createServerFn({ method: "GET" })
|
|
|
426
426
|
.order("name");
|
|
427
427
|
return { items: data ?? [] };
|
|
428
428
|
});
|
|
429
|
+
// ─── Beladingen per product ────────────────────────────────────────────────
|
|
430
|
+
// Geeft uitsluitend de packing-configuraties die daadwerkelijk aan het
|
|
431
|
+
// gekozen product gekoppeld zijn. Bronnen per identiteit:
|
|
432
|
+
// floriday_trade_items_cache.data.packingConfigurations
|
|
433
|
+
// trade_item_drafts.data.packingConfigurations
|
|
434
|
+
// products (plants_per_crate / crates_per_layer / layers_per_cart)
|
|
435
|
+
// product_groups → members (belading van de members)
|
|
436
|
+
export const listBeladingOptionsForProducts = createServerFn({ method: "POST" })
|
|
437
|
+
.middleware([requireSupabaseAuth])
|
|
438
|
+
.inputValidator((input) => z.object({ productIds: z.array(z.string()).max(200) }).parse(input))
|
|
439
|
+
.handler(async ({ data, context }) => {
|
|
440
|
+
const ids = Array.from(new Set(data.productIds.filter(Boolean)));
|
|
441
|
+
const byProduct = {};
|
|
442
|
+
if (!ids.length)
|
|
443
|
+
return { byProduct };
|
|
444
|
+
// Groepsleden meenemen als extra lookup-ids
|
|
445
|
+
const { data: giRows } = await context.supabase
|
|
446
|
+
.from("product_group_items")
|
|
447
|
+
.select("product_group_id, trade_item_id, sort_order")
|
|
448
|
+
.in("product_group_id", ids);
|
|
449
|
+
const membersByGroup = new Map();
|
|
450
|
+
for (const gi of giRows ?? []) {
|
|
451
|
+
const gid = gi.product_group_id;
|
|
452
|
+
const arr = membersByGroup.get(gid) ?? [];
|
|
453
|
+
arr.push(gi.trade_item_id);
|
|
454
|
+
membersByGroup.set(gid, arr);
|
|
455
|
+
}
|
|
456
|
+
const lookupIds = Array.from(new Set([...ids, ...Array.from(membersByGroup.values()).flat()]));
|
|
457
|
+
const [tiRes, draftRes, prodRes] = await Promise.all([
|
|
458
|
+
context.supabase
|
|
459
|
+
.from("floriday_trade_items_cache")
|
|
460
|
+
.select("floriday_id, data")
|
|
461
|
+
.in("floriday_id", lookupIds),
|
|
462
|
+
context.supabase.from("trade_item_drafts").select("id, data").in("id", lookupIds),
|
|
463
|
+
context.supabase
|
|
464
|
+
.from("products")
|
|
465
|
+
.select("id, plants_per_crate, crates_per_layer, layers_per_cart, custom_fields, trade_item_key")
|
|
466
|
+
.in("id", lookupIds),
|
|
467
|
+
]);
|
|
468
|
+
const packsById = new Map();
|
|
469
|
+
const push = (key, ppc, cpl, lpc, isDefault) => {
|
|
470
|
+
const a = Math.max(1, Math.round(Number(ppc ?? 1)) || 1);
|
|
471
|
+
const b = Math.max(1, Math.round(Number(cpl ?? 1)) || 1);
|
|
472
|
+
const c = Math.max(1, Math.round(Number(lpc ?? 1)) || 1);
|
|
473
|
+
const arr = packsById.get(key) ?? [];
|
|
474
|
+
const hit = arr.find((x) => x.plants_per_crate === a && x.crates_per_layer === b && x.layers_per_cart === c);
|
|
475
|
+
if (hit) {
|
|
476
|
+
if (isDefault)
|
|
477
|
+
hit.is_default = true;
|
|
478
|
+
return;
|
|
479
|
+
}
|
|
480
|
+
arr.push({ plants_per_crate: a, crates_per_layer: b, layers_per_cart: c, is_default: isDefault });
|
|
481
|
+
packsById.set(key, arr);
|
|
482
|
+
};
|
|
483
|
+
for (const r of tiRes.data ?? []) {
|
|
484
|
+
const key = r.floriday_id;
|
|
485
|
+
const packs = Array.isArray(r?.data?.packingConfigurations)
|
|
486
|
+
? r.data.packingConfigurations : [];
|
|
487
|
+
for (const p of packs) {
|
|
488
|
+
push(key, p?.piecesPerPackage ?? p?.unitsPerPackage, p?.packagesPerLayer, p?.layersPerLoadCarrier, !!(p?.primary || p?.isPrimary));
|
|
489
|
+
}
|
|
490
|
+
if (packs.length && !(packsById.get(key) ?? []).some((x) => x.is_default)) {
|
|
491
|
+
const first = packsById.get(key)[0];
|
|
492
|
+
if (first)
|
|
493
|
+
first.is_default = true;
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
for (const r of draftRes.data ?? []) {
|
|
497
|
+
const key = r.id;
|
|
498
|
+
const packs = Array.isArray(r?.data?.packingConfigurations)
|
|
499
|
+
? r.data.packingConfigurations : [];
|
|
500
|
+
for (const p of packs) {
|
|
501
|
+
push(key, p?.unitsPerPackage ?? p?.piecesPerPackage, p?.packagesPerLayer, p?.layersPerLoadCarrier, !!(p?.primary || p?.isPrimary));
|
|
502
|
+
}
|
|
503
|
+
if (packs.length && !(packsById.get(key) ?? []).some((x) => x.is_default)) {
|
|
504
|
+
const first = packsById.get(key)[0];
|
|
505
|
+
if (first)
|
|
506
|
+
first.is_default = true;
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
for (const p of prodRes.data ?? []) {
|
|
510
|
+
const key = p.id;
|
|
511
|
+
push(key, p.plants_per_crate, p.crates_per_layer, p.layers_per_cart, true);
|
|
512
|
+
// spiegelrij kan ook onder floriday-id / group-id bekend zijn
|
|
513
|
+
const fid = p.custom_fields?.floriday_id;
|
|
514
|
+
if (fid)
|
|
515
|
+
push(fid, p.plants_per_crate, p.crates_per_layer, p.layers_per_cart, false);
|
|
516
|
+
const tk = p.trade_item_key;
|
|
517
|
+
if (typeof tk === "string" && tk.startsWith("group:")) {
|
|
518
|
+
push(tk.slice("group:".length), p.plants_per_crate, p.crates_per_layer, p.layers_per_cart, true);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
for (const id of ids) {
|
|
522
|
+
const own = packsById.get(id) ?? [];
|
|
523
|
+
const memberCombos = [];
|
|
524
|
+
for (const m of membersByGroup.get(id) ?? []) {
|
|
525
|
+
for (const c of packsById.get(m) ?? [])
|
|
526
|
+
memberCombos.push(c);
|
|
527
|
+
}
|
|
528
|
+
const merged = [];
|
|
529
|
+
for (const c of [...own, ...memberCombos]) {
|
|
530
|
+
if (merged.some((x) => x.plants_per_crate === c.plants_per_crate
|
|
531
|
+
&& x.crates_per_layer === c.crates_per_layer
|
|
532
|
+
&& x.layers_per_cart === c.layers_per_cart))
|
|
533
|
+
continue;
|
|
534
|
+
merged.push({ ...c, is_default: c.is_default && own.includes(c) });
|
|
535
|
+
}
|
|
536
|
+
if (merged.length && !merged.some((x) => x.is_default))
|
|
537
|
+
merged[0].is_default = true;
|
|
538
|
+
byProduct[id] = merged
|
|
539
|
+
.sort((a, b) => a.plants_per_crate - b.plants_per_crate ||
|
|
540
|
+
a.crates_per_layer - b.crates_per_layer ||
|
|
541
|
+
a.layers_per_cart - b.layers_per_cart)
|
|
542
|
+
.map((v) => ({
|
|
543
|
+
...v,
|
|
544
|
+
crates_per_cart: v.crates_per_layer * v.layers_per_cart,
|
|
545
|
+
plants_per_cart: v.plants_per_crate * v.crates_per_layer * v.layers_per_cart,
|
|
546
|
+
}));
|
|
547
|
+
}
|
|
548
|
+
return { byProduct };
|
|
549
|
+
});
|
|
429
550
|
// ─── Beladingen (packing-configuraties) ────────────────────────────────────
|
|
430
551
|
// Alle in het systeem voorkomende beladingen: planten per fust ×
|
|
431
552
|
// fusten per laag × lagen per kar. Bron: Floriday trade items, interne
|
|
@@ -1262,6 +1262,8 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
|
|
|
1262
1262
|
require_same_crate_type: boolean;
|
|
1263
1263
|
require_same_delivery_date: boolean;
|
|
1264
1264
|
require_same_delivery_location: boolean;
|
|
1265
|
+
uniform_pick_time: boolean;
|
|
1266
|
+
uniform_pick_time_seconds: number;
|
|
1265
1267
|
updated_at: string;
|
|
1266
1268
|
updated_by: string | null;
|
|
1267
1269
|
};
|
|
@@ -1286,6 +1288,8 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
|
|
|
1286
1288
|
require_same_crate_type?: boolean;
|
|
1287
1289
|
require_same_delivery_date?: boolean;
|
|
1288
1290
|
require_same_delivery_location?: boolean;
|
|
1291
|
+
uniform_pick_time?: boolean;
|
|
1292
|
+
uniform_pick_time_seconds?: number;
|
|
1289
1293
|
updated_at?: string;
|
|
1290
1294
|
updated_by?: string | null;
|
|
1291
1295
|
};
|
|
@@ -1310,6 +1314,8 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
|
|
|
1310
1314
|
require_same_crate_type?: boolean;
|
|
1311
1315
|
require_same_delivery_date?: boolean;
|
|
1312
1316
|
require_same_delivery_location?: boolean;
|
|
1317
|
+
uniform_pick_time?: boolean;
|
|
1318
|
+
uniform_pick_time_seconds?: number;
|
|
1313
1319
|
updated_at?: string;
|
|
1314
1320
|
updated_by?: string | null;
|
|
1315
1321
|
};
|
|
@@ -15083,6 +15089,8 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
|
|
|
15083
15089
|
require_same_crate_type: boolean;
|
|
15084
15090
|
require_same_delivery_date: boolean;
|
|
15085
15091
|
require_same_delivery_location: boolean;
|
|
15092
|
+
uniform_pick_time: boolean;
|
|
15093
|
+
uniform_pick_time_seconds: number;
|
|
15086
15094
|
updated_at: string;
|
|
15087
15095
|
updated_by: string | null;
|
|
15088
15096
|
};
|
|
@@ -15107,6 +15115,8 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
|
|
|
15107
15115
|
require_same_crate_type?: boolean;
|
|
15108
15116
|
require_same_delivery_date?: boolean;
|
|
15109
15117
|
require_same_delivery_location?: boolean;
|
|
15118
|
+
uniform_pick_time?: boolean;
|
|
15119
|
+
uniform_pick_time_seconds?: number;
|
|
15110
15120
|
updated_at?: string;
|
|
15111
15121
|
updated_by?: string | null;
|
|
15112
15122
|
};
|
|
@@ -15131,6 +15141,8 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
|
|
|
15131
15141
|
require_same_crate_type?: boolean;
|
|
15132
15142
|
require_same_delivery_date?: boolean;
|
|
15133
15143
|
require_same_delivery_location?: boolean;
|
|
15144
|
+
uniform_pick_time?: boolean;
|
|
15145
|
+
uniform_pick_time_seconds?: number;
|
|
15134
15146
|
updated_at?: string;
|
|
15135
15147
|
updated_by?: string | null;
|
|
15136
15148
|
};
|
|
@@ -28913,6 +28925,8 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
|
|
|
28913
28925
|
require_same_crate_type: boolean;
|
|
28914
28926
|
require_same_delivery_date: boolean;
|
|
28915
28927
|
require_same_delivery_location: boolean;
|
|
28928
|
+
uniform_pick_time: boolean;
|
|
28929
|
+
uniform_pick_time_seconds: number;
|
|
28916
28930
|
updated_at: string;
|
|
28917
28931
|
updated_by: string | null;
|
|
28918
28932
|
};
|
|
@@ -28937,6 +28951,8 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
|
|
|
28937
28951
|
require_same_crate_type?: boolean;
|
|
28938
28952
|
require_same_delivery_date?: boolean;
|
|
28939
28953
|
require_same_delivery_location?: boolean;
|
|
28954
|
+
uniform_pick_time?: boolean;
|
|
28955
|
+
uniform_pick_time_seconds?: number;
|
|
28940
28956
|
updated_at?: string;
|
|
28941
28957
|
updated_by?: string | null;
|
|
28942
28958
|
};
|
|
@@ -28961,6 +28977,8 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
|
|
|
28961
28977
|
require_same_crate_type?: boolean;
|
|
28962
28978
|
require_same_delivery_date?: boolean;
|
|
28963
28979
|
require_same_delivery_location?: boolean;
|
|
28980
|
+
uniform_pick_time?: boolean;
|
|
28981
|
+
uniform_pick_time_seconds?: number;
|
|
28964
28982
|
updated_at?: string;
|
|
28965
28983
|
updated_by?: string | null;
|
|
28966
28984
|
};
|