@flowselections/floriday-verkoop-module 1.0.18 → 1.0.19

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 (30) hide show
  1. package/dist-lib/integrations/supabase/auth-middleware.d.ts +56 -0
  2. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  3. package/dist-lib/integrations/supabase/client.d.ts +56 -0
  4. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  5. package/dist-lib/integrations/supabase/client.server.d.ts +56 -0
  6. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  7. package/dist-lib/integrations/supabase/types.d.ts +56 -0
  8. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  9. package/dist-lib/lib/cart-lock.functions.d.ts +56 -0
  10. package/dist-lib/lib/cart-lock.functions.d.ts.map +1 -1
  11. package/dist-lib/lib/cart-replan.functions.d.ts +112 -0
  12. package/dist-lib/lib/cart-replan.functions.d.ts.map +1 -1
  13. package/dist-lib/lib/create-order.functions.d.ts +672 -0
  14. package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
  15. package/dist-lib/lib/create-order.functions.js +29 -19
  16. package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts +168 -0
  17. package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts.map +1 -1
  18. package/dist-lib/lib/floriday-logistic-labels.functions.d.ts +56 -0
  19. package/dist-lib/lib/floriday-logistic-labels.functions.d.ts.map +1 -1
  20. package/dist-lib/lib/floriday-public.functions.d.ts +392 -0
  21. package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
  22. package/dist-lib/lib/floriday-writes.functions.d.ts +280 -0
  23. package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
  24. package/dist-lib/lib/order-shipments.functions.d.ts +224 -0
  25. package/dist-lib/lib/order-shipments.functions.d.ts.map +1 -1
  26. package/dist-lib/lib/salesorders.functions.d.ts +168 -0
  27. package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
  28. package/dist-lib/lib/tradeitems.functions.d.ts +56 -0
  29. package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
  30. package/package.json +1 -1
@@ -513,7 +513,12 @@ export const createManualOrder = createServerFn({ method: "POST" })
513
513
  const groupById = new Map();
514
514
  for (const r of groupsRes.data ?? [])
515
515
  groupById.set(r.id, r);
516
- const missingLines = data.lines.filter((l) => !existingIds.has(l.product_id));
516
+ // Groepen krijgen GEEN spiegelrij in `products`: de database heeft een
517
+ // trigger die id-botsingen tussen products en product_groups tegenhoudt.
518
+ // De order-regel wordt daarom met product_id = null én naamprefix
519
+ // "[Groep] <naam>" opgeslagen; expand-group-order-items resolvt de groep
520
+ // dan op naam en splitst hem in members.
521
+ const missingLines = data.lines.filter((l) => !existingIds.has(l.product_id) && !groupById.has(l.product_id));
517
522
  if (missingLines.length > 0) {
518
523
  const shortRand = () => Array.from({ length: 6 }, () => Math.floor(Math.random() * 16).toString(16).toUpperCase()).join("");
519
524
  const seen = new Set();
@@ -548,13 +553,6 @@ export const createManualOrder = createServerFn({ method: "POST" })
548
553
  customFields.floriday_id = id;
549
554
  customFields.source = "sales-module-floriday-mirror";
550
555
  }
551
- else if (groupById.has(id)) {
552
- source = "group";
553
- tradeItemKey = `group:${id}`;
554
- articleNumber = l.article_code?.trim() || `GRP-${shortRand()}`;
555
- customFields.group_id = id;
556
- customFields.source = "sales-module-group-mirror";
557
- }
558
556
  else {
559
557
  source = "unknown";
560
558
  tradeItemKey = `product:${id}`;
@@ -576,9 +574,11 @@ export const createManualOrder = createServerFn({ method: "POST" })
576
574
  custom_fields: { ...customFields, mirror_kind: source },
577
575
  };
578
576
  });
579
- const { error: prodErr } = await supabaseAdmin.from("products").insert(toInsert);
580
- if (prodErr)
581
- throw new Error(`Product aanmaken faalde: ${prodErr.message}`);
577
+ if (toInsert.length > 0) {
578
+ const { error: prodErr } = await supabaseAdmin.from("products").insert(toInsert);
579
+ if (prodErr)
580
+ throw new Error(`Product aanmaken faalde: ${prodErr.message}`);
581
+ }
582
582
  }
583
583
  const total = data.lines.reduce((s, l) => s + (Number(l.unit_price ?? 0) * Number(l.quantity)), 0);
584
584
  const { data: order, error: orderErr } = await supabaseAdmin.from("orders").insert({
@@ -600,14 +600,24 @@ export const createManualOrder = createServerFn({ method: "POST" })
600
600
  }).select("id, order_number").single();
601
601
  if (orderErr)
602
602
  throw new Error(orderErr.message);
603
- const items = data.lines.map((l) => ({
604
- order_id: order.id,
605
- product_id: l.product_id,
606
- product_name: l.product_name,
607
- quantity: Math.max(1, Math.round(l.quantity)),
608
- unit: l.unit ?? "stuks",
609
- unit_price: l.unit_price ?? undefined,
610
- }));
603
+ const items = data.lines.map((l) => {
604
+ const isGroup = groupById.has(l.product_id);
605
+ const groupRow = isGroup ? groupById.get(l.product_id) : null;
606
+ const groupName = groupRow?.name ?? l.product_name;
607
+ const displayName = isGroup
608
+ ? (/^\s*\[Groep\]/i.test(l.product_name) ? l.product_name : `[Groep] ${groupName}`)
609
+ : l.product_name;
610
+ return {
611
+ order_id: order.id,
612
+ // Groepen krijgen product_id = null; expand-group-order-items
613
+ // resolvt hen op naam ("[Groep] <naam>").
614
+ product_id: isGroup ? null : l.product_id,
615
+ product_name: displayName,
616
+ quantity: Math.max(1, Math.round(l.quantity)),
617
+ unit: l.unit ?? "stuks",
618
+ unit_price: l.unit_price ?? undefined,
619
+ };
620
+ });
611
621
  const { error: itemsErr } = await supabaseAdmin.from("order_items").insert(items);
612
622
  if (itemsErr)
613
623
  throw new Error(itemsErr.message);
@@ -7693,6 +7693,39 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
7693
7693
  referencedColumns: ["id"];
7694
7694
  }];
7695
7695
  };
7696
+ product_merge_log: {
7697
+ Row: {
7698
+ canonical_product_id: string | null;
7699
+ id: string;
7700
+ merged_at: string;
7701
+ merged_from_id: string;
7702
+ notes: string | null;
7703
+ snapshot: import("../integrations/supabase/types").Json;
7704
+ source_table: string;
7705
+ status: string;
7706
+ };
7707
+ Insert: {
7708
+ canonical_product_id?: string | null;
7709
+ id?: string;
7710
+ merged_at?: string;
7711
+ merged_from_id: string;
7712
+ notes?: string | null;
7713
+ snapshot?: import("../integrations/supabase/types").Json;
7714
+ source_table: string;
7715
+ status?: string;
7716
+ };
7717
+ Update: {
7718
+ canonical_product_id?: string | null;
7719
+ id?: string;
7720
+ merged_at?: string;
7721
+ merged_from_id?: string;
7722
+ notes?: string | null;
7723
+ snapshot?: import("../integrations/supabase/types").Json;
7724
+ source_table?: string;
7725
+ status?: string;
7726
+ };
7727
+ Relationships: [];
7728
+ };
7696
7729
  products: {
7697
7730
  Row: {
7698
7731
  article_number: string | null;
@@ -7701,6 +7734,9 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
7701
7734
  crates_per_layer: number;
7702
7735
  created_at: string;
7703
7736
  custom_fields: import("../integrations/supabase/types").Json;
7737
+ floriday_active: boolean;
7738
+ floriday_payload: import("../integrations/supabase/types").Json;
7739
+ floriday_trade_item_id: string | null;
7704
7740
  id: string;
7705
7741
  image_url: string | null;
7706
7742
  incoming_quantity: number;
@@ -7725,6 +7761,9 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
7725
7761
  crates_per_layer?: number;
7726
7762
  created_at?: string;
7727
7763
  custom_fields?: import("../integrations/supabase/types").Json;
7764
+ floriday_active?: boolean;
7765
+ floriday_payload?: import("../integrations/supabase/types").Json;
7766
+ floriday_trade_item_id?: string | null;
7728
7767
  id?: string;
7729
7768
  image_url?: string | null;
7730
7769
  incoming_quantity?: number;
@@ -7749,6 +7788,9 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
7749
7788
  crates_per_layer?: number;
7750
7789
  created_at?: string;
7751
7790
  custom_fields?: import("../integrations/supabase/types").Json;
7791
+ floriday_active?: boolean;
7792
+ floriday_payload?: import("../integrations/supabase/types").Json;
7793
+ floriday_trade_item_id?: string | null;
7752
7794
  id?: string;
7753
7795
  image_url?: string | null;
7754
7796
  incoming_quantity?: number;
@@ -10707,6 +10749,13 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
10707
10749
  };
10708
10750
  Returns: number;
10709
10751
  };
10752
+ _migrate_rewrite_stock_key: {
10753
+ Args: {
10754
+ _from_key: string;
10755
+ _to_key: string;
10756
+ };
10757
+ Returns: undefined;
10758
+ };
10710
10759
  afh_city_code: {
10711
10760
  Args: {
10712
10761
  _city: string;
@@ -11265,6 +11314,13 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
11265
11314
  };
11266
11315
  Returns: undefined;
11267
11316
  };
11317
+ merge_products: {
11318
+ Args: {
11319
+ _canonical: string;
11320
+ _loser: string;
11321
+ };
11322
+ Returns: undefined;
11323
+ };
11268
11324
  next_manufacture_partij: {
11269
11325
  Args: {
11270
11326
  _tenant_id: string;
@@ -19471,6 +19527,39 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
19471
19527
  referencedColumns: ["id"];
19472
19528
  }];
19473
19529
  };
19530
+ product_merge_log: {
19531
+ Row: {
19532
+ canonical_product_id: string | null;
19533
+ id: string;
19534
+ merged_at: string;
19535
+ merged_from_id: string;
19536
+ notes: string | null;
19537
+ snapshot: import("../integrations/supabase/types").Json;
19538
+ source_table: string;
19539
+ status: string;
19540
+ };
19541
+ Insert: {
19542
+ canonical_product_id?: string | null;
19543
+ id?: string;
19544
+ merged_at?: string;
19545
+ merged_from_id: string;
19546
+ notes?: string | null;
19547
+ snapshot?: import("../integrations/supabase/types").Json;
19548
+ source_table: string;
19549
+ status?: string;
19550
+ };
19551
+ Update: {
19552
+ canonical_product_id?: string | null;
19553
+ id?: string;
19554
+ merged_at?: string;
19555
+ merged_from_id?: string;
19556
+ notes?: string | null;
19557
+ snapshot?: import("../integrations/supabase/types").Json;
19558
+ source_table?: string;
19559
+ status?: string;
19560
+ };
19561
+ Relationships: [];
19562
+ };
19474
19563
  products: {
19475
19564
  Row: {
19476
19565
  article_number: string | null;
@@ -19479,6 +19568,9 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
19479
19568
  crates_per_layer: number;
19480
19569
  created_at: string;
19481
19570
  custom_fields: import("../integrations/supabase/types").Json;
19571
+ floriday_active: boolean;
19572
+ floriday_payload: import("../integrations/supabase/types").Json;
19573
+ floriday_trade_item_id: string | null;
19482
19574
  id: string;
19483
19575
  image_url: string | null;
19484
19576
  incoming_quantity: number;
@@ -19503,6 +19595,9 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
19503
19595
  crates_per_layer?: number;
19504
19596
  created_at?: string;
19505
19597
  custom_fields?: import("../integrations/supabase/types").Json;
19598
+ floriday_active?: boolean;
19599
+ floriday_payload?: import("../integrations/supabase/types").Json;
19600
+ floriday_trade_item_id?: string | null;
19506
19601
  id?: string;
19507
19602
  image_url?: string | null;
19508
19603
  incoming_quantity?: number;
@@ -19527,6 +19622,9 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
19527
19622
  crates_per_layer?: number;
19528
19623
  created_at?: string;
19529
19624
  custom_fields?: import("../integrations/supabase/types").Json;
19625
+ floriday_active?: boolean;
19626
+ floriday_payload?: import("../integrations/supabase/types").Json;
19627
+ floriday_trade_item_id?: string | null;
19530
19628
  id?: string;
19531
19629
  image_url?: string | null;
19532
19630
  incoming_quantity?: number;
@@ -22485,6 +22583,13 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
22485
22583
  };
22486
22584
  Returns: number;
22487
22585
  };
22586
+ _migrate_rewrite_stock_key: {
22587
+ Args: {
22588
+ _from_key: string;
22589
+ _to_key: string;
22590
+ };
22591
+ Returns: undefined;
22592
+ };
22488
22593
  afh_city_code: {
22489
22594
  Args: {
22490
22595
  _city: string;
@@ -23043,6 +23148,13 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
23043
23148
  };
23044
23149
  Returns: undefined;
23045
23150
  };
23151
+ merge_products: {
23152
+ Args: {
23153
+ _canonical: string;
23154
+ _loser: string;
23155
+ };
23156
+ Returns: undefined;
23157
+ };
23046
23158
  next_manufacture_partij: {
23047
23159
  Args: {
23048
23160
  _tenant_id: string;
@@ -31258,6 +31370,39 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
31258
31370
  referencedColumns: ["id"];
31259
31371
  }];
31260
31372
  };
31373
+ product_merge_log: {
31374
+ Row: {
31375
+ canonical_product_id: string | null;
31376
+ id: string;
31377
+ merged_at: string;
31378
+ merged_from_id: string;
31379
+ notes: string | null;
31380
+ snapshot: import("../integrations/supabase/types").Json;
31381
+ source_table: string;
31382
+ status: string;
31383
+ };
31384
+ Insert: {
31385
+ canonical_product_id?: string | null;
31386
+ id?: string;
31387
+ merged_at?: string;
31388
+ merged_from_id: string;
31389
+ notes?: string | null;
31390
+ snapshot?: import("../integrations/supabase/types").Json;
31391
+ source_table: string;
31392
+ status?: string;
31393
+ };
31394
+ Update: {
31395
+ canonical_product_id?: string | null;
31396
+ id?: string;
31397
+ merged_at?: string;
31398
+ merged_from_id?: string;
31399
+ notes?: string | null;
31400
+ snapshot?: import("../integrations/supabase/types").Json;
31401
+ source_table?: string;
31402
+ status?: string;
31403
+ };
31404
+ Relationships: [];
31405
+ };
31261
31406
  products: {
31262
31407
  Row: {
31263
31408
  article_number: string | null;
@@ -31266,6 +31411,9 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
31266
31411
  crates_per_layer: number;
31267
31412
  created_at: string;
31268
31413
  custom_fields: import("../integrations/supabase/types").Json;
31414
+ floriday_active: boolean;
31415
+ floriday_payload: import("../integrations/supabase/types").Json;
31416
+ floriday_trade_item_id: string | null;
31269
31417
  id: string;
31270
31418
  image_url: string | null;
31271
31419
  incoming_quantity: number;
@@ -31290,6 +31438,9 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
31290
31438
  crates_per_layer?: number;
31291
31439
  created_at?: string;
31292
31440
  custom_fields?: import("../integrations/supabase/types").Json;
31441
+ floriday_active?: boolean;
31442
+ floriday_payload?: import("../integrations/supabase/types").Json;
31443
+ floriday_trade_item_id?: string | null;
31293
31444
  id?: string;
31294
31445
  image_url?: string | null;
31295
31446
  incoming_quantity?: number;
@@ -31314,6 +31465,9 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
31314
31465
  crates_per_layer?: number;
31315
31466
  created_at?: string;
31316
31467
  custom_fields?: import("../integrations/supabase/types").Json;
31468
+ floriday_active?: boolean;
31469
+ floriday_payload?: import("../integrations/supabase/types").Json;
31470
+ floriday_trade_item_id?: string | null;
31317
31471
  id?: string;
31318
31472
  image_url?: string | null;
31319
31473
  incoming_quantity?: number;
@@ -34272,6 +34426,13 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
34272
34426
  };
34273
34427
  Returns: number;
34274
34428
  };
34429
+ _migrate_rewrite_stock_key: {
34430
+ Args: {
34431
+ _from_key: string;
34432
+ _to_key: string;
34433
+ };
34434
+ Returns: undefined;
34435
+ };
34275
34436
  afh_city_code: {
34276
34437
  Args: {
34277
34438
  _city: string;
@@ -34830,6 +34991,13 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
34830
34991
  };
34831
34992
  Returns: undefined;
34832
34993
  };
34994
+ merge_products: {
34995
+ Args: {
34996
+ _canonical: string;
34997
+ _loser: string;
34998
+ };
34999
+ Returns: undefined;
35000
+ };
34833
35001
  next_manufacture_partij: {
34834
35002
  Args: {
34835
35003
  _tenant_id: string;