@flowselections/floriday-verkoop-module 1.0.98 → 1.0.103
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.
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts +9 -0
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts.map +1 -0
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.js +26 -0
- package/dist-lib/components/karindeling/AfmetingenTab.d.ts +6 -0
- package/dist-lib/components/karindeling/AfmetingenTab.d.ts.map +1 -0
- package/dist-lib/components/karindeling/AfmetingenTab.js +128 -0
- package/dist-lib/components/karindeling/KarindelingPage.d.ts +2 -0
- package/dist-lib/components/karindeling/KarindelingPage.d.ts.map +1 -0
- package/dist-lib/components/karindeling/KarindelingPage.js +102 -0
- package/dist-lib/components/ui/dropdown-menu.d.ts +9 -0
- package/dist-lib/components/ui/dropdown-menu.d.ts.map +1 -0
- package/dist-lib/components/ui/dropdown-menu.js +14 -0
- package/dist-lib/components/verkoop/AnalyticsCards.d.ts +1 -1
- package/dist-lib/components/verkoop/AnalyticsCards.d.ts.map +1 -1
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.d.ts +4 -0
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.d.ts.map +1 -0
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.js +95 -0
- package/dist-lib/components/verkoop/CartAssignmentWizard.d.ts +1 -1
- package/dist-lib/components/verkoop/CartAssignmentWizard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CartLayersDialog.d.ts +1 -1
- package/dist-lib/components/verkoop/CartLayersDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/ConfirmDialog.d.ts +11 -0
- package/dist-lib/components/verkoop/ConfirmDialog.d.ts.map +1 -0
- package/dist-lib/components/verkoop/ConfirmDialog.js +10 -0
- package/dist-lib/components/verkoop/CreateOrderDialog.d.ts +5 -0
- package/dist-lib/components/verkoop/CreateOrderDialog.d.ts.map +1 -0
- package/dist-lib/components/verkoop/CreateOrderDialog.js +33 -0
- package/dist-lib/components/verkoop/CreateOrderPage.d.ts +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.js +79 -15
- package/dist-lib/components/verkoop/DiagnoseConnectionDialog.d.ts +1 -1
- package/dist-lib/components/verkoop/DiagnoseConnectionDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.js +11 -5
- package/dist-lib/components/verkoop/EngineBufferCard.d.ts +1 -1
- package/dist-lib/components/verkoop/EngineBufferCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/FloridayStageLine.d.ts +2 -2
- package/dist-lib/components/verkoop/FloridayStageLine.d.ts.map +1 -1
- package/dist-lib/components/verkoop/InvoiceTimingSettings.d.ts +1 -1
- package/dist-lib/components/verkoop/InvoiceTimingSettings.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderAfleverbrievenCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderAfleverbrievenCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderCarrierPicker.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderCarrierPicker.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderControlStatusCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderControlStatusCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.js +28 -2
- package/dist-lib/components/verkoop/OrderLinePackingCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderLinePackingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderLinePackingCard.js +1 -1
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.js +16 -13
- package/dist-lib/components/verkoop/PlanCoverageBadge.d.ts +1 -1
- package/dist-lib/components/verkoop/PlanCoverageBadge.d.ts.map +1 -1
- package/dist-lib/components/verkoop/ProductDimensionsSettings.d.ts +1 -1
- package/dist-lib/components/verkoop/ProductDimensionsSettings.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +6 -6
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts +1 -2
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.js +1 -1
- package/dist-lib/components/verkoop/SearchableSelect.d.ts +1 -1
- package/dist-lib/components/verkoop/SearchableSelect.d.ts.map +1 -1
- package/dist-lib/components/verkoop/StockConsumptionAlertsBanner.d.ts +1 -1
- package/dist-lib/components/verkoop/StockConsumptionAlertsBanner.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/WeekCalendar.d.ts +1 -1
- package/dist-lib/components/verkoop/WeekCalendar.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.js +1 -1
- package/dist-lib/integrations/supabase/client.server.js +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +1055 -15
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.d.ts +20 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +129 -13
- package/dist-lib/lib/cron/mirror-floriday-orders.d.ts +4 -0
- package/dist-lib/lib/cron/mirror-floriday-orders.d.ts.map +1 -0
- package/dist-lib/lib/cron/mirror-floriday-orders.js +23 -0
- package/dist-lib/lib/cron/push-order-statuses.d.ts +4 -0
- package/dist-lib/lib/cron/push-order-statuses.d.ts.map +1 -0
- package/dist-lib/lib/cron/push-order-statuses.js +23 -0
- package/dist-lib/lib/customer-stickers.check.d.ts +2 -0
- package/dist-lib/lib/customer-stickers.check.d.ts.map +1 -0
- package/dist-lib/lib/customer-stickers.check.js +19 -0
- package/dist-lib/lib/customer-stickers.d.ts +14 -0
- package/dist-lib/lib/customer-stickers.d.ts.map +1 -0
- package/dist-lib/lib/customer-stickers.js +19 -0
- package/dist-lib/lib/departure-preview.check.js +24 -1
- package/dist-lib/lib/departure-preview.d.ts +25 -1
- package/dist-lib/lib/departure-preview.d.ts.map +1 -1
- package/dist-lib/lib/departure-preview.functions.d.ts +1 -0
- package/dist-lib/lib/departure-preview.functions.d.ts.map +1 -1
- package/dist-lib/lib/departure-preview.functions.js +1 -0
- package/dist-lib/lib/departure-preview.js +65 -2
- package/dist-lib/lib/departure-preview.server.d.ts +1 -0
- package/dist-lib/lib/departure-preview.server.d.ts.map +1 -1
- package/dist-lib/lib/departure-preview.server.js +3 -0
- package/dist-lib/lib/floriday/floriday.server.d.ts +14 -0
- package/dist-lib/lib/floriday/floriday.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday/floriday.server.js +92 -0
- package/dist-lib/lib/floriday/sales-orders.functions.d.ts +4736 -0
- package/dist-lib/lib/floriday/sales-orders.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday/sales-orders.functions.js +193 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts +77581 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-auto-fulfillment.functions.js +65 -0
- package/dist-lib/lib/floriday-auto-fulfillment.server.d.ts +21 -0
- package/dist-lib/lib/floriday-auto-fulfillment.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday-auto-fulfillment.server.js +352 -0
- package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.functions.js +54 -1
- package/dist-lib/lib/floriday-status-sync.server.d.ts +14 -0
- package/dist-lib/lib/floriday-status-sync.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday-status-sync.server.js +130 -0
- package/dist-lib/lib/invoice-timing.server.d.ts +3 -1
- package/dist-lib/lib/invoice-timing.server.d.ts.map +1 -1
- package/dist-lib/lib/invoice-timing.server.js +3 -2
- package/dist-lib/lib/module-version.d.ts +2 -0
- package/dist-lib/lib/module-version.d.ts.map +1 -0
- package/dist-lib/lib/module-version.js +3 -0
- package/dist-lib/lib/order-item-packing.functions.d.ts +2 -0
- package/dist-lib/lib/order-item-packing.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-item-packing.functions.js +2 -1
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +2 -1
- package/dist-lib/lib/salesorders-mapping.d.ts +2 -0
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.js +4 -0
- package/dist-lib/lib/tradeitems.functions.d.ts +12 -1117
- package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
- package/dist-lib/lib/useBufferEvents.d.ts +2 -2
- package/dist-lib/lib/useBufferEvents.d.ts.map +1 -1
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.d.ts +2 -2
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrderDetailQuery.d.ts +1 -1
- package/dist-lib/lib/useSalesOrderDetailQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.d.ts +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.d.ts.map +1 -1
- package/package.json +9 -4
- package/schema/verkoop.sql +1939 -0
- package/dist-lib/lib/order-cart-count.server.d.ts +0 -8
- package/dist-lib/lib/order-cart-count.server.d.ts.map +0 -1
- package/dist-lib/lib/order-cart-count.server.js +0 -69
|
@@ -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;
|
|
@@ -150,6 +151,9 @@ export declare const createManualOrder: import("@tanstack/start-client-core").Op
|
|
|
150
151
|
acceptLateSignup?: boolean | undefined;
|
|
151
152
|
acceptedByName?: string | null | undefined;
|
|
152
153
|
source?: "manual" | "mailbox" | undefined;
|
|
154
|
+
customerReference?: string | null | undefined;
|
|
155
|
+
ownTransport?: boolean | undefined;
|
|
156
|
+
ownTransportPickupAt?: string | null | undefined;
|
|
153
157
|
}, Promise<{
|
|
154
158
|
ok: true;
|
|
155
159
|
orderId: string;
|
|
@@ -211,6 +215,7 @@ export declare const getLocalOrderForEdit: import("@tanstack/start-client-core")
|
|
|
211
215
|
quantity: number;
|
|
212
216
|
unit: string | null;
|
|
213
217
|
plantsPerCrate: number;
|
|
218
|
+
needsSticker: boolean;
|
|
214
219
|
shippedQuantity: number;
|
|
215
220
|
plannedQuantity: number;
|
|
216
221
|
minQuantity: number;
|
|
@@ -238,6 +243,11 @@ export declare const updateLocalOrder: import("@tanstack/start-client-core").Opt
|
|
|
238
243
|
plantsPerCrate?: number | null | undefined;
|
|
239
244
|
cratesPerLayer?: number | null | undefined;
|
|
240
245
|
layersPerCart?: number | null | undefined;
|
|
246
|
+
needsSticker?: boolean | undefined;
|
|
247
|
+
}[] | undefined;
|
|
248
|
+
stickers?: {
|
|
249
|
+
itemId: string;
|
|
250
|
+
needsSticker: boolean;
|
|
241
251
|
}[] | undefined;
|
|
242
252
|
}, Promise<{
|
|
243
253
|
ok: true;
|
|
@@ -257,4 +267,14 @@ export declare const getEffectivePrices: import("@tanstack/start-client-core").O
|
|
|
257
267
|
price: number;
|
|
258
268
|
source: string | null;
|
|
259
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
|
+
}>>;
|
|
260
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;
|
|
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(),
|
|
@@ -665,6 +667,11 @@ const CreateManualOrderInput = z.object({
|
|
|
665
667
|
acceptLateSignup: z.boolean().optional(),
|
|
666
668
|
acceptedByName: z.string().max(255).nullable().optional(),
|
|
667
669
|
source: z.enum(["manual", "mailbox"]).optional(),
|
|
670
|
+
// Referentie van de klant (custom_fields.customer_reference).
|
|
671
|
+
customerReference: z.string().trim().max(100).nullable().optional(),
|
|
672
|
+
// Eigen vervoer / zelf afleveren: geen vervoerder, bewuste keuze.
|
|
673
|
+
ownTransport: z.boolean().optional(),
|
|
674
|
+
ownTransportPickupAt: z.string().regex(/(Z|[+-]\d{2}:\d{2})$/, "Tijd zonder tijdzone").nullable().optional(),
|
|
668
675
|
});
|
|
669
676
|
export const createManualOrder = createServerFn({ method: "POST" })
|
|
670
677
|
.middleware([requireSupabaseAuth])
|
|
@@ -681,7 +688,9 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
681
688
|
const loadCarrierType = await resolveLoadCarrierType(context.supabase, data.loadCarrierType);
|
|
682
689
|
// Ophaalmoment en haalbaarheid komen alleen van de Logistiek Engine
|
|
683
690
|
// (logistics_departure_preview). Geen eigen berekening of terugval.
|
|
684
|
-
|
|
691
|
+
const ownTransport = !data.isReservation && data.ownTransport === true;
|
|
692
|
+
let carrierId = data.isReservation || ownTransport ? null : (data.carrierId ?? null);
|
|
693
|
+
let ownTransportInfo = null;
|
|
685
694
|
let momentKey = null;
|
|
686
695
|
let deliveryTime = null;
|
|
687
696
|
let lateSignup = null;
|
|
@@ -694,11 +703,25 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
694
703
|
carrierId,
|
|
695
704
|
deliveryLocation: data.deliveryLocationId,
|
|
696
705
|
deliveryDate: data.deliveryDate.slice(0, 10),
|
|
697
|
-
momentKey: data.momentKey ?? null,
|
|
706
|
+
momentKey: ownTransport ? null : (data.momentKey ?? null),
|
|
707
|
+
ownTransport,
|
|
698
708
|
});
|
|
699
709
|
const d = decidePreview(preview);
|
|
700
710
|
if (d.kind === "blocked")
|
|
701
711
|
throw new Error(d.reason);
|
|
712
|
+
// Vervoerder al vertrokken: nooit aanmaken, ook niet met "toch aanmaken".
|
|
713
|
+
if (d.kind === "departed") {
|
|
714
|
+
throw new Error(d.firstDate ? `${d.reason} De eerstvolgende leverdatum is ${d.firstDate}.` : d.reason);
|
|
715
|
+
}
|
|
716
|
+
if (ownTransport) {
|
|
717
|
+
const by = context.claims?.email ?? null;
|
|
718
|
+
ownTransportInfo = {
|
|
719
|
+
by: data.acceptedByName ?? by ?? context.userId ?? null,
|
|
720
|
+
by_user_id: context.userId ?? null,
|
|
721
|
+
at: new Date().toISOString(),
|
|
722
|
+
...(data.ownTransportPickupAt ? { pickup_at: data.ownTransportPickupAt } : {}),
|
|
723
|
+
};
|
|
724
|
+
}
|
|
702
725
|
if (d.kind === "late") {
|
|
703
726
|
if (!data.acceptLateSignup) {
|
|
704
727
|
throw new Error(d.firstDate
|
|
@@ -717,11 +740,13 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
717
740
|
source: data.source ?? "manual",
|
|
718
741
|
};
|
|
719
742
|
}
|
|
720
|
-
|
|
721
|
-
|
|
743
|
+
if (!ownTransport)
|
|
744
|
+
carrierId = preview?.carrierId ?? carrierId;
|
|
745
|
+
if (!ownTransport && !carrierId)
|
|
722
746
|
throw new Error("Er is geen vervoerder bekend voor deze afleverlocatie. Kies een vervoerder.");
|
|
723
747
|
momentKey = d.momentKey;
|
|
724
|
-
|
|
748
|
+
if (!ownTransport)
|
|
749
|
+
deliveryTime = await deliveryTimeForMoment(context.supabase, carrierId, momentKey);
|
|
725
750
|
}
|
|
726
751
|
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
727
752
|
// Zorg dat elk product_id (= identiteit uit de voorraadmodule) een rij
|
|
@@ -839,6 +864,8 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
839
864
|
delivery_time: deliveryTime,
|
|
840
865
|
pickup_moment: momentKey,
|
|
841
866
|
...(lateSignup ? { late_signup_override: lateSignup } : {}),
|
|
867
|
+
...(ownTransportInfo ? { own_transport: ownTransportInfo } : {}),
|
|
868
|
+
...(data.customerReference ? { customer_reference: data.customerReference } : {}),
|
|
842
869
|
is_reservation: !!data.isReservation,
|
|
843
870
|
load_carrier_type: loadCarrierType,
|
|
844
871
|
},
|
|
@@ -866,6 +893,7 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
866
893
|
crates_per_layer: l.crates_per_layer ?? null,
|
|
867
894
|
layers_per_cart: l.layers_per_cart ?? null,
|
|
868
895
|
unit_price: l.unit_price ?? undefined,
|
|
896
|
+
needs_sticker: l.needs_sticker === true,
|
|
869
897
|
};
|
|
870
898
|
});
|
|
871
899
|
const { error: itemsErr } = await supabaseAdmin.from("order_items").insert(items);
|
|
@@ -1065,8 +1093,14 @@ const UpdateLocalOrderInput = z.object({
|
|
|
1065
1093
|
plantsPerCrate: z.number().int().positive().nullish(),
|
|
1066
1094
|
cratesPerLayer: z.number().int().positive().nullish(),
|
|
1067
1095
|
layersPerCart: z.number().int().positive().nullish(),
|
|
1096
|
+
needsSticker: z.boolean().optional(),
|
|
1068
1097
|
}))
|
|
1069
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(),
|
|
1070
1104
|
});
|
|
1071
1105
|
export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
1072
1106
|
.middleware([requireSupabaseAuth])
|
|
@@ -1088,7 +1122,7 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
|
1088
1122
|
}
|
|
1089
1123
|
const { data: items, error: iErr } = await context.supabase
|
|
1090
1124
|
.from("order_items")
|
|
1091
|
-
.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)")
|
|
1092
1126
|
.eq("order_id", data.orderId)
|
|
1093
1127
|
.is("quarantined_at", null)
|
|
1094
1128
|
.order("id");
|
|
@@ -1250,6 +1284,7 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
|
1250
1284
|
quantity: Number(it.quantity ?? 0),
|
|
1251
1285
|
unit: it.unit,
|
|
1252
1286
|
plantsPerCrate: ppc,
|
|
1287
|
+
needsSticker: it.needs_sticker === true,
|
|
1253
1288
|
shippedQuantity: shipped,
|
|
1254
1289
|
plannedQuantity: planned,
|
|
1255
1290
|
minQuantity: shipped + planned,
|
|
@@ -1278,6 +1313,34 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1278
1313
|
}
|
|
1279
1314
|
const removeIds = data.removeItemIds ?? [];
|
|
1280
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;
|
|
1281
1344
|
// Producten wijzigen mag alleen zolang er nog niets is geprint in het
|
|
1282
1345
|
// Pickstation (orders.plan_locked_at).
|
|
1283
1346
|
if ((removeIds.length > 0 || newItems.length > 0) && order.plan_locked_at) {
|
|
@@ -1379,6 +1442,7 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1379
1442
|
crates_per_layer: n.cratesPerLayer ?? null,
|
|
1380
1443
|
layers_per_cart: n.layersPerCart ?? null,
|
|
1381
1444
|
unit_price: n.unitPrice ?? undefined,
|
|
1445
|
+
needs_sticker: n.needsSticker === true,
|
|
1382
1446
|
};
|
|
1383
1447
|
});
|
|
1384
1448
|
const { error: nErr } = await supabaseAdmin.from("order_items").insert(rowsToInsert);
|
|
@@ -1404,6 +1468,10 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1404
1468
|
const d = decidePreview(preview);
|
|
1405
1469
|
if (d.kind === "blocked")
|
|
1406
1470
|
throw new Error(d.reason);
|
|
1471
|
+
// Vervoerder al vertrokken: ook bij wijzigen nooit doorlaten.
|
|
1472
|
+
if (d.kind === "departed") {
|
|
1473
|
+
throw new Error(d.firstDate ? `${d.reason} De eerstvolgende leverdatum is ${d.firstDate}.` : d.reason);
|
|
1474
|
+
}
|
|
1407
1475
|
if (d.kind === "late") {
|
|
1408
1476
|
if (!data.acceptLateSignup) {
|
|
1409
1477
|
throw new Error(d.firstDate ? `${d.reason} De eerste haalbare leverdatum is ${d.firstDate}.` : d.reason);
|
|
@@ -1452,14 +1520,25 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1452
1520
|
.update({ total: String(total.toFixed(2)), updated_at: new Date().toISOString() })
|
|
1453
1521
|
.eq("id", data.orderId);
|
|
1454
1522
|
}
|
|
1455
|
-
//
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
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}`);
|
|
1460
1531
|
}
|
|
1461
|
-
|
|
1462
|
-
|
|
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
|
+
}
|
|
1463
1542
|
}
|
|
1464
1543
|
return { ok: true };
|
|
1465
1544
|
});
|
|
@@ -1490,3 +1569,40 @@ export const getEffectivePrices = createServerFn({ method: "POST" })
|
|
|
1490
1569
|
}
|
|
1491
1570
|
return out;
|
|
1492
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,4 @@
|
|
|
1
|
+
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
export declare function mirrorFloridayOrdersCron(request: Request, _supabase: SupabaseClient): Promise<Response>;
|
|
3
|
+
export declare function mirrorFloridayOrdersCronHint(_request: Request, _supabase: SupabaseClient): Promise<Response>;
|
|
4
|
+
//# sourceMappingURL=mirror-floriday-orders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mirror-floriday-orders.d.ts","sourceRoot":"","sources":["../../../src/lib/cron/mirror-floriday-orders.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAG5D,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,QAAQ,CAAC,CAmBnB;AAED,wBAAsB,4BAA4B,CAChD,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,QAAQ,CAAC,CAKnB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { mirrorFloridayOrdersFromCron } from "../floriday-mirror.functions.js";
|
|
2
|
+
export async function mirrorFloridayOrdersCron(request, _supabase) {
|
|
3
|
+
const apikey = request.headers.get("apikey") ?? request.headers.get("x-api-key");
|
|
4
|
+
const expected = process.env.SUPABASE_PUBLISHABLE_KEY;
|
|
5
|
+
if (!expected || !apikey || apikey !== expected) {
|
|
6
|
+
return new Response("Unauthorized", { status: 401 });
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
const url = new URL(request.url);
|
|
10
|
+
const limit = Number(url.searchParams.get("limit") ?? "200");
|
|
11
|
+
const result = await mirrorFloridayOrdersFromCron(Number.isFinite(limit) && limit > 0 ? Math.min(1000, limit) : 200);
|
|
12
|
+
return Response.json(result);
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
return Response.json({ ok: false, error: err.message }, { status: 500 });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function mirrorFloridayOrdersCronHint(_request, _supabase) {
|
|
19
|
+
return Response.json({
|
|
20
|
+
ok: true,
|
|
21
|
+
hint: "POST to mirror recent Floriday sales orders into local orders",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SupabaseClient } from "@supabase/supabase-js";
|
|
2
|
+
export declare function pushOrderStatusesCron(request: Request, _supabase: SupabaseClient): Promise<Response>;
|
|
3
|
+
export declare function pushOrderStatusesCronHint(_request: Request, _supabase: SupabaseClient): Promise<Response>;
|
|
4
|
+
//# sourceMappingURL=push-order-statuses.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"push-order-statuses.d.ts","sourceRoot":"","sources":["../../../src/lib/cron/push-order-statuses.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,QAAQ,CAAC,CAiBnB;AAED,wBAAsB,yBAAyB,CAC7C,QAAQ,EAAE,OAAO,EACjB,SAAS,EAAE,cAAc,GACxB,OAAO,CAAC,QAAQ,CAAC,CAKnB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export async function pushOrderStatusesCron(request, _supabase) {
|
|
2
|
+
const apikey = request.headers.get("apikey") ?? request.headers.get("x-api-key");
|
|
3
|
+
const expected = process.env.SUPABASE_PUBLISHABLE_KEY;
|
|
4
|
+
if (!expected || !apikey || apikey !== expected) {
|
|
5
|
+
return new Response("Unauthorized", { status: 401 });
|
|
6
|
+
}
|
|
7
|
+
try {
|
|
8
|
+
const url = new URL(request.url);
|
|
9
|
+
const limit = Number(url.searchParams.get("limit") ?? "100");
|
|
10
|
+
const { pushOrderStatusesToFloriday } = await import("../floriday-status-sync.server.js");
|
|
11
|
+
const result = await pushOrderStatusesToFloriday(Number.isFinite(limit) && limit > 0 ? Math.min(500, limit) : 100);
|
|
12
|
+
return Response.json(result);
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
return Response.json({ ok: false, error: err.message }, { status: 500 });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export async function pushOrderStatusesCronHint(_request, _supabase) {
|
|
19
|
+
return Response.json({
|
|
20
|
+
ok: true,
|
|
21
|
+
hint: "POST to push ERP order status changes to Floriday",
|
|
22
|
+
});
|
|
23
|
+
}
|
|
@@ -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,5 +1,7 @@
|
|
|
1
1
|
// Controle voorbeeld-ophaalmoment. Draai: bun src/lib/departure-preview.check.ts
|
|
2
|
-
import { decidePreview, normalizePreview } from "./departure-preview.js";
|
|
2
|
+
import { decidePreview, normalizePreview, firstDateText } from "./departure-preview.js";
|
|
3
|
+
// Vaste "nu" zodat de controles niet verouderen.
|
|
4
|
+
Date.now = () => Date.parse("2026-10-19T12:00:00Z");
|
|
3
5
|
import { LIST_CHUNK } from "./order-departure.server.js";
|
|
4
6
|
let failed = 0;
|
|
5
7
|
function check(name, got, want) {
|
|
@@ -30,6 +32,27 @@ check("ok=false: geblokkeerd", bad.kind, "blocked");
|
|
|
30
32
|
check("ok=false: alleen reden", bad.kind === "blocked" ? bad.reason : null, "Geen vervoerder bekend");
|
|
31
33
|
check("geen antwoord: geblokkeerd", decidePreview(null).kind, "blocked");
|
|
32
34
|
check("lijst in delen van 1000", LIST_CHUNK, 1000);
|
|
35
|
+
// Vervoerder al vertrokken (HO-2601443): aanmeldtijd én ophaalmoment voorbij → niet "toch aanmaken".
|
|
36
|
+
const gone = decidePreview(normalizePreview({
|
|
37
|
+
ok: true, deliveryDateFeasible: false, reason: "Aanmelden kon tot ma 19-10 13:00",
|
|
38
|
+
chosen: { momentKey: "k", departureAt: "2026-10-19T13:00:00Z" },
|
|
39
|
+
firstFeasibleDeliveryDate: "2026-10-21",
|
|
40
|
+
}), Date.parse("2026-10-19T20:58:00Z"));
|
|
41
|
+
check("vertrokken (afgeleid uit vertrekmoment)", gone.kind, "departed");
|
|
42
|
+
check("vertrokken: eerste datum", gone.kind === "departed" ? gone.firstDate : null, "2026-10-21");
|
|
43
|
+
const lateNotGone = decidePreview(normalizePreview({
|
|
44
|
+
ok: true, deliveryDateFeasible: false, chosen: { momentKey: "k", departureAt: "2026-10-19T13:00:00Z" },
|
|
45
|
+
}), Date.parse("2026-10-19T11:30:00Z"));
|
|
46
|
+
check("aanmeldtijd voorbij, ophalen nog niet: te laat", lateNotGone.kind, "late");
|
|
47
|
+
const engineSays = decidePreview(normalizePreview({
|
|
48
|
+
ok: true, deliveryDateFeasible: true,
|
|
49
|
+
chosen: { momentKey: "k", departureAt: "2026-10-30T13:00:00Z", departed: true },
|
|
50
|
+
nextFeasibleMoment: { momentKey: "n", departureAt: "x", signupDeadline: null, deliveryDate: "2026-10-31" },
|
|
51
|
+
}));
|
|
52
|
+
check("Engine-veld departed gaat voor", engineSays.kind, "departed");
|
|
53
|
+
check("volgende moment uit Engine", engineSays.kind === "departed" ? engineSays.firstDate : null, "2026-10-31");
|
|
54
|
+
check("eigen vervoer: nooit vertrokken", decidePreview(normalizePreview({ ok: true, ownTransport: true, deliveryDateFeasible: true, chosen: { departureAt: "2026-10-01T10:00:00Z" } })).kind, "ok");
|
|
55
|
+
check("tekst eerste leverdatum", firstDateText("2026-10-21", "2026-10-20T11:00:00Z"), "Eerst mogelijke leverdatum: woensdag 21 oktober (aanmelden vóór dinsdag 13:00).");
|
|
33
56
|
if (failed) {
|
|
34
57
|
console.error(`${failed} controle(s) mislukt`);
|
|
35
58
|
process.exit(1);
|
|
@@ -3,6 +3,14 @@ export interface PreviewMoment {
|
|
|
3
3
|
departureAt: string | null;
|
|
4
4
|
signupDeadline: string | null;
|
|
5
5
|
feasible: boolean;
|
|
6
|
+
/** Ophaalmoment al voorbij (Engine 1.0.168; anders afgeleid uit departureAt). */
|
|
7
|
+
departed: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface NextFeasibleMoment {
|
|
10
|
+
momentKey: string | null;
|
|
11
|
+
departureAt: string | null;
|
|
12
|
+
signupDeadline: string | null;
|
|
13
|
+
deliveryDate: string | null;
|
|
6
14
|
}
|
|
7
15
|
export interface DeparturePreview {
|
|
8
16
|
ok: boolean;
|
|
@@ -13,7 +21,10 @@ export interface DeparturePreview {
|
|
|
13
21
|
momentKey: string | null;
|
|
14
22
|
departureAt: string | null;
|
|
15
23
|
signupDeadline: string | null;
|
|
24
|
+
departed: boolean | null;
|
|
16
25
|
} | null;
|
|
26
|
+
nextFeasibleMoment: NextFeasibleMoment | null;
|
|
27
|
+
ownTransport: boolean;
|
|
17
28
|
deliveryDateFeasible: boolean;
|
|
18
29
|
deliveryDateReason: string | null;
|
|
19
30
|
firstFeasibleDeliveryDate: string | null;
|
|
@@ -32,16 +43,29 @@ export type PreviewDecision = {
|
|
|
32
43
|
firstReason: string | null;
|
|
33
44
|
momentKey: string | null;
|
|
34
45
|
text: string | null;
|
|
46
|
+
} | {
|
|
47
|
+
kind: "departed";
|
|
48
|
+
reason: string;
|
|
49
|
+
firstDate: string | null;
|
|
50
|
+
next: NextFeasibleMoment | null;
|
|
35
51
|
} | {
|
|
36
52
|
kind: "blocked";
|
|
37
53
|
reason: string;
|
|
38
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Is het gekozen ophaalmoment al voorbij? Eerst het veld van de Engine
|
|
57
|
+
* (chosen.departed); ontbreekt dat, dan alleen het door de Engine gegeven
|
|
58
|
+
* vertrekmoment met nu vergelijken — geen eigen rekenwerk.
|
|
59
|
+
*/
|
|
60
|
+
export declare function chosenDeparted(p: DeparturePreview, now?: number): boolean;
|
|
39
61
|
/**
|
|
40
62
|
* Wat je ziet / of je mag aanmaken.
|
|
41
63
|
* - ok = false of geen antwoord: geblokkeerd, alleen de reden.
|
|
42
64
|
* - leverdatum niet haalbaar: "te laat" — alleen aanmaken na bewuste keuze.
|
|
43
65
|
*/
|
|
44
|
-
export declare function decidePreview(p: DeparturePreview | null): PreviewDecision;
|
|
66
|
+
export declare function decidePreview(p: DeparturePreview | null, now?: number): PreviewDecision;
|
|
45
67
|
export declare function momentLabel(m: PreviewMoment): string;
|
|
68
|
+
/** "Eerst mogelijke leverdatum: woensdag 21 oktober (aanmelden vóór dinsdag 13:00)." */
|
|
69
|
+
export declare function firstDateText(date: string | null, signupDeadline: string | null): string | null;
|
|
46
70
|
export declare const LATE_CONFIRM = "Deze order komt na de aanmeldtijd. De vervoerder krijgt hem als te laat aangemeld. Doorgaan?";
|
|
47
71
|
//# sourceMappingURL=departure-preview.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"departure-preview.d.ts","sourceRoot":"","sources":["../../src/lib/departure-preview.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"departure-preview.d.ts","sourceRoot":"","sources":["../../src/lib/departure-preview.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,QAAQ,EAAE,OAAO,CAAC;IAClB,iFAAiF;IACjF,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,MAAM,EAAE;QAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;IACjI,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,CAAC;IAC9C,YAAY,EAAE,OAAO,CAAC;IACtB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;CACpC;AAID,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,GAAG,IAAI,CA2CtE;AAED,eAAO,MAAM,eAAe,6EAA6E,CAAC;AAE1G,MAAM,MAAM,eAAe,GACvB;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GACrI;IAAE,IAAI,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,kBAAkB,GAAG,IAAI,CAAA;CAAE,GAC/F;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAExC;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,gBAAgB,EAAE,GAAG,GAAE,MAAmB,GAAG,OAAO,CAKrF;AASD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,EAAE,gBAAgB,GAAG,IAAI,EAAE,GAAG,GAAE,MAAmB,GAAG,eAAe,CAyBnG;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,aAAa,GAAG,MAAM,CAEpD;AAgBD,wFAAwF;AACxF,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAM/F;AAED,eAAO,MAAM,YAAY,iGACuE,CAAC"}
|
|
@@ -7,6 +7,7 @@ export declare const getDeparturePreview: import("@tanstack/start-client-core").
|
|
|
7
7
|
deliveryLocation: string;
|
|
8
8
|
deliveryDate: string;
|
|
9
9
|
momentKey?: string | null | undefined;
|
|
10
|
+
ownTransport?: boolean | undefined;
|
|
10
11
|
}, Promise<{
|
|
11
12
|
preview: import("./departure-preview.js").DeparturePreview | null;
|
|
12
13
|
}>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"departure-preview.functions.d.ts","sourceRoot":"","sources":["../../src/lib/departure-preview.functions.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;;;;8CAEN,OAAO
|
|
1
|
+
{"version":3,"file":"departure-preview.functions.d.ts","sourceRoot":"","sources":["../../src/lib/departure-preview.functions.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,mBAAmB;;;;8CAEN,OAAO;;;;;;;;GAc7B,CAAC"}
|
|
@@ -9,6 +9,7 @@ export const getDeparturePreview = createServerFn({ method: "GET" })
|
|
|
9
9
|
deliveryLocation: z.string().min(1).max(100),
|
|
10
10
|
deliveryDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
|
11
11
|
momentKey: z.string().max(64).nullable().optional(),
|
|
12
|
+
ownTransport: z.boolean().optional(),
|
|
12
13
|
})
|
|
13
14
|
.parse(input))
|
|
14
15
|
.handler(async ({ data, context }) => {
|