@flowselections/floriday-verkoop-module 1.0.87 → 1.0.90
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/CreateOrderPage.js +1 -1
- package/dist-lib/components/verkoop/DiagnoseConnectionDialog.js +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.js +3 -3
- package/dist-lib/components/verkoop/OrderControlStatusCard.js +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.js +2 -2
- package/dist-lib/components/verkoop/OrderLinePackingCard.js +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.js +1 -1
- package/dist-lib/components/verkoop/ProductDimensionsSettings.js +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +12 -12
- package/dist-lib/components/verkoop/SalesOrdersFilterPanel.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.js +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.js +2 -2
- package/dist-lib/components/verkoop/StockConsumptionAlertsBanner.js +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +15 -15
- package/dist-lib/index.d.ts +4 -5
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +5 -6
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +1 -1
- package/dist-lib/lib/belading.server.js +1 -1
- package/dist-lib/lib/buffer-events.functions.d.ts +1 -1
- package/dist-lib/lib/buffer-events.functions.js +1 -1
- package/dist-lib/lib/cart-layers.functions.d.ts +4 -4
- package/dist-lib/lib/cart-layers.functions.js +2 -2
- package/dist-lib/lib/cart-lock.functions.d.ts +1 -1
- package/dist-lib/lib/cart-lock.functions.js +2 -2
- package/dist-lib/lib/cart-planning-settings.functions.d.ts +11 -11
- package/dist-lib/lib/cart-planning-settings.functions.js +1 -1
- package/dist-lib/lib/cart-replan.functions.d.ts +4 -4
- package/dist-lib/lib/cart-replan.functions.js +9 -9
- package/dist-lib/lib/create-order.functions.d.ts +18 -18
- package/dist-lib/lib/create-order.functions.js +15 -15
- package/dist-lib/lib/cron/index.d.ts +3 -3
- package/dist-lib/lib/cron/index.js +3 -3
- package/dist-lib/lib/cron/invoice-due.js +1 -1
- package/dist-lib/lib/cron/sync-salesorders.js +2 -2
- package/dist-lib/lib/cron/sync-tradeitems.js +1 -1
- package/dist-lib/lib/engine-block-alerts.server.js +4 -4
- package/dist-lib/lib/expand-group-order-items.d.ts +1 -1
- package/dist-lib/lib/floriday-change-diff.check.js +2 -2
- package/dist-lib/lib/floriday-gateway.server.d.ts +1 -1
- package/dist-lib/lib/floriday-gateway.server.js +2 -2
- package/dist-lib/lib/floriday-logistic-labels.functions.d.ts +2 -2
- package/dist-lib/lib/floriday-logistic-labels.functions.js +5 -5
- package/dist-lib/lib/floriday-mirror.functions.d.ts +1 -1
- package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.functions.js +19 -12
- package/dist-lib/lib/floriday-public.functions.d.ts +7 -7
- package/dist-lib/lib/floriday-public.functions.js +2 -2
- package/dist-lib/lib/floriday-status.d.ts +1 -1
- package/dist-lib/lib/floriday-status.server.d.ts +1 -1
- package/dist-lib/lib/floriday-status.server.js +2 -2
- package/dist-lib/lib/floriday-sync.js +1 -1
- package/dist-lib/lib/floriday-unlinked-products.js +1 -1
- package/dist-lib/lib/floriday-writes.functions.d.ts +3 -3
- package/dist-lib/lib/floriday-writes.functions.js +3 -3
- package/dist-lib/lib/invoice-timing.functions.d.ts +5 -5
- package/dist-lib/lib/invoice-timing.functions.js +8 -8
- package/dist-lib/lib/invoice-timing.server.d.ts +8 -3
- package/dist-lib/lib/invoice-timing.server.d.ts.map +1 -1
- package/dist-lib/lib/invoice-timing.server.js +70 -34
- package/dist-lib/lib/load-carriers.functions.d.ts +2 -2
- package/dist-lib/lib/load-carriers.functions.js +2 -2
- package/dist-lib/lib/load-carriers.server.d.ts +1 -1
- package/dist-lib/lib/load-carriers.server.js +1 -1
- package/dist-lib/lib/logistics-buffer.server.js +1 -1
- package/dist-lib/lib/logistics-engine.functions.d.ts +8 -8
- package/dist-lib/lib/logistics-engine.functions.js +6 -6
- package/dist-lib/lib/logistics-engine.server.d.ts +1 -1
- package/dist-lib/lib/logistics-engine.server.js +4 -4
- package/dist-lib/lib/logistics-stock.functions.d.ts +3 -3
- package/dist-lib/lib/logistics-stock.functions.js +3 -3
- package/dist-lib/lib/order-addresses.functions.d.ts +1 -1
- package/dist-lib/lib/order-addresses.functions.js +2 -2
- package/dist-lib/lib/order-block-mail.server.js +3 -3
- package/dist-lib/lib/order-buffers.functions.d.ts +3 -3
- package/dist-lib/lib/order-buffers.functions.js +3 -3
- package/dist-lib/lib/order-cancel.server.js +6 -6
- package/dist-lib/lib/order-carrier.functions.d.ts +2 -2
- package/dist-lib/lib/order-carrier.functions.js +2 -2
- package/dist-lib/lib/order-fulfill.functions.d.ts +1 -1
- package/dist-lib/lib/order-fulfill.functions.js +3 -3
- package/dist-lib/lib/order-item-packing.functions.d.ts +3 -3
- package/dist-lib/lib/order-item-packing.functions.js +3 -3
- package/dist-lib/lib/order-patch.check.d.ts +2 -0
- package/dist-lib/lib/order-patch.check.d.ts.map +1 -0
- package/dist-lib/lib/order-patch.check.js +40 -0
- package/dist-lib/lib/order-patch.d.ts +18 -0
- package/dist-lib/lib/order-patch.d.ts.map +1 -0
- package/dist-lib/lib/order-patch.js +105 -0
- package/dist-lib/lib/order-pickup.functions.d.ts +2 -2
- package/dist-lib/lib/order-pickup.functions.js +3 -3
- package/dist-lib/lib/order-shipments.functions.d.ts +4 -4
- package/dist-lib/lib/order-shipments.functions.js +6 -6
- package/dist-lib/lib/plan-coverage.check.js +1 -1
- package/dist-lib/lib/plan-coverage.server.d.ts +1 -1
- package/dist-lib/lib/plan-coverage.server.js +1 -1
- package/dist-lib/lib/product-dimensions.functions.d.ts +2 -2
- package/dist-lib/lib/product-dimensions.functions.js +1 -1
- package/dist-lib/lib/salesorders-list.functions.d.ts +5 -5
- package/dist-lib/lib/salesorders-list.functions.js +4 -4
- package/dist-lib/lib/salesorders-list.server.d.ts +2 -2
- package/dist-lib/lib/salesorders-list.server.js +17 -17
- package/dist-lib/lib/salesorders-mapping.d.ts +3 -3
- package/dist-lib/lib/salesorders-mapping.js +2 -2
- package/dist-lib/lib/salesorders.functions.d.ts +7 -7
- package/dist-lib/lib/salesorders.functions.js +20 -20
- package/dist-lib/lib/stock-consumption-alerts.functions.d.ts +2 -2
- package/dist-lib/lib/stock-consumption-alerts.functions.js +1 -1
- package/dist-lib/lib/tradeitems.functions.d.ts +1068 -1068
- package/dist-lib/lib/tradeitems.functions.js +3 -3
- package/dist-lib/lib/useAllowedLoadCarriers.d.ts +1 -1
- package/dist-lib/lib/useAllowedLoadCarriers.js +1 -1
- package/dist-lib/lib/useBufferEvents.d.ts +1 -1
- package/dist-lib/lib/useBufferEvents.js +2 -2
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.d.ts +2 -2
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.js +2 -2
- package/dist-lib/lib/useSalesOrderDetailQuery.d.ts +1 -1
- package/dist-lib/lib/useSalesOrderDetailQuery.js +2 -2
- package/dist-lib/lib/useSalesOrdersQuery.d.ts +2 -2
- package/dist-lib/lib/useSalesOrdersQuery.js +3 -3
- package/package.json +2 -2
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
// precies `${timestamp}.${body}`, header `x-floriday-signature: sha256=<hex>`.
|
|
6
6
|
// - Max 100 id's per verzoek, kort geheugen (30 s) per id.
|
|
7
7
|
// - Fail closed: bij een fout geen stand, wel de foutcode (bv. invalid_signature).
|
|
8
|
-
import { parseFloridayStatusEntry } from "./floriday-status";
|
|
8
|
+
import { parseFloridayStatusEntry } from "./floriday-status.js";
|
|
9
9
|
const TTL_MS = 30000;
|
|
10
10
|
const MAX_IDS = 100;
|
|
11
11
|
const cache = new Map();
|
|
@@ -31,7 +31,7 @@ export async function loadFloridayStatuses(salesOrderIds) {
|
|
|
31
31
|
return { entries, error: null };
|
|
32
32
|
let error = null;
|
|
33
33
|
try {
|
|
34
|
-
const { getFloridayGatewaySecret, getGatewayBaseUrl } = await import("./central-secrets.server");
|
|
34
|
+
const { getFloridayGatewaySecret, getGatewayBaseUrl } = await import("./central-secrets.server.js");
|
|
35
35
|
const secret = await getFloridayGatewaySecret();
|
|
36
36
|
const base = await getGatewayBaseUrl();
|
|
37
37
|
for (let i = 0; i < wanted.length; i += MAX_IDS) {
|
|
@@ -36,7 +36,7 @@ async function markSyncSuccess(supabase, connectionId, entityType) {
|
|
|
36
36
|
}
|
|
37
37
|
export async function syncBySequence(supabase, opts) {
|
|
38
38
|
// Lazy import vermijdt circular dependency tussen sync en gateway.
|
|
39
|
-
const { florydayFetch } = await import("./floriday-gateway.server");
|
|
39
|
+
const { florydayFetch } = await import("./floriday-gateway.server.js");
|
|
40
40
|
const { connection, entityType, maxEndpoint, syncEndpointBase, cacheTable, conflictTarget, mapRow } = opts;
|
|
41
41
|
let active = connection;
|
|
42
42
|
const maxCall = await florydayFetch(supabase, active, {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// De synchronisatie koppelt uitsluitend op trade-item-id; lukt dat niet, dan
|
|
3
3
|
// blijft product_id leeg. Deze helper maakt dat zichtbaar — er wordt niets
|
|
4
4
|
// geschreven en de regel wordt niet apart gezet.
|
|
5
|
-
import { resolveProductName } from "./product-name";
|
|
5
|
+
import { resolveProductName } from "./product-name.js";
|
|
6
6
|
export function unlinkedFloridayProducts(row) {
|
|
7
7
|
const cf = (row?.custom_fields ?? {});
|
|
8
8
|
if (cf.source !== "floriday")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { FlorydayWriteResult } from "./floriday-gateway.server";
|
|
1
|
+
import type { FlorydayWriteResult } from "./floriday-gateway.server.js";
|
|
2
2
|
export declare const publishTradeItem: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
3
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
3
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
4
4
|
userId: string;
|
|
5
5
|
claims: import("@supabase/auth-js").User;
|
|
6
6
|
}, undefined, undefined, undefined>], (d: unknown) => {
|
|
@@ -9,7 +9,7 @@ export declare const publishTradeItem: import("@tanstack/start-client-core").Opt
|
|
|
9
9
|
payload: Record<string, any>;
|
|
10
10
|
}, Promise<FlorydayWriteResult>>;
|
|
11
11
|
export declare const upsertSupplyLine: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
12
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
12
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
13
13
|
userId: string;
|
|
14
14
|
claims: import("@supabase/auth-js").User;
|
|
15
15
|
}, undefined, undefined, undefined>], (d: unknown) => {
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Niemand mag fetch met Authorization-header zelf bouwen.
|
|
3
3
|
import { createServerFn } from "@tanstack/react-start";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
5
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
6
6
|
const EnvSchema = z.enum(["staging", "live"]);
|
|
7
7
|
async function callGateway(env, args, userId) {
|
|
8
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
9
|
-
const { florydayWrite } = await import("./floriday-gateway.server");
|
|
8
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
9
|
+
const { florydayWrite } = await import("./floriday-gateway.server.js");
|
|
10
10
|
return florydayWrite(supabaseAdmin, env, args, userId);
|
|
11
11
|
}
|
|
12
12
|
// ─── Orderstatussen ───────────────────────────────────────────────────────
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type InvoiceTimingSettings } from "./invoice-timing";
|
|
1
|
+
import { type InvoiceTimingSettings } from "./invoice-timing.js";
|
|
2
2
|
export declare const getInvoiceTimingSettings: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
3
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
3
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
4
4
|
userId: string;
|
|
5
5
|
claims: import("@supabase/auth-js").User;
|
|
6
6
|
}, undefined, undefined, undefined>], undefined, Promise<InvoiceTimingSettings>>;
|
|
7
7
|
export declare const saveInvoiceTimingSettings: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
8
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
8
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
9
9
|
userId: string;
|
|
10
10
|
claims: import("@supabase/auth-js").User;
|
|
11
11
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -23,7 +23,7 @@ export declare const saveInvoiceTimingSettings: import("@tanstack/start-client-c
|
|
|
23
23
|
recomputed: number;
|
|
24
24
|
}>>;
|
|
25
25
|
export declare const recomputeInvoiceDueForOrder: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
26
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
26
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
27
27
|
userId: string;
|
|
28
28
|
claims: import("@supabase/auth-js").User;
|
|
29
29
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -32,7 +32,7 @@ export declare const recomputeInvoiceDueForOrder: import("@tanstack/start-client
|
|
|
32
32
|
invoiceDueAt: any;
|
|
33
33
|
}>>;
|
|
34
34
|
export declare const getOrderInvoiceMoment: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
35
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
35
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
36
36
|
userId: string;
|
|
37
37
|
claims: import("@supabase/auth-js").User;
|
|
38
38
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// Server functions voor het instelbare factuurmoment.
|
|
2
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
5
|
-
import { resolveOrderRow, assertRowsAffected } from "./order-row.server";
|
|
6
|
-
import { DEFAULT_INVOICE_TIMING, normalizeTimeOfDay, } from "./invoice-timing";
|
|
4
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
5
|
+
import { resolveOrderRow, assertRowsAffected } from "./order-row.server.js";
|
|
6
|
+
import { DEFAULT_INVOICE_TIMING, normalizeTimeOfDay, } from "./invoice-timing.js";
|
|
7
7
|
const ANCHORS = [
|
|
8
8
|
"order_created",
|
|
9
9
|
"confirmed",
|
|
@@ -27,7 +27,7 @@ const settingsSchema = z.object({
|
|
|
27
27
|
export const getInvoiceTimingSettings = createServerFn({ method: "GET" })
|
|
28
28
|
.middleware([requireSupabaseAuth])
|
|
29
29
|
.handler(async ({ context }) => {
|
|
30
|
-
const { loadInvoiceTimingSettings } = await import("./invoice-timing.server");
|
|
30
|
+
const { loadInvoiceTimingSettings } = await import("./invoice-timing.server.js");
|
|
31
31
|
return loadInvoiceTimingSettings(context.supabase);
|
|
32
32
|
});
|
|
33
33
|
export const saveInvoiceTimingSettings = createServerFn({ method: "POST" })
|
|
@@ -53,8 +53,8 @@ export const saveInvoiceTimingSettings = createServerFn({ method: "POST" })
|
|
|
53
53
|
if (error)
|
|
54
54
|
throw new Error(error.message);
|
|
55
55
|
// Direct doorrekenen zodat de orders het nieuwe moment tonen.
|
|
56
|
-
const { recomputeInvoiceDueDates } = await import("./invoice-timing.server");
|
|
57
|
-
const { updated } = await recomputeInvoiceDueDates(supabase
|
|
56
|
+
const { recomputeInvoiceDueDates } = await import("./invoice-timing.server.js");
|
|
57
|
+
const { updated } = await recomputeInvoiceDueDates(supabase);
|
|
58
58
|
return { ok: true, recomputed: updated };
|
|
59
59
|
});
|
|
60
60
|
export const recomputeInvoiceDueForOrder = createServerFn({ method: "POST" })
|
|
@@ -63,7 +63,7 @@ export const recomputeInvoiceDueForOrder = createServerFn({ method: "POST" })
|
|
|
63
63
|
.handler(async ({ data, context }) => {
|
|
64
64
|
// DTO-id kan een Floriday salesOrderId zijn.
|
|
65
65
|
const order = await resolveOrderRow(context.supabase, data.orderId);
|
|
66
|
-
const { recomputeInvoiceDueDates } = await import("./invoice-timing.server");
|
|
66
|
+
const { recomputeInvoiceDueDates } = await import("./invoice-timing.server.js");
|
|
67
67
|
await recomputeInvoiceDueDates(context.supabase, { orderIds: [order.id] });
|
|
68
68
|
const { data: row } = await context.supabase
|
|
69
69
|
.from("orders")
|
|
@@ -79,7 +79,7 @@ export const getOrderInvoiceMoment = createServerFn({ method: "GET" })
|
|
|
79
79
|
.handler(async ({ data, context }) => {
|
|
80
80
|
// DTO-id kan een Floriday salesOrderId zijn.
|
|
81
81
|
const order = await resolveOrderRow(context.supabase, data.orderId);
|
|
82
|
-
const { loadInvoiceTimingSettings } = await import("./invoice-timing.server");
|
|
82
|
+
const { loadInvoiceTimingSettings } = await import("./invoice-timing.server.js");
|
|
83
83
|
const settings = await loadInvoiceTimingSettings(context.supabase).catch(() => DEFAULT_INVOICE_TIMING);
|
|
84
84
|
const { data: row } = await context.supabase
|
|
85
85
|
.from("orders")
|
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
import { type InvoiceTimingSettings } from "./invoice-timing";
|
|
1
|
+
import { type InvoiceTimingSettings } from "./invoice-timing.js";
|
|
2
2
|
/** Status die de facturatiemodule oppakt zodra het factuurmoment is bereikt. */
|
|
3
3
|
export declare const INVOICE_READY_STATUS = "Gereed voor facturatie";
|
|
4
4
|
export declare function loadInvoiceTimingSettings(supabase: any): Promise<InvoiceTimingSettings>;
|
|
5
|
-
/**
|
|
5
|
+
/**
|
|
6
|
+
* Herberekent `invoice_due_at` voor de meegegeven orders, of voor álle orders
|
|
7
|
+
* die nog niet gefactureerd, niet geannuleerd en niet verwijderd zijn (in delen
|
|
8
|
+
* van 200). Slaat alleen op als het moment echt verandert, met dezelfde
|
|
9
|
+
* voorwaarde ook in de database.
|
|
10
|
+
*/
|
|
6
11
|
export declare function recomputeInvoiceDueDates(supabase: any, options?: {
|
|
7
12
|
orderIds?: string[];
|
|
8
|
-
limit?: number;
|
|
9
13
|
}): Promise<{
|
|
10
14
|
updated: number;
|
|
15
|
+
checked: number;
|
|
11
16
|
}>;
|
|
12
17
|
/** Zet orders waarvan het factuurmoment is bereikt op de facturatiestatus. */
|
|
13
18
|
export declare function releaseDueInvoices(supabase: any, limit?: number): Promise<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoice-timing.server.d.ts","sourceRoot":"","sources":["../../src/lib/invoice-timing.server.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAC;AAE1B,gFAAgF;AAChF,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D,wBAAsB,yBAAyB,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAkB7F;
|
|
1
|
+
{"version":3,"file":"invoice-timing.server.d.ts","sourceRoot":"","sources":["../../src/lib/invoice-timing.server.ts"],"names":[],"mappings":"AACA,OAAO,EAML,KAAK,qBAAqB,EAC3B,MAAM,kBAAkB,CAAC;AAE1B,gFAAgF;AAChF,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D,wBAAsB,yBAAyB,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAkB7F;AA6ED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,QAAQ,EAAE,GAAG,EACb,OAAO,GAAE;IAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;CAAO,GACpC,OAAO,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAmD/C;AAED,8EAA8E;AAC9E,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,GAAG,EACb,KAAK,SAAM,GACV,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAgCnD;AAED,8DAA8D;AAC9D,wBAAsB,qBAAqB,IAAI,OAAO,CAAC;IACrD,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC,CAKD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Server-side toepassing van het instelbare factuurmoment.
|
|
2
|
-
import { DEFAULT_INVOICE_TIMING, computeInvoiceDueAt, normalizeTimeOfDay, } from "./invoice-timing";
|
|
2
|
+
import { DEFAULT_INVOICE_TIMING, computeInvoiceDueAt, normalizeTimeOfDay, } from "./invoice-timing.js";
|
|
3
3
|
/** Status die de facturatiemodule oppakt zodra het factuurmoment is bereikt. */
|
|
4
4
|
export const INVOICE_READY_STATUS = "Gereed voor facturatie";
|
|
5
5
|
export async function loadInvoiceTimingSettings(supabase) {
|
|
@@ -83,39 +83,72 @@ async function buildAnchorInputs(supabase, rows) {
|
|
|
83
83
|
}
|
|
84
84
|
return out;
|
|
85
85
|
}
|
|
86
|
-
/**
|
|
86
|
+
/** Statussen waarbij de order al bij facturatie ligt: factuurmoment niet meer herberekenen. */
|
|
87
|
+
const INVOICED_STATUSES = [INVOICE_READY_STATUS, "Gefactureerd", "gefactureerd"];
|
|
88
|
+
const CHUNK = 200;
|
|
89
|
+
/**
|
|
90
|
+
* Herberekent `invoice_due_at` voor de meegegeven orders, of voor álle orders
|
|
91
|
+
* die nog niet gefactureerd, niet geannuleerd en niet verwijderd zijn (in delen
|
|
92
|
+
* van 200). Slaat alleen op als het moment echt verandert, met dezelfde
|
|
93
|
+
* voorwaarde ook in de database.
|
|
94
|
+
*/
|
|
87
95
|
export async function recomputeInvoiceDueDates(supabase, options = {}) {
|
|
96
|
+
const { updateOrderIfChanged } = await import("./order-patch.js");
|
|
88
97
|
const settings = await loadInvoiceTimingSettings(supabase);
|
|
89
|
-
|
|
90
|
-
.from("orders")
|
|
91
|
-
.select("id, created_at, delivery_date, status, custom_fields")
|
|
92
|
-
.is("deleted_at", null)
|
|
93
|
-
.limit(options.limit ?? 500);
|
|
94
|
-
if (options.orderIds?.length)
|
|
95
|
-
query = query.in("id", options.orderIds.slice(0, 500));
|
|
96
|
-
else
|
|
97
|
-
query = query.order("created_at", { ascending: false });
|
|
98
|
-
const { data, error } = await query;
|
|
99
|
-
if (error)
|
|
100
|
-
throw new Error(error.message);
|
|
101
|
-
const rows = (data ?? []);
|
|
102
|
-
if (rows.length === 0)
|
|
103
|
-
return { updated: 0 };
|
|
104
|
-
const inputs = await buildAnchorInputs(supabase, rows);
|
|
98
|
+
const ids = options.orderIds?.length ? Array.from(new Set(options.orderIds)) : null;
|
|
105
99
|
let updated = 0;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const { error: upErr } = await supabase
|
|
100
|
+
let checked = 0;
|
|
101
|
+
let lastId = null;
|
|
102
|
+
let idOffset = 0;
|
|
103
|
+
for (;;) {
|
|
104
|
+
let query = supabase
|
|
112
105
|
.from("orders")
|
|
113
|
-
.
|
|
114
|
-
.
|
|
115
|
-
if (
|
|
116
|
-
|
|
106
|
+
.select("id, created_at, delivery_date, status, custom_fields, invoice_due_at")
|
|
107
|
+
.is("deleted_at", null);
|
|
108
|
+
if (ids) {
|
|
109
|
+
const part = ids.slice(idOffset, idOffset + CHUNK);
|
|
110
|
+
if (part.length === 0)
|
|
111
|
+
break;
|
|
112
|
+
idOffset += CHUNK;
|
|
113
|
+
query = query.in("id", part);
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
query = query
|
|
117
|
+
.is("cancelled_at", null)
|
|
118
|
+
.not("status", "in", `(${INVOICED_STATUSES.map((s) => `"${s}"`).join(",")})`)
|
|
119
|
+
.order("id", { ascending: true })
|
|
120
|
+
.limit(CHUNK);
|
|
121
|
+
if (lastId)
|
|
122
|
+
query = query.gt("id", lastId);
|
|
123
|
+
}
|
|
124
|
+
const { data, error } = await query;
|
|
125
|
+
if (error)
|
|
126
|
+
throw new Error(error.message);
|
|
127
|
+
const rows = (data ?? []);
|
|
128
|
+
if (rows.length === 0) {
|
|
129
|
+
if (ids)
|
|
130
|
+
continue;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
checked += rows.length;
|
|
134
|
+
const inputs = await buildAnchorInputs(supabase, rows);
|
|
135
|
+
for (const row of rows) {
|
|
136
|
+
const input = inputs.get(String(row.id));
|
|
137
|
+
if (!input)
|
|
138
|
+
continue;
|
|
139
|
+
const due = computeInvoiceDueAt(input, settings);
|
|
140
|
+
const r = await updateOrderIfChanged(supabase, String(row.id), row, {
|
|
141
|
+
invoice_due_at: due,
|
|
142
|
+
});
|
|
143
|
+
updated += r.written;
|
|
144
|
+
}
|
|
145
|
+
if (!ids) {
|
|
146
|
+
lastId = String(rows[rows.length - 1].id);
|
|
147
|
+
if (rows.length < CHUNK)
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
117
150
|
}
|
|
118
|
-
return { updated };
|
|
151
|
+
return { updated, checked };
|
|
119
152
|
}
|
|
120
153
|
/** Zet orders waarvan het factuurmoment is bereikt op de facturatiestatus. */
|
|
121
154
|
export async function releaseDueInvoices(supabase, limit = 200) {
|
|
@@ -137,19 +170,22 @@ export async function releaseDueInvoices(supabase, limit = 200) {
|
|
|
137
170
|
String(r.order_source ?? "").toLowerCase() !== "floriday");
|
|
138
171
|
const orderIds = [];
|
|
139
172
|
for (const r of rows) {
|
|
140
|
-
|
|
173
|
+
// Ook in de database: alleen als de status nog anders is.
|
|
174
|
+
const { data: done, error: upErr } = await supabase
|
|
141
175
|
.from("orders")
|
|
142
176
|
.update({ status: INVOICE_READY_STATUS })
|
|
143
|
-
.eq("id", r.id)
|
|
144
|
-
|
|
177
|
+
.eq("id", r.id)
|
|
178
|
+
.or(`status.is.null,status.neq."${INVOICE_READY_STATUS}"`)
|
|
179
|
+
.select("id");
|
|
180
|
+
if (!upErr && (done ?? []).length > 0)
|
|
145
181
|
orderIds.push(String(r.id));
|
|
146
182
|
}
|
|
147
183
|
return { released: orderIds.length, orderIds };
|
|
148
184
|
}
|
|
149
185
|
/** Volledige cyclus: eerst herberekenen, daarna vrijgeven. */
|
|
150
186
|
export async function runInvoiceTimingCycle() {
|
|
151
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
152
|
-
const recomputed = (await recomputeInvoiceDueDates(supabaseAdmin
|
|
187
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
188
|
+
const recomputed = (await recomputeInvoiceDueDates(supabaseAdmin)).updated;
|
|
153
189
|
const released = (await releaseDueInvoices(supabaseAdmin, 200)).released;
|
|
154
190
|
return { recomputed, released };
|
|
155
191
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/** Lijst met ladingdragers die de Engine toestaat (alleen enabled). */
|
|
2
2
|
export declare const listAllowedLoadCarriers: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
3
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
3
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
4
4
|
userId: string;
|
|
5
5
|
claims: import("@supabase/auth-js").User;
|
|
6
6
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
7
7
|
strategyId?: string | null | undefined;
|
|
8
|
-
}, Promise<import("./load-carriers").AllowedLoadCarriers>>;
|
|
8
|
+
}, Promise<import("./load-carriers.js").AllowedLoadCarriers>>;
|
|
9
9
|
//# sourceMappingURL=load-carriers.functions.d.ts.map
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
// Rule Engine (stap Beladingindeling) kan elk moment wijzigen.
|
|
4
4
|
import { createServerFn } from "@tanstack/react-start";
|
|
5
5
|
import { z } from "zod";
|
|
6
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
7
|
-
import { normalizeAllowedLoadCarriers } from "./load-carriers";
|
|
6
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
7
|
+
import { normalizeAllowedLoadCarriers } from "./load-carriers.js";
|
|
8
8
|
/** Lijst met ladingdragers die de Engine toestaat (alleen enabled). */
|
|
9
9
|
export const listAllowedLoadCarriers = createServerFn({ method: "POST" })
|
|
10
10
|
.middleware([requireSupabaseAuth])
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function fetchAllowedLoadCarriers(supabase: any, strategyId?: string | null): Promise<import("./load-carriers").AllowedLoadCarriers>;
|
|
1
|
+
export declare function fetchAllowedLoadCarriers(supabase: any, strategyId?: string | null): Promise<import("./load-carriers.js").AllowedLoadCarriers>;
|
|
2
2
|
/**
|
|
3
3
|
* Valideert de gekozen ladingdrager. Zonder keuze wordt de default van de
|
|
4
4
|
* Engine teruggegeven. Geen eigen controle: alleen de Engine beslist.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Leest de ladingdragerlijst van de Engine. Geen eigen blokkade (koppelprompt 22).
|
|
2
|
-
import { normalizeAllowedLoadCarriers, normalizeLoadCarrierCode, } from "./load-carriers";
|
|
2
|
+
import { normalizeAllowedLoadCarriers, normalizeLoadCarrierCode, } from "./load-carriers.js";
|
|
3
3
|
export async function fetchAllowedLoadCarriers(supabase, strategyId = null) {
|
|
4
4
|
const { data, error } = await supabase.rpc("logistics_allowed_load_carriers", {
|
|
5
5
|
p_strategy_id: strategyId,
|
|
@@ -31,7 +31,7 @@ function normalizeDecision(raw) {
|
|
|
31
31
|
* payload is het besluit niet beschikbaar en wordt er niets geschreven.
|
|
32
32
|
*/
|
|
33
33
|
export async function getEngineBufferDecision(orderId) {
|
|
34
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
34
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
35
35
|
const { data: payload, error: pErr } = await supabaseAdmin.rpc("logistics_buffer_payload", { p_order_id: orderId });
|
|
36
36
|
if (pErr || payload == null) {
|
|
37
37
|
return { available: false, error: pErr?.message ?? BUFFER_DECISION_UNAVAILABLE };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Meld een order aan de Engine (order.received / order.changed). */
|
|
2
2
|
export declare const sendOrderEventToEngine: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
3
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
3
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
4
4
|
userId: string;
|
|
5
5
|
claims: import("@supabase/auth-js").User;
|
|
6
6
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -17,7 +17,7 @@ export declare const sendOrderEventToEngine: import("@tanstack/start-client-core
|
|
|
17
17
|
}>>;
|
|
18
18
|
/** Taken van de Engine ophalen (default: geplande/gereed taken). */
|
|
19
19
|
export declare const listEngineTasks: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
20
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
20
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
21
21
|
userId: string;
|
|
22
22
|
claims: import("@supabase/auth-js").User;
|
|
23
23
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -31,7 +31,7 @@ export declare const listEngineTasks: import("@tanstack/start-client-core").Opti
|
|
|
31
31
|
} | {
|
|
32
32
|
ok: true;
|
|
33
33
|
tasks: {
|
|
34
|
-
attempt_log: import("../integrations/supabase/types").Json;
|
|
34
|
+
attempt_log: import("../integrations/supabase/types.js").Json;
|
|
35
35
|
attempts: number;
|
|
36
36
|
buffer_ref: string | null;
|
|
37
37
|
claimed_at: string | null;
|
|
@@ -46,12 +46,12 @@ export declare const listEngineTasks: import("@tanstack/start-client-core").Opti
|
|
|
46
46
|
next_attempt_at: string | null;
|
|
47
47
|
order_ref: string;
|
|
48
48
|
owner_module: string;
|
|
49
|
-
payload: import("../integrations/supabase/types").Json;
|
|
49
|
+
payload: import("../integrations/supabase/types.js").Json;
|
|
50
50
|
plan_run_id: string | null;
|
|
51
51
|
planned_end: string | null;
|
|
52
52
|
planned_start: string | null;
|
|
53
53
|
priority: number;
|
|
54
|
-
result: import("../integrations/supabase/types").Json | null;
|
|
54
|
+
result: import("../integrations/supabase/types.js").Json | null;
|
|
55
55
|
rule_config_id: string | null;
|
|
56
56
|
rule_version: number | null;
|
|
57
57
|
sequence: number;
|
|
@@ -68,7 +68,7 @@ export declare const listEngineTasks: import("@tanstack/start-client-core").Opti
|
|
|
68
68
|
}>>;
|
|
69
69
|
/** Taak afmelden (status + result op dezelfde rij). */
|
|
70
70
|
export declare const completeEngineTask: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
71
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
71
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
72
72
|
userId: string;
|
|
73
73
|
claims: import("@supabase/auth-js").User;
|
|
74
74
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -83,7 +83,7 @@ export declare const completeEngineTask: import("@tanstack/start-client-core").O
|
|
|
83
83
|
* (`logistics_buffer_decision`) — nooit uit een eigen regel of cache.
|
|
84
84
|
*/
|
|
85
85
|
export declare const getEngineBufferForOrder: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
86
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
86
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
87
87
|
userId: string;
|
|
88
88
|
claims: import("@supabase/auth-js").User;
|
|
89
89
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -112,7 +112,7 @@ export declare const getEngineBufferForOrder: import("@tanstack/start-client-cor
|
|
|
112
112
|
}>>;
|
|
113
113
|
/** Buffer handmatig vrijgeven (release === "manual"): taak afmelden als done. */
|
|
114
114
|
export declare const releaseEngineBuffer: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
115
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
115
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
116
116
|
userId: string;
|
|
117
117
|
claims: import("@supabase/auth-js").User;
|
|
118
118
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// gedeelde Supabase-tabellen logistics_events en logistics_tasks.
|
|
3
3
|
import { createServerFn } from "@tanstack/react-start";
|
|
4
4
|
import { z } from "zod";
|
|
5
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
6
|
-
import { resolveOrderRow } from "./order-row.server";
|
|
5
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
6
|
+
import { resolveOrderRow } from "./order-row.server.js";
|
|
7
7
|
const TaskStatus = z.enum([
|
|
8
8
|
"planned",
|
|
9
9
|
"ready",
|
|
@@ -25,7 +25,7 @@ export const sendOrderEventToEngine = createServerFn({ method: "POST" })
|
|
|
25
25
|
.handler(async ({ data, context }) => {
|
|
26
26
|
// DTO-id kan een Floriday salesOrderId zijn.
|
|
27
27
|
const order = await resolveOrderRow(context.supabase, data.orderId);
|
|
28
|
-
const { buildEngineOrderPayload, insertLogisticsEvent } = await import("./logistics-engine.server");
|
|
28
|
+
const { buildEngineOrderPayload, insertLogisticsEvent } = await import("./logistics-engine.server.js");
|
|
29
29
|
const payload = await buildEngineOrderPayload(order.id);
|
|
30
30
|
if (!payload)
|
|
31
31
|
throw new Error("Order niet gevonden");
|
|
@@ -44,7 +44,7 @@ export const listEngineTasks = createServerFn({ method: "POST" })
|
|
|
44
44
|
})
|
|
45
45
|
.parse(input ?? {}))
|
|
46
46
|
.handler(async ({ data, context }) => {
|
|
47
|
-
const { isEngineShadowMode } = await import("./logistics-engine.server");
|
|
47
|
+
const { isEngineShadowMode } = await import("./logistics-engine.server.js");
|
|
48
48
|
let query = context.supabase
|
|
49
49
|
.from("logistics_tasks")
|
|
50
50
|
.select("*")
|
|
@@ -98,8 +98,8 @@ export const getEngineBufferForOrder = createServerFn({ method: "POST" })
|
|
|
98
98
|
.middleware([requireSupabaseAuth])
|
|
99
99
|
.inputValidator((input) => z.object({ orderId: z.string().min(1) }).parse(input))
|
|
100
100
|
.handler(async ({ data, context }) => {
|
|
101
|
-
const { isEngineShadowMode } = await import("./logistics-engine.server");
|
|
102
|
-
const { getEngineBufferDecision, BUFFER_DECISION_UNAVAILABLE } = await import("./logistics-buffer.server");
|
|
101
|
+
const { isEngineShadowMode } = await import("./logistics-engine.server.js");
|
|
102
|
+
const { getEngineBufferDecision, BUFFER_DECISION_UNAVAILABLE } = await import("./logistics-buffer.server.js");
|
|
103
103
|
const shadow = isEngineShadowMode();
|
|
104
104
|
// DTO-id kan een Floriday salesOrderId zijn.
|
|
105
105
|
const order = await resolveOrderRow(context.supabase, data.orderId);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { EngineLoadCarrierCode } from "./load-carriers";
|
|
1
|
+
import type { EngineLoadCarrierCode } from "./load-carriers.js";
|
|
2
2
|
export type LoadCarrierType = EngineLoadCarrierCode;
|
|
3
3
|
export type EngineTaskStatus = "planned" | "ready" | "in_progress" | "done" | "skipped" | "cancelled" | "failed";
|
|
4
4
|
export interface EngineOrderPayload {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// De Engine beslist over buffering, belading, picken, controle, printen en
|
|
4
4
|
// transport. Deze module meldt alleen gebeurtenissen (rij in logistics_events)
|
|
5
5
|
// en voert taken uit (logistics_tasks). Geen HTTP, geen secret.
|
|
6
|
-
import { normalizeLoadCarrierCode } from "./load-carriers";
|
|
6
|
+
import { normalizeLoadCarrierCode } from "./load-carriers.js";
|
|
7
7
|
export function isEngineShadowMode() {
|
|
8
8
|
const raw = (process.env.LOGISTICS_ENGINE_SHADOW ?? "true").toLowerCase();
|
|
9
9
|
return raw !== "false" && raw !== "0";
|
|
@@ -13,7 +13,7 @@ export function isEngineShadowMode() {
|
|
|
13
13
|
* Gebruikt de service-role client zodat het ook vanuit cron werkt.
|
|
14
14
|
*/
|
|
15
15
|
export async function buildEngineOrderPayload(orderId) {
|
|
16
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
16
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
17
17
|
const { data: order } = await supabaseAdmin
|
|
18
18
|
.from("orders")
|
|
19
19
|
.select("id, order_number, customer_id, delivery_date, custom_fields, buffer_id")
|
|
@@ -25,7 +25,7 @@ export async function buildEngineOrderPayload(orderId) {
|
|
|
25
25
|
const cf = (o.custom_fields ?? {});
|
|
26
26
|
// Karren uit de Engine-leesfunctie (gedeelde bufferkarren inbegrepen).
|
|
27
27
|
// Fail closed: lukt de vraag niet, dan geen payload (zoals voorheen bij een leesfout).
|
|
28
|
-
const { loadPlanCoverage } = await import("./plan-coverage.server");
|
|
28
|
+
const { loadPlanCoverage } = await import("./plan-coverage.server.js");
|
|
29
29
|
const cov = (await loadPlanCoverage(supabaseAdmin, [orderId])).get(orderId);
|
|
30
30
|
if (!cov || cov.state === "onbekend") {
|
|
31
31
|
throw new Error(cov?.error ?? "Indeling niet beschikbaar bij de Logistiek Engine");
|
|
@@ -63,7 +63,7 @@ export async function buildEngineOrderPayload(orderId) {
|
|
|
63
63
|
}
|
|
64
64
|
/** Meld een gebeurtenis aan de Engine: rij in logistics_events. */
|
|
65
65
|
export async function insertLogisticsEvent(input) {
|
|
66
|
-
const { supabaseAdmin } = await import("../integrations/supabase/client.server");
|
|
66
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
67
67
|
const { orderRef, ...rest } = input.order;
|
|
68
68
|
const { data, error } = await supabaseAdmin
|
|
69
69
|
.from("logistics_events")
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Voorraadcontrole voor een (concept)order. Antwoord nooit cachen. */
|
|
2
2
|
export declare const checkOrderStockAllowed: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
3
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
3
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
4
4
|
userId: string;
|
|
5
5
|
claims: import("@supabase/auth-js").User;
|
|
6
6
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -9,10 +9,10 @@ export declare const checkOrderStockAllowed: import("@tanstack/start-client-core
|
|
|
9
9
|
quantity: number;
|
|
10
10
|
}[];
|
|
11
11
|
strategyId?: string | null | undefined;
|
|
12
|
-
}, Promise<import("./logistics-stock.server").StockCheckResult>>;
|
|
12
|
+
}, Promise<import("./logistics-stock.server.js").StockCheckResult>>;
|
|
13
13
|
/** Alleen de Engine-instelling opvragen (uitleveren zonder voorraad ja/nee). */
|
|
14
14
|
export declare const getBackorderAllowed: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
15
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
15
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
16
16
|
userId: string;
|
|
17
17
|
claims: import("@supabase/auth-js").User;
|
|
18
18
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// Server functions voor de voorraadcontrole van de Logistics Engine.
|
|
2
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
4
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
5
5
|
const LinesInput = z.object({
|
|
6
6
|
lines: z
|
|
7
7
|
.array(z.object({ productId: z.string().min(1), quantity: z.number() }))
|
|
@@ -13,7 +13,7 @@ export const checkOrderStockAllowed = createServerFn({ method: "POST" })
|
|
|
13
13
|
.middleware([requireSupabaseAuth])
|
|
14
14
|
.inputValidator((input) => LinesInput.parse(input ?? {}))
|
|
15
15
|
.handler(async ({ data, context }) => {
|
|
16
|
-
const { checkOrderAllowed } = await import("./logistics-stock.server");
|
|
16
|
+
const { checkOrderAllowed } = await import("./logistics-stock.server.js");
|
|
17
17
|
return await checkOrderAllowed(context.supabase, data.lines, data.strategyId ?? null);
|
|
18
18
|
});
|
|
19
19
|
/** Alleen de Engine-instelling opvragen (uitleveren zonder voorraad ja/nee). */
|
|
@@ -21,6 +21,6 @@ export const getBackorderAllowed = createServerFn({ method: "POST" })
|
|
|
21
21
|
.middleware([requireSupabaseAuth])
|
|
22
22
|
.inputValidator((input) => z.object({ strategyId: z.string().uuid().nullable().optional() }).parse(input ?? {}))
|
|
23
23
|
.handler(async ({ data, context }) => {
|
|
24
|
-
const { backorderAllowed } = await import("./logistics-stock.server");
|
|
24
|
+
const { backorderAllowed } = await import("./logistics-stock.server.js");
|
|
25
25
|
return { allowed: await backorderAllowed(context.supabase, data.strategyId ?? null) };
|
|
26
26
|
});
|
|
@@ -12,7 +12,7 @@ export interface OrderAddress {
|
|
|
12
12
|
* orders.id (uuid) of een Floriday sales-order-id zijn.
|
|
13
13
|
*/
|
|
14
14
|
export declare const getOrderAddresses: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
15
|
-
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
15
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
16
16
|
userId: string;
|
|
17
17
|
claims: import("@supabase/auth-js").User;
|
|
18
18
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Adresgegevens (aflever- en ophaaladres) voor een order of orderbuffer.
|
|
2
2
|
import { createServerFn } from "@tanstack/react-start";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
5
|
-
import { resolveOrderRow } from "./order-row.server";
|
|
4
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
5
|
+
import { resolveOrderRow } from "./order-row.server.js";
|
|
6
6
|
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
7
7
|
function s(v) {
|
|
8
8
|
if (v == null)
|