@flowselections/floriday-verkoop-module 1.0.154 → 1.0.156
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/verkoop/AnalyticsCards.d.ts +1 -1
- package/dist-lib/components/verkoop/AnalyticsCards.d.ts.map +1 -1
- 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 +1 -1
- package/dist-lib/components/verkoop/ConfirmDialog.d.ts.map +1 -1
- 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 +60 -32
- 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/EngineActieButtons.d.ts +1 -1
- package/dist-lib/components/verkoop/EngineActieButtons.d.ts.map +1 -1
- 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/FloridaySyncSettings.d.ts +1 -1
- package/dist-lib/components/verkoop/FloridaySyncSettings.d.ts.map +1 -1
- package/dist-lib/components/verkoop/InvoiceSignoffSettings.d.ts +1 -1
- package/dist-lib/components/verkoop/InvoiceSignoffSettings.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/OrderInvoiceCard.d.ts +1 -1
- package/dist-lib/components/verkoop/OrderInvoiceCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts +2 -2
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts.map +1 -1
- 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/OrderPickupMomentPicker.d.ts +4 -2
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.js +2 -2
- 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/OrderTransportCard.d.ts +46 -0
- package/dist-lib/components/verkoop/OrderTransportCard.d.ts.map +1 -0
- package/dist-lib/components/verkoop/OrderTransportCard.js +98 -0
- package/dist-lib/components/verkoop/PickupLocationsSettings.d.ts +1 -1
- package/dist-lib/components/verkoop/PickupLocationsSettings.d.ts.map +1 -1
- 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 +13 -12
- 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 +7 -4
- 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 +7 -2
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.js +10 -4
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.js +8 -1
- package/dist-lib/components/verkoop/SearchableSelect.js +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/VerkoopOrdersPage.js +39 -17
- package/dist-lib/components/verkoop/WeekCalendar.d.ts +1 -1
- package/dist-lib/components/verkoop/WeekCalendar.d.ts.map +1 -1
- package/dist-lib/components/verkoop/klok/KlokNotice.d.ts +3 -0
- package/dist-lib/components/verkoop/klok/KlokNotice.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/KlokNotice.js +12 -0
- package/dist-lib/components/verkoop/klok/KlokOrderPage.d.ts +2 -0
- package/dist-lib/components/verkoop/klok/KlokOrderPage.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/KlokOrderPage.js +403 -0
- package/dist-lib/components/verkoop/klok/KlokOrdersList.d.ts +10 -0
- package/dist-lib/components/verkoop/klok/KlokOrdersList.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/KlokOrdersList.js +120 -0
- package/dist-lib/components/verkoop/klok/KlokPage.d.ts +2 -0
- package/dist-lib/components/verkoop/klok/KlokPage.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/KlokPage.js +82 -0
- package/dist-lib/components/verkoop/klok/KlokStatusBadge.d.ts +5 -0
- package/dist-lib/components/verkoop/klok/KlokStatusBadge.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/KlokStatusBadge.js +20 -0
- package/dist-lib/components/verkoop/klok/useKlok.d.ts +17 -0
- package/dist-lib/components/verkoop/klok/useKlok.d.ts.map +1 -0
- package/dist-lib/components/verkoop/klok/useKlok.js +36 -0
- package/dist-lib/components/verkoop/v3/ArticlesHover.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/ArticlesHover.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/CustomerName.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/CustomerName.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/EmptyState.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/EmptyState.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/HoverTip.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/HoverTip.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/InfoCard.d.ts +3 -3
- package/dist-lib/components/verkoop/v3/InfoCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/KpiTile.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/KpiTile.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/NavigationTooltip.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/NavigationTooltip.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/NoticeBar.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/NoticeBar.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/OrderProgress.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/OrderProgress.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/OrderStepper.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/OrderStepper.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/RowMenu.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/RowMenu.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/ShortcutHelp.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/ShortcutHelp.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/SourceIcon.d.ts +1 -1
- package/dist-lib/components/verkoop/v3/SourceIcon.d.ts.map +1 -1
- package/dist-lib/index.d.ts +2 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +8 -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 +1168 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/all-rows.d.ts +11 -0
- package/dist-lib/lib/all-rows.d.ts.map +1 -0
- package/dist-lib/lib/all-rows.js +20 -0
- package/dist-lib/lib/belading.server.d.ts.map +1 -1
- package/dist-lib/lib/belading.server.js +20 -9
- package/dist-lib/lib/create-order-form.d.ts +45 -0
- package/dist-lib/lib/create-order-form.d.ts.map +1 -1
- package/dist-lib/lib/create-order-form.js +72 -0
- package/dist-lib/lib/create-order.functions.d.ts +21 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +63 -5
- package/dist-lib/lib/floriday-mirror.server.js +1 -1
- package/dist-lib/lib/klok-form.d.ts +59 -0
- package/dist-lib/lib/klok-form.d.ts.map +1 -0
- package/dist-lib/lib/klok-form.js +127 -0
- package/dist-lib/lib/klok-gateway.server.d.ts +35 -0
- package/dist-lib/lib/klok-gateway.server.d.ts.map +1 -0
- package/dist-lib/lib/klok-gateway.server.js +123 -0
- package/dist-lib/lib/klok-labels.d.ts +76 -0
- package/dist-lib/lib/klok-labels.d.ts.map +1 -0
- package/dist-lib/lib/klok-labels.js +175 -0
- package/dist-lib/lib/klok-payload.d.ts +34 -0
- package/dist-lib/lib/klok-payload.d.ts.map +1 -0
- package/dist-lib/lib/klok-payload.js +38 -0
- package/dist-lib/lib/klok-sales-row.d.ts +2 -0
- package/dist-lib/lib/klok-sales-row.d.ts.map +1 -0
- package/dist-lib/lib/klok-sales-row.js +5 -0
- package/dist-lib/lib/klok-sales.server.d.ts +5 -0
- package/dist-lib/lib/klok-sales.server.d.ts.map +1 -0
- package/dist-lib/lib/klok-sales.server.js +33 -0
- package/dist-lib/lib/klok.functions.d.ts +265 -0
- package/dist-lib/lib/klok.functions.d.ts.map +1 -0
- package/dist-lib/lib/klok.functions.js +355 -0
- package/dist-lib/lib/klok.server.d.ts +47 -0
- package/dist-lib/lib/klok.server.d.ts.map +1 -0
- package/dist-lib/lib/klok.server.js +369 -0
- package/dist-lib/lib/module-version.d.ts +1 -1
- package/dist-lib/lib/module-version.js +1 -1
- package/dist-lib/lib/order-cart-count.server.d.ts +8 -0
- package/dist-lib/lib/order-cart-count.server.d.ts.map +1 -0
- package/dist-lib/lib/order-cart-count.server.js +69 -0
- package/dist-lib/lib/order-search.d.ts +16 -0
- package/dist-lib/lib/order-search.d.ts.map +1 -1
- package/dist-lib/lib/order-search.js +16 -1
- package/dist-lib/lib/order-transport.functions.d.ts +50 -0
- package/dist-lib/lib/order-transport.functions.d.ts.map +1 -0
- package/dist-lib/lib/order-transport.functions.js +42 -0
- package/dist-lib/lib/order-transport.server.d.ts +17 -0
- package/dist-lib/lib/order-transport.server.d.ts.map +1 -0
- package/dist-lib/lib/order-transport.server.js +45 -0
- package/dist-lib/lib/own-transport.d.ts +45 -0
- package/dist-lib/lib/own-transport.d.ts.map +1 -1
- package/dist-lib/lib/own-transport.js +61 -0
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +20 -17
- package/dist-lib/lib/salesorders-mapping.d.ts +5 -0
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-mapping.js +1 -0
- package/dist-lib/lib/tradeitems.functions.d.ts +1117 -12
- package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
- package/dist-lib/lib/useBufferCarts.d.ts +2 -2
- package/dist-lib/lib/useBufferCarts.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/usePickupMoment.d.ts +2 -2
- package/dist-lib/lib/usePickupMoment.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/package.json +22 -4
- package/schema/verkoop.sql +213 -0
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts +0 -9
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.d.ts.map +0 -1
- package/dist-lib/components/floriday/FlorydaySyncHealthBanner.js +0 -26
- package/dist-lib/components/karindeling/AfmetingenTab.d.ts +0 -6
- package/dist-lib/components/karindeling/AfmetingenTab.d.ts.map +0 -1
- package/dist-lib/components/karindeling/AfmetingenTab.js +0 -128
- package/dist-lib/components/karindeling/KarindelingPage.d.ts +0 -2
- package/dist-lib/components/karindeling/KarindelingPage.d.ts.map +0 -1
- package/dist-lib/components/karindeling/KarindelingPage.js +0 -102
- package/dist-lib/components/ui/dropdown-menu.d.ts +0 -9
- package/dist-lib/components/ui/dropdown-menu.d.ts.map +0 -1
- package/dist-lib/components/ui/dropdown-menu.js +0 -14
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.d.ts +0 -4
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.d.ts.map +0 -1
- package/dist-lib/components/verkoop/AutoFulfillmentStatusCard.js +0 -95
- package/dist-lib/components/verkoop/CreateOrderDialog.d.ts +0 -5
- package/dist-lib/components/verkoop/CreateOrderDialog.d.ts.map +0 -1
- package/dist-lib/components/verkoop/CreateOrderDialog.js +0 -33
- package/dist-lib/lib/cron/mirror-floriday-orders.d.ts +0 -4
- package/dist-lib/lib/cron/mirror-floriday-orders.d.ts.map +0 -1
- package/dist-lib/lib/cron/mirror-floriday-orders.js +0 -23
- package/dist-lib/lib/cron/push-order-statuses.d.ts +0 -4
- package/dist-lib/lib/cron/push-order-statuses.d.ts.map +0 -1
- package/dist-lib/lib/cron/push-order-statuses.js +0 -23
- package/dist-lib/lib/floriday/floriday.server.d.ts +0 -14
- package/dist-lib/lib/floriday/floriday.server.d.ts.map +0 -1
- package/dist-lib/lib/floriday/floriday.server.js +0 -92
- package/dist-lib/lib/floriday/sales-orders.functions.d.ts +0 -4736
- package/dist-lib/lib/floriday/sales-orders.functions.d.ts.map +0 -1
- package/dist-lib/lib/floriday/sales-orders.functions.js +0 -193
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts +0 -77581
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts.map +0 -1
- package/dist-lib/lib/floriday-auto-fulfillment.functions.js +0 -65
- package/dist-lib/lib/floriday-auto-fulfillment.server.d.ts +0 -21
- package/dist-lib/lib/floriday-auto-fulfillment.server.d.ts.map +0 -1
- package/dist-lib/lib/floriday-auto-fulfillment.server.js +0 -352
- package/dist-lib/lib/floriday-status-sync.server.d.ts +0 -14
- package/dist-lib/lib/floriday-status-sync.server.d.ts.map +0 -1
- package/dist-lib/lib/floriday-status-sync.server.js +0 -130
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const ALLE_RIJEN_PORTIE = 1000;
|
|
2
|
+
export declare function alleRijen<T = any>(page: (from: number, to: number) => PromiseLike<{
|
|
3
|
+
data: T[] | null;
|
|
4
|
+
error: {
|
|
5
|
+
message: string;
|
|
6
|
+
} | null;
|
|
7
|
+
}>, opts?: {
|
|
8
|
+
portie?: number;
|
|
9
|
+
max?: number;
|
|
10
|
+
}): Promise<T[]>;
|
|
11
|
+
//# sourceMappingURL=all-rows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"all-rows.d.ts","sourceRoot":"","sources":["../../src/lib/all-rows.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,iBAAiB,OAAO,CAAC;AAEtC,wBAAsB,SAAS,CAAC,CAAC,GAAG,GAAG,EACrC,IAAI,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,KAAK,WAAW,CAAC;IAAE,IAAI,EAAE,CAAC,EAAE,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;CAAE,CAAC,EACxG,IAAI,GAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,CAAC,EAAE,MAAM,CAAA;CAAO,GAC3C,OAAO,CAAC,CAAC,EAAE,CAAC,CAad"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Alle rijen lezen in porties van 1000 (de server geeft per verzoek nooit meer).
|
|
2
|
+
// Zelfde werkwijze als alleRijen() in de voorraadmodule. Een fout wordt
|
|
3
|
+
// doorgegeven, nooit stil afgekapt; een veiligheidsgrens voorkomt eindeloos lezen.
|
|
4
|
+
export const ALLE_RIJEN_PORTIE = 1000;
|
|
5
|
+
export async function alleRijen(page, opts = {}) {
|
|
6
|
+
const portie = opts.portie ?? ALLE_RIJEN_PORTIE;
|
|
7
|
+
const max = opts.max ?? 100000;
|
|
8
|
+
const out = [];
|
|
9
|
+
for (let from = 0; from < max; from += portie) {
|
|
10
|
+
const { data, error } = await page(from, from + portie - 1);
|
|
11
|
+
if (error)
|
|
12
|
+
throw new Error(error.message);
|
|
13
|
+
const rows = data ?? [];
|
|
14
|
+
out.push(...rows);
|
|
15
|
+
if (rows.length < portie)
|
|
16
|
+
return out;
|
|
17
|
+
}
|
|
18
|
+
console.error(`[alleRijen] veiligheidsgrens van ${max} rijen bereikt; lijst kan onvolledig zijn`);
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"belading.server.d.ts","sourceRoot":"","sources":["../../src/lib/belading.server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"belading.server.d.ts","sourceRoot":"","sources":["../../src/lib/belading.server.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,cAAc;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,4EAA4E;IAC5E,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAWD;;;;GAIG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,GAAG,EACb,UAAU,EAAE,MAAM,EAAE,GACnB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC,CA+O3C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Beladingen (packing-configuraties) per product — centrale bron.
|
|
2
2
|
// Geen eigen controle op ladingdragers: alleen de Logistiek Engine beslist
|
|
3
3
|
// of een belading kan (koppelprompt 22).
|
|
4
|
+
import { alleRijen } from "./all-rows.js";
|
|
4
5
|
import { cratePackageName, loadCarrierName } from "./load-carrier-labels.js";
|
|
5
6
|
import { posOrNull } from "./packing-snapshot.js";
|
|
6
7
|
/**
|
|
@@ -13,10 +14,13 @@ export async function computeBeladingByProduct(supabase, productIds) {
|
|
|
13
14
|
const byProduct = {};
|
|
14
15
|
if (!ids.length)
|
|
15
16
|
return byProduct;
|
|
16
|
-
const
|
|
17
|
+
const giRows = await alleRijen((f, t) => supabase
|
|
17
18
|
.from("product_group_items")
|
|
18
19
|
.select("product_group_id, trade_item_id, sort_order")
|
|
19
|
-
.in("product_group_id", ids)
|
|
20
|
+
.in("product_group_id", ids)
|
|
21
|
+
.order("product_group_id")
|
|
22
|
+
.order("trade_item_id")
|
|
23
|
+
.range(f, t)).catch((e) => { console.error("[belading] productgroepen lezen mislukt:", e?.message ?? e); return []; });
|
|
20
24
|
const membersByGroup = new Map();
|
|
21
25
|
for (const gi of giRows ?? []) {
|
|
22
26
|
const gid = gi.product_group_id;
|
|
@@ -25,16 +29,22 @@ export async function computeBeladingByProduct(supabase, productIds) {
|
|
|
25
29
|
membersByGroup.set(gid, arr);
|
|
26
30
|
}
|
|
27
31
|
const lookupIds = Array.from(new Set([...ids, ...Array.from(membersByGroup.values()).flat()]));
|
|
32
|
+
// Zoals voorheen: één bron die faalt maakt de rest niet onbruikbaar, maar wordt wel gelogd.
|
|
33
|
+
const asRes = (p, bron) => p.then((data) => ({ data, error: null }), (e) => { console.error(`[belading] ${bron} lezen mislukt:`, e?.message ?? e); return { data: [], error: e }; });
|
|
28
34
|
const [tiRes, draftRes, prodRes] = await Promise.all([
|
|
29
|
-
supabase
|
|
35
|
+
asRes(alleRijen((f, t) => supabase
|
|
30
36
|
.from("floriday_trade_items_cache")
|
|
31
37
|
.select("floriday_id, data")
|
|
32
|
-
.in("floriday_id", lookupIds)
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
.in("floriday_id", lookupIds)
|
|
39
|
+
.order("floriday_id")
|
|
40
|
+
.range(f, t)), "trade items"),
|
|
41
|
+
asRes(alleRijen((f, t) => supabase.from("trade_item_drafts").select("id, data").in("id", lookupIds).order("id").range(f, t)), "concepten"),
|
|
42
|
+
asRes(alleRijen((f, t) => supabase
|
|
35
43
|
.from("products")
|
|
36
44
|
.select("id, plants_per_crate, crates_per_layer, layers_per_cart, custom_fields, trade_item_key")
|
|
37
|
-
.in("id", lookupIds)
|
|
45
|
+
.in("id", lookupIds)
|
|
46
|
+
.order("id")
|
|
47
|
+
.range(f, t)), "producten"),
|
|
38
48
|
]);
|
|
39
49
|
const packsById = new Map();
|
|
40
50
|
const push = (key, ppc, cpl, lpc, isDefault, crateCode, cartCode) => {
|
|
@@ -126,11 +136,12 @@ export async function computeBeladingByProduct(supabase, productIds) {
|
|
|
126
136
|
// Fust-omschrijvingen (Floricode/VBN) voor de weergave van het type.
|
|
127
137
|
const crateDescriptions = {};
|
|
128
138
|
{
|
|
129
|
-
const
|
|
139
|
+
const floricodeRows = await alleRijen((f, t) => supabase
|
|
130
140
|
.from("floricode_records")
|
|
131
141
|
.select("data")
|
|
132
142
|
.eq("resource", "LoadCarrier")
|
|
133
|
-
.
|
|
143
|
+
.order("record_id")
|
|
144
|
+
.range(f, t)).catch((e) => { console.error("[belading] fustomschrijvingen lezen mislukt:", e?.message ?? e); return []; });
|
|
134
145
|
for (const row of floricodeRows ?? []) {
|
|
135
146
|
const d = row.data ?? {};
|
|
136
147
|
if (d?.code == null)
|
|
@@ -9,6 +9,8 @@ export interface FormState {
|
|
|
9
9
|
/** Regels met product maar zonder (volledige) belading. */
|
|
10
10
|
linesWithoutBelading: number;
|
|
11
11
|
stockBlocked: boolean;
|
|
12
|
+
/** Regels met product maar zonder prijs > 0 (en 0 niet bewust bevestigd). */
|
|
13
|
+
linesWithoutPrice?: number;
|
|
12
14
|
previewPending: boolean;
|
|
13
15
|
previewBlockedReason: string | null;
|
|
14
16
|
}
|
|
@@ -44,6 +46,49 @@ export declare function applyFirstFeasible(s: {
|
|
|
44
46
|
export declare function attentionItems(s: {
|
|
45
47
|
linesWithoutPrice: number;
|
|
46
48
|
linesOverStock: number;
|
|
49
|
+
linesPriceError?: number;
|
|
47
50
|
}): string[];
|
|
51
|
+
export type OrderprijsBron = "klantprijs" | "prijsgroep" | "klantkorting" | "standaardprijs";
|
|
52
|
+
export interface Orderprijs {
|
|
53
|
+
net_price: number;
|
|
54
|
+
currency: string | null;
|
|
55
|
+
bron: string | null;
|
|
56
|
+
price_group_id: string | null;
|
|
57
|
+
price_group_name: string | null;
|
|
58
|
+
}
|
|
59
|
+
export type OrderprijsUitkomst = {
|
|
60
|
+
ok: true;
|
|
61
|
+
prijs: Orderprijs | null;
|
|
62
|
+
} | {
|
|
63
|
+
ok: false;
|
|
64
|
+
};
|
|
65
|
+
export declare const PRIJS_ONBEKEND_TEXT = "Geen prijs bekend; vul zelf een prijs in";
|
|
66
|
+
/** Prijs uit klanten_orderprijs die echt bekend is: net_price 0 betekent "geen prijs bekend" (artikel zonder verkoopprijs). */
|
|
67
|
+
export declare function bekendePrijs(p: Orderprijs | null | undefined): {
|
|
68
|
+
unit_price: number | null;
|
|
69
|
+
price_source: string | null;
|
|
70
|
+
};
|
|
71
|
+
/** Regel blokkeert aanmaken tot er een prijs > 0 is, of de gebruiker 0 bewust bevestigt. */
|
|
72
|
+
export declare function regelMistPrijs(l: {
|
|
73
|
+
product_id: string | null;
|
|
74
|
+
unit_price: number | null;
|
|
75
|
+
price_zero_ok?: boolean;
|
|
76
|
+
}): boolean;
|
|
77
|
+
export declare const PRIJS_FOUT_TEXT = "Prijs ophalen lukt niet; vul hem zelf in of probeer het opnieuw.";
|
|
78
|
+
/** "Prijsgroep: Groothandel", "Klantprijs", "Klantkorting", "Standaardprijs". */
|
|
79
|
+
export declare function prijsBronLabel(p: Pick<Orderprijs, "bron" | "price_group_name"> | null | undefined): string | null;
|
|
80
|
+
/** Eén rij uit klanten_orderprijs naar een prijs; geen geldige prijs = null (nooit 0 of een gok). */
|
|
81
|
+
export declare function parseOrderprijs(rows: unknown): Orderprijs | null;
|
|
82
|
+
/** Sleutel waarop een automatische prijs opnieuw wordt opgehaald. */
|
|
83
|
+
export declare function prijsSleutel(customerId: string | null, productId: string | null, datum: string, aantal: number | null): string | null;
|
|
84
|
+
/**
|
|
85
|
+
* Servercontrole handmatige order (createManualOrder): elke regel prijs > 0, of 0 met vinkje "Prijs 0 is juist".
|
|
86
|
+
* Eerste overtreding → "Vul een prijs in bij {artikel}."; alles goed → null.
|
|
87
|
+
*/
|
|
88
|
+
export declare function prijsRegelFout(lines: {
|
|
89
|
+
product_name?: string | null;
|
|
90
|
+
unit_price?: number | null;
|
|
91
|
+
price_zero_ok?: boolean;
|
|
92
|
+
}[]): string | null;
|
|
48
93
|
export {};
|
|
49
94
|
//# sourceMappingURL=create-order-form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-order-form.d.ts","sourceRoot":"","sources":["../../src/lib/create-order-form.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"create-order-form.d.ts","sourceRoot":"","sources":["../../src/lib/create-order-form.ts"],"names":[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G,IAAI,CAAC;IAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAGzH;AAED,4FAA4F;AAC5F,wBAAgB,cAAc,CAAC,CAAC,EAAE;IAAE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAK5H;AAED,eAAO,MAAM,eAAe,qEAAqE,CAAC;AAElG,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,kBAAkB,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CASjH;AAED,qGAAqG;AACrG,wBAAgB,eAAe,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,GAAG,IAAI,CAYhE;AAED,qEAAqE;AACrE,wBAAgB,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAGrI;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,GAAG,MAAM,GAAG,IAAI,CAU5I"}
|
|
@@ -15,6 +15,8 @@ export function missingItems(s) {
|
|
|
15
15
|
out.push("Voeg minimaal één product toe");
|
|
16
16
|
if (s.linesWithoutBelading > 0)
|
|
17
17
|
out.push(s.linesWithoutBelading === 1 ? "Kies een belading bij 1 regel" : `Kies een belading bij ${s.linesWithoutBelading} regels`);
|
|
18
|
+
if ((s.linesWithoutPrice ?? 0) > 0)
|
|
19
|
+
out.push(s.linesWithoutPrice === 1 ? "Vul een prijs in bij 1 regel" : `Vul een prijs in bij ${s.linesWithoutPrice} regels`);
|
|
18
20
|
if (s.stockBlocked)
|
|
19
21
|
out.push("Pas de aantallen aan: onvoldoende voorraad");
|
|
20
22
|
if (!s.isReservation && s.customerId && s.deliveryLocationId && s.pickupLocationId) {
|
|
@@ -71,9 +73,79 @@ export function applyFirstFeasible(s) {
|
|
|
71
73
|
export function attentionItems(s) {
|
|
72
74
|
const out = [];
|
|
73
75
|
const n = (k) => (k === 1 ? "1 regel" : `${k} regels`);
|
|
76
|
+
if ((s.linesPriceError ?? 0) > 0)
|
|
77
|
+
out.push(`Prijs ophalen lukt niet bij ${n(s.linesPriceError)}`);
|
|
74
78
|
if (s.linesWithoutPrice > 0)
|
|
75
79
|
out.push(`${n(s.linesWithoutPrice)} zonder prijs`);
|
|
76
80
|
if (s.linesOverStock > 0)
|
|
77
81
|
out.push(`${n(s.linesOverStock)} meer dan beschikbaar`);
|
|
78
82
|
return out;
|
|
79
83
|
}
|
|
84
|
+
export const PRIJS_ONBEKEND_TEXT = "Geen prijs bekend; vul zelf een prijs in";
|
|
85
|
+
/** Prijs uit klanten_orderprijs die echt bekend is: net_price 0 betekent "geen prijs bekend" (artikel zonder verkoopprijs). */
|
|
86
|
+
export function bekendePrijs(p) {
|
|
87
|
+
if (!p || !(p.net_price > 0))
|
|
88
|
+
return { unit_price: null, price_source: null };
|
|
89
|
+
return { unit_price: p.net_price, price_source: prijsBronLabel(p) };
|
|
90
|
+
}
|
|
91
|
+
/** Regel blokkeert aanmaken tot er een prijs > 0 is, of de gebruiker 0 bewust bevestigt. */
|
|
92
|
+
export function regelMistPrijs(l) {
|
|
93
|
+
if (!l.product_id)
|
|
94
|
+
return false;
|
|
95
|
+
const p = Number(l.unit_price);
|
|
96
|
+
if (l.unit_price != null && p > 0)
|
|
97
|
+
return false;
|
|
98
|
+
return !(l.price_zero_ok && l.unit_price != null && p === 0);
|
|
99
|
+
}
|
|
100
|
+
export const PRIJS_FOUT_TEXT = "Prijs ophalen lukt niet; vul hem zelf in of probeer het opnieuw.";
|
|
101
|
+
/** "Prijsgroep: Groothandel", "Klantprijs", "Klantkorting", "Standaardprijs". */
|
|
102
|
+
export function prijsBronLabel(p) {
|
|
103
|
+
if (!p?.bron)
|
|
104
|
+
return null;
|
|
105
|
+
switch (p.bron) {
|
|
106
|
+
case "klantprijs": return "Klantprijs";
|
|
107
|
+
case "prijsgroep": return p.price_group_name ? `Prijsgroep: ${p.price_group_name}` : "Prijsgroep";
|
|
108
|
+
case "klantkorting": return "Klantkorting";
|
|
109
|
+
case "standaardprijs": return "Standaardprijs";
|
|
110
|
+
default: return null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** Eén rij uit klanten_orderprijs naar een prijs; geen geldige prijs = null (nooit 0 of een gok). */
|
|
114
|
+
export function parseOrderprijs(rows) {
|
|
115
|
+
const r = Array.isArray(rows) ? rows[0] : rows;
|
|
116
|
+
if (!r)
|
|
117
|
+
return null;
|
|
118
|
+
const net = Number(r.net_price);
|
|
119
|
+
if (r.net_price == null || !Number.isFinite(net) || net < 0)
|
|
120
|
+
return null;
|
|
121
|
+
return {
|
|
122
|
+
net_price: net,
|
|
123
|
+
currency: r.currency ?? null,
|
|
124
|
+
bron: r.bron ?? null,
|
|
125
|
+
price_group_id: r.price_group_id ?? null,
|
|
126
|
+
price_group_name: r.price_group_name ?? null,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/** Sleutel waarop een automatische prijs opnieuw wordt opgehaald. */
|
|
130
|
+
export function prijsSleutel(customerId, productId, datum, aantal) {
|
|
131
|
+
if (!customerId || !productId || customerId.startsWith("twinfield:"))
|
|
132
|
+
return null;
|
|
133
|
+
return `${customerId}|${productId}|${datum}|${aantal ?? ""}`;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Servercontrole handmatige order (createManualOrder): elke regel prijs > 0, of 0 met vinkje "Prijs 0 is juist".
|
|
137
|
+
* Eerste overtreding → "Vul een prijs in bij {artikel}."; alles goed → null.
|
|
138
|
+
*/
|
|
139
|
+
export function prijsRegelFout(lines) {
|
|
140
|
+
for (let i = 0; i < lines.length; i++) {
|
|
141
|
+
const l = lines[i];
|
|
142
|
+
const p = l.unit_price == null ? NaN : Number(l.unit_price);
|
|
143
|
+
if (p > 0)
|
|
144
|
+
continue;
|
|
145
|
+
if (p === 0 && l.price_zero_ok === true)
|
|
146
|
+
continue;
|
|
147
|
+
const naam = String(l.product_name ?? "").trim() || `regel ${i + 1}`;
|
|
148
|
+
return `Vul een prijs in bij ${naam}.`;
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
@@ -115,6 +115,7 @@ export declare const listCarriersForCreateOrder: import("@tanstack/start-client-
|
|
|
115
115
|
pickup_weekdays: number[];
|
|
116
116
|
delivery_weekdays: number[];
|
|
117
117
|
pickup_moments: import("../integrations/supabase/types.js").Json;
|
|
118
|
+
carrier_kind: string | null;
|
|
118
119
|
}[];
|
|
119
120
|
}>>;
|
|
120
121
|
export declare const listBeladingOptionsForProducts: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
@@ -163,6 +164,7 @@ export declare const createManualOrder: import("@tanstack/start-client-core").Op
|
|
|
163
164
|
quantity: number;
|
|
164
165
|
unit?: string | null | undefined;
|
|
165
166
|
unit_price?: number | undefined;
|
|
167
|
+
price_zero_ok?: boolean | undefined;
|
|
166
168
|
plants_per_crate?: number | undefined;
|
|
167
169
|
crates_per_layer?: number | undefined;
|
|
168
170
|
layers_per_cart?: number | undefined;
|
|
@@ -185,6 +187,7 @@ export declare const createManualOrder: import("@tanstack/start-client-core").Op
|
|
|
185
187
|
ownTransport?: boolean | undefined;
|
|
186
188
|
confirmZeroPrice?: boolean | undefined;
|
|
187
189
|
ownTransportPickupAt?: string | null | undefined;
|
|
190
|
+
ownPickupTime?: string | null | undefined;
|
|
188
191
|
}, Promise<{
|
|
189
192
|
ok: true;
|
|
190
193
|
orderId: string;
|
|
@@ -315,6 +318,24 @@ export declare const getEffectivePrices: import("@tanstack/start-client-core").O
|
|
|
315
318
|
price: number;
|
|
316
319
|
source: string | null;
|
|
317
320
|
} | null>>>;
|
|
321
|
+
export declare const getOrderPrices: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
322
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
323
|
+
userId: string;
|
|
324
|
+
claims: import("@supabase/auth-js").User;
|
|
325
|
+
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
326
|
+
customerId: string;
|
|
327
|
+
lines: {
|
|
328
|
+
productId: string;
|
|
329
|
+
quantity?: number | undefined;
|
|
330
|
+
}[];
|
|
331
|
+
onDate?: string | undefined;
|
|
332
|
+
}, Promise<({
|
|
333
|
+
ok: false;
|
|
334
|
+
prijs?: undefined;
|
|
335
|
+
} | {
|
|
336
|
+
ok: true;
|
|
337
|
+
prijs: import("./create-order-form.js").Orderprijs | null;
|
|
338
|
+
})[]>>;
|
|
318
339
|
export declare const listCustomerStickerProducts: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
319
340
|
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
320
341
|
userId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,2BAA2B;;;;;;YAwBpB,MAAM;sBACc,MAAM,GAAG,IAAI;yBACG,MAAM,GAAG,IAAI;cACnC,MAAM,GAAG,IAAI;eACX,MAAM,GAAG,IAAI;wBACK,MAAM,GAAG,IAAI;gBACvC,MAAM;;;GAkB9B,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,GAAG,IAAI;0BACb,MAAM,GAAG,IAAI;yBACd,MAAM,GAAG,IAAI;wBACd,MAAM;wBACN,MAAM;yBACL,MAAM;kBACb,OAAO;gBACT,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS;;GA6TpD,CAAC;AAGL,eAAO,MAAM,kCAAkC;;;;0CAEzB,OAAO;;;;;;;;;;;;;;;;;;;;;;GAkDzB,CAAC;AAOL,eAAO,MAAM,uBAAuB;;;;0CAEd,OAAO;;;;GAWzB,CAAC;AAKL,eAAO,MAAM,qBAAqB;;;;;;;;;;YAuCI,MAAM;;;;;GAIxC,CAAC;AAGL,eAAO,MAAM,0BAA0B
|
|
1
|
+
{"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,2BAA2B;;;;;;YAwBpB,MAAM;sBACc,MAAM,GAAG,IAAI;yBACG,MAAM,GAAG,IAAI;cACnC,MAAM,GAAG,IAAI;eACX,MAAM,GAAG,IAAI;wBACK,MAAM,GAAG,IAAI;gBACvC,MAAM;;;GAkB9B,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,GAAG,IAAI;0BACb,MAAM,GAAG,IAAI;yBACd,MAAM,GAAG,IAAI;wBACd,MAAM;wBACN,MAAM;yBACL,MAAM;kBACb,OAAO;gBACT,UAAU,GAAG,OAAO,GAAG,OA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AAG,IAAI;WAmBhE,CAAC;AAML,eAAO,MAAM,cAAc;;;;8CAED,OAAO;;;;;;;;;;;;;MA+B7B,CAAC;AAML,eAAO,MAAM,2BAA2B;;;;8CAEd,OAAO;;;;gBAIgC,MAAM,EAAE;GAoCrE,CAAC"}
|
|
@@ -624,7 +624,7 @@ export const listCarriersForCreateOrder = createServerFn({ method: "GET" })
|
|
|
624
624
|
.handler(async ({ context }) => {
|
|
625
625
|
const { data, error } = await context.supabase
|
|
626
626
|
.from("carriers")
|
|
627
|
-
.select("id, name, is_default, sort_order, delivery_days, signup_time_1, signup_time_2, signup_days_before_delivery, pickup_weekdays, delivery_weekdays, pickup_moments")
|
|
627
|
+
.select("id, name, is_default, sort_order, delivery_days, signup_time_1, signup_time_2, signup_days_before_delivery, pickup_weekdays, delivery_weekdays, pickup_moments, carrier_kind")
|
|
628
628
|
.order("sort_order", { ascending: true, nullsFirst: false })
|
|
629
629
|
.order("name");
|
|
630
630
|
// Fout niet inslikken: het scherm toont hem.
|
|
@@ -724,6 +724,8 @@ const LineInput = z.object({
|
|
|
724
724
|
quantity: z.number().int().positive(), // aantal PLANTEN (== fusten * plants_per_crate)
|
|
725
725
|
unit: z.string().max(50).nullable().optional(),
|
|
726
726
|
unit_price: z.number().nonnegative().optional(),
|
|
727
|
+
// Gebruiker bevestigt bewust prijs 0 op deze regel ("Prijs 0 is juist").
|
|
728
|
+
price_zero_ok: z.boolean().optional(),
|
|
727
729
|
// Packing-info uit voorraadmodule; nodig om ontbrekende products-rij aan te maken
|
|
728
730
|
plants_per_crate: z.number().int().positive().optional(),
|
|
729
731
|
crates_per_layer: z.number().int().positive().optional(),
|
|
@@ -791,14 +793,17 @@ const CreateManualOrderInput = z.object({
|
|
|
791
793
|
// Prijs € 0 op een regel moet uitdrukkelijk bevestigd zijn.
|
|
792
794
|
confirmZeroPrice: z.boolean().optional(),
|
|
793
795
|
ownTransportPickupAt: z.string().regex(/(Z|[+-]\d{2}:\d{2})$/, "Tijd zonder tijdzone").nullable().optional(),
|
|
796
|
+
// Vertrek-/ophaaltijd (HH:MM, Europe/Amsterdam) bij eigen vervoer of klant haalt op.
|
|
797
|
+
ownPickupTime: z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/).nullable().optional(),
|
|
794
798
|
});
|
|
795
799
|
export const createManualOrder = createServerFn({ method: "POST" })
|
|
796
800
|
.middleware([requireSupabaseAuth])
|
|
797
801
|
.inputValidator((input) => CreateManualOrderInput.parse(input))
|
|
798
802
|
.handler(async ({ data, context }) => {
|
|
799
803
|
{
|
|
800
|
-
|
|
801
|
-
const
|
|
804
|
+
// Prijs 0 alleen met het vinkje "Prijs 0 is juist" per regel (confirmZeroPrice blijft alleen voor oude aanroepers in het schema).
|
|
805
|
+
const { prijsRegelFout } = await import("./create-order-form.js");
|
|
806
|
+
const refusal = prijsRegelFout(data.lines);
|
|
802
807
|
if (refusal)
|
|
803
808
|
throw stockError(refusal);
|
|
804
809
|
}
|
|
@@ -829,6 +834,19 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
829
834
|
.order("name", { ascending: true }).limit(1).maybeSingle();
|
|
830
835
|
ownCarrierId = oc?.id ?? null;
|
|
831
836
|
}
|
|
837
|
+
// Eigen vervoer of een handmatig gekozen vervoerder van soort eigen_vervoer/
|
|
838
|
+
// klant_haalt_op: pickup_moment = "YYYY-MM-DD|HH:MM", leeg zonder gekozen tijd.
|
|
839
|
+
let ownPickupKind = ownTransport;
|
|
840
|
+
if (!ownPickupKind && carrierId) {
|
|
841
|
+
const { data: ck } = await context.supabase.from("carriers").select("carrier_kind").eq("id", carrierId).maybeSingle();
|
|
842
|
+
const { isOwnTransportKind } = await import("./own-transport.js");
|
|
843
|
+
ownPickupKind = isOwnTransportKind(ck?.carrier_kind);
|
|
844
|
+
}
|
|
845
|
+
let ownPickupMoment = null;
|
|
846
|
+
if (ownPickupKind && !data.isReservation && data.deliveryDate) {
|
|
847
|
+
const { buildOwnPickupMoment } = await import("./own-transport.js");
|
|
848
|
+
ownPickupMoment = buildOwnPickupMoment(data.deliveryDate, data.ownPickupTime ?? null);
|
|
849
|
+
}
|
|
832
850
|
let momentKey = null;
|
|
833
851
|
let deliveryTime = null;
|
|
834
852
|
let lateSignup = null;
|
|
@@ -1016,12 +1034,18 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
1016
1034
|
delivery_location: data.deliveryLocationId,
|
|
1017
1035
|
pickup_location: data.pickupLocationId,
|
|
1018
1036
|
delivery_time: deliveryTime,
|
|
1019
|
-
pickup_moment: momentKey,
|
|
1037
|
+
pickup_moment: ownPickupKind ? ownPickupMoment : momentKey,
|
|
1020
1038
|
...(lateSignup ? { late_signup_override: lateSignup } : {}),
|
|
1021
1039
|
...(ownTransportInfo ? { own_transport: ownTransportInfo } : {}),
|
|
1022
1040
|
...(data.customerReference ? { customer_reference: data.customerReference } : {}),
|
|
1041
|
+
// Per regel vastgelegd welke prijs 0 bewust is bevestigd (verkoop_insert_manual_order neemt geen regelvelden buiten de vaste kolommen over).
|
|
1023
1042
|
...(data.lines.some((l) => !(Number(l.unit_price) > 0))
|
|
1024
|
-
? { zero_price_confirmed: {
|
|
1043
|
+
? { zero_price_confirmed: {
|
|
1044
|
+
by: context.userId ?? "server",
|
|
1045
|
+
at: new Date().toISOString(),
|
|
1046
|
+
lines: data.lines.filter((l) => !(Number(l.unit_price) > 0)).length,
|
|
1047
|
+
items: data.lines.filter((l) => !(Number(l.unit_price) > 0)).map((l) => ({ product_id: l.product_id, product_name: l.product_name, price_zero_ok: l.price_zero_ok === true })),
|
|
1048
|
+
} }
|
|
1025
1049
|
: {}),
|
|
1026
1050
|
is_reservation: !!data.isReservation,
|
|
1027
1051
|
load_carrier_type: loadCarrierType,
|
|
@@ -1816,6 +1840,40 @@ export const getEffectivePrices = createServerFn({ method: "POST" })
|
|
|
1816
1840
|
}
|
|
1817
1841
|
return out;
|
|
1818
1842
|
});
|
|
1843
|
+
// ─── Orderprijs via klanten_orderprijs (module Klanten) ─────────────────────
|
|
1844
|
+
// Per regel één aanroep. Een fout geeft ok:false voor die regel — het scherm
|
|
1845
|
+
// toont dan een melding en vult nooit stil een andere prijs in.
|
|
1846
|
+
export const getOrderPrices = createServerFn({ method: "POST" })
|
|
1847
|
+
.middleware([requireSupabaseAuth])
|
|
1848
|
+
.inputValidator((input) => z
|
|
1849
|
+
.object({
|
|
1850
|
+
customerId: z.string().uuid(),
|
|
1851
|
+
onDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
1852
|
+
lines: z.array(z.object({ productId: z.string().uuid(), quantity: z.number().positive().optional() })).max(200),
|
|
1853
|
+
})
|
|
1854
|
+
.parse(input))
|
|
1855
|
+
.handler(async ({ data, context }) => {
|
|
1856
|
+
const { parseOrderprijs } = await import("./create-order-form.js");
|
|
1857
|
+
return await Promise.all(data.lines.map(async (l) => {
|
|
1858
|
+
try {
|
|
1859
|
+
const { data: rows, error } = await context.supabase.rpc("klanten_orderprijs", {
|
|
1860
|
+
p_customer_id: data.customerId,
|
|
1861
|
+
p_product_id: l.productId,
|
|
1862
|
+
...(data.onDate ? { p_datum: data.onDate } : {}),
|
|
1863
|
+
...(l.quantity ? { p_aantal: l.quantity } : {}),
|
|
1864
|
+
});
|
|
1865
|
+
if (error) {
|
|
1866
|
+
console.error("[orderprijs] klanten_orderprijs mislukt:", error.message);
|
|
1867
|
+
return { ok: false };
|
|
1868
|
+
}
|
|
1869
|
+
return { ok: true, prijs: parseOrderprijs(rows) };
|
|
1870
|
+
}
|
|
1871
|
+
catch (e) {
|
|
1872
|
+
console.error("[orderprijs] klanten_orderprijs mislukt:", e?.message ?? e);
|
|
1873
|
+
return { ok: false };
|
|
1874
|
+
}
|
|
1875
|
+
}));
|
|
1876
|
+
});
|
|
1819
1877
|
// ─── Standaard stickervinkje bij een nieuwe bestelling ──────────────────────
|
|
1820
1878
|
// Vinkje vooraf aan als er voor deze klant + dit product een vaste klantsticker
|
|
1821
1879
|
// bestaat (customer_product_stickers). Alleen lezen; matcht op id/code, nooit
|
|
@@ -234,7 +234,7 @@ async function mirrorUnlocked(limit, since, onlyIds = null) {
|
|
|
234
234
|
cacheRows = cacheRows.concat((more ?? []));
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
|
-
const rows = (cacheRows ?? []);
|
|
237
|
+
const rows = await (await import("./klok-sales.server.js")).claimKlokVerkopen((cacheRows ?? []));
|
|
238
238
|
if (rows.length === 0) {
|
|
239
239
|
// Ook zonder nieuwe Floriday-gegevens: orders koppelen aan klanten die
|
|
240
240
|
// inmiddels (bijv. door de Klanten-module) zijn aangemaakt.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
export type KlokVervoer = "geen" | "eigen" | "transporteur";
|
|
2
|
+
export interface KlokKop {
|
|
3
|
+
veillocatie_id: string | null;
|
|
4
|
+
veillocatie_naam: string | null;
|
|
5
|
+
veillocatie_gln: string | null;
|
|
6
|
+
veillocatie_org_id: string | null;
|
|
7
|
+
veildatum: string | null;
|
|
8
|
+
veilgroep: string | null;
|
|
9
|
+
verzendlocatie_id: string | null;
|
|
10
|
+
verzendlocatie_naam: string | null;
|
|
11
|
+
vervoer: KlokVervoer;
|
|
12
|
+
carrier_org_id: string | null;
|
|
13
|
+
}
|
|
14
|
+
export interface KlokKeurcode {
|
|
15
|
+
vbnCode: string;
|
|
16
|
+
vbnValueCode: string;
|
|
17
|
+
}
|
|
18
|
+
export interface KlokRegel {
|
|
19
|
+
key: string;
|
|
20
|
+
product_id: string | null;
|
|
21
|
+
trade_item_id: string | null;
|
|
22
|
+
product_name: string;
|
|
23
|
+
vbn_product_code: string | null;
|
|
24
|
+
fusten: number | null;
|
|
25
|
+
stuks_per_fust: number | null;
|
|
26
|
+
fust_per_laag: number | null;
|
|
27
|
+
lagen_per_kar: number | null;
|
|
28
|
+
vbn_package_code: string | null;
|
|
29
|
+
load_carrier: string | null;
|
|
30
|
+
custom_package_id: string | null;
|
|
31
|
+
min_prijs: number | null;
|
|
32
|
+
voorverkoop_prijs: number | null;
|
|
33
|
+
/** Wanneer de voorgestelde prijs voor het laatst echt is gebruikt. */
|
|
34
|
+
prijs_at: string | null;
|
|
35
|
+
/** false = voorstel (grijs) dat de gebruiker nog moet bevestigen. */
|
|
36
|
+
prijs_bevestigd: boolean;
|
|
37
|
+
kwaliteit: string | null;
|
|
38
|
+
keurcodes: KlokKeurcode[];
|
|
39
|
+
veil_opmerking: string | null;
|
|
40
|
+
aflever_opmerking: string | null;
|
|
41
|
+
}
|
|
42
|
+
export declare const LEGE_KOP: KlokKop;
|
|
43
|
+
/** Wat ontbreekt nog vóór versturen (concept opslaan mag altijd). */
|
|
44
|
+
export declare function klokOntbreekt(kop: KlokKop, regels: KlokRegel[]): string[];
|
|
45
|
+
/** Prijs overnemen uit een eerdere veilbrief/sjabloon: oud = voorstel. */
|
|
46
|
+
export declare function neemPrijsOver(r: KlokRegel, now?: Date): KlokRegel;
|
|
47
|
+
/** Geheel getal uit tekst of getal ("28" → 28); anders null. Floriday eist gehele getallen. */
|
|
48
|
+
export declare function alsGeheelGetal(v: unknown): number | null;
|
|
49
|
+
/** Veld op het scherm: "veillocatie" | "veildatum" | "veilgroep" | "verzendlocatie" | "regel:<key>:<deel>". */
|
|
50
|
+
export type KlokVeld = string;
|
|
51
|
+
export interface KlokFout {
|
|
52
|
+
tekst: string;
|
|
53
|
+
veld: KlokVeld | null;
|
|
54
|
+
}
|
|
55
|
+
/** Weigering van Floriday als lijst: één regel per fout, met het veld waar hij bij hoort. */
|
|
56
|
+
export declare function klokFoutLijst(errors: unknown[] | undefined, reason: string | undefined, regels: KlokRegel[]): KlokFout[];
|
|
57
|
+
/** Velden die rood moeten bij "Ontbreekt nog" (zelfde teksten als klokOntbreekt). */
|
|
58
|
+
export declare function klokOntbreektVelden(kop: KlokKop, regels: KlokRegel[]): Set<KlokVeld>;
|
|
59
|
+
//# sourceMappingURL=klok-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"klok-form.d.ts","sour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ruikt dezelfde controle vóór versturen.
|
|
3
|
+
import { isGeldigeVeilgroep, klokPrijsVerouderd } from "./klok-labels.js";
|
|
4
|
+
export const LEGE_KOP = {
|
|
5
|
+
veillocatie_id: null,
|
|
6
|
+
veillocatie_naam: null,
|
|
7
|
+
veillocatie_gln: null,
|
|
8
|
+
veillocatie_org_id: null,
|
|
9
|
+
veildatum: null,
|
|
10
|
+
veilgroep: null,
|
|
11
|
+
verzendlocatie_id: null,
|
|
12
|
+
verzendlocatie_naam: null,
|
|
13
|
+
vervoer: "geen",
|
|
14
|
+
carrier_org_id: null,
|
|
15
|
+
};
|
|
16
|
+
/** Wat ontbreekt nog vóór versturen (concept opslaan mag altijd). */
|
|
17
|
+
export function klokOntbreekt(kop, regels) {
|
|
18
|
+
const out = [];
|
|
19
|
+
if (!kop.veillocatie_id)
|
|
20
|
+
out.push("Veillocatie");
|
|
21
|
+
if (!kop.veildatum)
|
|
22
|
+
out.push("Veildatum");
|
|
23
|
+
if (!kop.veilgroep)
|
|
24
|
+
out.push("Veilgroep");
|
|
25
|
+
else if (!isGeldigeVeilgroep(kop.veilgroep))
|
|
26
|
+
out.push("Veilgroep (alleen cijfers)");
|
|
27
|
+
if (!kop.verzendlocatie_id)
|
|
28
|
+
out.push("Verzendlocatie");
|
|
29
|
+
if (regels.length === 0)
|
|
30
|
+
out.push("Minimaal één regel");
|
|
31
|
+
regels.forEach((r, i) => {
|
|
32
|
+
const n = `Regel ${i + 1}`;
|
|
33
|
+
if (!r.trade_item_id)
|
|
34
|
+
out.push(`${n}: artikel uit Floriday`);
|
|
35
|
+
if (!(Number(r.fusten) > 0))
|
|
36
|
+
out.push(`${n}: fusten`);
|
|
37
|
+
if (!(Number(r.stuks_per_fust) > 0))
|
|
38
|
+
out.push(`${n}: stuks per fust`);
|
|
39
|
+
if (r.trade_item_id && alsGeheelGetal(r.vbn_package_code) == null)
|
|
40
|
+
out.push(`${n}: fust (geen geldig fustnummer)`);
|
|
41
|
+
if (!(Number(r.min_prijs) > 0))
|
|
42
|
+
out.push(`${n}: minimumprijs`);
|
|
43
|
+
else if (!r.prijs_bevestigd)
|
|
44
|
+
out.push(`${n}: minimumprijs bevestigen`);
|
|
45
|
+
});
|
|
46
|
+
return out;
|
|
47
|
+
}
|
|
48
|
+
/** Prijs overnemen uit een eerdere veilbrief/sjabloon: oud = voorstel. */
|
|
49
|
+
export function neemPrijsOver(r, now = new Date()) {
|
|
50
|
+
if (r.min_prijs == null)
|
|
51
|
+
return { ...r, prijs_bevestigd: false };
|
|
52
|
+
return { ...r, prijs_bevestigd: !klokPrijsVerouderd(r.prijs_at, now) };
|
|
53
|
+
}
|
|
54
|
+
/** Geheel getal uit tekst of getal ("28" → 28); anders null. Floriday eist gehele getallen. */
|
|
55
|
+
export function alsGeheelGetal(v) {
|
|
56
|
+
if (v == null)
|
|
57
|
+
return null;
|
|
58
|
+
const s = String(v).trim();
|
|
59
|
+
if (!/^\d+$/.test(s))
|
|
60
|
+
return null;
|
|
61
|
+
const n = Number(s);
|
|
62
|
+
return Number.isSafeInteger(n) ? n : null;
|
|
63
|
+
}
|
|
64
|
+
const KOPVELDEN = [
|
|
65
|
+
[/veilgroep|auctionGroup/i, "veilgroep"],
|
|
66
|
+
[/veillocatie|auctionLocation/i, "veillocatie"],
|
|
67
|
+
[/veildatum|auctionDate/i, "veildatum"],
|
|
68
|
+
[/verzendlocatie|despatchWarehouse/i, "verzendlocatie"],
|
|
69
|
+
];
|
|
70
|
+
function regelDeel(t) {
|
|
71
|
+
if (/minimumprijs|minimumPrice|prijs/i.test(t))
|
|
72
|
+
return "prijs";
|
|
73
|
+
if (/stuks|piecesPerPackage/i.test(t))
|
|
74
|
+
return "stuks";
|
|
75
|
+
if (/fusten|numberOfPackages|aantal/i.test(t))
|
|
76
|
+
return "fusten";
|
|
77
|
+
if (/fust|vbnPackageCode|packing/i.test(t))
|
|
78
|
+
return "fust";
|
|
79
|
+
return "artikel";
|
|
80
|
+
}
|
|
81
|
+
/** Weigering van Floriday als lijst: één regel per fout, met het veld waar hij bij hoort. */
|
|
82
|
+
export function klokFoutLijst(errors, reason, regels) {
|
|
83
|
+
const out = [];
|
|
84
|
+
for (const e of errors ?? []) {
|
|
85
|
+
const o = e;
|
|
86
|
+
const tekst = typeof o === "string" ? o : String(o?.message ?? o?.reason ?? "");
|
|
87
|
+
if (!tekst)
|
|
88
|
+
continue;
|
|
89
|
+
const pad = typeof o === "object" && o ? String(o.path ?? o.field ?? "") : "";
|
|
90
|
+
const hooi = `${pad} ${tekst}`;
|
|
91
|
+
let veld = null;
|
|
92
|
+
const m = /lines?\[?\.?(\d+)/i.exec(pad);
|
|
93
|
+
let regelIdx = m ? Number(m[1]) : -1;
|
|
94
|
+
if (regelIdx < 0)
|
|
95
|
+
regelIdx = regels.findIndex((r) => r.product_name && tekst.includes(r.product_name));
|
|
96
|
+
if (regelIdx < 0) {
|
|
97
|
+
const rm = /regel\s+(\d+)/i.exec(tekst);
|
|
98
|
+
if (rm)
|
|
99
|
+
regelIdx = Number(rm[1]) - 1;
|
|
100
|
+
}
|
|
101
|
+
if (regelIdx >= 0 && regels[regelIdx])
|
|
102
|
+
veld = `regel:${regels[regelIdx].key}:${regelDeel(hooi)}`;
|
|
103
|
+
else
|
|
104
|
+
veld = KOPVELDEN.find(([re]) => re.test(hooi))?.[1] ?? null;
|
|
105
|
+
out.push({ tekst, veld });
|
|
106
|
+
}
|
|
107
|
+
if (!out.length && reason)
|
|
108
|
+
out.push({ tekst: reason, veld: KOPVELDEN.find(([re]) => re.test(reason))?.[1] ?? null });
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
/** Velden die rood moeten bij "Ontbreekt nog" (zelfde teksten als klokOntbreekt). */
|
|
112
|
+
export function klokOntbreektVelden(kop, regels) {
|
|
113
|
+
const s = new Set();
|
|
114
|
+
for (const t of klokOntbreekt(kop, regels)) {
|
|
115
|
+
const rm = /^Regel (\d+): (.*)$/.exec(t);
|
|
116
|
+
if (rm) {
|
|
117
|
+
const r = regels[Number(rm[1]) - 1];
|
|
118
|
+
if (r)
|
|
119
|
+
s.add(`regel:${r.key}:${regelDeel(rm[2])}`);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const k = KOPVELDEN.find(([re]) => re.test(t));
|
|
123
|
+
if (k)
|
|
124
|
+
s.add(k[1]);
|
|
125
|
+
}
|
|
126
|
+
return s;
|
|
127
|
+
}
|