@flowselections/floriday-verkoop-module 1.0.49 → 1.0.51

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.
Files changed (61) hide show
  1. package/dist-lib/integrations/supabase/auth-middleware.d.ts +288 -1
  2. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  3. package/dist-lib/integrations/supabase/client.d.ts +288 -1
  4. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  5. package/dist-lib/integrations/supabase/client.server.d.ts +288 -1
  6. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  7. package/dist-lib/integrations/supabase/types.d.ts +294 -1
  8. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  9. package/dist-lib/lib/cart-lock.functions.d.ts +288 -1
  10. package/dist-lib/lib/cart-lock.functions.d.ts.map +1 -1
  11. package/dist-lib/lib/cart-planner.d.ts +15 -4
  12. package/dist-lib/lib/cart-planner.d.ts.map +1 -1
  13. package/dist-lib/lib/cart-planner.js +44 -12
  14. package/dist-lib/lib/cart-planning-settings.functions.d.ts +3600 -443
  15. package/dist-lib/lib/cart-planning-settings.functions.d.ts.map +1 -1
  16. package/dist-lib/lib/cart-replan.functions.d.ts +876 -3
  17. package/dist-lib/lib/cart-replan.functions.d.ts.map +1 -1
  18. package/dist-lib/lib/cart-replan.functions.js +49 -3
  19. package/dist-lib/lib/create-order.functions.d.ts +5657 -773
  20. package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
  21. package/dist-lib/lib/create-order.functions.js +48 -4
  22. package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts +864 -3
  23. package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts.map +1 -1
  24. package/dist-lib/lib/floriday-logistic-labels.functions.d.ts +288 -1
  25. package/dist-lib/lib/floriday-logistic-labels.functions.d.ts.map +1 -1
  26. package/dist-lib/lib/floriday-mirror.functions.d.ts +288 -1
  27. package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
  28. package/dist-lib/lib/floriday-mirror.functions.js +28 -1
  29. package/dist-lib/lib/floriday-public.functions.d.ts +2232 -223
  30. package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
  31. package/dist-lib/lib/floriday-writes.functions.d.ts +1548 -113
  32. package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
  33. package/dist-lib/lib/invoice-timing.functions.d.ts +1260 -112
  34. package/dist-lib/lib/invoice-timing.functions.d.ts.map +1 -1
  35. package/dist-lib/lib/load-carriers.functions.d.ts +288 -1
  36. package/dist-lib/lib/load-carriers.functions.d.ts.map +1 -1
  37. package/dist-lib/lib/logistics-engine.functions.d.ts +1548 -113
  38. package/dist-lib/lib/logistics-engine.functions.d.ts.map +1 -1
  39. package/dist-lib/lib/logistics-stock.functions.d.ts +576 -2
  40. package/dist-lib/lib/logistics-stock.functions.d.ts.map +1 -1
  41. package/dist-lib/lib/order-addresses.functions.d.ts +288 -1
  42. package/dist-lib/lib/order-addresses.functions.d.ts.map +1 -1
  43. package/dist-lib/lib/order-buffers.functions.d.ts +864 -3
  44. package/dist-lib/lib/order-buffers.functions.d.ts.map +1 -1
  45. package/dist-lib/lib/order-carrier.functions.d.ts +576 -2
  46. package/dist-lib/lib/order-carrier.functions.d.ts.map +1 -1
  47. package/dist-lib/lib/order-pickup.functions.d.ts +576 -2
  48. package/dist-lib/lib/order-pickup.functions.d.ts.map +1 -1
  49. package/dist-lib/lib/order-shipments.functions.d.ts +1260 -112
  50. package/dist-lib/lib/order-shipments.functions.d.ts.map +1 -1
  51. package/dist-lib/lib/salesorders-list.functions.d.ts +288 -1
  52. package/dist-lib/lib/salesorders-list.functions.d.ts.map +1 -1
  53. package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
  54. package/dist-lib/lib/salesorders-list.server.js +61 -3
  55. package/dist-lib/lib/salesorders.functions.d.ts +1548 -113
  56. package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
  57. package/dist-lib/lib/stock-consumption-alerts.functions.d.ts +576 -2
  58. package/dist-lib/lib/stock-consumption-alerts.functions.d.ts.map +1 -1
  59. package/dist-lib/lib/tradeitems.functions.d.ts +288 -1
  60. package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
  61. package/package.json +1 -1
@@ -435,15 +435,51 @@ export async function buildSalesOrdersList(supabase, params) {
435
435
  return dto;
436
436
  });
437
437
  // 10) Lokale orders → DTO.
438
+ // Leesvolgorde van de belading van een lokale orderregel:
439
+ // a. order_items.plants_per_crate/crates_per_layer/layers_per_cart → "orderregel"
440
+ // b. groeps-/productrecord (products.*) → "product"
441
+ // c. niets → geen packing (de orderkop toont "—", geen 1×1×1)
442
+ // De orderregel wint van het product, net zoals de order wint van het
443
+ // trade item in de Floriday-tak (resolvePacking, 26-08).
438
444
  const resolveLinePacking = (item) => {
445
+ const ppc = Number(item?.plants_per_crate ?? 0);
446
+ const cpl = Number(item?.crates_per_layer ?? 0);
447
+ const lpc = Number(item?.layers_per_cart ?? 0);
448
+ if (ppc > 0 || cpl > 0 || lpc > 0) {
449
+ return {
450
+ plants_per_crate: ppc || null,
451
+ crates_per_layer: cpl || null,
452
+ layers_per_cart: lpc || null,
453
+ __source: "orderregel",
454
+ };
455
+ }
439
456
  const name = String(item?.product_name ?? "");
440
457
  if (name.startsWith("[Groep] ")) {
441
458
  const gname = name.slice("[Groep] ".length).trim().toLowerCase();
442
459
  const gp = groupPacking.get(gname);
443
460
  if (gp)
444
- return gp;
461
+ return { ...gp, __source: "product" };
445
462
  }
446
- return item?.products ?? null;
463
+ const prod = item?.products ?? null;
464
+ return prod ? { ...prod, __source: "product" } : null;
465
+ };
466
+ /** Floriday-vormige packingConfiguration uit een lokale regel-packing. */
467
+ const localPackingConfiguration = (packing, cfg, loadCarrierCode) => {
468
+ const pieces = Number(packing?.plants_per_crate ?? 0);
469
+ const perLayer = Number(packing?.crates_per_layer ?? 0);
470
+ const layers = Number(packing?.layers_per_cart ?? 0);
471
+ if (pieces <= 0 && perLayer <= 0 && layers <= 0)
472
+ return null;
473
+ const vbn = cfg?.package?.vbnPackageCode ?? null;
474
+ const custom = cfg?.package?.customPackageId ?? null;
475
+ return {
476
+ piecesPerPackage: pieces || null,
477
+ packagesPerLayer: perLayer || null,
478
+ layersPerLoadCarrier: layers || null,
479
+ // Geen fustcode-fallback: ontbreekt de vbn-code, dan blijft package null.
480
+ package: vbn != null || custom != null ? { vbnPackageCode: vbn, customPackageId: custom } : null,
481
+ loadCarrier: loadCarrierCode ?? null,
482
+ };
447
483
  };
448
484
  const localOrders = [];
449
485
  const includedOrderIds = new Set();
@@ -463,6 +499,11 @@ export async function buildSalesOrdersList(supabase, params) {
463
499
  let karTotalRaw = 0;
464
500
  const crateNames = [];
465
501
  const cartNames = [];
502
+ // Belading van de eerste regel: die bepaalt de notatie in de orderkop.
503
+ // Bij gemengde regels tonen we bewust die eerste configuratie; het
504
+ // "Gemengd"-signaal komt uit mergeTypeNames (crate-/cartTypeName).
505
+ let headPacking = null;
506
+ let headCfg = null;
466
507
  for (const item of lineItems) {
467
508
  const pieces = toNumber(item?.quantity) || 0;
468
509
  if (pieces <= 0)
@@ -486,6 +527,10 @@ export async function buildSalesOrdersList(supabase, params) {
486
527
  return Array.isArray(payload) ? payload : [];
487
528
  })();
488
529
  const cfg = pickPackingConfigForLine(configs, packing);
530
+ if (headPacking === null && packing) {
531
+ headPacking = packing;
532
+ headCfg = cfg;
533
+ }
489
534
  crateNames.push(cratePackageName(cfg?.package?.vbnPackageCode ?? cfg?.package?.customPackageId ?? null, crateDescriptions));
490
535
  cartNames.push(loadCarrierName(cfg?.loadCarrier ?? null));
491
536
  }
@@ -510,6 +555,10 @@ export async function buildSalesOrdersList(supabase, params) {
510
555
  const firstProduct = pickString(firstLine?.product_name);
511
556
  const firstPacking = firstLine ? resolveLinePacking(firstLine) : null;
512
557
  const firstPlantsPerCrate = Math.max(1, Number(firstPacking?.plants_per_crate ?? 1));
558
+ const localPacking = localPackingConfiguration(headPacking ?? firstPacking, headCfg, normalizeLoadCarrierCode(cf.load_carrier_type) ?? null);
559
+ const localPackingSource = localPacking
560
+ ? ((headPacking ?? firstPacking)?.__source ?? "product")
561
+ : undefined;
513
562
  localOrders.push({
514
563
  id: `local:${r.id}`,
515
564
  orderNumber: centralOrderNumber(r.order_number),
@@ -556,7 +605,16 @@ export async function buildSalesOrdersList(supabase, params) {
556
605
  ...(r.customer_id || r.customer_name ? [] : ["geen klant gekoppeld"]),
557
606
  ...(r.delivery_date ? [] : ["geen leverdatum"]),
558
607
  ],
559
- raw: { order: { status: r.status ?? null }, customer: null, tradeItem: null },
608
+ packingSource: localPackingSource,
609
+ raw: {
610
+ order: {
611
+ status: r.status ?? null,
612
+ numberOfPieces: totalQuantity,
613
+ ...(localPacking ? { packingConfiguration: localPacking } : {}),
614
+ },
615
+ customer: null,
616
+ tradeItem: null,
617
+ },
560
618
  bufferId: bufferByLocalId.get(String(r.id)) ?? null,
561
619
  });
562
620
  }