@flowselections/floriday-klanten-module 1.0.91 → 1.0.93

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 (43) hide show
  1. package/dist-lib/components/klanten/GroupedKlantDetail.d.ts.map +1 -1
  2. package/dist-lib/components/klanten/GroupedKlantDetail.js +20 -1
  3. package/dist-lib/components/klanten/KlantenOverzicht.d.ts.map +1 -1
  4. package/dist-lib/components/klanten/KlantenOverzicht.js +19 -6
  5. package/dist-lib/components/klanten/pricegroups/CustomerPriceGroupSelect.d.ts.map +1 -1
  6. package/dist-lib/components/klanten/pricegroups/CustomerPriceGroupSelect.js +18 -6
  7. package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.d.ts.map +1 -1
  8. package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.js +26 -2
  9. package/dist-lib/components/settings/CustomerFieldsCard.d.ts.map +1 -1
  10. package/dist-lib/components/settings/CustomerFieldsCard.js +25 -6
  11. package/dist-lib/integrations/supabase/types.d.ts +721 -0
  12. package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
  13. package/dist-lib/lib/carriers.functions.d.ts.map +1 -1
  14. package/dist-lib/lib/carriers.functions.js +5 -4
  15. package/dist-lib/lib/customer-assortment.functions.d.ts.map +1 -1
  16. package/dist-lib/lib/customer-assortment.functions.js +7 -6
  17. package/dist-lib/lib/customer-schemas.d.ts +13 -13
  18. package/dist-lib/lib/customers.functions.d.ts +37 -7
  19. package/dist-lib/lib/customers.functions.d.ts.map +1 -1
  20. package/dist-lib/lib/customers.functions.js +74 -9
  21. package/dist-lib/lib/delivery-locations.functions.d.ts +3 -3
  22. package/dist-lib/lib/delivery-locations.functions.d.ts.map +1 -1
  23. package/dist-lib/lib/delivery-locations.functions.js +9 -8
  24. package/dist-lib/lib/fetch-all-paged.d.ts +16 -0
  25. package/dist-lib/lib/fetch-all-paged.d.ts.map +1 -0
  26. package/dist-lib/lib/fetch-all-paged.js +28 -0
  27. package/dist-lib/lib/floriday-assortment.functions.d.ts.map +1 -1
  28. package/dist-lib/lib/floriday-assortment.functions.js +5 -4
  29. package/dist-lib/lib/klanten-bron.d.ts +12 -0
  30. package/dist-lib/lib/klanten-bron.d.ts.map +1 -0
  31. package/dist-lib/lib/klanten-bron.js +13 -0
  32. package/dist-lib/lib/logistics-strategy.functions.d.ts +2 -2
  33. package/dist-lib/lib/price-groups-local.functions.d.ts +43 -0
  34. package/dist-lib/lib/price-groups-local.functions.d.ts.map +1 -1
  35. package/dist-lib/lib/price-groups-local.functions.js +121 -20
  36. package/dist-lib/lib/price-groups.functions.d.ts.map +1 -1
  37. package/dist-lib/lib/price-groups.functions.js +5 -4
  38. package/dist-lib/lib/pricing.d.ts.map +1 -1
  39. package/dist-lib/lib/pricing.js +11 -4
  40. package/dist-lib/lib/twinfield-adopt.functions.d.ts +2 -2
  41. package/dist-lib/lib/twinfield-defaults.d.ts +2 -2
  42. package/package.json +7 -3
  43. package/schema/klanten.sql +247 -1
@@ -1 +1 @@
1
- {"version":3,"file":"carriers.functions.d.ts","sourceRoot":"","sources":["../../src/lib/carriers.functions.ts"],"names":[],"mappings":"AAIA,OAAO,EAEL,KAAK,aAAa,EAElB,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AA4D1B,wFAAwF;AACxF,eAAO,MAAM,kBAAkB;;;;;cAkBQ,aAAa,EAAE;;GAClD,CAAC;AAQL,0FAA0F;AAC1F,eAAO,MAAM,uBAAuB;;;;8CAEV,OAAO;;;;;;;;GAI7B,CAAC;AAEL,yFAAyF;AACzF,eAAO,MAAM,yBAAyB;;;;8CAEZ,OAAO;;;;wBAY0B,MAAM,GAAG,IAAI;GACpE,CAAC;AAEL,eAAO,MAAM,yBAAyB;;;;8CAEZ,OAAO;;;wBAQqC,MAAM,GAAG,IAAI;GAC/E,CAAC;AAIL,MAAM,MAAM,aAAa,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,I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E,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAEzG,4FAA4F;AAC5F,MAAM,MAAM,qBAAqB,GAAG;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAE5I,eAAO,MAAM,mBAAmB;;;;;;;GA4B5B,CAAC;AAEL,MAAM,MAAM,oBAAoB,GAAG;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,QAAQ,EAAE,cAAc,CAAC;CAC1B,CAAC;AAEF,yGAAyG;AACzG,eAAO,MAAM,0BAA0B;;;;;;GAuBnC,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { fetchAllPagedResult } from "./fetch-all-paged.js";
1
2
  import { createServerFn } from "@tanstack/react-start";
2
3
  import { z } from "zod";
3
4
  import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
@@ -68,10 +69,10 @@ export const listCarrierOptions = createServerFn({ method: "POST" })
68
69
  if (error)
69
70
  throw new Error(`Vervoerders ophalen mislukt: ${error.message}`);
70
71
  const usage = {};
71
- const loc = await sb.from("customer_delivery_locations").select("carrier_id").not("carrier_id", "is", null);
72
+ const loc = await fetchAllPagedResult((from, to) => sb.from("customer_delivery_locations").select("carrier_id").not("carrier_id", "is", null).range(from, to));
72
73
  if (loc.error)
73
74
  throw new Error(`Gebruik van vervoerders ophalen mislukt: ${loc.error.message}`);
74
- const cust = await sb.from("customers").select("default_carrier_id").not("default_carrier_id", "is", null);
75
+ const cust = await fetchAllPagedResult((from, to) => sb.from("customers").select("default_carrier_id").not("default_carrier_id", "is", null).range(from, to));
75
76
  if (cust.error)
76
77
  throw new Error(`Gebruik van vervoerders ophalen mislukt: ${cust.error.message}`);
77
78
  for (const r of [...(loc.data ?? []).map((x) => x.carrier_id), ...(cust.data ?? []).map((x) => x.default_carrier_id)]) {
@@ -160,11 +161,11 @@ export const reviewAutoCarrierLocations = createServerFn({ method: "POST" })
160
161
  .middleware([requireSupabaseAuth])
161
162
  .handler(async ({ context }) => {
162
163
  const sb = context.supabase;
163
- const { data, error } = await sb
164
+ const { data, error } = await fetchAllPagedResult((from, to) => sb
164
165
  .from("customer_delivery_locations")
165
166
  .select("id, name, customer_id, carrier_id, carriers(name)")
166
167
  .eq("carrier_assignment_source", "auto")
167
- .not("carrier_id", "is", null);
168
+ .not("carrier_id", "is", null).range(from, to));
168
169
  if (error)
169
170
  throw new Error(error.message);
170
171
  const list = (data ?? []);
@@ -1 +1 @@
1
- {"version":3,"file":"customer-assortment.functions.d.ts","sourceRoot":"","sources":["../../src/lib/customer-assortment.functions.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,sBAAsB,GAAG;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,kBAAkB,E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eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;QAC1B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;QAC5B,QAAQ,EAAE,MAAM,CAAC;KAClB,GAAG,IAAI,CAAC;IACT,OAAO,EAAE;QACP,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,aAAa,EAAE,MAAM,CAAC;QACtB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;KAC/B,CAAC;CAEH,CAAC;AAuCF,eAAO,MAAM,sBAAsB;;;;8CAET,OAAO;;;qCAsQ7B,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { fetchAllPagedResult } from "./fetch-all-paged.js";
1
2
  import { createServerFn } from "@tanstack/react-start";
2
3
  import { z } from "zod";
3
4
  import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
@@ -79,19 +80,19 @@ export const listCustomerAssortment = createServerFn({ method: "POST" })
79
80
  ownAssortment.add(String(r.trade_item_key));
80
81
  }
81
82
  // 2) Alle Floriday-handelsartikelen uit de cache
82
- const { data: cacheRows, error: cacheErr } = await sb
83
+ const { data: cacheRows, error: cacheErr } = await fetchAllPagedResult((from, to) => sb
83
84
  .from("floriday_trade_items_cache")
84
85
  .select("floriday_id, data, fetched_at")
85
- .eq("is_deleted", false);
86
+ .eq("is_deleted", false).range(from, to));
86
87
  if (cacheErr)
87
88
  throw new Error(cacheErr.message);
88
89
  // 3) Handmatige prijzen per artikel binnen de prijsgroep
89
90
  const manual = new Map();
90
91
  if (group?.id) {
91
- const { data: tip } = await sb
92
+ const { data: tip } = await fetchAllPagedResult((from, to) => sb
92
93
  .from("trade_item_prices")
93
94
  .select("trade_item_key, price_per_piece, currency")
94
- .eq("price_group_id", group.id);
95
+ .eq("price_group_id", group.id).range(from, to));
95
96
  for (const r of tip ?? []) {
96
97
  if (r?.trade_item_key == null || r?.price_per_piece == null)
97
98
  continue;
@@ -119,10 +120,10 @@ export const listCustomerAssortment = createServerFn({ method: "POST" })
119
120
  const floridayPrice = new Map();
120
121
  const floridayGroupNames = [group?.name ?? null];
121
122
  if (orgId) {
122
- const { data: pgRows } = await sb
123
+ const { data: pgRows } = await fetchAllPagedResult((from, to) => sb
123
124
  .from("floriday_price_groups_cache")
124
125
  .select("floriday_id, data, fetched_at")
125
- .eq("is_deleted", false);
126
+ .eq("is_deleted", false).range(from, to));
126
127
  for (const row of pgRows ?? []) {
127
128
  const d = row?.data ?? {};
128
129
  const buyers = [
@@ -6,9 +6,9 @@ export declare const customerCreateSchema: z.ZodPipe<z.ZodObject<{
6
6
  ledger_account: z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>;
7
7
  credit_limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
8
8
  send_reminder: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
9
- no: "no";
10
9
  file: "file";
11
10
  file_email: "file_email";
11
+ no: "no";
12
12
  }>>>;
13
13
  payment_spec_method: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
14
14
  email: "email";
@@ -22,8 +22,8 @@ export declare const customerCreateSchema: z.ZodPipe<z.ZodObject<{
22
22
  e_invoicing: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
23
23
  blocked: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
24
24
  discount_surcharge: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
25
- none: "none";
26
25
  discount: "discount";
26
+ none: "none";
27
27
  surcharge: "surcharge";
28
28
  }>>>;
29
29
  company_name: z.ZodString;
@@ -72,12 +72,12 @@ export declare const customerCreateSchema: z.ZodPipe<z.ZodObject<{
72
72
  force: boolean;
73
73
  twinfield_create: boolean;
74
74
  credit_limit: number;
75
- send_reminder: "no" | "file" | "file_email";
75
+ send_reminder: "file" | "file_email" | "no";
76
76
  payment_spec_method: "email" | "file";
77
77
  invoice_send_as: "link" | "pdf" | "print";
78
78
  e_invoicing: boolean;
79
79
  blocked: boolean;
80
- discount_surcharge: "none" | "discount" | "surcharge";
80
+ discount_surcharge: "discount" | "none" | "surcharge";
81
81
  company_name: string;
82
82
  postal_code: string | undefined;
83
83
  bank_postal_code: string | undefined;
@@ -123,12 +123,12 @@ export declare const customerCreateSchema: z.ZodPipe<z.ZodObject<{
123
123
  force: boolean;
124
124
  twinfield_create: boolean;
125
125
  credit_limit: number;
126
- send_reminder: "no" | "file" | "file_email";
126
+ send_reminder: "file" | "file_email" | "no";
127
127
  payment_spec_method: "email" | "file";
128
128
  invoice_send_as: "link" | "pdf" | "print";
129
129
  e_invoicing: boolean;
130
130
  blocked: boolean;
131
- discount_surcharge: "none" | "discount" | "surcharge";
131
+ discount_surcharge: "discount" | "none" | "surcharge";
132
132
  company_name: string;
133
133
  postal_code: string | undefined;
134
134
  bank_postal_code: string | undefined;
@@ -181,9 +181,9 @@ export declare const customerUpdateSchema: z.ZodObject<{
181
181
  ledger_account: z.ZodOptional<z.ZodUnion<[z.ZodOptional<z.ZodString>, z.ZodLiteral<"">]>>;
182
182
  credit_limit: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>>;
183
183
  send_reminder: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodEnum<{
184
- no: "no";
185
184
  file: "file";
186
185
  file_email: "file_email";
186
+ no: "no";
187
187
  }>>>>;
188
188
  payment_spec_method: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodEnum<{
189
189
  email: "email";
@@ -197,8 +197,8 @@ export declare const customerUpdateSchema: z.ZodObject<{
197
197
  e_invoicing: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
198
198
  blocked: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodBoolean>>>;
199
199
  discount_surcharge: z.ZodOptional<z.ZodDefault<z.ZodOptional<z.ZodEnum<{
200
- none: "none";
201
200
  discount: "discount";
201
+ none: "none";
202
202
  surcharge: "surcharge";
203
203
  }>>>>;
204
204
  company_name: z.ZodOptional<z.ZodString>;
@@ -251,9 +251,9 @@ export declare const customerImportRowSchema: z.ZodObject<{
251
251
  is_active: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
252
252
  credit_limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
253
253
  send_reminder: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
254
- no: "no";
255
254
  file: "file";
256
255
  file_email: "file_email";
256
+ no: "no";
257
257
  }>>>;
258
258
  payment_spec_method: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
259
259
  email: "email";
@@ -267,8 +267,8 @@ export declare const customerImportRowSchema: z.ZodObject<{
267
267
  e_invoicing: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
268
268
  blocked: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
269
269
  discount_surcharge: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
270
- none: "none";
271
270
  discount: "discount";
271
+ none: "none";
272
272
  surcharge: "surcharge";
273
273
  }>>>;
274
274
  company_name: z.ZodString;
@@ -319,9 +319,9 @@ export declare const customerImportSchema: z.ZodObject<{
319
319
  is_active: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
320
320
  credit_limit: z.ZodDefault<z.ZodOptional<z.ZodCoercedNumber<unknown>>>;
321
321
  send_reminder: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
322
- no: "no";
323
322
  file: "file";
324
323
  file_email: "file_email";
324
+ no: "no";
325
325
  }>>>;
326
326
  payment_spec_method: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
327
327
  email: "email";
@@ -335,8 +335,8 @@ export declare const customerImportSchema: z.ZodObject<{
335
335
  e_invoicing: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
336
336
  blocked: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
337
337
  discount_surcharge: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
338
- none: "none";
339
338
  discount: "discount";
339
+ none: "none";
340
340
  surcharge: "surcharge";
341
341
  }>>>;
342
342
  company_name: z.ZodString;
@@ -393,9 +393,9 @@ export declare const listFiltersSchema: z.ZodObject<{
393
393
  inactive: "inactive";
394
394
  }>>>;
395
395
  source: z.ZodDefault<z.ZodOptional<z.ZodEnum<{
396
+ all: "all";
396
397
  local: "local";
397
398
  floriday: "floriday";
398
- all: "all";
399
399
  }>>>;
400
400
  since: z.ZodOptional<z.ZodString>;
401
401
  }, z.core.$strip>;
@@ -62,7 +62,7 @@ export declare const listCustomers: import("@tanstack/start-client-core").Requir
62
62
  customer_class: string;
63
63
  country: string;
64
64
  is_active: "active" | "all" | "inactive";
65
- source: "local" | "floriday" | "all";
65
+ source: "all" | "local" | "floriday";
66
66
  since?: string | undefined;
67
67
  }, Promise<{
68
68
  customers: any[];
@@ -255,12 +255,12 @@ export declare const createCustomer: import("@tanstack/start-client-core").Requi
255
255
  force: boolean;
256
256
  twinfield_create: boolean;
257
257
  credit_limit: number;
258
- send_reminder: "no" | "file" | "file_email";
258
+ send_reminder: "file" | "file_email" | "no";
259
259
  payment_spec_method: "email" | "file";
260
260
  invoice_send_as: "link" | "pdf" | "print";
261
261
  e_invoicing: boolean;
262
262
  blocked: boolean;
263
- discount_surcharge: "none" | "discount" | "surcharge";
263
+ discount_surcharge: "discount" | "none" | "surcharge";
264
264
  company_name: string;
265
265
  postal_code: string | undefined;
266
266
  bank_postal_code: string | undefined;
@@ -417,12 +417,12 @@ export declare const updateCustomer: import("@tanstack/start-client-core").Optio
417
417
  twinfield_create?: boolean | undefined;
418
418
  ledger_account?: string | undefined;
419
419
  credit_limit?: number | undefined;
420
- send_reminder?: "no" | "file" | "file_email" | undefined;
420
+ send_reminder?: "file" | "file_email" | "no" | undefined;
421
421
  payment_spec_method?: "email" | "file" | undefined;
422
422
  invoice_send_as?: "link" | "pdf" | "print" | undefined;
423
423
  e_invoicing?: boolean | undefined;
424
424
  blocked?: boolean | undefined;
425
- discount_surcharge?: "none" | "discount" | "surcharge" | undefined;
425
+ discount_surcharge?: "discount" | "none" | "surcharge" | undefined;
426
426
  company_name?: string | undefined;
427
427
  vat_number?: string | undefined;
428
428
  contact_person?: string | undefined;
@@ -617,6 +617,15 @@ export declare const listFloridayNetwork: import("@tanstack/start-client-core").
617
617
  offset: number;
618
618
  truncated: boolean;
619
619
  }>>;
620
+ /** Standaardwaarden van de module (klantklasse A/B/C als die ontbreekt, eenmalige overzetting prijsgroepen). */
621
+ export declare const ensureKlantenDefaults: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
622
+ supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
623
+ userId: string;
624
+ claims: import("@supabase/auth-js").JwtPayload;
625
+ }, undefined, undefined, undefined>], undefined, Promise<{
626
+ ok: true;
627
+ result: string;
628
+ }>>;
620
629
  export declare const listCustomerClasses: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
621
630
  supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
622
631
  userId: string;
@@ -624,6 +633,27 @@ export declare const listCustomerClasses: import("@tanstack/start-client-core").
624
633
  }, undefined, undefined, undefined>], undefined, Promise<{
625
634
  classes: string[];
626
635
  }>>;
636
+ /**
637
+ * Orderprijs voor een handmatige order (voor Verkoop):
638
+ * klantprijs > prijsgroep van de klant (eigen groep voor Floriday-groep) > standaardprijs artikel.
639
+ * Floriday-orders houden hun eigen Floriday-prijs; deze functie is daar niet voor.
640
+ */
641
+ export declare const getKlantOrderprijs: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
642
+ supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
643
+ userId: string;
644
+ claims: import("@supabase/auth-js").JwtPayload;
645
+ }, undefined, undefined, undefined>], (input: unknown) => {
646
+ customerId: string;
647
+ productId: string;
648
+ datum?: string | undefined;
649
+ aantal?: number | undefined;
650
+ }, Promise<{
651
+ prijs: number;
652
+ valuta: string;
653
+ bron: "klantprijs" | "prijsgroep" | "klantkorting" | "standaardprijs";
654
+ prijsgroepId: string | null;
655
+ prijsgroepNaam: string | null;
656
+ } | null>>;
627
657
  export declare const bulkImportCustomers: import("@tanstack/start-client-core").RequiredFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
628
658
  supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
629
659
  userId: string;
@@ -632,12 +662,12 @@ export declare const bulkImportCustomers: import("@tanstack/start-client-core").
632
662
  rows: {
633
663
  is_active: boolean;
634
664
  credit_limit: number;
635
- send_reminder: "no" | "file" | "file_email";
665
+ send_reminder: "file" | "file_email" | "no";
636
666
  payment_spec_method: "email" | "file";
637
667
  invoice_send_as: "link" | "pdf" | "print";
638
668
  e_invoicing: boolean;
639
669
  blocked: boolean;
640
- discount_surcharge: "none" | "discount" | "surcharge";
670
+ discount_surcharge: "discount" | "none" | "surcharge";
641
671
  company_name: string;
642
672
  email: string;
643
673
  street: string;
@@ -1 +1 @@
1
- {"version":3,"file":"customers.functions.d.ts","sourceRoot":"","sources":["../../src/lib/customers.functions.ts"],"names":[],"mappings":"AAIA,OAAO,EAKL,KAAK,mBAAmB,EACxB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACtB,MAAM,oBAAoB,CAAC;AAM5B,KAAK,cAAc,GAAG;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAkCS,MAAM;aAAO,MAAM;gBAAU,MAAM;;GAwDnE,CAAC;AAEL,eAAO,MAAM,cAAc;;;;8CAED;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE;;;;GAQpC,CAAC;AAEL,eAAO,MAAM,mBAAmB;;;;8CAGpB;IACN,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFD,CAAC;AAEL,gHAAgH;AAChH,eAAO,MAAM,qBAAqB;;;;;;;GAS9B,CAAC;AAEL,eAAO,MAAM,mBAAmB;;;;;aAWQ,MAAM,EAAE;GAQ5C,CAAC;AAEL;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;8CAEL,OAAO;;;;;;;;UAwBX,YAAY,GAAG,YAAY,GAAG,cAAc,GAAG,gBAAgB;;;UAIjF,CAAC;AAEL,eAAO,MAAM,mBAAmB;;;;8CAEN,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAM9B,MAAM;aACN,MAAM;YACP,MAAM;YACN,KAAK,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;GAqCtE,CAAC"}
@@ -105,7 +105,7 @@ export const listCustomers = createServerFn({ method: "POST" })
105
105
  let q = supabase
106
106
  .from("customers")
107
107
  .select("*")
108
- .in("source", ["local", "floriday"])
108
+ .in("source", data.source === "all" ? ["local", "floriday"] : [data.source])
109
109
  .order("company_name");
110
110
  if (data.customer_class)
111
111
  q = q.eq("customer_class", data.customer_class);
@@ -139,12 +139,24 @@ export const listCustomers = createServerFn({ method: "POST" })
139
139
  .map((r) => r.floriday_organization_id)
140
140
  .filter((v) => typeof v === "string" && !!v);
141
141
  const priceGroupsByOrg = await buildPriceGroupsMap(supabase, orgIds);
142
- const enriched = list.map((r) => ({
143
- ...r,
144
- price_groups: r.floriday_organization_id
145
- ? priceGroupsByOrg[r.floriday_organization_id] ?? []
146
- : [],
147
- }));
142
+ // Bepalende prijsgroep per klant (ook klanten buiten Floriday), in porties van 1000 id's.
143
+ const bepalend = new Map();
144
+ for (let i = 0; i < list.length; i += 1000) {
145
+ const ids = list.slice(i, i + 1000).map((r) => r.id);
146
+ const { data: pg, error: pgErr } = await supabase.rpc("klanten_prijsgroepen_voor_klanten", { p_ids: ids });
147
+ if (pgErr) {
148
+ console.error("[klanten] prijsgroepen per klant laden mislukt", pgErr);
149
+ break;
150
+ }
151
+ for (const row of (pg ?? []))
152
+ bepalend.set(row.customer_id, { id: row.price_group_id, name: row.naam, bron: row.bron });
153
+ }
154
+ const enriched = list.map((r) => {
155
+ const fd = r.floriday_organization_id ? priceGroupsByOrg[r.floriday_organization_id] ?? [] : [];
156
+ const own = bepalend.get(r.id);
157
+ const groups = own && !fd.some((g) => g.id === own.id) ? [{ id: own.id, name: own.name }, ...fd] : fd;
158
+ return { ...r, price_groups: groups };
159
+ });
148
160
  // server_now: klok van de database als bladwijzer voor delta-verversing.
149
161
  const { data: serverNow } = await supabase.rpc("server_now");
150
162
  return { customers: enriched, server_now: serverNow ?? new Date().toISOString() };
@@ -500,23 +512,76 @@ export const listFloridayNetwork = createServerFn({ method: "POST" })
500
512
  truncated: (count ?? 0) > data.offset + organizations.length,
501
513
  };
502
514
  });
515
+ /** Standaardwaarden van de module (klantklasse A/B/C als die ontbreekt, eenmalige overzetting prijsgroepen). */
516
+ export const ensureKlantenDefaults = createServerFn({ method: "POST" })
517
+ .middleware([requireSupabaseAuth])
518
+ .handler(async ({ context }) => {
519
+ const { data, error } = await context.supabase.rpc("klanten_ensure_defaults");
520
+ if (error) {
521
+ console.error("[klanten] standaardwaarden klaarzetten mislukt", error);
522
+ throw new Error("De standaardinstellingen konden niet worden klaargezet. Probeer het opnieuw.");
523
+ }
524
+ return { ok: true, result: JSON.stringify(data ?? null) };
525
+ });
503
526
  export const listCustomerClasses = createServerFn({ method: "POST" })
504
527
  .middleware([requireSupabaseAuth])
505
528
  .handler(async ({ context }) => {
506
- const { data: field } = await context.supabase
529
+ const { error: defErr } = await context.supabase.rpc("klanten_ensure_defaults");
530
+ if (defErr)
531
+ console.error("[klanten] standaardwaarden klantklasse mislukt", defErr);
532
+ const { data: field, error: fErr } = await context.supabase
507
533
  .from("customer_field_settings")
508
534
  .select("id")
509
535
  .eq("field_key", "customer_class")
510
536
  .maybeSingle();
537
+ if (fErr)
538
+ throw new Error(friendlyError(fErr, "Klantklassen laden lukt niet."));
511
539
  if (!field)
512
540
  return { classes: [] };
513
- const { data } = await context.supabase
541
+ const { data, error } = await context.supabase
514
542
  .from("customer_field_options")
515
543
  .select("label, sort_order")
516
544
  .eq("field_setting_id", field.id)
517
545
  .order("sort_order");
546
+ if (error)
547
+ throw new Error(friendlyError(error, "Klantklassen laden lukt niet."));
518
548
  return { classes: (data ?? []).map((d) => d.label) };
519
549
  });
550
+ /**
551
+ * Orderprijs voor een handmatige order (voor Verkoop):
552
+ * klantprijs > prijsgroep van de klant (eigen groep voor Floriday-groep) > standaardprijs artikel.
553
+ * Floriday-orders houden hun eigen Floriday-prijs; deze functie is daar niet voor.
554
+ */
555
+ export const getKlantOrderprijs = createServerFn({ method: "POST" })
556
+ .middleware([requireSupabaseAuth])
557
+ .inputValidator((input) => z.object({
558
+ customerId: z.string().uuid(),
559
+ productId: z.string().uuid(),
560
+ datum: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
561
+ aantal: z.number().positive().optional(),
562
+ }).parse(input))
563
+ .handler(async ({ data, context }) => {
564
+ const { data: rows, error } = await context.supabase.rpc("klanten_orderprijs", {
565
+ p_customer_id: data.customerId,
566
+ p_product_id: data.productId,
567
+ ...(data.datum ? { p_datum: data.datum } : {}),
568
+ ...(data.aantal ? { p_aantal: data.aantal } : {}),
569
+ });
570
+ if (error) {
571
+ console.error("[klanten] orderprijs berekenen mislukt", error);
572
+ throw new Error("De prijs kon niet worden berekend. Probeer het opnieuw.");
573
+ }
574
+ const r = (rows ?? [])[0];
575
+ if (!r)
576
+ return null;
577
+ return {
578
+ prijs: Number(r.net_price),
579
+ valuta: String(r.currency ?? "EUR"),
580
+ bron: r.bron,
581
+ prijsgroepId: r.price_group_id ?? null,
582
+ prijsgroepNaam: r.price_group_name ?? null,
583
+ };
584
+ });
520
585
  export const bulkImportCustomers = createServerFn({ method: "POST" })
521
586
  .middleware([requireSupabaseAuth])
522
587
  .inputValidator((input) => customerImportSchema.parse(input))
@@ -24,8 +24,8 @@ declare const locationSchema: z.ZodObject<{
24
24
  add: z.ZodArray<z.ZodObject<{
25
25
  gln: z.ZodString;
26
26
  source: z.ZodEnum<{
27
- manual: "manual";
28
27
  floriday: "floriday";
28
+ manual: "manual";
29
29
  }>;
30
30
  floriday_location_id: z.ZodNullable<z.ZodString>;
31
31
  }, z.core.$strip>>;
@@ -130,7 +130,7 @@ export declare const upsertDeliveryLocation: import("@tanstack/start-client-core
130
130
  gln_changes?: {
131
131
  add: {
132
132
  gln: string;
133
- source: "manual" | "floriday";
133
+ source: "floriday" | "manual";
134
134
  floriday_location_id: string | null;
135
135
  }[];
136
136
  primary: string | null;
@@ -210,7 +210,7 @@ export declare const addLocationGln: import("@tanstack/start-client-core").Requi
210
210
  }) => {
211
211
  location_id: string;
212
212
  gln: string;
213
- source?: "manual" | "floriday" | undefined;
213
+ source?: "floriday" | "manual" | undefined;
214
214
  floriday_location_id?: string | null | undefined;
215
215
  }, Promise<GlnConflict | {
216
216
  ok: true;
@@ -1 +1 @@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AChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;CACrB,CAAC;AA4BF,eAAO,MAAM,+BAA+B;;;;8CAElB,OAAO;;yCA4J7B,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { fetchAllPagedResult } from "./fetch-all-paged.js";
1
2
  import { createServerFn } from "@tanstack/react-start";
2
3
  import { z } from "zod";
3
4
  import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
@@ -341,17 +342,17 @@ export const importFloridayDeliveryLocations = createServerFn({ method: "POST" }
341
342
  .inputValidator((input) => z.object({ preview: z.boolean().default(false) }).parse(input ?? {}))
342
343
  .handler(async ({ data, context }) => {
343
344
  const sb = context.supabase;
344
- const { data: cacheRows, error: cacheErr } = await sb
345
+ const { data: cacheRows, error: cacheErr } = await fetchAllPagedResult((from, to) => sb
345
346
  .from("floriday_delivery_locations_cache")
346
347
  .select("floriday_id, name, gln_code, organization_id, data, is_deleted")
347
- .eq("is_deleted", false);
348
+ .eq("is_deleted", false).range(from, to));
348
349
  if (cacheErr)
349
350
  throw new Error(`floriday_delivery_locations_cache: ${cacheErr.message}`);
350
351
  // Floriday organizationId → group_key + klantnaam
351
352
  const orgToGroup = new Map();
352
- const { data: grouped, error: gErr } = await sb
353
+ const { data: grouped, error: gErr } = await fetchAllPagedResult((from, to) => sb
353
354
  .from("external_customers_grouped")
354
- .select("group_key, display_name, sources");
355
+ .select("group_key, display_name, sources").range(from, to));
355
356
  if (gErr)
356
357
  throw new Error(gErr.message);
357
358
  for (const row of grouped ?? []) {
@@ -366,10 +367,10 @@ export const importFloridayDeliveryLocations = createServerFn({ method: "POST" }
366
367
  }
367
368
  }
368
369
  // Bestaande geïmporteerde locaties
369
- const { data: existingRows, error: exErr } = await sb
370
+ const { data: existingRows, error: exErr } = await fetchAllPagedResult((from, to) => sb
370
371
  .from("customer_delivery_locations")
371
372
  .select("id, floriday_location_id")
372
- .eq("external_provider", "floriday");
373
+ .eq("external_provider", "floriday").range(from, to));
373
374
  if (exErr)
374
375
  throw new Error(exErr.message);
375
376
  const existing = new Map();
@@ -379,11 +380,11 @@ export const importFloridayDeliveryLocations = createServerFn({ method: "POST" }
379
380
  }
380
381
  // Bekende GLN's / Floriday-ID's per klant (ook verwijderd of genegeerd): die maken nooit een nieuwe locatie aan.
381
382
  const orgToCustomer = new Map();
382
- const { data: custRows } = await sb.from("customers").select("id, floriday_organization_id").not("floriday_organization_id", "is", null);
383
+ const { data: custRows } = await fetchAllPagedResult((from, to) => sb.from("customers").select("id, floriday_organization_id").not("floriday_organization_id", "is", null).range(from, to));
383
384
  for (const c of custRows ?? [])
384
385
  orgToCustomer.set(String(c.floriday_organization_id), String(c.id));
385
386
  const known = new Set();
386
- const { data: glnRows, error: glnErr } = await sb.from("customer_delivery_location_glns").select("customer_id, gln, floriday_location_id");
387
+ const { data: glnRows, error: glnErr } = await fetchAllPagedResult((from, to) => sb.from("customer_delivery_location_glns").select("customer_id, gln, floriday_location_id").range(from, to));
387
388
  if (glnErr)
388
389
  throw new Error(glnErr.message);
389
390
  const { data: ignRows, error: ignErr } = await sb.from("customer_delivery_location_ignored").select("customer_id, gln, floriday_location_id");
@@ -0,0 +1,16 @@
1
+ /** Leest een lijst in porties van 1000 tot alles binnen is (de database levert nooit meer per aanvraag). */
2
+ export declare function fetchAllPaged<T>(page: (from: number, to: number) => PromiseLike<{
3
+ data: unknown;
4
+ error: {
5
+ message: string;
6
+ } | null;
7
+ }>, size?: number): Promise<T[]>;
8
+ /** Zelfde als fetchAllPaged, maar met de vorm { data, error } van een gewone opvraging. */
9
+ export declare function fetchAllPagedResult<T = any>(page: (from: number, to: number) => PromiseLike<{
10
+ data: unknown;
11
+ error: any;
12
+ }>, size?: number): Promise<{
13
+ data: T[] | null;
14
+ error: any;
15
+ }>;
16
+ //# sourceMappingURL=fetch-all-paged.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch-all-paged.d.ts","sourceRoot":"","sources":["../../src/lib/fetch-all-paged.ts"],"names":[],"mappings":"AAAA,4GAA4G;AAC5G,wBAAsB,aAAa,CAAC,CAAC,EACnC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,WAAW,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,CAAC,EACrG,IAAI,SAAO,GACV,OAAO,CAAC,CAAC,EAAE,CAAC,CAUd;AAED,2FAA2F;AAC3F,wBAAsB,mBAAmB,CAAC,CAAC,GAAG,GAAG,EAC/C,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,WAAW,CAAC;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,CAAC,EAC9E,IAAI,SAAO,GACV,OAAO,CAAC;IAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,GAAG,CAAA;CAAE,CAAC,CAU3C"}
@@ -0,0 +1,28 @@
1
+ /** Leest een lijst in porties van 1000 tot alles binnen is (de database levert nooit meer per aanvraag). */
2
+ export async function fetchAllPaged(page, size = 1000) {
3
+ const all = [];
4
+ for (let from = 0;; from += size) {
5
+ const { data, error } = await page(from, from + size - 1);
6
+ if (error)
7
+ throw new Error(error.message);
8
+ const chunk = data ?? [];
9
+ all.push(...chunk);
10
+ if (chunk.length < size)
11
+ break;
12
+ }
13
+ return all;
14
+ }
15
+ /** Zelfde als fetchAllPaged, maar met de vorm { data, error } van een gewone opvraging. */
16
+ export async function fetchAllPagedResult(page, size = 1000) {
17
+ const all = [];
18
+ for (let from = 0;; from += size) {
19
+ const { data, error } = await page(from, from + size - 1);
20
+ if (error)
21
+ return { data: null, error };
22
+ const chunk = data ?? [];
23
+ all.push(...chunk);
24
+ if (chunk.length < size)
25
+ break;
26
+ }
27
+ return { data: all, error: null };
28
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"floriday-assortment.functions.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-assortment.functions.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,UAAU,CAAC;AAE1D,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,OAAO,EAAE;QACP,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;KAC/B,CAAC;CACH,CAAC;AAiEF,eAAO,MAAM,8BAA8B;;;;8CAEjB,OAAO;;6BAoJ7B,CAAC"}
1
+ {"version":3,"file":"floriday-assortment.functions.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-assortment.functions.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,gBAAgB,GAAG,aAAa,GAAG,UAAU,CAAC;AAE1D,MAAM,MAAM,aAAa,GAAG;IAC1B,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,gBAAgB,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,OAAO,EAAE;QACP,YAAY,EAAE,MAAM,CAAC;QACrB,SAAS,EAAE,MAAM,CAAC;QAClB,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;KAC/B,CAAC;CACH,CAAC;AAiEF,eAAO,MAAM,8BAA8B;;;;8CAEjB,OAAO;;6BAoJ7B,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { fetchAllPagedResult } from "./fetch-all-paged.js";
1
2
  import { createServerFn } from "@tanstack/react-start";
2
3
  import { z } from "zod";
3
4
  import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
@@ -80,10 +81,10 @@ export const listFloridayCustomerAssortment = createServerFn({ method: "POST" })
80
81
  lastSynced = s;
81
82
  };
82
83
  // 1) Price groups
83
- const { data: pgRows, error: pgErr } = await sb
84
+ const { data: pgRows, error: pgErr } = await fetchAllPagedResult((from, to) => sb
84
85
  .from("floriday_price_groups_cache")
85
86
  .select("floriday_id, data, fetched_at, is_deleted")
86
- .eq("is_deleted", false);
87
+ .eq("is_deleted", false).range(from, to));
87
88
  if (pgErr)
88
89
  throw new Error(`floriday_price_groups_cache: ${pgErr.message}`);
89
90
  // Koppeling kan ook in de handelsinstellingen van de koper staan.
@@ -182,10 +183,10 @@ export const listFloridayCustomerAssortment = createServerFn({ method: "POST" })
182
183
  // 3) Enrich with trade items
183
184
  const tradeItemIds = Array.from(new Set(rows.map((r) => r.trade_item_id)));
184
185
  if (tradeItemIds.length > 0) {
185
- const { data: items } = await sb
186
+ const { data: items } = await fetchAllPagedResult((from, to) => sb
186
187
  .from("floriday_trade_items_cache")
187
188
  .select("floriday_id, data")
188
- .in("floriday_id", tradeItemIds);
189
+ .in("floriday_id", tradeItemIds).range(from, to));
189
190
  const map = new Map();
190
191
  for (const it of items ?? [])
191
192
  map.set(String(it.floriday_id), it.data ?? {});