@flowselections/floriday-verkoop-module 1.0.100 → 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.
Files changed (33) hide show
  1. package/dist-lib/components/verkoop/CreateOrderPage.d.ts.map +1 -1
  2. package/dist-lib/components/verkoop/CreateOrderPage.js +44 -4
  3. package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts.map +1 -1
  4. package/dist-lib/components/verkoop/EditLocalOrderDialog.js +11 -5
  5. package/dist-lib/components/verkoop/OrderLinePackingCard.d.ts.map +1 -1
  6. package/dist-lib/components/verkoop/OrderLinePackingCard.js +1 -1
  7. package/dist-lib/integrations/supabase/types.d.ts +956 -15
  8. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  9. package/dist-lib/lib/create-order.functions.d.ts +17 -0
  10. package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
  11. package/dist-lib/lib/create-order.functions.js +95 -8
  12. package/dist-lib/lib/customer-stickers.check.d.ts +2 -0
  13. package/dist-lib/lib/customer-stickers.check.d.ts.map +1 -0
  14. package/dist-lib/lib/customer-stickers.check.js +19 -0
  15. package/dist-lib/lib/customer-stickers.d.ts +14 -0
  16. package/dist-lib/lib/customer-stickers.d.ts.map +1 -0
  17. package/dist-lib/lib/customer-stickers.js +19 -0
  18. package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
  19. package/dist-lib/lib/floriday-mirror.functions.js +60 -77
  20. package/dist-lib/lib/floriday-promote-customer.check.d.ts +2 -0
  21. package/dist-lib/lib/floriday-promote-customer.check.d.ts.map +1 -0
  22. package/dist-lib/lib/floriday-promote-customer.check.js +28 -0
  23. package/dist-lib/lib/floriday-promote-customer.d.ts +12 -0
  24. package/dist-lib/lib/floriday-promote-customer.d.ts.map +1 -0
  25. package/dist-lib/lib/floriday-promote-customer.js +43 -0
  26. package/dist-lib/lib/module-version.d.ts +1 -1
  27. package/dist-lib/lib/module-version.d.ts.map +1 -1
  28. package/dist-lib/lib/module-version.js +1 -1
  29. package/dist-lib/lib/order-item-packing.functions.d.ts +2 -0
  30. package/dist-lib/lib/order-item-packing.functions.d.ts.map +1 -1
  31. package/dist-lib/lib/order-item-packing.functions.js +2 -1
  32. package/package.json +9 -4
  33. package/schema/verkoop.sql +1939 -0
@@ -140,6 +140,7 @@ export declare const createManualOrder: import("@tanstack/start-client-core").Op
140
140
  crates_per_layer?: number | undefined;
141
141
  layers_per_cart?: number | undefined;
142
142
  article_code?: string | null | undefined;
143
+ needs_sticker?: boolean | undefined;
143
144
  }[];
144
145
  carrierId?: string | null | undefined;
145
146
  deliveryDate?: string | null | undefined;
@@ -214,6 +215,7 @@ export declare const getLocalOrderForEdit: import("@tanstack/start-client-core")
214
215
  quantity: number;
215
216
  unit: string | null;
216
217
  plantsPerCrate: number;
218
+ needsSticker: boolean;
217
219
  shippedQuantity: number;
218
220
  plannedQuantity: number;
219
221
  minQuantity: number;
@@ -241,6 +243,11 @@ export declare const updateLocalOrder: import("@tanstack/start-client-core").Opt
241
243
  plantsPerCrate?: number | null | undefined;
242
244
  cratesPerLayer?: number | null | undefined;
243
245
  layersPerCart?: number | null | undefined;
246
+ needsSticker?: boolean | undefined;
247
+ }[] | undefined;
248
+ stickers?: {
249
+ itemId: string;
250
+ needsSticker: boolean;
244
251
  }[] | undefined;
245
252
  }, Promise<{
246
253
  ok: true;
@@ -260,4 +267,14 @@ export declare const getEffectivePrices: import("@tanstack/start-client-core").O
260
267
  price: number;
261
268
  source: string | null;
262
269
  } | null>>>;
270
+ export declare const listCustomerStickerProducts: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
271
+ supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
272
+ userId: string;
273
+ claims: import("@supabase/auth-js").User;
274
+ }, undefined, undefined, undefined>], (input: unknown) => {
275
+ customerId: string;
276
+ productIds: string[];
277
+ }, Promise<{
278
+ productIds: string[];
279
+ }>>;
263
280
  //# sourceMappingURL=create-order.functions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,2BAA2B;;;;;;GA+CpC,CAAC;AAIL,eAAO,MAAM,2BAA2B;;;;0CAElB,OAAO;;;;GAoDzB,CAAC;AAWL,eAAO,MAAM,0BAA0B;;;;;;YA+D7B,MAAM;iBACD,MAAM;sBACD,MAAM,GAAG,IAAI;cACrB,MAAM;oBACA,MAAM,GAAG,IAAI;0BACP,MAAM;0BACN,MAAM;yBACP,MAAM;wBACP,MAAM;wBACN,MAAM;yBACL,MAAM;kBACb,OAAO;gBACT,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS;;GA6RpD,CAAC;AAGL,eAAO,MAAM,kCAAkC;;;;0CAEzB,OAAO;;;;;;;;;;;;;;;;;;;;;;GAkDzB,CAAC;AAKL,eAAO,MAAM,qBAAqB;;;;;;YAoBI,MAAM;;;GAIxC,CAAC;AAGL,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;GAWnC,CAAC;AASL,eAAO,MAAM,8BAA8B;;;;8CAEjB,OAAO;;;;GAU7B,CAAC;AASL,eAAO,MAAM,mBAAmB;;;;;;;;0BAgBuB,MAAM;0BAAoB,MAAM;yBAAmB,MAAM;;;GA8C5G,CAAC;AAGL,eAAO,MAAM,kBAAkB;;;;;;GAU3B,CAAC;AA+CL,eAAO,MAAM,iBAAiB;;;;8CAEJ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA4PY,MAAM;GAE/C,CAAC;AAKL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;;GAY7B,CAAC;AAQL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;GAoG7B,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;8CAER,OAAO;;;;GAyB7B,CAAC;AA0CL,eAAO,MAAM,oBAAoB;;;;8CAEP,OAAO;;;aA0JG,MAAM;iBACQ,MAAM,GAAG,IAAI;kBACX,MAAM;;YAEnB,MAAM,GAAG,IAAI;;;;YAkB7B,MAAM;mBACS,MAAM,GAAG,IAAI;qBACT,MAAM;;cAErB,MAAM,GAAG,IAAI;;;;;;GAQpC,CAAC;AAIL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;;;;;;;;;;;;;;;;GAuO7B,CAAC;AAKL,eAAO,MAAM,kBAAkB;;;;8CAEL,OAAO;;;;;;;;WAUM,MAAM;YAAU,MAAM,GAAG,IAAI;WAahE,CAAC"}
1
+ {"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,2BAA2B;;;;;;GA+CpC,CAAC;AAIL,eAAO,MAAM,2BAA2B;;;;0CAElB,OAAO;;;;GAoDzB,CAAC;AAWL,eAAO,MAAM,0BAA0B;;;;;;YA+D7B,MAAM;iBACD,MAAM;sBACD,MAAM,GAAG,IAAI;cACrB,MAAM;oBACA,MAAM,GAAG,IAAI;0BACP,MAAM;0BACN,MAAM;yBACP,MAAM;wBACP,MAAM;wBACN,MAAM;yBACL,MAAM;kBACb,OAAO;gBACT,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS;;GA6RpD,CAAC;AAGL,eAAO,MAAM,kCAAkC;;;;0CAEzB,OAAO;;;;;;;;;;;;;;;;;;;;;;GAkDzB,CAAC;AAKL,eAAO,MAAM,qBAAqB;;;;;;YAoBI,MAAM;;;GAIxC,CAAC;AAGL,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;GAWnC,CAAC;AASL,eAAO,MAAM,8BAA8B;;;;8CAEjB,OAAO;;;;GAU7B,CAAC;AASL,eAAO,MAAM,mBAAmB;;;;;;;;0BAgBuB,MAAM;0BAAoB,MAAM;yBAAmB,MAAM;;;GA8C5G,CAAC;AAGL,eAAO,MAAM,kBAAkB;;;;;;GAU3B,CAAC;AAiDL,eAAO,MAAM,iBAAiB;;;;8CAEJ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aA6PY,MAAM;GAE/C,CAAC;AAKL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;;GAY7B,CAAC;AAQL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;GAoG7B,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;8CAER,OAAO;;;;GAyB7B,CAAC;AAgDL,eAAO,MAAM,oBAAoB;;;;8CAEP,OAAO;;;aA0JG,MAAM;iBACQ,MAAM,GAAG,IAAI;kBACX,MAAM;;YAEnB,MAAM,GAAG,IAAI;;;;YAkB7B,MAAM;mBACS,MAAM,GAAG,IAAI;qBACT,MAAM;;cAErB,MAAM,GAAG,IAAI;;;;;;;GASpC,CAAC;AAIL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;GAgR7B,CAAC;AAKL,eAAO,MAAM,kBAAkB;;;;8CAEL,OAAO;;;;;;;;WAUM,MAAM;YAAU,MAAM,GAAG,IAAI;WAahE,CAAC;AAOL,eAAO,MAAM,2BAA2B;;;;8CAEd,OAAO;;;;gBAIgC,MAAM,EAAE;GAwBrE,CAAC"}
@@ -643,6 +643,8 @@ const LineInput = z.object({
643
643
  crates_per_layer: z.number().int().positive().optional(),
644
644
  layers_per_cart: z.number().int().positive().optional(),
645
645
  article_code: z.string().max(100).nullable().optional(),
646
+ // Sticker nodig op deze regel (alleen vastleggen; telt nergens mee).
647
+ needs_sticker: z.boolean().optional(),
646
648
  });
647
649
  const CreateManualOrderInput = z.object({
648
650
  customerId: z.string().uuid(),
@@ -891,6 +893,7 @@ export const createManualOrder = createServerFn({ method: "POST" })
891
893
  crates_per_layer: l.crates_per_layer ?? null,
892
894
  layers_per_cart: l.layers_per_cart ?? null,
893
895
  unit_price: l.unit_price ?? undefined,
896
+ needs_sticker: l.needs_sticker === true,
894
897
  };
895
898
  });
896
899
  const { error: itemsErr } = await supabaseAdmin.from("order_items").insert(items);
@@ -1090,8 +1093,14 @@ const UpdateLocalOrderInput = z.object({
1090
1093
  plantsPerCrate: z.number().int().positive().nullish(),
1091
1094
  cratesPerLayer: z.number().int().positive().nullish(),
1092
1095
  layersPerCart: z.number().int().positive().nullish(),
1096
+ needsSticker: z.boolean().optional(),
1093
1097
  }))
1094
1098
  .optional(),
1099
+ // Stickervinkje per bestaande regel. Alleen gewijzigde waarden worden
1100
+ // opgeslagen; een wijziging van alleen het vinkje start niets anders.
1101
+ stickers: z
1102
+ .array(z.object({ itemId: z.string().uuid(), needsSticker: z.boolean() }))
1103
+ .optional(),
1095
1104
  });
1096
1105
  export const getLocalOrderForEdit = createServerFn({ method: "POST" })
1097
1106
  .middleware([requireSupabaseAuth])
@@ -1113,7 +1122,7 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
1113
1122
  }
1114
1123
  const { data: items, error: iErr } = await context.supabase
1115
1124
  .from("order_items")
1116
- .select("id, product_id, product_name, quantity, unit, products(plants_per_crate)")
1125
+ .select("id, product_id, product_name, quantity, unit, needs_sticker, products(plants_per_crate)")
1117
1126
  .eq("order_id", data.orderId)
1118
1127
  .is("quarantined_at", null)
1119
1128
  .order("id");
@@ -1275,6 +1284,7 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
1275
1284
  quantity: Number(it.quantity ?? 0),
1276
1285
  unit: it.unit,
1277
1286
  plantsPerCrate: ppc,
1287
+ needsSticker: it.needs_sticker === true,
1278
1288
  shippedQuantity: shipped,
1279
1289
  plannedQuantity: planned,
1280
1290
  minQuantity: shipped + planned,
@@ -1303,6 +1313,34 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
1303
1313
  }
1304
1314
  const removeIds = data.removeItemIds ?? [];
1305
1315
  const newItems = data.newItems ?? [];
1316
+ // Huidige regels: alleen echt gewijzigde aantallen en stickervinkjes
1317
+ // verwerken. Een wijziging van alleen het vinkje start geen
1318
+ // voorraadcontrole, herberekening of nieuwe planning.
1319
+ const { data: currentRows, error: cErr } = await supabaseAdmin
1320
+ .from("order_items")
1321
+ .select("id, quantity, needs_sticker")
1322
+ .eq("order_id", data.orderId);
1323
+ if (cErr)
1324
+ throw new Error(cErr.message);
1325
+ const currentById = new Map((currentRows ?? []).map((r) => [
1326
+ r.id,
1327
+ { quantity: Number(r.quantity ?? 0), needsSticker: r.needs_sticker === true },
1328
+ ]));
1329
+ const changedItems = (data.items ?? []).filter((i) => {
1330
+ const cur = currentById.get(i.itemId);
1331
+ return !cur || cur.quantity !== i.quantity;
1332
+ });
1333
+ data.items = changedItems;
1334
+ const stickerChanges = (data.stickers ?? []).filter((st) => {
1335
+ const cur = currentById.get(st.itemId);
1336
+ return !!cur && cur.needsSticker !== st.needsSticker && !removeIds.includes(st.itemId);
1337
+ });
1338
+ const dateChanged = !!data.deliveryDate &&
1339
+ !order.is_reservation &&
1340
+ String(data.deliveryDate).slice(0, 10) !== String(order.delivery_date ?? "").slice(0, 10);
1341
+ if (!dateChanged)
1342
+ data.deliveryDate = undefined;
1343
+ const realChange = changedItems.length > 0 || removeIds.length > 0 || newItems.length > 0 || dateChanged;
1306
1344
  // Producten wijzigen mag alleen zolang er nog niets is geprint in het
1307
1345
  // Pickstation (orders.plan_locked_at).
1308
1346
  if ((removeIds.length > 0 || newItems.length > 0) && order.plan_locked_at) {
@@ -1404,6 +1442,7 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
1404
1442
  crates_per_layer: n.cratesPerLayer ?? null,
1405
1443
  layers_per_cart: n.layersPerCart ?? null,
1406
1444
  unit_price: n.unitPrice ?? undefined,
1445
+ needs_sticker: n.needsSticker === true,
1407
1446
  };
1408
1447
  });
1409
1448
  const { error: nErr } = await supabaseAdmin.from("order_items").insert(rowsToInsert);
@@ -1481,14 +1520,25 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
1481
1520
  .update({ total: String(total.toFixed(2)), updated_at: new Date().toISOString() })
1482
1521
  .eq("id", data.orderId);
1483
1522
  }
1484
- // Karindeling: de Logistiek Engine plant opnieuw in haar eigen ronde.
1485
- // Logistics Engine informeren (schaduwmodus): Engine plant de keten.
1486
- try {
1487
- const { notifyEngineOrder } = await import("./logistics-engine.server.js");
1488
- await notifyEngineOrder(data.orderId, "order.changed");
1523
+ // Stickervinkjes: alleen deze kolom, alleen bij een echte wijziging.
1524
+ for (const st of stickerChanges) {
1525
+ const { error: sErr } = await supabaseAdmin.from("order_items")
1526
+ .update({ needs_sticker: st.needsSticker })
1527
+ .eq("id", st.itemId)
1528
+ .eq("order_id", data.orderId);
1529
+ if (sErr)
1530
+ throw new Error(`Sticker bijwerken faalde: ${sErr.message}`);
1489
1531
  }
1490
- catch (err) {
1491
- console.warn("[updateLocalOrder] engine-event faalde:", err);
1532
+ // Karindeling: de Logistiek Engine plant opnieuw in haar eigen ronde.
1533
+ // Alleen melden bij een echte wijziging (niet bij alleen het stickervinkje).
1534
+ if (realChange) {
1535
+ try {
1536
+ const { notifyEngineOrder } = await import("./logistics-engine.server.js");
1537
+ await notifyEngineOrder(data.orderId, "order.changed");
1538
+ }
1539
+ catch (err) {
1540
+ console.warn("[updateLocalOrder] engine-event faalde:", err);
1541
+ }
1492
1542
  }
1493
1543
  return { ok: true };
1494
1544
  });
@@ -1519,3 +1569,40 @@ export const getEffectivePrices = createServerFn({ method: "POST" })
1519
1569
  }
1520
1570
  return out;
1521
1571
  });
1572
+ // ─── Standaard stickervinkje bij een nieuwe bestelling ──────────────────────
1573
+ // Vinkje vooraf aan als er voor deze klant + dit product een vaste klantsticker
1574
+ // bestaat (customer_product_stickers). Alleen lezen; matcht op id/code, nooit
1575
+ // op naam. Lukt het lezen niet, dan staat het vinkje uit.
1576
+ export const listCustomerStickerProducts = createServerFn({ method: "POST" })
1577
+ .middleware([requireSupabaseAuth])
1578
+ .inputValidator((input) => z.object({ customerId: z.string().uuid(), productIds: z.array(z.string().uuid()).max(200) }).parse(input))
1579
+ .handler(async ({ data, context }) => {
1580
+ if (data.productIds.length === 0)
1581
+ return { productIds: [] };
1582
+ const sb = context.supabase;
1583
+ const { data: cust } = await sb
1584
+ .from("customers")
1585
+ .select("id, twinfield_code, floriday_organization_id")
1586
+ .eq("id", data.customerId)
1587
+ .maybeSingle();
1588
+ if (!cust)
1589
+ return { productIds: [] };
1590
+ const { stickerCustomerKeys, stickerProductIds } = await import("./customer-stickers.js");
1591
+ const customerKeys = stickerCustomerKeys(cust);
1592
+ const { data: prods } = await sb
1593
+ .from("products")
1594
+ .select("id, trade_item_key")
1595
+ .in("id", data.productIds);
1596
+ const productKeyRows = (prods ?? []).map((p) => ({ id: p.id, tradeItemKey: p.trade_item_key ?? null }));
1597
+ const keys = Array.from(new Set(productKeyRows.flatMap((p) => [p.id, p.tradeItemKey].filter(Boolean))));
1598
+ if (keys.length === 0)
1599
+ return { productIds: [] };
1600
+ const { data: rows, error } = await sb
1601
+ .from("customer_product_stickers")
1602
+ .select("customer_key, trade_item_key")
1603
+ .in("customer_key", customerKeys)
1604
+ .in("trade_item_key", keys);
1605
+ if (error)
1606
+ return { productIds: [] };
1607
+ return { productIds: stickerProductIds(productKeyRows, (rows ?? [])) };
1608
+ });
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=customer-stickers.check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-stickers.check.d.ts","sourceRoot":"","sources":["../../src/lib/customer-stickers.check.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ // Draaien met: bun src/lib/customer-stickers.check.ts
2
+ import { stickerCustomerKeys, stickerProductIds } from "./customer-stickers.js";
3
+ let failed = 0;
4
+ const eq = (name, a, b) => {
5
+ const ok = JSON.stringify(a) === JSON.stringify(b);
6
+ if (!ok)
7
+ failed++;
8
+ console.log(`${ok ? "ok " : "FOUT"} ${name}`);
9
+ };
10
+ eq("klantsleutels met Twinfield-code", stickerCustomerKeys({ id: "c1", twinfield_code: "1015" }), ["c1", "tf:1015"]);
11
+ eq("klantsleutels zonder codes", stickerCustomerKeys({ id: "c1", twinfield_code: " " }), ["c1"]);
12
+ eq("product met vaste sticker op id staat aan", stickerProductIds([{ id: "p1", tradeItemKey: null }, { id: "p2", tradeItemKey: null }], [{ trade_item_key: "p1" }]), ["p1"]);
13
+ eq("product met vaste sticker op artikelsleutel staat aan", stickerProductIds([{ id: "p1", tradeItemKey: "t1" }], [{ trade_item_key: "t1" }]), ["p1"]);
14
+ eq("geen vaste sticker: uit", stickerProductIds([{ id: "p1", tradeItemKey: "t1" }], []), []);
15
+ if (failed) {
16
+ console.error(`${failed} controle(s) mislukt`);
17
+ process.exit(1);
18
+ }
19
+ console.log("alle controles geslaagd");
@@ -0,0 +1,14 @@
1
+ /** Sleutels waaronder een klant in customer_product_stickers kan staan. */
2
+ export declare function stickerCustomerKeys(c: {
3
+ id: string;
4
+ twinfield_code?: string | null;
5
+ floriday_organization_id?: string | null;
6
+ }): string[];
7
+ /** Product-id's waarvoor een vaste klantsticker bestaat (op id of artikelsleutel). */
8
+ export declare function stickerProductIds(products: {
9
+ id: string;
10
+ tradeItemKey: string | null;
11
+ }[], rows: {
12
+ trade_item_key: string | null;
13
+ }[]): string[];
14
+ //# sourceMappingURL=customer-stickers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"customer-stickers.d.ts","sourceRoot":"","sources":["../../src/lib/customer-stickers.ts"],"names":[],"mappings":"AAIA,2EAA2E;AAC3E,wBAAgB,mBAAmB,CAAC,CAAC,EAAE;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,wBAAwB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1C,GAAG,MAAM,EAAE,CAOX;AAED,sFAAsF;AACtF,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,EACvD,IAAI,EAAE;IAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,GACxC,MAAM,EAAE,CAGV"}
@@ -0,0 +1,19 @@
1
+ // Vaste klantstickers (customer_product_stickers) koppelen aan een nieuwe
2
+ // bestelling. Alleen voor de standaardwaarde van het stickervinkje; matcht op
3
+ // id/code, nooit op naam.
4
+ /** Sleutels waaronder een klant in customer_product_stickers kan staan. */
5
+ export function stickerCustomerKeys(c) {
6
+ const keys = [c.id];
7
+ const tf = String(c.twinfield_code ?? "").trim();
8
+ if (tf)
9
+ keys.push(`tf:${tf}`);
10
+ const org = String(c.floriday_organization_id ?? "").trim();
11
+ if (org)
12
+ keys.push(org);
13
+ return keys;
14
+ }
15
+ /** Product-id's waarvoor een vaste klantsticker bestaat (op id of artikelsleutel). */
16
+ export function stickerProductIds(products, rows) {
17
+ const have = new Set(rows.map((r) => String(r.trade_item_key ?? "")).filter(Boolean));
18
+ return products.filter((p) => have.has(p.id) || (!!p.tradeItemKey && have.has(p.tradeItemKey))).map((p) => p.id);
19
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"floriday-mirror.functions.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-mirror.functions.ts"],"names":[],"mappings":"AAgJA,UAAU,YAAY;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,OAAO,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACnD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAy5CD,wBAAsB,4BAA4B,CAAC,KAAK,SAAgB,yBAEvE;AAED,eAAO,MAAM,oBAAoB;;;;8CAEP,OAAO;;yBAG0C,CAAC"}
1
+ {"version":3,"file":"floriday-mirror.functions.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-mirror.functions.ts"],"names":[],"mappings":"AAyKA,UAAU,YAAY;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,OAAO,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACnD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAi3CD,wBAAsB,4BAA4B,CAAC,KAAK,SAAgB,yBAEvE;AAED,eAAO,MAAM,oBAAoB;;;;8CAEP,OAAO;;yBAG0C,CAAC"}
@@ -1,5 +1,6 @@
1
1
  import { diffBuyerChanges } from "./floriday-change-diff.js";
2
2
  import { MISSING_LINE_KEY_NOTICE, splitByLineKey } from "./floriday-line-key.js";
3
+ import { keepOrSetCustomer, promoteCustomers } from "./floriday-promote-customer.js";
3
4
  // Spiegelt Floriday-verkooporders (FO's) uit `floriday_salesorders_cache`
4
5
  // naar de lokale `orders`-tabel, zodat ze via `resolveBufferForOrderInternal`
5
6
  // in dezelfde buffer terechtkomen als lokale orders en gedeelde karren
@@ -64,39 +65,56 @@ function buyerOrgIdOf(row) {
64
65
  return String(row?.buyer_organization_id ?? row?.data?.customerOrganizationId ?? "");
65
66
  }
66
67
  /**
67
- * Vult customer_id bij Floriday-orders waar die leeg is, alleen als precies
68
- * één klant het organisatienummer (custom_fields.floriday_customer_id) heeft.
69
- * Maakt nooit klanten aan en overschrijft nooit een bestaande koppeling.
68
+ * Vangnet: Floriday-orders zonder customer_id krijgen de klant die
69
+ * promote_floriday_customer teruggeeft. Organisatienummer: custom_fields.
70
+ * floriday_customer_id, anders de koper uit de Floriday-gegevens. Alleen
71
+ * customer_id wordt gezet, alleen als die nog leeg is.
70
72
  */
71
73
  async function linkCustomersForFloridayOrders() {
72
74
  const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
73
- const { data: custs, error: cErr } = await supabaseAdmin
74
- .from("customers")
75
- .select("id, floriday_organization_id")
76
- .not("floriday_organization_id", "is", null);
77
- if (cErr)
78
- throw new Error(cErr.message);
79
- const byOrg = new Map();
80
- for (const c of custs ?? []) {
81
- const k = String(c.floriday_organization_id);
82
- byOrg.set(k, byOrg.has(k) ? null : String(c.id));
83
- }
84
- for (const [k, v] of byOrg) {
85
- if (v === null)
86
- console.warn(`[floriday-mirror] organisatienummer ${k} hoort bij meerdere klanten; geen klant gekoppeld.`);
87
- }
88
- if (byOrg.size === 0)
75
+ const { data: loose, error: lErr } = await supabaseAdmin
76
+ .from("orders")
77
+ .select("id, floriday_sales_order_id, custom_fields")
78
+ .is("customer_id", null)
79
+ .not("floriday_sales_order_id", "is", null)
80
+ .limit(1000);
81
+ if (lErr)
82
+ throw new Error(lErr.message);
83
+ const todo = (loose ?? []);
84
+ if (!todo.length)
89
85
  return 0;
86
+ const needCache = [
87
+ ...new Set(todo.filter((o) => !o?.custom_fields?.floriday_customer_id).map((o) => String(o.floriday_sales_order_id))),
88
+ ];
89
+ const orgBySo = new Map();
90
+ for (let i = 0; i < needCache.length; i += 200) {
91
+ const { data: cache, error: cErr } = await supabaseAdmin
92
+ .from("floriday_salesorders_cache")
93
+ .select("floriday_id, buyer_organization_id")
94
+ .in("floriday_id", needCache.slice(i, i + 200));
95
+ if (cErr)
96
+ throw new Error(cErr.message);
97
+ for (const r of cache ?? []) {
98
+ const org = r.buyer_organization_id;
99
+ if (org)
100
+ orgBySo.set(String(r.floriday_id), String(org));
101
+ }
102
+ }
103
+ const orgOf = (o) => (o?.custom_fields?.floriday_customer_id ? String(o.custom_fields.floriday_customer_id) : null) ??
104
+ orgBySo.get(String(o.floriday_sales_order_id)) ??
105
+ null;
106
+ const promoted = await promoteCustomers(todo.map(orgOf).filter(Boolean), (org) => supabaseAdmin.rpc("promote_floriday_customer", { _org_id: org }));
90
107
  let linked = 0;
91
- for (const [org, custId] of byOrg) {
108
+ for (const o of todo) {
109
+ const org = orgOf(o);
110
+ const custId = org ? promoted.get(org) : null;
92
111
  if (!custId)
93
112
  continue;
94
113
  const { data, error } = await supabaseAdmin
95
114
  .from("orders")
96
115
  .update({ customer_id: custId })
116
+ .eq("id", o.id)
97
117
  .is("customer_id", null)
98
- .not("floriday_sales_order_id", "is", null)
99
- .eq("custom_fields->>floriday_customer_id", org)
100
118
  .select("id");
101
119
  if (error)
102
120
  throw new Error(error.message);
@@ -173,7 +191,16 @@ async function mirrorUnlocked(limit) {
173
191
  throw new Error(cacheErr.message);
174
192
  const rows = (cacheRows ?? []);
175
193
  if (rows.length === 0) {
176
- return { ok: true, processed: 0, inserted: 0, updated: 0, skipped: 0, failed: 0, errors: [] };
194
+ // Ook zonder nieuwe Floriday-gegevens: orders koppelen aan klanten die
195
+ // inmiddels (bijv. door de Klanten-module) zijn aangemaakt.
196
+ const errors = [];
197
+ try {
198
+ await linkCustomersForFloridayOrders();
199
+ }
200
+ catch (e) {
201
+ errors.push(`klantkoppeling: ${String(e?.message ?? e).slice(0, 150)}`);
202
+ }
203
+ return { ok: errors.length === 0, processed: 0, inserted: 0, updated: 0, skipped: 0, failed: 0, errors };
177
204
  }
178
205
  // Bestaande mirrors ophalen (voor insert/update-onderscheid).
179
206
  const foIds = rows.map((r) => String(r.floriday_id));
@@ -288,63 +315,17 @@ async function mirrorUnlocked(limit) {
288
315
  catch {
289
316
  /* afhandelstatus is best-effort */
290
317
  }
291
- // Klant-lookup: floriday_organization_id → customers.id + name.
318
+ // Klant per koper: altijd via de Klanten-module (promote_floriday_customer),
319
+ // één aanroep per organisatienummer per ronde. Fout → geen klant.
292
320
  const orgIds = Array.from(new Set(rows.map((r) => buyerOrgIdOf(r)).filter(Boolean)));
293
321
  const customerByOrgId = new Map();
294
322
  if (orgIds.length > 0) {
295
- const { data: custRows } = await supabaseAdmin
296
- .from("customers")
297
- .select("id, company_name, commercial_name, floriday_organization_id")
298
- .in("floriday_organization_id", orgIds);
299
- // Alleen eenduidige koppelingen: hoort een organisatienummer bij meer
300
- // dan één klant, dan koppelen we geen klant (geen giswerk).
301
- const ambiguous = new Set();
302
- for (const c of custRows ?? []) {
303
- const key = String(c.floriday_organization_id);
304
- if (customerByOrgId.has(key))
305
- ambiguous.add(key);
306
- customerByOrgId.set(key, {
307
- id: c.id,
308
- name: c.commercial_name ?? c.company_name ?? "Onbekende klant",
309
- });
310
- }
311
- for (const key of ambiguous) {
312
- console.warn(`[floriday-mirror] organisatienummer ${key} hoort bij meerdere klanten; geen klant gekoppeld.`);
313
- customerByOrgId.delete(key);
314
- }
315
- // Floriday-only koper direct laten omzetten door de Klanten-module
316
- // (promote_floriday_customer). Alleen bij geen treffer; nooit bij
317
- // ambigue nummers; fail-closed: bij fout blijft customer_id leeg.
318
- const toPromote = orgIds.filter((o) => !customerByOrgId.has(String(o)) && !ambiguous.has(String(o)));
319
- const promotedIds = new Map();
320
- for (let i = 0; i < toPromote.length; i += 12) {
321
- await Promise.all(toPromote.slice(i, i + 12).map(async (org) => {
322
- try {
323
- const { data, error } = await supabaseAdmin.rpc("promote_floriday_customer", { _org_id: org });
324
- if (error)
325
- throw new Error(error.message);
326
- const raw = Array.isArray(data) ? data[0] : data;
327
- const id = typeof raw === "string"
328
- ? raw
329
- : raw && typeof raw === "object"
330
- ? (raw.id ?? raw.customer_id ?? raw.promote_floriday_customer ?? null)
331
- : null;
332
- if (!id) {
333
- console.warn(`[floriday-mirror] promote_floriday_customer gaf geen klant voor ${org}; geen klant gekoppeld.`);
334
- return;
335
- }
336
- promotedIds.set(org, String(id));
337
- }
338
- catch (e) {
339
- console.warn(`[floriday-mirror] klant omzetten mislukt voor ${org}: ${e.message}; geen klant gekoppeld.`);
340
- }
341
- }));
342
- }
323
+ const promotedIds = await promoteCustomers(orgIds, (org) => supabaseAdmin.rpc("promote_floriday_customer", { _org_id: org }));
343
324
  if (promotedIds.size > 0) {
344
325
  const { data: promRows } = await supabaseAdmin
345
326
  .from("customers")
346
327
  .select("id, company_name, commercial_name")
347
- .in("id", Array.from(promotedIds.values()));
328
+ .in("id", Array.from(new Set(promotedIds.values())));
348
329
  const byId = new Map((promRows ?? []).map((c) => [String(c.id), c]));
349
330
  for (const [org, id] of promotedIds) {
350
331
  const c = byId.get(id);
@@ -1060,10 +1041,12 @@ async function mirrorUnlocked(limit) {
1060
1041
  // Verschillende kopers op één order: nooit gokken welke klant.
1061
1042
  ...(lvl.multiBuyer
1062
1043
  ? {}
1063
- : {
1064
- customer_id: primary.custId ?? target?.customer_id ?? null,
1065
- customer_name: primary.customerName,
1066
- }),
1044
+ : target?.customer_id
1045
+ ? {} // bestaande klant nooit overschrijven
1046
+ : {
1047
+ customer_id: keepOrSetCustomer(null, primary.custId),
1048
+ customer_name: primary.customerName,
1049
+ }),
1067
1050
  delivery_date: lvl.deliveryDate,
1068
1051
  order_date: lvl.orderDate ?? primary.orderDateIso,
1069
1052
  ...statusPatch,
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=floriday-promote-customer.check.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floriday-promote-customer.check.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-promote-customer.check.ts"],"names":[],"mappings":""}
@@ -0,0 +1,28 @@
1
+ // Losse controle: bun src/lib/floriday-promote-customer.check.ts
2
+ import { extractCustomerId, keepOrSetCustomer, promoteCustomers } from "./floriday-promote-customer.js";
3
+ let fails = 0;
4
+ const ok = (c, m) => { if (!c) {
5
+ fails++;
6
+ console.error("FOUT:", m);
7
+ }
8
+ else
9
+ console.log("ok:", m); };
10
+ const calls = [];
11
+ const res = await promoteCustomers(["A", "A", "B", "C", ""], async (org) => {
12
+ calls.push(org);
13
+ if (org === "A")
14
+ return { data: "klant-a", error: null };
15
+ if (org === "B")
16
+ return { data: null, error: { message: "organisatie onbekend" } };
17
+ return { data: null, error: null };
18
+ }, () => { });
19
+ ok(calls.length === 3, "één aanroep per uniek nummer, leeg overgeslagen");
20
+ ok(res.get("A") === "klant-a", "teruggegeven id wordt gebruikt");
21
+ ok(!res.has("B"), "fout → geen klant");
22
+ ok(!res.has("C"), "leeg antwoord → geen klant");
23
+ ok(extractCustomerId([{ id: "x" }]) === "x", "rij-antwoord met id");
24
+ ok(keepOrSetCustomer("bestaand", "nieuw") === "bestaand", "bestaande klant blijft");
25
+ ok(keepOrSetCustomer(null, "nieuw") === "nieuw", "lege klant wordt gevuld");
26
+ ok(keepOrSetCustomer(null, null) === null, "niets gevonden → leeg");
27
+ if (fails)
28
+ process.exit(1);
@@ -0,0 +1,12 @@
1
+ export type PromoteRpc = (orgId: string) => Promise<{
2
+ data: unknown;
3
+ error: {
4
+ message: string;
5
+ } | null;
6
+ }>;
7
+ export declare function extractCustomerId(data: unknown): string | null;
8
+ /** Roept de functie één keer per uniek nummer aan, max 12 tegelijk. */
9
+ export declare function promoteCustomers(orgIds: Iterable<string>, rpc: PromoteRpc, warn?: (msg: string) => void): Promise<Map<string, string>>;
10
+ /** Regel 4: een bestaande klant op de order wordt nooit overschreven. */
11
+ export declare function keepOrSetCustomer(existing: string | null | undefined, found: string | null | undefined): string | null;
12
+ //# sourceMappingURL=floriday-promote-customer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"floriday-promote-customer.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-promote-customer.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,UAAU,GAAG,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,CAAC,CAAC;AAE1G,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAS9D;AAED,uEAAuE;AACvE,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,EACxB,GAAG,EAAE,UAAU,EACf,IAAI,GAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAA6B,GACnD,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAsB9B;AAED,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAEtH"}
@@ -0,0 +1,43 @@
1
+ // Floriday-koper → klant, altijd via de Klanten-module
2
+ // (public.promote_floriday_customer). Deze module maakt nooit zelf klanten
3
+ // aan en wijzigt nooit klantgegevens. Fail closed: fout of leeg antwoord →
4
+ // geen klant (de Klanten-ronde probeert het later opnieuw).
5
+ export function extractCustomerId(data) {
6
+ const raw = Array.isArray(data) ? data[0] : data;
7
+ if (typeof raw === "string")
8
+ return raw.trim() || null;
9
+ if (raw && typeof raw === "object") {
10
+ const r = raw;
11
+ const id = r.id ?? r.customer_id ?? r.promote_floriday_customer;
12
+ return typeof id === "string" && id.trim() ? id : null;
13
+ }
14
+ return null;
15
+ }
16
+ /** Roept de functie één keer per uniek nummer aan, max 12 tegelijk. */
17
+ export async function promoteCustomers(orgIds, rpc, warn = (m) => console.warn(m)) {
18
+ const unique = [...new Set([...orgIds].map((o) => String(o ?? "").trim()).filter(Boolean))];
19
+ const out = new Map();
20
+ for (let i = 0; i < unique.length; i += 12) {
21
+ await Promise.all(unique.slice(i, i + 12).map(async (org) => {
22
+ try {
23
+ const { data, error } = await rpc(org);
24
+ if (error)
25
+ throw new Error(error.message);
26
+ const id = extractCustomerId(data);
27
+ if (!id) {
28
+ warn(`[floriday-mirror] promote_floriday_customer gaf geen klant voor ${org}; geen klant gekoppeld.`);
29
+ return;
30
+ }
31
+ out.set(org, id);
32
+ }
33
+ catch (e) {
34
+ warn(`[floriday-mirror] klant omzetten mislukt voor ${org}: ${e.message}; geen klant gekoppeld.`);
35
+ }
36
+ }));
37
+ }
38
+ return out;
39
+ }
40
+ /** Regel 4: een bestaande klant op de order wordt nooit overschreven. */
41
+ export function keepOrSetCustomer(existing, found) {
42
+ return existing || found || null;
43
+ }
@@ -1,2 +1,2 @@
1
- export declare const MODULE_VERSION = "1.0.99";
1
+ export declare const MODULE_VERSION = "1.0.103";
2
2
  //# sourceMappingURL=module-version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"module-version.d.ts","sourceRoot":"","sources":["../../src/lib/module-version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,WAAW,CAAC"}
1
+ {"version":3,"file":"module-version.d.ts","sourceRoot":"","sources":["../../src/lib/module-version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,YAAY,CAAC"}
@@ -1,3 +1,3 @@
1
1
  // Versie van deze module, meegestuurd in antwoorden van geplande taken zodat
2
2
  // je ziet welke code echt draait. Bijwerken samen met package.json.
3
- export const MODULE_VERSION = "1.0.99";
3
+ export const MODULE_VERSION = "1.0.103";
@@ -7,6 +7,8 @@ export interface OrderItemPackingRow {
7
7
  layersPerCart: number | null;
8
8
  lockedAt: string | null;
9
9
  lockedByName: string | null;
10
+ /** Sticker nodig op deze orderregel (alleen weergave). */
11
+ needsSticker: boolean;
10
12
  }
11
13
  /**
12
14
  * Belading per bestelregel van één order, inclusief de handmatige
@@ -1 +1 @@
1
- {"version":3,"file":"order-item-packing.functions.d.ts","sourceRoot":"","sources":["../../src/lib/order-item-packing.functions.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;8CAEP,OAAO;;;WAYU,mBAAmB,EAAE;GAwC5D,CAAC;AASL,yDAAyD;AACzD,eAAO,MAAM,mBAAmB;;;;8CAEN,OAAO;;;;;;;;GAa7B,CAAC;AAEL,kFAAkF;AAClF,eAAO,MAAM,yBAAyB;;;;8CAEZ,OAAO;;;;;GAY7B,CAAC"}
1
+ {"version":3,"file":"order-item-packing.functions.d.ts","sourceRoot":"","sources":["../../src/lib/order-item-packing.functions.ts"],"names":[],"mappings":"AAgBA,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,0DAA0D;IAC1D,YAAY,EAAE,OAAO,CAAC;CACvB;AAED;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;8CAEP,OAAO;;;WAYU,mBAAmB,EAAE;GAyC5D,CAAC;AASL,yDAAyD;AACzD,eAAO,MAAM,mBAAmB;;;;8CAEN,OAAO;;;;;;;;GAa7B,CAAC;AAEL,kFAAkF;AAClF,eAAO,MAAM,yBAAyB;;;;8CAEZ,OAAO;;;;;GAY7B,CAAC"}
@@ -35,7 +35,7 @@ export const listOrderItemPacking = createServerFn({ method: "GET" })
35
35
  return { items: [] };
36
36
  const { data: rows, error } = await supabase
37
37
  .from("order_items")
38
- .select("id, product_name, quantity, plants_per_crate, crates_per_layer, layers_per_cart, packing_locked_at, packing_locked_by")
38
+ .select("id, product_name, quantity, plants_per_crate, crates_per_layer, layers_per_cart, packing_locked_at, packing_locked_by, needs_sticker")
39
39
  .eq("order_id", orderRowId)
40
40
  .is("quarantined_at", null)
41
41
  .order("product_name", { ascending: true });
@@ -64,6 +64,7 @@ export const listOrderItemPacking = createServerFn({ method: "GET" })
64
64
  lockedByName: r.packing_locked_by
65
65
  ? nameById.get(r.packing_locked_by) ?? "Onbekende medewerker"
66
66
  : null,
67
+ needsSticker: r.needs_sticker === true,
67
68
  })),
68
69
  };
69
70
  });