@flowselections/floriday-verkoop-module 1.0.137 → 1.0.139
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/EditLocalOrderDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.js +32 -22
- package/dist-lib/components/verkoop/FloridaySyncSettings.d.ts +2 -0
- package/dist-lib/components/verkoop/FloridaySyncSettings.d.ts.map +1 -0
- package/dist-lib/components/verkoop/FloridaySyncSettings.js +48 -0
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.js +32 -5
- package/dist-lib/components/verkoop/OrderShipmentsCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.js +2 -3
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +12 -2
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +7 -2
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts +3 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.js +13 -51
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts +17 -3
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.js +168 -116
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +203 -89
- package/dist-lib/components/verkoop/v3/CustomerName.d.ts +9 -0
- package/dist-lib/components/verkoop/v3/CustomerName.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/CustomerName.js +16 -0
- package/dist-lib/components/verkoop/v3/HoverTip.d.ts +15 -0
- package/dist-lib/components/verkoop/v3/HoverTip.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/HoverTip.js +24 -0
- package/dist-lib/components/verkoop/v3/KpiTile.d.ts +13 -0
- package/dist-lib/components/verkoop/v3/KpiTile.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/KpiTile.js +8 -0
- package/dist-lib/components/verkoop/v3/OrderProgress.d.ts +7 -0
- package/dist-lib/components/verkoop/v3/OrderProgress.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/OrderProgress.js +127 -0
- package/dist-lib/components/verkoop/v3/RowMenu.d.ts +13 -0
- package/dist-lib/components/verkoop/v3/RowMenu.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/RowMenu.js +17 -0
- package/dist-lib/components/verkoop/v3/SourceIcon.d.ts +17 -0
- package/dist-lib/components/verkoop/v3/SourceIcon.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/SourceIcon.js +45 -0
- package/dist-lib/components/verkoop/v3/floriday-logo.d.ts +2 -0
- package/dist-lib/components/verkoop/v3/floriday-logo.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/floriday-logo.js +2 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +2 -0
- package/dist-lib/integrations/supabase/types.d.ts +431 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/buffer-carts.check.d.ts +2 -0
- package/dist-lib/lib/buffer-carts.check.d.ts.map +1 -0
- package/dist-lib/lib/buffer-carts.check.js +23 -0
- package/dist-lib/lib/buffer-carts.d.ts +35 -0
- package/dist-lib/lib/buffer-carts.d.ts.map +1 -0
- package/dist-lib/lib/buffer-carts.functions.d.ts +12 -0
- package/dist-lib/lib/buffer-carts.functions.d.ts.map +1 -0
- package/dist-lib/lib/buffer-carts.functions.js +18 -0
- package/dist-lib/lib/buffer-carts.js +41 -0
- package/dist-lib/lib/create-order.functions.d.ts +7 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +87 -30
- package/dist-lib/lib/floriday-public.functions.d.ts +1 -1
- package/dist-lib/lib/module-version.d.ts +1 -1
- package/dist-lib/lib/module-version.js +1 -1
- package/dist-lib/lib/motion.d.ts +13 -0
- package/dist-lib/lib/motion.d.ts.map +1 -0
- package/dist-lib/lib/motion.js +36 -0
- package/dist-lib/lib/order-price-lock.check.d.ts +2 -0
- package/dist-lib/lib/order-price-lock.check.d.ts.map +1 -0
- package/dist-lib/lib/order-price-lock.check.js +43 -0
- package/dist-lib/lib/order-price-lock.d.ts +29 -0
- package/dist-lib/lib/order-price-lock.d.ts.map +1 -0
- package/dist-lib/lib/order-price-lock.js +60 -0
- package/dist-lib/lib/order-price-lock.server.d.ts +2 -0
- package/dist-lib/lib/order-price-lock.server.d.ts.map +1 -0
- package/dist-lib/lib/order-price-lock.server.js +31 -0
- package/dist-lib/lib/order-progress.check.d.ts +2 -0
- package/dist-lib/lib/order-progress.check.d.ts.map +1 -0
- package/dist-lib/lib/order-progress.check.js +83 -0
- package/dist-lib/lib/order-progress.d.ts +154 -0
- package/dist-lib/lib/order-progress.d.ts.map +1 -0
- package/dist-lib/lib/order-progress.js +171 -0
- package/dist-lib/lib/order-progress.server.d.ts +41 -0
- package/dist-lib/lib/order-progress.server.d.ts.map +1 -0
- package/dist-lib/lib/order-progress.server.js +136 -0
- package/dist-lib/lib/order-status.js +2 -2
- package/dist-lib/lib/own-transport.d.ts +11 -0
- package/dist-lib/lib/own-transport.d.ts.map +1 -0
- package/dist-lib/lib/own-transport.js +10 -0
- package/dist-lib/lib/period-range.check.d.ts +2 -0
- package/dist-lib/lib/period-range.check.d.ts.map +1 -0
- package/dist-lib/lib/period-range.check.js +63 -0
- package/dist-lib/lib/period-range.d.ts +66 -0
- package/dist-lib/lib/period-range.d.ts.map +1 -0
- package/dist-lib/lib/period-range.js +213 -0
- package/dist-lib/lib/plan-coverage.d.ts +17 -0
- package/dist-lib/lib/plan-coverage.d.ts.map +1 -1
- package/dist-lib/lib/plan-coverage.js +24 -0
- package/dist-lib/lib/salesorders-list.functions.d.ts +4 -2
- package/dist-lib/lib/salesorders-list.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.functions.js +5 -1
- package/dist-lib/lib/salesorders-list.server.d.ts +6 -1
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +84 -18
- package/dist-lib/lib/salesorders-mapping.d.ts +18 -0
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-mapping.js +19 -58
- package/dist-lib/lib/session-error.check.d.ts +2 -0
- package/dist-lib/lib/session-error.check.d.ts.map +1 -0
- package/dist-lib/lib/session-error.check.js +17 -0
- package/dist-lib/lib/session-error.d.ts +2 -0
- package/dist-lib/lib/session-error.d.ts.map +1 -0
- package/dist-lib/lib/session-error.js +10 -0
- package/dist-lib/lib/useBufferCarts.d.ts +6 -0
- package/dist-lib/lib/useBufferCarts.d.ts.map +1 -0
- package/dist-lib/lib/useBufferCarts.js +15 -0
- package/dist-lib/lib/useSalesOrdersQuery.d.ts +11 -2
- package/dist-lib/lib/useSalesOrdersQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.js +75 -52
- package/package.json +3 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-carts.check.d.ts","sourceRoot":"","sources":["../../src/lib/buffer-carts.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Draai: bun src/lib/buffer-carts.check.ts
|
|
2
|
+
import { parseBufferCarts, ladingdragerSummary } from "./buffer-carts.js";
|
|
3
|
+
import { parsePlanCoverage, verouderdRegels, verouderdToon } from "./plan-coverage.js";
|
|
4
|
+
let failed = 0;
|
|
5
|
+
function eq(n, g, w) { const ok = JSON.stringify(g) === JSON.stringify(w); if (!ok)
|
|
6
|
+
failed++; console.log(`${ok ? "OK " : "FOUT"} ${n}: ${JSON.stringify(g)}`); }
|
|
7
|
+
const b = parseBufferCarts({ bufferId: "b", orders: ["HO-1"], karren: 5, ladingdragers: [{ ladingdrager: "Stapelwagen", aantal: 3 }, { ladingdrager: "Deense container", aantal: 1 }, { ladingdrager: null, aantal: 1 }],
|
|
8
|
+
carts: [{ cartId: "k1", seq: 1, pickDocument: { id: "p", documentNumber: "PB-AO-2601451-K4" } }], dubbeleDocumenten: [{ documentNumber: "PB-AO-2601451-K4", documenten: [{}, {}] }] });
|
|
9
|
+
eq("gemengde soorten apart", ladingdragerSummary(b), "3 × Stapelwagen, 1 × Deense container, 1 × Geen ladingdrager");
|
|
10
|
+
eq("karren uit Engine", b.karren, 5);
|
|
11
|
+
eq("dubbel document", b.dubbeleDocumenten, [{ documentNumber: "PB-AO-2601451-K4", aantal: 2 }]);
|
|
12
|
+
eq("ontbrekend antwoord → null (huidig gedrag)", parseBufferCarts(null), null);
|
|
13
|
+
const c = parsePlanCoverage({ state: "ingedeeld", carts: [{ cartId: "k", verouderdReden: "hoofd", verouderdRedenen: [{ code: "eerdere_buffer", tekst: "A" }, { code: "aantal", tekst: "B" }] }] }).carts[0];
|
|
14
|
+
eq("alle redenen uit lijst", verouderdRegels(c).map((r) => r.tekst), ["A", "B"]);
|
|
15
|
+
const old = parsePlanCoverage({ state: "ingedeeld", carts: [{ cartId: "k", verouderdReden: "hoofd" }] }).carts[0];
|
|
16
|
+
eq("oudere Engine → hoofdreden", verouderdRegels(old).map((r) => r.tekst), ["hoofd"]);
|
|
17
|
+
eq("aantal blokkeert", verouderdToon("aantal"), "blok");
|
|
18
|
+
eq("te_veel_lagen alleen melding", verouderdToon("te_veel_lagen"), "melding");
|
|
19
|
+
if (failed) {
|
|
20
|
+
console.error(`${failed} fout(en)`);
|
|
21
|
+
process.exit(1);
|
|
22
|
+
}
|
|
23
|
+
console.log("Alles OK");
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type VerouderdReden } from "./plan-coverage.js";
|
|
2
|
+
export type BufferCart = {
|
|
3
|
+
cartId: string;
|
|
4
|
+
seq: number | null;
|
|
5
|
+
total: number | null;
|
|
6
|
+
ladingdrager: string | null;
|
|
7
|
+
carrierType: string | null;
|
|
8
|
+
verouderd: boolean;
|
|
9
|
+
verouderdReden: string | null;
|
|
10
|
+
verouderdRedenen: VerouderdReden[] | null;
|
|
11
|
+
pickDocument: {
|
|
12
|
+
id: string | null;
|
|
13
|
+
documentNumber: string | null;
|
|
14
|
+
printedAt: string | null;
|
|
15
|
+
} | null;
|
|
16
|
+
};
|
|
17
|
+
export type BufferCarts = {
|
|
18
|
+
bufferId: string;
|
|
19
|
+
orders: string[];
|
|
20
|
+
karren: number;
|
|
21
|
+
ladingdragers: Array<{
|
|
22
|
+
ladingdrager: string;
|
|
23
|
+
aantal: number;
|
|
24
|
+
}>;
|
|
25
|
+
carts: BufferCart[];
|
|
26
|
+
dubbeleDocumenten: Array<{
|
|
27
|
+
documentNumber: string;
|
|
28
|
+
aantal: number;
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
/** Leest het jsonb-antwoord; geen bruikbaar antwoord → null (dan blijft het huidige gedrag). */
|
|
32
|
+
export declare function parseBufferCarts(raw: unknown): BufferCarts | null;
|
|
33
|
+
/** "3 × Stapelwagen, 1 × Deense container" — elke soort apart, nooit één soort voor alles. */
|
|
34
|
+
export declare function ladingdragerSummary(b: Pick<BufferCarts, "ladingdragers">): string;
|
|
35
|
+
//# sourceMappingURL=buffer-carts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-carts.d.ts","sourceRoot":"","sources":["../../src/lib/buffer-carts.ts"],"names":[],"mappings":"AAEA,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAE7E,MAAM,MAAM,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,gBAAgB,EAAE,cAAc,EAAE,GAAG,IAAI,CAAC;IAC1C,YAAY,EAAE;QAAE,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CACrG,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,KAAK,CAAC;QAAE,YAAY,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/D,KAAK,EAAE,UAAU,EAAE,CAAC;IACpB,iBAAiB,EAAE,KAAK,CAAC;QAAE,cAAc,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CACtE,CAAC;AAKF,gGAAgG;AAChG,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,GAAG,IAAI,CA6BjE;AAED,8FAA8F;AAC9F,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,GAAG,MAAM,CAEjF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type BufferCarts } from "./buffer-carts.js";
|
|
2
|
+
export declare const getBufferCarts: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
3
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
4
|
+
userId: string;
|
|
5
|
+
claims: import("@supabase/auth-js").User;
|
|
6
|
+
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
7
|
+
bufferId: string;
|
|
8
|
+
}, Promise<{
|
|
9
|
+
carts: BufferCarts | null;
|
|
10
|
+
error: string | null;
|
|
11
|
+
}>>;
|
|
12
|
+
//# sourceMappingURL=buffer-carts.functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-carts.functions.d.ts","sourceRoot":"","sources":["../../src/lib/buffer-carts.functions.ts"],"names":[],"mappings":"AAKA,OAAO,EAAoB,KAAK,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAEpE,eAAO,MAAM,cAAc;;;;8CAED,OAAO;;;WACsB,WAAW,GAAG,IAAI;WAAS,MAAM,GAAG,IAAI;GAQ3F,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Buffertelling lezen via de Logistiek Engine (logistics_buffer_carts). Alleen lezen.
|
|
2
|
+
// Ontbreekt de functie (oudere Engine), dan { carts: null } en blijft het huidige gedrag.
|
|
3
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
4
|
+
import { z } from "zod";
|
|
5
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
6
|
+
import { parseBufferCarts } from "./buffer-carts.js";
|
|
7
|
+
export const getBufferCarts = createServerFn({ method: "GET" })
|
|
8
|
+
.middleware([requireSupabaseAuth])
|
|
9
|
+
.inputValidator((input) => z.object({ bufferId: z.string().uuid() }).parse(input))
|
|
10
|
+
.handler(async ({ data, context }) => {
|
|
11
|
+
const { data: raw, error } = await context.supabase.rpc("logistics_buffer_carts", { p_buffer_id: data.bufferId });
|
|
12
|
+
if (error) {
|
|
13
|
+
const code = String(error.code ?? "");
|
|
14
|
+
const missing = code === "PGRST202" || code === "42883" || /could not find the function|does not exist/i.test(String(error.message ?? ""));
|
|
15
|
+
return { carts: null, error: missing ? null : String(error.message ?? "onbekende fout") };
|
|
16
|
+
}
|
|
17
|
+
return { carts: parseBufferCarts(raw), error: null };
|
|
18
|
+
});
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Buffertelling van de Logistiek Engine (logistics_buffer_carts, Engine 1.0.220). Client-safe, puur.
|
|
2
|
+
// Verkoop telt niets zelf: kop, karindeling en pickdocumenten komen precies uit dit antwoord.
|
|
3
|
+
import { parseVerouderdRedenen } from "./plan-coverage.js";
|
|
4
|
+
const str = (v) => (typeof v === "string" && v.trim() ? v.trim() : null);
|
|
5
|
+
const num = (v) => (typeof v === "number" && Number.isFinite(v) ? v : null);
|
|
6
|
+
/** Leest het jsonb-antwoord; geen bruikbaar antwoord → null (dan blijft het huidige gedrag). */
|
|
7
|
+
export function parseBufferCarts(raw) {
|
|
8
|
+
const d = raw && typeof raw === "object" ? raw : null;
|
|
9
|
+
if (!d || !str(d.bufferId) || !Array.isArray(d.carts))
|
|
10
|
+
return null;
|
|
11
|
+
const carts = d.carts
|
|
12
|
+
.filter((c) => c && str(c.cartId))
|
|
13
|
+
.map((c) => ({
|
|
14
|
+
cartId: String(c.cartId),
|
|
15
|
+
seq: num(c.seq),
|
|
16
|
+
total: num(c.total),
|
|
17
|
+
ladingdrager: str(c.ladingdrager),
|
|
18
|
+
carrierType: str(c.carrierType),
|
|
19
|
+
verouderd: c.verouderd === true,
|
|
20
|
+
verouderdReden: str(c.verouderdReden),
|
|
21
|
+
verouderdRedenen: parseVerouderdRedenen(c.verouderdRedenen),
|
|
22
|
+
pickDocument: c.pickDocument && typeof c.pickDocument === "object"
|
|
23
|
+
? { id: str(c.pickDocument.id), documentNumber: str(c.pickDocument.documentNumber), printedAt: str(c.pickDocument.printedAt) }
|
|
24
|
+
: null,
|
|
25
|
+
}));
|
|
26
|
+
return {
|
|
27
|
+
bufferId: String(d.bufferId),
|
|
28
|
+
orders: Array.isArray(d.orders) ? d.orders.filter((x) => typeof x === "string") : [],
|
|
29
|
+
karren: num(d.karren) ?? carts.length,
|
|
30
|
+
ladingdragers: (Array.isArray(d.ladingdragers) ? d.ladingdragers : [])
|
|
31
|
+
.map((l) => ({ ladingdrager: str(l?.ladingdrager) ?? "Geen ladingdrager", aantal: num(l?.aantal) ?? 0 }))
|
|
32
|
+
.filter((l) => l.aantal > 0),
|
|
33
|
+
carts,
|
|
34
|
+
dubbeleDocumenten: (Array.isArray(d.dubbeleDocumenten) ? d.dubbeleDocumenten : [])
|
|
35
|
+
.map((g) => ({ documentNumber: str(g?.documentNumber) ?? "?", aantal: Array.isArray(g?.documenten) ? g.documenten.length : 0 })),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** "3 × Stapelwagen, 1 × Deense container" — elke soort apart, nooit één soort voor alles. */
|
|
39
|
+
export function ladingdragerSummary(b) {
|
|
40
|
+
return b.ladingdragers.map((l) => `${l.aantal} × ${l.ladingdrager}`).join(", ");
|
|
41
|
+
}
|
|
@@ -222,6 +222,8 @@ export declare const getLocalOrderForEdit: import("@tanstack/start-client-core")
|
|
|
222
222
|
status: string | null;
|
|
223
223
|
planLockedAt: string | null;
|
|
224
224
|
canEditProducts: boolean;
|
|
225
|
+
shippedLock: string | null;
|
|
226
|
+
priceLock: string | null;
|
|
225
227
|
items: {
|
|
226
228
|
id: string;
|
|
227
229
|
productId: string | null;
|
|
@@ -230,6 +232,7 @@ export declare const getLocalOrderForEdit: import("@tanstack/start-client-core")
|
|
|
230
232
|
unit: string | null;
|
|
231
233
|
plantsPerCrate: number | null;
|
|
232
234
|
needsSticker: boolean;
|
|
235
|
+
unitPrice: number | null;
|
|
233
236
|
shippedQuantity: number;
|
|
234
237
|
plannedQuantity: number;
|
|
235
238
|
minQuantity: number;
|
|
@@ -247,6 +250,10 @@ export declare const updateLocalOrder: import("@tanstack/start-client-core").Opt
|
|
|
247
250
|
itemId: string;
|
|
248
251
|
quantity: number;
|
|
249
252
|
}[] | undefined;
|
|
253
|
+
prices?: {
|
|
254
|
+
itemId: string;
|
|
255
|
+
unitPrice: number;
|
|
256
|
+
}[] | undefined;
|
|
250
257
|
removeItemIds?: string[] | undefined;
|
|
251
258
|
newItems?: {
|
|
252
259
|
productId: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,2BAA2B;;;;;;GA+CpC,CAAC;AAIL,eAAO,MAAM,2BAA2B;;;;0CAElB,OAAO;;;;GAoDzB,CAAC;AAWL,eAAO,MAAM,0BAA0B;;;;;;YA+D7B,MAAM;iBACD,MAAM;sBACD,MAAM,GAAG,IAAI;cACrB,MAAM;oBACA,MAAM,GAAG,IAAI;0BACP,MAAM,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;;GA2SpD,CAAC;AAGL,eAAO,MAAM,kCAAkC;;;;0CAEzB,OAAO;;;;;;;;;;;;;;;;;;;;;;GAkDzB,CAAC;AAKL,eAAO,MAAM,qBAAqB;;;;;;YAoBI,MAAM;;;GAIxC,CAAC;AAGL,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;GAanC,CAAC;AASL,eAAO,MAAM,8BAA8B;;;;8CAEjB,OAAO;;;;GAU7B,CAAC;AASL,eAAO,MAAM,mBAAmB;;;;;;;;0BAgBuB,MAAM;0BAAoB,MAAM;yBAAmB,MAAM;;;GA8C5G,CAAC;AAGL,eAAO,MAAM,kBAAkB;;;;;;GAU3B,CAAC;AAkFL,eAAO,MAAM,iBAAiB;;;;8CAEJ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAmTL,MAAM;;;;GAK9B,CAAC;AAKL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;;GAc7B,CAAC;AAQL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;GAoG7B,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,qBAAqB;;;;8CAER,OAAO;;;;GAyB7B,CAAC;AAkDL,eAAO,MAAM,oBAAoB;;;;8CAEP,OAAO;;;aA2JG,MAAM;iBACQ,MAAM,GAAG,IAAI;kBACX,MAAM;;YAEnB,MAAM,GAAG,IAAI;;;;;;YA8B7B,MAAM;mBACS,MAAM,GAAG,IAAI;qBACT,MAAM;;cAErB,MAAM,GAAG,IAAI;;;;;;;;GAUpC,CAAC;AAIL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuT7B,CAAC;AAKL,eAAO,MAAM,kBAAkB;;;;8CAEL,OAAO;;;;;;;;WAUM,MAAM;YAAU,MAAM,GAAG,IAAI;WAmBhE,CAAC;AAOL,eAAO,MAAM,2BAA2B;;;;8CAEd,OAAO;;;;gBAIgC,MAAM,EAAE;GAoCrE,CAAC"}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { stockError, stockErrorText } from "./stock-errors.js";
|
|
5
5
|
import { posOrNull, choosePacking } from "./packing-snapshot.js";
|
|
6
6
|
import { createServerFn } from "@tanstack/react-start";
|
|
7
|
+
import { shippedLockReason } from "./order-price-lock.js";
|
|
7
8
|
import { productNameForStorage } from "./product-name.js";
|
|
8
9
|
import { z } from "zod";
|
|
9
10
|
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
@@ -752,6 +753,16 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
752
753
|
// Alleen voor de terugval bij een oude Engine (custom_fields.carrier).
|
|
753
754
|
let fallbackCarrierId = null;
|
|
754
755
|
let ownTransportInfo = null;
|
|
756
|
+
// Eigen vervoer: vastleggen als de Engine-vervoerder met soort eigen_vervoer
|
|
757
|
+
// (carriers.carrier_kind), zodat de Engine geen favoriet kiest en niet
|
|
758
|
+
// bundelt met vervoerdersorders. Ontbreekt die, dan geen vervoerder.
|
|
759
|
+
let ownCarrierId = null;
|
|
760
|
+
if (ownTransport) {
|
|
761
|
+
const { data: oc } = await context.supabase
|
|
762
|
+
.from("carriers").select("id").eq("carrier_kind", "eigen_vervoer").is("archived_at", null)
|
|
763
|
+
.order("name", { ascending: true }).limit(1).maybeSingle();
|
|
764
|
+
ownCarrierId = oc?.id ?? null;
|
|
765
|
+
}
|
|
755
766
|
let momentKey = null;
|
|
756
767
|
let deliveryTime = null;
|
|
757
768
|
let lateSignup = null;
|
|
@@ -922,8 +933,8 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
922
933
|
const orderPayload = {
|
|
923
934
|
// Vervoerder via de Engine in dezelfde transactie (logistics_set_order_carrier);
|
|
924
935
|
// geen custom_fields.carrier meer, behalve als terugval bij een oude Engine.
|
|
925
|
-
manual_carrier_id: carrierId,
|
|
926
|
-
fallback_carrier_id: fallbackCarrierId,
|
|
936
|
+
manual_carrier_id: carrierId ?? ownCarrierId,
|
|
937
|
+
fallback_carrier_id: fallbackCarrierId ?? ownCarrierId,
|
|
927
938
|
set_by_user_id: context.userId ?? null,
|
|
928
939
|
customer_name: data.customerName,
|
|
929
940
|
customer_id: data.customerId,
|
|
@@ -1181,6 +1192,8 @@ const UpdateLocalOrderInput = z.object({
|
|
|
1181
1192
|
quantity: z.number().int().positive(),
|
|
1182
1193
|
}))
|
|
1183
1194
|
.optional(),
|
|
1195
|
+
// Prijs per bestaande regel (alleen HO/AO/MO, niet na een definitieve factuur).
|
|
1196
|
+
prices: z.array(z.object({ itemId: z.string().uuid(), unitPrice: z.number().min(0).max(1000000) })).max(500).optional(),
|
|
1184
1197
|
// Regels verwijderen — alleen zolang de order niet in het Pickstation is
|
|
1185
1198
|
// geprint (orders.plan_locked_at is leeg).
|
|
1186
1199
|
removeItemIds: z.array(z.string().uuid()).optional(),
|
|
@@ -1224,7 +1237,7 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
|
1224
1237
|
}
|
|
1225
1238
|
const { data: items, error: iErr } = await context.supabase
|
|
1226
1239
|
.from("order_items")
|
|
1227
|
-
.select("id, product_id, product_name, quantity, unit, needs_sticker, plants_per_crate, products(plants_per_crate)")
|
|
1240
|
+
.select("id, product_id, product_name, quantity, unit, needs_sticker, unit_price, plants_per_crate, products(plants_per_crate)")
|
|
1228
1241
|
.eq("order_id", data.orderId)
|
|
1229
1242
|
.is("quarantined_at", null)
|
|
1230
1243
|
.order("id");
|
|
@@ -1365,6 +1378,18 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
|
1365
1378
|
status: order.status,
|
|
1366
1379
|
planLockedAt: order.plan_locked_at ?? null,
|
|
1367
1380
|
canEditProducts: !order.plan_locked_at,
|
|
1381
|
+
shippedLock: shippedLockReason(order.status, false),
|
|
1382
|
+
// Prijs wijzigen: null = mag; anders de reden (definitieve factuur / Twinfield).
|
|
1383
|
+
priceLock: await (async () => {
|
|
1384
|
+
try {
|
|
1385
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
1386
|
+
const { loadPriceLock } = await import("./order-price-lock.server.js");
|
|
1387
|
+
return await loadPriceLock(context.supabase, supabaseAdmin, order.id, false);
|
|
1388
|
+
}
|
|
1389
|
+
catch (e) {
|
|
1390
|
+
return `Factuurstand onbekend: ${e?.message ?? "fout"}`;
|
|
1391
|
+
}
|
|
1392
|
+
})(),
|
|
1368
1393
|
items: rows.map((it) => {
|
|
1369
1394
|
// Eerst de vastgelegde verpakking van de regel zelf; onbekend = null.
|
|
1370
1395
|
let ppc = posOrNull(it.plants_per_crate) ?? posOrNull(it.products?.plants_per_crate);
|
|
@@ -1390,6 +1415,7 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
|
1390
1415
|
unit: it.unit,
|
|
1391
1416
|
plantsPerCrate: ppc,
|
|
1392
1417
|
needsSticker: it.needs_sticker === true,
|
|
1418
|
+
unitPrice: it.unit_price == null ? null : Number(it.unit_price),
|
|
1393
1419
|
shippedQuantity: shipped,
|
|
1394
1420
|
plannedQuantity: planned,
|
|
1395
1421
|
minQuantity: shipped + planned,
|
|
@@ -1404,7 +1430,7 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1404
1430
|
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
1405
1431
|
const { data: order, error: oErr } = await supabaseAdmin
|
|
1406
1432
|
.from("orders")
|
|
1407
|
-
.select("id, custom_fields, order_source, is_reservation, plan_locked_at, delivery_date")
|
|
1433
|
+
.select("id, custom_fields, order_source, is_reservation, plan_locked_at, delivery_date, status")
|
|
1408
1434
|
.eq("id", data.orderId)
|
|
1409
1435
|
.maybeSingle();
|
|
1410
1436
|
if (oErr)
|
|
@@ -1423,7 +1449,7 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1423
1449
|
// voorraadcontrole, herberekening of nieuwe planning.
|
|
1424
1450
|
const { data: currentRows, error: cErr } = await supabaseAdmin
|
|
1425
1451
|
.from("order_items")
|
|
1426
|
-
.select("id, quantity, needs_sticker")
|
|
1452
|
+
.select("id, quantity, needs_sticker, unit_price")
|
|
1427
1453
|
.eq("order_id", data.orderId);
|
|
1428
1454
|
if (cErr)
|
|
1429
1455
|
throw stockError(cErr.message);
|
|
@@ -1431,6 +1457,14 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1431
1457
|
r.id,
|
|
1432
1458
|
{ quantity: Number(r.quantity ?? 0), needsSticker: r.needs_sticker === true },
|
|
1433
1459
|
]));
|
|
1460
|
+
const priceById = new Map((currentRows ?? []).map((r) => [r.id, Number(r.unit_price ?? 0)]));
|
|
1461
|
+
const priceChanges = (data.prices ?? []).filter((p) => priceById.has(p.itemId) && !removeIds.includes(p.itemId) && Math.abs((priceById.get(p.itemId) ?? 0) - p.unitPrice) > 0.00001);
|
|
1462
|
+
if (priceChanges.length > 0) {
|
|
1463
|
+
const { loadPriceLock } = await import("./order-price-lock.server.js");
|
|
1464
|
+
const lock = await loadPriceLock(context.supabase, supabaseAdmin, data.orderId, false);
|
|
1465
|
+
if (lock)
|
|
1466
|
+
throw stockError(lock);
|
|
1467
|
+
}
|
|
1434
1468
|
const changedItems = (data.items ?? []).filter((i) => {
|
|
1435
1469
|
const cur = currentById.get(i.itemId);
|
|
1436
1470
|
return !cur || cur.quantity !== i.quantity;
|
|
@@ -1445,7 +1479,12 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1445
1479
|
String(data.deliveryDate).slice(0, 10) !== String(order.delivery_date ?? "").slice(0, 10);
|
|
1446
1480
|
if (!dateChanged)
|
|
1447
1481
|
data.deliveryDate = undefined;
|
|
1448
|
-
const realChange = changedItems.length > 0 || removeIds.length > 0 || newItems.length > 0 || dateChanged;
|
|
1482
|
+
const realChange = priceChanges.length > 0 || changedItems.length > 0 || removeIds.length > 0 || newItems.length > 0 || dateChanged;
|
|
1483
|
+
if (realChange) {
|
|
1484
|
+
const shipLock = shippedLockReason(order.status, false);
|
|
1485
|
+
if (shipLock)
|
|
1486
|
+
throw stockError(shipLock);
|
|
1487
|
+
}
|
|
1449
1488
|
// Producten wijzigen mag alleen zolang er nog niets is geprint in het
|
|
1450
1489
|
// Pickstation (orders.plan_locked_at).
|
|
1451
1490
|
if ((removeIds.length > 0 || newItems.length > 0) && order.plan_locked_at) {
|
|
@@ -1564,32 +1603,42 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1564
1603
|
if (newDate !== String(order.delivery_date ?? "").slice(0, 10) && cf?.delivery_location) {
|
|
1565
1604
|
const { loadDeparturePreview, deliveryTimeForMoment } = await import("./departure-preview.server.js");
|
|
1566
1605
|
const { decidePreview } = await import("./departure-preview.js");
|
|
1567
|
-
const
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
if (d.kind === "blocked")
|
|
1575
|
-
throw stockError(d.reason);
|
|
1576
|
-
// Vervoerder al vertrokken: ook bij wijzigen nooit doorlaten.
|
|
1577
|
-
if (d.kind === "departed") {
|
|
1578
|
-
throw stockError(d.firstDate ? `${d.reason} De eerstvolgende leverdatum is ${d.firstDate}.` : d.reason);
|
|
1606
|
+
const { resolveCarrierOne } = await import("./carrier-resolve.server.js");
|
|
1607
|
+
const { ownTransportDateDecision } = await import("./own-transport.js");
|
|
1608
|
+
const resolved = await resolveCarrierOne(context.supabase, data.orderId, { id: cf?.carrier ?? null, name: null });
|
|
1609
|
+
const ownDec = ownTransportDateDecision({ ownTransport: !!cf?.own_transport, carrierKind: resolved.carrierKind });
|
|
1610
|
+
if (ownDec.skipDeparture) {
|
|
1611
|
+
newMoment = null;
|
|
1612
|
+
newDeliveryTime = null;
|
|
1579
1613
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1614
|
+
else {
|
|
1615
|
+
const preview = await loadDeparturePreview(context.supabase, {
|
|
1616
|
+
carrierId: resolved.carrierId ?? cf?.carrier ?? null,
|
|
1617
|
+
deliveryLocation: String(cf.delivery_location),
|
|
1618
|
+
deliveryDate: newDate,
|
|
1619
|
+
momentKey: null,
|
|
1620
|
+
});
|
|
1621
|
+
const d = decidePreview(preview);
|
|
1622
|
+
if (d.kind === "blocked")
|
|
1623
|
+
throw stockError(d.reason);
|
|
1624
|
+
// Vervoerder al vertrokken: ook bij wijzigen nooit doorlaten.
|
|
1625
|
+
if (d.kind === "departed") {
|
|
1626
|
+
throw stockError(d.firstDate ? `${d.reason} De eerstvolgende leverdatum is ${d.firstDate}.` : d.reason);
|
|
1627
|
+
}
|
|
1628
|
+
if (d.kind === "late") {
|
|
1629
|
+
if (!data.acceptLateSignup) {
|
|
1630
|
+
throw stockError(d.firstDate ? `${d.reason} De eerste haalbare leverdatum is ${d.firstDate}.` : d.reason);
|
|
1631
|
+
}
|
|
1632
|
+
const by = context.claims?.email ?? null;
|
|
1633
|
+
lateOverride = {
|
|
1634
|
+
by_user_id: context.userId ?? null, by_email: by, by_name: by,
|
|
1635
|
+
at: new Date().toISOString(), delivery_date: newDate,
|
|
1636
|
+
signup_deadline: preview?.chosen?.signupDeadline ?? null, reason: d.reason, source: "manual",
|
|
1637
|
+
};
|
|
1583
1638
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
by_user_id: context.userId ?? null, by_email: by, by_name: by,
|
|
1587
|
-
at: new Date().toISOString(), delivery_date: newDate,
|
|
1588
|
-
signup_deadline: preview?.chosen?.signupDeadline ?? null, reason: d.reason, source: "manual",
|
|
1589
|
-
};
|
|
1639
|
+
newMoment = d.momentKey;
|
|
1640
|
+
newDeliveryTime = await deliveryTimeForMoment(context.supabase, resolved.carrierId ?? cf?.carrier ?? null, newMoment);
|
|
1590
1641
|
}
|
|
1591
|
-
newMoment = d.momentKey;
|
|
1592
|
-
newDeliveryTime = await deliveryTimeForMoment(context.supabase, cf?.carrier ?? null, newMoment);
|
|
1593
1642
|
}
|
|
1594
1643
|
const { error: uErr } = await supabaseAdmin.from("orders")
|
|
1595
1644
|
.update({
|
|
@@ -1613,7 +1662,15 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1613
1662
|
throw stockError(`Aantal bijwerken faalde: ${iErr.message}`);
|
|
1614
1663
|
}
|
|
1615
1664
|
}
|
|
1616
|
-
|
|
1665
|
+
for (const pc of priceChanges) {
|
|
1666
|
+
const { error: pErr } = await supabaseAdmin.from("order_items")
|
|
1667
|
+
.update({ unit_price: pc.unitPrice })
|
|
1668
|
+
.eq("id", pc.itemId)
|
|
1669
|
+
.eq("order_id", data.orderId);
|
|
1670
|
+
if (pErr)
|
|
1671
|
+
throw stockError(`Prijs bijwerken faalde: ${pErr.message}`);
|
|
1672
|
+
}
|
|
1673
|
+
if ((data.items?.length ?? 0) > 0 || removeIds.length > 0 || newItems.length > 0 || priceChanges.length > 0) {
|
|
1617
1674
|
// Hertellen ordertotaal op basis van items × unit_price.
|
|
1618
1675
|
const { data: itemsAll } = await supabaseAdmin
|
|
1619
1676
|
.from("order_items")
|
|
@@ -8,7 +8,7 @@ export declare const getFlorydayCachedList: import("@tanstack/start-client-core"
|
|
|
8
8
|
limit?: number | undefined;
|
|
9
9
|
since?: string | undefined;
|
|
10
10
|
until?: string | undefined;
|
|
11
|
-
dateField?: "
|
|
11
|
+
dateField?: "delivery" | "ordered" | undefined;
|
|
12
12
|
}, Promise<{
|
|
13
13
|
entity: string;
|
|
14
14
|
rows: any;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const MODULE_VERSION = "1.0.
|
|
1
|
+
export declare const MODULE_VERSION = "1.0.138";
|
|
2
2
|
//# sourceMappingURL=module-version.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare function prefersReducedMotion(): boolean;
|
|
2
|
+
/** Inschuiven/infaden: `y` px omhoog en van 0 naar 1 opacity. */
|
|
3
|
+
export declare function animateIn(el: Element | null, opts: {
|
|
4
|
+
duration: number;
|
|
5
|
+
y?: number;
|
|
6
|
+
}): void;
|
|
7
|
+
/** Korte achtergrondmarkering die in `duration` ms uitfadet (nieuwe rij). */
|
|
8
|
+
export declare function flashBackground(el: Element | null, color: string, duration?: number): void;
|
|
9
|
+
/** Inline transitie-stijl die wegvalt bij reduced motion. */
|
|
10
|
+
export declare function transitionStyle(props: string, ms: number): {
|
|
11
|
+
transition?: string;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/lib/motion.ts"],"names":[],"mappings":"AAIA,wBAAgB,oBAAoB,IAAI,OAAO,CAG9C;AAID,iEAAiE;AACjE,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,EAAE,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,CAAC,CAAC,EAAE,MAAM,CAAA;CAAE,QAUnF;AAED,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,SAAO,QAOjF;AAED,6DAA6D;AAC7D,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG;IAAE,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAGlF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Subtiele animaties zonder bibliotheek of keyframes in CSS: de Web
|
|
2
|
+
// Animations API werkt in elke shell, ook als de shell de klassen van deze
|
|
3
|
+
// module niet meecompileert. Alles valt weg bij prefers-reduced-motion.
|
|
4
|
+
export function prefersReducedMotion() {
|
|
5
|
+
if (typeof window === "undefined" || !window.matchMedia)
|
|
6
|
+
return true;
|
|
7
|
+
return window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
8
|
+
}
|
|
9
|
+
const EASE_OUT = "cubic-bezier(0.16, 1, 0.3, 1)";
|
|
10
|
+
/** Inschuiven/infaden: `y` px omhoog en van 0 naar 1 opacity. */
|
|
11
|
+
export function animateIn(el, opts) {
|
|
12
|
+
if (!el || prefersReducedMotion() || typeof el.animate !== "function")
|
|
13
|
+
return;
|
|
14
|
+
const y = opts.y ?? 0;
|
|
15
|
+
el.animate([
|
|
16
|
+
{ opacity: 0, transform: `translateY(${y}px)` },
|
|
17
|
+
{ opacity: 1, transform: "translateY(0)" },
|
|
18
|
+
], { duration: opts.duration, easing: EASE_OUT });
|
|
19
|
+
}
|
|
20
|
+
/** Korte achtergrondmarkering die in `duration` ms uitfadet (nieuwe rij). */
|
|
21
|
+
export function flashBackground(el, color, duration = 2000) {
|
|
22
|
+
if (!el || typeof el.animate !== "function")
|
|
23
|
+
return;
|
|
24
|
+
if (prefersReducedMotion())
|
|
25
|
+
return;
|
|
26
|
+
el.animate([{ backgroundColor: color }, { backgroundColor: "transparent" }], {
|
|
27
|
+
duration,
|
|
28
|
+
easing: EASE_OUT,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Inline transitie-stijl die wegvalt bij reduced motion. */
|
|
32
|
+
export function transitionStyle(props, ms) {
|
|
33
|
+
if (prefersReducedMotion())
|
|
34
|
+
return {};
|
|
35
|
+
return { transition: props.split(",").map((p) => `${p.trim()} ${ms}ms ${EASE_OUT}`).join(", ") };
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-price-lock.check.d.ts","sourceRoot":"","sources":["../../src/lib/order-price-lock.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// Draai: bun src/lib/order-price-lock.check.ts
|
|
2
|
+
import { orderUuid, priceLockReason, shippedLockReason, SHIPPED_LOCK_TEXT, PRICE_LOCK_ERP_TEXT, PRICE_LOCK_FLORIDAY_TEXT, PRICE_LOCK_TWINFIELD_TEXT } from "./order-price-lock.js";
|
|
3
|
+
import { ownTransportDateDecision } from "./own-transport.js";
|
|
4
|
+
let failed = 0;
|
|
5
|
+
function check(name, got, want) {
|
|
6
|
+
const ok = JSON.stringify(got) === JSON.stringify(want);
|
|
7
|
+
if (!ok)
|
|
8
|
+
failed++;
|
|
9
|
+
console.log(`${ok ? "OK " : "FOUT"} ${name}: ${JSON.stringify(got)}${ok ? "" : ` (verwacht ${JSON.stringify(want)})`}`);
|
|
10
|
+
}
|
|
11
|
+
check("Floriday-order geweigerd", priceLockReason({ isFloriday: true, erpInvoices: [], links: [] }), PRICE_LOCK_FLORIDAY_TEXT);
|
|
12
|
+
const inv = (status, extra = {}) => ({ id: "A", invoice_number: "FS-1", kind: "factuur", status, total: 100, ...extra });
|
|
13
|
+
for (const st of ["verstuurd", "boeking_wacht", "boeking_wijkt_af", "boeking_afgewezen", "definitief", "geboekt"]) {
|
|
14
|
+
check(`factuur met nummer, status ${st} → geblokkeerd`, priceLockReason({ isFloriday: false, erpInvoices: [inv(st)], links: [] }), PRICE_LOCK_ERP_TEXT);
|
|
15
|
+
}
|
|
16
|
+
check("AO-2601452: boeking_afgewezen TEST-FS-2026-00001 → geblokkeerd", priceLockReason({ isFloriday: false, erpInvoices: [inv("boeking_afgewezen", { invoice_number: "TEST-FS-2026-00001" })], links: [] }), PRICE_LOCK_ERP_TEXT);
|
|
17
|
+
check("ERP-concept zonder nummer → toegestaan", priceLockReason({ isFloriday: false, erpInvoices: [{ id: "A", invoice_number: null, kind: "factuur", status: "concept", total: 100 }], links: [] }), null);
|
|
18
|
+
const credit = (extra = {}) => ({ id: "C", invoice_number: "FS-2", kind: "credit", status: "definitief", total: -100, original_invoice_id: "A", ...extra });
|
|
19
|
+
check("volledige credit naar de factuur → toegestaan", priceLockReason({ isFloriday: false, erpInvoices: [inv("geboekt"), credit()], links: [] }), null);
|
|
20
|
+
check("gedeeltelijke credit → geblokkeerd", priceLockReason({ isFloriday: false, erpInvoices: [inv("geboekt"), credit({ total: -40 })], links: [] }), PRICE_LOCK_ERP_TEXT);
|
|
21
|
+
check("credit zonder nummer → geblokkeerd", priceLockReason({ isFloriday: false, erpInvoices: [inv("geboekt"), credit({ invoice_number: null })], links: [] }), PRICE_LOCK_ERP_TEXT);
|
|
22
|
+
check("credit zonder verwijzing → geblokkeerd", priceLockReason({ isFloriday: false, erpInvoices: [inv("geboekt"), credit({ original_invoice_id: undefined })], links: [] }), PRICE_LOCK_ERP_TEXT);
|
|
23
|
+
check("factuur A gecrediteerd + nieuwe factuur B → geblokkeerd", priceLockReason({ isFloriday: false, erpInvoices: [inv("geboekt"), credit(), inv("verstuurd", { id: "B", invoice_number: "FS-3" })], links: [] }), PRICE_LOCK_ERP_TEXT);
|
|
24
|
+
for (const st of ["Verzonden", "Geleverd", "Gereed voor facturatie"])
|
|
25
|
+
check(`status ${st} → vergrendeld`, shippedLockReason(st, false), SHIPPED_LOCK_TEXT);
|
|
26
|
+
check("Nog te picken → niet vergrendeld", shippedLockReason("Nog te picken", false), null);
|
|
27
|
+
check("Floriday-order: verzonden-slot niet van toepassing", shippedLockReason("Verzonden", true), null);
|
|
28
|
+
check("AO-2601453 (Verzonden in zeta) → vergrendeld", shippedLockReason("Verzonden", false), SHIPPED_LOCK_TEXT);
|
|
29
|
+
check("HO-2601467 (Nog te picken in zeta) → te bewerken", shippedLockReason("Nog te picken", false), null);
|
|
30
|
+
check("status hoofdletterongevoelig (' verzonden ') → vergrendeld", shippedLockReason(" verzonden ", false), SHIPPED_LOCK_TEXT);
|
|
31
|
+
check("oude Twinfield-concept 40 (AO-2601453)", priceLockReason({ isFloriday: false, erpInvoices: [], links: [{ status: "sent", invoice_number: "40" }] }), PRICE_LOCK_TWINFIELD_TEXT);
|
|
32
|
+
check("link met ERP-nummer: ERP-melding, geen Twinfield-melding", priceLockReason({ isFloriday: false, erpInvoices: [{ invoice_number: "FS-1", kind: "factuur", status: "concept" }], links: [{ status: "sent", invoice_number: "FS-1" }] }), PRICE_LOCK_ERP_TEXT);
|
|
33
|
+
check("zonder Facturatie → toegestaan", priceLockReason({ isFloriday: false, erpInvoices: null, links: null }), null);
|
|
34
|
+
check("local:-id → uuid", orderUuid("local:6f1c2b9e-1111-4222-8333-944455556666"), "6f1c2b9e-1111-4222-8333-944455556666");
|
|
35
|
+
check("Floriday-id zonder uuid → null", orderUuid("FO-2601463"), null);
|
|
36
|
+
check("eigen vervoer: geen vertrekcontrole", ownTransportDateDecision({ ownTransport: true, carrierKind: "extern" }), { skipDeparture: true, clearMoment: true });
|
|
37
|
+
check("klant haalt op: geen vertrekcontrole", ownTransportDateDecision({ ownTransport: false, carrierKind: "klant_haalt_op" }), { skipDeparture: true, clearMoment: true });
|
|
38
|
+
check("externe vervoerder: wel controle", ownTransportDateDecision({ ownTransport: false, carrierKind: "extern" }), { skipDeparture: false, clearMoment: false });
|
|
39
|
+
if (failed) {
|
|
40
|
+
console.error(`${failed} fout(en)`);
|
|
41
|
+
process.exit(1);
|
|
42
|
+
}
|
|
43
|
+
console.log("Alles OK");
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export declare const PRICE_LOCK_ERP_TEXT = "Er staat al een factuur met nummer; eerst crediteren.";
|
|
2
|
+
export declare const PRICE_LOCK_TWINFIELD_TEXT = "Er staat al een factuur in Twinfield; verwijder of crediteer die eerst.";
|
|
3
|
+
export declare const PRICE_LOCK_FLORIDAY_TEXT = "Bij Floriday-orders blijft de prijs uit Floriday staan.";
|
|
4
|
+
export declare const SHIPPED_LOCK_TEXT = "Deze order is al verzonden; wijzigen kan niet meer.";
|
|
5
|
+
/** Verzonden/Geleverd/Gereed voor facturatie: leverdatum, aantallen en prijs vast. Floriday-orders: ongewijzigd gedrag. */
|
|
6
|
+
export declare function shippedLockReason(status: string | null | undefined, isFloriday: boolean): string | null;
|
|
7
|
+
export type ErpInvoiceLockRow = {
|
|
8
|
+
id?: string | null;
|
|
9
|
+
invoice_number: string | null;
|
|
10
|
+
kind: string | null;
|
|
11
|
+
status: string | null;
|
|
12
|
+
total?: number | string | null;
|
|
13
|
+
/** Bij creditfacturen: de gecrediteerde factuur. Ontbreekt → telt niet als credit (fail closed). */
|
|
14
|
+
original_invoice_id?: string | null;
|
|
15
|
+
};
|
|
16
|
+
export type PriceLockInput = {
|
|
17
|
+
isFloriday: boolean;
|
|
18
|
+
/** null = Facturatie niet aanwezig (functie of tabel ontbreekt). */
|
|
19
|
+
erpInvoices: ErpInvoiceLockRow[] | null;
|
|
20
|
+
/** null = koppeltabel niet aanwezig. */
|
|
21
|
+
links: Array<{
|
|
22
|
+
status: string | null;
|
|
23
|
+
invoice_number: string | null;
|
|
24
|
+
}> | null;
|
|
25
|
+
};
|
|
26
|
+
export declare function priceLockReason(i: PriceLockInput): string | null;
|
|
27
|
+
/** "local:<uuid>" of "<uuid>" → uuid; anders null. */
|
|
28
|
+
export declare function orderUuid(id: unknown): string | null;
|
|
29
|
+
//# sourceMappingURL=order-price-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-price-lock.d.ts","sourceRoot":"","sources":["../../src/lib/order-price-lock.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,0DAA0D,CAAC;AAC3F,eAAO,MAAM,yBAAyB,4EAA4E,CAAC;AACnH,eAAO,MAAM,wBAAwB,4DAA4D,CAAC;AAClG,eAAO,MAAM,iBAAiB,wDAAwD,CAAC;AAIvF,2HAA2H;AAC3H,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,UAAU,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAGvG;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC9B,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC/B,oGAAoG;IACpG,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,oEAAoE;IACpE,WAAW,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAC;IACxC,wCAAwC;IACxC,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;CAC/E,CAAC;AA4BF,wBAAgB,eAAe,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAWhE;AAED,sDAAsD;AACtD,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAGpD"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
// Mag de prijs van een bestaande order nog gewijzigd worden? (client-safe, puur)
|
|
2
|
+
// Alleen HO/AO/MO; Floriday-orders houden de prijs uit Floriday.
|
|
3
|
+
export const PRICE_LOCK_ERP_TEXT = "Er staat al een factuur met nummer; eerst crediteren.";
|
|
4
|
+
export const PRICE_LOCK_TWINFIELD_TEXT = "Er staat al een factuur in Twinfield; verwijder of crediteer die eerst.";
|
|
5
|
+
export const PRICE_LOCK_FLORIDAY_TEXT = "Bij Floriday-orders blijft de prijs uit Floriday staan.";
|
|
6
|
+
export const SHIPPED_LOCK_TEXT = "Deze order is al verzonden; wijzigen kan niet meer.";
|
|
7
|
+
const SHIPPED_STATUSES = new Set(["verzonden", "geleverd", "gereed voor facturatie", "shipped", "delivered"]);
|
|
8
|
+
/** Verzonden/Geleverd/Gereed voor facturatie: leverdatum, aantallen en prijs vast. Floriday-orders: ongewijzigd gedrag. */
|
|
9
|
+
export function shippedLockReason(status, isFloriday) {
|
|
10
|
+
if (isFloriday)
|
|
11
|
+
return null;
|
|
12
|
+
return SHIPPED_STATUSES.has(String(status ?? "").trim().toLowerCase()) ? SHIPPED_LOCK_TEXT : null;
|
|
13
|
+
}
|
|
14
|
+
const hasNumber = (r) => !!String(r.invoice_number ?? "").trim();
|
|
15
|
+
const amount = (v) => {
|
|
16
|
+
if (v === null || v === undefined || v === "")
|
|
17
|
+
return null;
|
|
18
|
+
const n = Math.abs(Number(v));
|
|
19
|
+
return Number.isFinite(n) ? n : null;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Factuur (geen credit) met nummer die niet volledig gecrediteerd is.
|
|
23
|
+
* Gecrediteerd = creditfacturen met nummer die via original_invoice_id naar deze factuur
|
|
24
|
+
* verwijzen en samen het volledige bedrag dekken. Status maakt niet uit.
|
|
25
|
+
*/
|
|
26
|
+
function isOpenNumberedInvoice(r, all) {
|
|
27
|
+
if ((r.kind ?? "factuur") === "credit" || !hasNumber(r))
|
|
28
|
+
return false;
|
|
29
|
+
const total = amount(r.total);
|
|
30
|
+
if (!r.id || total === null)
|
|
31
|
+
return true;
|
|
32
|
+
let credited = 0;
|
|
33
|
+
for (const c of all) {
|
|
34
|
+
if (c.kind !== "credit" || !hasNumber(c) || !c.original_invoice_id || c.original_invoice_id !== r.id)
|
|
35
|
+
continue;
|
|
36
|
+
const a = amount(c.total);
|
|
37
|
+
if (a === null)
|
|
38
|
+
return true;
|
|
39
|
+
credited += a;
|
|
40
|
+
}
|
|
41
|
+
return credited + 0.005 < total;
|
|
42
|
+
}
|
|
43
|
+
export function priceLockReason(i) {
|
|
44
|
+
if (i.isFloriday)
|
|
45
|
+
return PRICE_LOCK_FLORIDAY_TEXT;
|
|
46
|
+
if (i.erpInvoices && i.erpInvoices.some((r) => isOpenNumberedInvoice(r, i.erpInvoices)))
|
|
47
|
+
return PRICE_LOCK_ERP_TEXT;
|
|
48
|
+
if (i.links && i.erpInvoices) {
|
|
49
|
+
const known = new Set(i.erpInvoices.map((r) => String(r.invoice_number ?? "").trim()).filter(Boolean));
|
|
50
|
+
const legacy = i.links.some((l) => l.status === "sent" && !!String(l.invoice_number ?? "").trim() && !known.has(String(l.invoice_number).trim()));
|
|
51
|
+
if (legacy)
|
|
52
|
+
return PRICE_LOCK_TWINFIELD_TEXT;
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
/** "local:<uuid>" of "<uuid>" → uuid; anders null. */
|
|
57
|
+
export function orderUuid(id) {
|
|
58
|
+
const s = String(id ?? "").replace(/^local:/, "").trim();
|
|
59
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s) ? s : null;
|
|
60
|
+
}
|