@flowselections/floriday-verkoop-module 1.0.49 → 1.0.50

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 (60) hide show
  1. package/dist-lib/integrations/supabase/auth-middleware.d.ts +55 -1
  2. package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
  3. package/dist-lib/integrations/supabase/client.d.ts +55 -1
  4. package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
  5. package/dist-lib/integrations/supabase/client.server.d.ts +55 -1
  6. package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
  7. package/dist-lib/integrations/supabase/types.d.ts +58 -1
  8. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  9. package/dist-lib/lib/cart-lock.functions.d.ts +55 -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 +605 -11
  15. package/dist-lib/lib/cart-planning-settings.functions.d.ts.map +1 -1
  16. package/dist-lib/lib/cart-replan.functions.d.ts +177 -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 +940 -17
  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 +165 -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 +55 -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 +55 -1
  27. package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
  28. package/dist-lib/lib/floriday-public.functions.d.ts +385 -7
  29. package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
  30. package/dist-lib/lib/floriday-writes.functions.d.ts +275 -5
  31. package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
  32. package/dist-lib/lib/invoice-timing.functions.d.ts +220 -4
  33. package/dist-lib/lib/invoice-timing.functions.d.ts.map +1 -1
  34. package/dist-lib/lib/load-carriers.functions.d.ts +55 -1
  35. package/dist-lib/lib/load-carriers.functions.d.ts.map +1 -1
  36. package/dist-lib/lib/logistics-engine.functions.d.ts +275 -5
  37. package/dist-lib/lib/logistics-engine.functions.d.ts.map +1 -1
  38. package/dist-lib/lib/logistics-stock.functions.d.ts +110 -2
  39. package/dist-lib/lib/logistics-stock.functions.d.ts.map +1 -1
  40. package/dist-lib/lib/order-addresses.functions.d.ts +55 -1
  41. package/dist-lib/lib/order-addresses.functions.d.ts.map +1 -1
  42. package/dist-lib/lib/order-buffers.functions.d.ts +165 -3
  43. package/dist-lib/lib/order-buffers.functions.d.ts.map +1 -1
  44. package/dist-lib/lib/order-carrier.functions.d.ts +110 -2
  45. package/dist-lib/lib/order-carrier.functions.d.ts.map +1 -1
  46. package/dist-lib/lib/order-pickup.functions.d.ts +110 -2
  47. package/dist-lib/lib/order-pickup.functions.d.ts.map +1 -1
  48. package/dist-lib/lib/order-shipments.functions.d.ts +220 -4
  49. package/dist-lib/lib/order-shipments.functions.d.ts.map +1 -1
  50. package/dist-lib/lib/salesorders-list.functions.d.ts +55 -1
  51. package/dist-lib/lib/salesorders-list.functions.d.ts.map +1 -1
  52. package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
  53. package/dist-lib/lib/salesorders-list.server.js +61 -3
  54. package/dist-lib/lib/salesorders.functions.d.ts +275 -5
  55. package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
  56. package/dist-lib/lib/stock-consumption-alerts.functions.d.ts +110 -2
  57. package/dist-lib/lib/stock-consumption-alerts.functions.d.ts.map +1 -1
  58. package/dist-lib/lib/tradeitems.functions.d.ts +55 -1
  59. package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
  60. package/package.json +1 -1
@@ -4,6 +4,7 @@
4
4
  import { createServerFn } from "@tanstack/react-start";
5
5
  import { z } from "zod";
6
6
  import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
7
+ import { CART_PLANNER_VERSION } from "./cart-planner";
7
8
  // ─── Klanten ────────────────────────────────────────────────────────────────
8
9
  // Bron 1: lokale `customers` (incl. eerder geïmporteerde Twinfield-klanten).
9
10
  // Bron 2: `twinfield_customers_cache` — klanten die alleen in Twinfield staan.
@@ -1059,11 +1060,31 @@ export const planAndSaveAutoCarts = createServerFn({ method: "POST" })
1059
1060
  cartNumber = existingMax[0].cart_number + 1;
1060
1061
  const autoCarts = [];
1061
1062
  const remainders = [];
1063
+ const blockedLines = [];
1062
1064
  for (const it of items ?? []) {
1063
1065
  const prod = it.products ?? {};
1064
- const ppc = Math.max(1, Number(prod.plants_per_crate ?? 1));
1065
- const cpl = Math.max(1, Number(prod.crates_per_layer ?? 1));
1066
- const lpc = Math.max(1, Number(prod.layers_per_cart ?? 1));
1066
+ // Onbekend blijft onbekend: geen terugval op 1 (1x1x1 = 1 plant per kar).
1067
+ const pos = (v) => {
1068
+ if (v === null || v === undefined)
1069
+ return null;
1070
+ const n = Math.round(Number(v));
1071
+ return Number.isFinite(n) && n > 0 ? n : null;
1072
+ };
1073
+ const ppc = pos(prod.plants_per_crate);
1074
+ const cpl = pos(prod.crates_per_layer);
1075
+ const lpc = pos(prod.layers_per_cart);
1076
+ if (ppc === null || cpl === null || lpc === null) {
1077
+ blockedLines.push({
1078
+ order_item_id: it.id,
1079
+ product_name: it.product_name,
1080
+ missing: [
1081
+ ppc === null ? "plants_per_crate" : null,
1082
+ cpl === null ? "crates_per_layer" : null,
1083
+ lpc === null ? "layers_per_cart" : null,
1084
+ ].filter((m) => m !== null),
1085
+ });
1086
+ continue;
1087
+ }
1067
1088
  const cratesPerCart = cpl * lpc;
1068
1089
  const totalPlants = Math.max(0, Number(it.quantity ?? 0));
1069
1090
  const totalCrates = Math.ceil(totalPlants / ppc);
@@ -1076,6 +1097,9 @@ export const planAndSaveAutoCarts = createServerFn({ method: "POST" })
1076
1097
  cart_number: cartNumber,
1077
1098
  is_auto: true,
1078
1099
  is_complete: true,
1100
+ // Expliciet zetten: nooit op de kolom-default leunen.
1101
+ source: "auto",
1102
+ algorithm_version: CART_PLANNER_VERSION,
1079
1103
  }).select("id").single();
1080
1104
  if (cErr)
1081
1105
  throw new Error(cErr.message);
@@ -1135,7 +1159,24 @@ export const planAndSaveAutoCarts = createServerFn({ method: "POST" })
1135
1159
  const adjustedRemainders = remainders
1136
1160
  .map((r) => ({ ...r, crates_remaining: Math.max(0, r.crates_remaining - (assignedByItem[r.order_item_id] ?? 0)) }))
1137
1161
  .filter((r) => r.crates_remaining > 0);
1138
- return { ok: true, autoCarts, remainders: adjustedRemainders, existingManualCarts, nextCartNumber: cartNumber };
1162
+ if (blockedLines.length > 0) {
1163
+ const { error: blockErr } = await supabaseAdmin.rpc("logistics_plan_block", {
1164
+ p_order_ids: [data.orderId],
1165
+ p_reason: "belading_onbekend",
1166
+ p_details: { source: "floriday-verkoop-module/planAndSaveAutoCarts", items: blockedLines },
1167
+ });
1168
+ if (blockErr) {
1169
+ console.warn("[karindeling] blokkade niet vastgelegd:", blockErr.message, blockedLines);
1170
+ }
1171
+ }
1172
+ return {
1173
+ ok: true,
1174
+ autoCarts,
1175
+ remainders: adjustedRemainders,
1176
+ existingManualCarts,
1177
+ nextCartNumber: cartNumber,
1178
+ blockedLines,
1179
+ };
1139
1180
  });
1140
1181
  const ManualCartItemSchema = z.object({
1141
1182
  order_item_id: z.string().uuid().nullable(),
@@ -1169,6 +1210,9 @@ export const saveManualCarts = createServerFn({ method: "POST" })
1169
1210
  is_auto: false,
1170
1211
  is_complete: !!cart.is_complete,
1171
1212
  notes: cart.notes ?? null,
1213
+ // Expliciet zetten: nooit op de kolom-default leunen.
1214
+ source: "manual",
1215
+ algorithm_version: CART_PLANNER_VERSION,
1172
1216
  }).select("id").single();
1173
1217
  if (cErr)
1174
1218
  throw new Error(cErr.message);
@@ -18619,6 +18619,7 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
18619
18619
  werkbon_package_items: {
18620
18620
  Row: {
18621
18621
  article_number: string | null;
18622
+ artikel_id: string | null;
18622
18623
  created_at: string;
18623
18624
  gtin: string | null;
18624
18625
  id: string;
@@ -18636,6 +18637,7 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
18636
18637
  };
18637
18638
  Insert: {
18638
18639
  article_number?: string | null;
18640
+ artikel_id?: string | null;
18639
18641
  created_at?: string;
18640
18642
  gtin?: string | null;
18641
18643
  id?: string;
@@ -18653,6 +18655,7 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
18653
18655
  };
18654
18656
  Update: {
18655
18657
  article_number?: string | null;
18658
+ artikel_id?: string | null;
18656
18659
  created_at?: string;
18657
18660
  gtin?: string | null;
18658
18661
  id?: string;
@@ -18669,6 +18672,12 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
18669
18672
  updated_at?: string;
18670
18673
  };
18671
18674
  Relationships: [{
18675
+ foreignKeyName: "werkbon_package_items_artikel_id_fkey";
18676
+ columns: ["artikel_id"];
18677
+ isOneToOne: false;
18678
+ referencedRelation: "artikelen_cache";
18679
+ referencedColumns: ["id"];
18680
+ }, {
18672
18681
  foreignKeyName: "werkbon_package_items_package_id_fkey";
18673
18682
  columns: ["package_id"];
18674
18683
  isOneToOne: false;
@@ -19891,6 +19900,20 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
19891
19900
  referencedColumns: ["id"];
19892
19901
  }];
19893
19902
  };
19903
+ v_werkbon_totalen: {
19904
+ Row: {
19905
+ packages_cents: number | null;
19906
+ packages_minutes: number | null;
19907
+ werkbon_id: string | null;
19908
+ };
19909
+ Relationships: [{
19910
+ foreignKeyName: "werkbon_package_lines_werkbon_id_fkey";
19911
+ columns: ["werkbon_id"];
19912
+ isOneToOne: false;
19913
+ referencedRelation: "werkbonnen";
19914
+ referencedColumns: ["id"];
19915
+ }];
19916
+ };
19894
19917
  };
19895
19918
  Functions: {
19896
19919
  _floriday_schedule_job: {
@@ -21827,6 +21850,25 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
21827
21850
  };
21828
21851
  Returns: string;
21829
21852
  };
21853
+ pakket_suggesties_voor_tekst: {
21854
+ Args: {
21855
+ _tekst: string;
21856
+ };
21857
+ Returns: {
21858
+ hit_type: string;
21859
+ package_id: string;
21860
+ priority: number;
21861
+ }[];
21862
+ };
21863
+ pakket_voor_reistijd: {
21864
+ Args: {
21865
+ _minuten: number;
21866
+ };
21867
+ Returns: {
21868
+ package_id: string;
21869
+ priority: number;
21870
+ }[];
21871
+ };
21830
21872
  pick_active_printers: {
21831
21873
  Args: never;
21832
21874
  Returns: {
@@ -22877,6 +22919,18 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
22877
22919
  Args: never;
22878
22920
  Returns: string;
22879
22921
  };
22922
+ werkbon_totalen: {
22923
+ Args: {
22924
+ _werkbon_id: string;
22925
+ };
22926
+ Returns: {
22927
+ materials_cents: number;
22928
+ packages_cents: number;
22929
+ packages_minutes: number;
22930
+ total_cents: number;
22931
+ total_minutes: number;
22932
+ }[];
22933
+ };
22880
22934
  wo_create_from_source: {
22881
22935
  Args: {
22882
22936
  _payload?: import("../integrations/supabase/types").Json;
@@ -22915,7 +22969,7 @@ export declare const getPreferredWarehouseStatus: import("@tanstack/start-client
22915
22969
  };
22916
22970
  CompositeTypes: { [_ in never]: never; };
22917
22971
  }, {
22918
- PostgrestVersion: "14.5";
22972
+ PostgrestVersion: "14.17";
22919
22973
  }>;
22920
22974
  userId: string;
22921
22975
  claims: import("@supabase/auth-js").User;
@@ -41544,6 +41598,7 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
41544
41598
  werkbon_package_items: {
41545
41599
  Row: {
41546
41600
  article_number: string | null;
41601
+ artikel_id: string | null;
41547
41602
  created_at: string;
41548
41603
  gtin: string | null;
41549
41604
  id: string;
@@ -41561,6 +41616,7 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
41561
41616
  };
41562
41617
  Insert: {
41563
41618
  article_number?: string | null;
41619
+ artikel_id?: string | null;
41564
41620
  created_at?: string;
41565
41621
  gtin?: string | null;
41566
41622
  id?: string;
@@ -41578,6 +41634,7 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
41578
41634
  };
41579
41635
  Update: {
41580
41636
  article_number?: string | null;
41637
+ artikel_id?: string | null;
41581
41638
  created_at?: string;
41582
41639
  gtin?: string | null;
41583
41640
  id?: string;
@@ -41594,6 +41651,12 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
41594
41651
  updated_at?: string;
41595
41652
  };
41596
41653
  Relationships: [{
41654
+ foreignKeyName: "werkbon_package_items_artikel_id_fkey";
41655
+ columns: ["artikel_id"];
41656
+ isOneToOne: false;
41657
+ referencedRelation: "artikelen_cache";
41658
+ referencedColumns: ["id"];
41659
+ }, {
41597
41660
  foreignKeyName: "werkbon_package_items_package_id_fkey";
41598
41661
  columns: ["package_id"];
41599
41662
  isOneToOne: false;
@@ -42816,6 +42879,20 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
42816
42879
  referencedColumns: ["id"];
42817
42880
  }];
42818
42881
  };
42882
+ v_werkbon_totalen: {
42883
+ Row: {
42884
+ packages_cents: number | null;
42885
+ packages_minutes: number | null;
42886
+ werkbon_id: string | null;
42887
+ };
42888
+ Relationships: [{
42889
+ foreignKeyName: "werkbon_package_lines_werkbon_id_fkey";
42890
+ columns: ["werkbon_id"];
42891
+ isOneToOne: false;
42892
+ referencedRelation: "werkbonnen";
42893
+ referencedColumns: ["id"];
42894
+ }];
42895
+ };
42819
42896
  };
42820
42897
  Functions: {
42821
42898
  _floriday_schedule_job: {
@@ -44752,6 +44829,25 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
44752
44829
  };
44753
44830
  Returns: string;
44754
44831
  };
44832
+ pakket_suggesties_voor_tekst: {
44833
+ Args: {
44834
+ _tekst: string;
44835
+ };
44836
+ Returns: {
44837
+ hit_type: string;
44838
+ package_id: string;
44839
+ priority: number;
44840
+ }[];
44841
+ };
44842
+ pakket_voor_reistijd: {
44843
+ Args: {
44844
+ _minuten: number;
44845
+ };
44846
+ Returns: {
44847
+ package_id: string;
44848
+ priority: number;
44849
+ }[];
44850
+ };
44755
44851
  pick_active_printers: {
44756
44852
  Args: never;
44757
44853
  Returns: {
@@ -45802,6 +45898,18 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
45802
45898
  Args: never;
45803
45899
  Returns: string;
45804
45900
  };
45901
+ werkbon_totalen: {
45902
+ Args: {
45903
+ _werkbon_id: string;
45904
+ };
45905
+ Returns: {
45906
+ materials_cents: number;
45907
+ packages_cents: number;
45908
+ packages_minutes: number;
45909
+ total_cents: number;
45910
+ total_minutes: number;
45911
+ }[];
45912
+ };
45805
45913
  wo_create_from_source: {
45806
45914
  Args: {
45807
45915
  _payload?: import("../integrations/supabase/types").Json;
@@ -45840,7 +45948,7 @@ export declare const getAutoFulfillmentStatus: import("@tanstack/start-client-co
45840
45948
  };
45841
45949
  CompositeTypes: { [_ in never]: never; };
45842
45950
  }, {
45843
- PostgrestVersion: "14.5";
45951
+ PostgrestVersion: "14.17";
45844
45952
  }>;
45845
45953
  userId: string;
45846
45954
  claims: import("@supabase/auth-js").User;
@@ -64478,6 +64586,7 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
64478
64586
  werkbon_package_items: {
64479
64587
  Row: {
64480
64588
  article_number: string | null;
64589
+ artikel_id: string | null;
64481
64590
  created_at: string;
64482
64591
  gtin: string | null;
64483
64592
  id: string;
@@ -64495,6 +64604,7 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
64495
64604
  };
64496
64605
  Insert: {
64497
64606
  article_number?: string | null;
64607
+ artikel_id?: string | null;
64498
64608
  created_at?: string;
64499
64609
  gtin?: string | null;
64500
64610
  id?: string;
@@ -64512,6 +64622,7 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
64512
64622
  };
64513
64623
  Update: {
64514
64624
  article_number?: string | null;
64625
+ artikel_id?: string | null;
64515
64626
  created_at?: string;
64516
64627
  gtin?: string | null;
64517
64628
  id?: string;
@@ -64528,6 +64639,12 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
64528
64639
  updated_at?: string;
64529
64640
  };
64530
64641
  Relationships: [{
64642
+ foreignKeyName: "werkbon_package_items_artikel_id_fkey";
64643
+ columns: ["artikel_id"];
64644
+ isOneToOne: false;
64645
+ referencedRelation: "artikelen_cache";
64646
+ referencedColumns: ["id"];
64647
+ }, {
64531
64648
  foreignKeyName: "werkbon_package_items_package_id_fkey";
64532
64649
  columns: ["package_id"];
64533
64650
  isOneToOne: false;
@@ -65750,6 +65867,20 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
65750
65867
  referencedColumns: ["id"];
65751
65868
  }];
65752
65869
  };
65870
+ v_werkbon_totalen: {
65871
+ Row: {
65872
+ packages_cents: number | null;
65873
+ packages_minutes: number | null;
65874
+ werkbon_id: string | null;
65875
+ };
65876
+ Relationships: [{
65877
+ foreignKeyName: "werkbon_package_lines_werkbon_id_fkey";
65878
+ columns: ["werkbon_id"];
65879
+ isOneToOne: false;
65880
+ referencedRelation: "werkbonnen";
65881
+ referencedColumns: ["id"];
65882
+ }];
65883
+ };
65753
65884
  };
65754
65885
  Functions: {
65755
65886
  _floriday_schedule_job: {
@@ -67686,6 +67817,25 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
67686
67817
  };
67687
67818
  Returns: string;
67688
67819
  };
67820
+ pakket_suggesties_voor_tekst: {
67821
+ Args: {
67822
+ _tekst: string;
67823
+ };
67824
+ Returns: {
67825
+ hit_type: string;
67826
+ package_id: string;
67827
+ priority: number;
67828
+ }[];
67829
+ };
67830
+ pakket_voor_reistijd: {
67831
+ Args: {
67832
+ _minuten: number;
67833
+ };
67834
+ Returns: {
67835
+ package_id: string;
67836
+ priority: number;
67837
+ }[];
67838
+ };
67689
67839
  pick_active_printers: {
67690
67840
  Args: never;
67691
67841
  Returns: {
@@ -68736,6 +68886,18 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
68736
68886
  Args: never;
68737
68887
  Returns: string;
68738
68888
  };
68889
+ werkbon_totalen: {
68890
+ Args: {
68891
+ _werkbon_id: string;
68892
+ };
68893
+ Returns: {
68894
+ materials_cents: number;
68895
+ packages_cents: number;
68896
+ packages_minutes: number;
68897
+ total_cents: number;
68898
+ total_minutes: number;
68899
+ }[];
68900
+ };
68739
68901
  wo_create_from_source: {
68740
68902
  Args: {
68741
68903
  _payload?: import("../integrations/supabase/types").Json;
@@ -68774,7 +68936,7 @@ export declare const retryAutoFulfillment: import("@tanstack/start-client-core")
68774
68936
  };
68775
68937
  CompositeTypes: { [_ in never]: never; };
68776
68938
  }, {
68777
- PostgrestVersion: "14.5";
68939
+ PostgrestVersion: "14.17";
68778
68940
  }>;
68779
68941
  userId: string;
68780
68942
  claims: import("@supabase/auth-js").User;