@flowselections/floriday-verkoop-module 1.0.142 → 1.0.143
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.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.js +274 -203
- package/dist-lib/components/verkoop/EngineBufferCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EngineBufferCard.js +2 -4
- package/dist-lib/components/verkoop/FloridaySyncSettings.d.ts.map +1 -1
- package/dist-lib/components/verkoop/FloridaySyncSettings.js +2 -1
- package/dist-lib/components/verkoop/OrderControlStatusCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderControlStatusCard.js +2 -10
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts +7 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.js +4 -3
- package/dist-lib/components/verkoop/OrderLinePackingCard.js +2 -2
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderPickupMomentPicker.js +4 -8
- package/dist-lib/components/verkoop/OrderShipmentsCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.js +2 -4
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +15 -7
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +24 -15
- package/dist-lib/components/verkoop/SalesOrdersTable.js +3 -3
- package/dist-lib/components/verkoop/SearchableSelect.d.ts +10 -1
- package/dist-lib/components/verkoop/SearchableSelect.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SearchableSelect.js +13 -4
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +3 -2
- package/dist-lib/components/verkoop/v3/OrderProgress.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/OrderProgress.js +3 -8
- package/dist-lib/components/verkoop/v3/OrderStepper.d.ts.map +1 -1
- package/dist-lib/components/verkoop/v3/OrderStepper.js +2 -4
- package/dist-lib/integrations/supabase/types.d.ts +16 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/buffer-carts.d.ts +15 -0
- package/dist-lib/lib/buffer-carts.d.ts.map +1 -1
- package/dist-lib/lib/buffer-carts.js +21 -0
- package/dist-lib/lib/buffer-pick-progress.check.d.ts +2 -0
- package/dist-lib/lib/buffer-pick-progress.check.d.ts.map +1 -0
- package/dist-lib/lib/buffer-pick-progress.check.js +11 -0
- package/dist-lib/lib/create-order-customers.d.ts +8 -0
- package/dist-lib/lib/create-order-customers.d.ts.map +1 -0
- package/dist-lib/lib/create-order-customers.js +18 -0
- package/dist-lib/lib/create-order-form.check.d.ts +2 -0
- package/dist-lib/lib/create-order-form.check.d.ts.map +1 -0
- package/dist-lib/lib/create-order-form.check.js +27 -0
- package/dist-lib/lib/create-order-form.d.ts +22 -0
- package/dist-lib/lib/create-order-form.d.ts.map +1 -0
- package/dist-lib/lib/create-order-form.js +52 -0
- package/dist-lib/lib/create-order.functions.d.ts +21 -1
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +66 -19
- package/dist-lib/lib/delivery-format.check.js +6 -2
- package/dist-lib/lib/delivery-format.d.ts +14 -0
- package/dist-lib/lib/delivery-format.d.ts.map +1 -1
- package/dist-lib/lib/delivery-format.js +28 -0
- package/dist-lib/lib/floriday-invoice-line.check.d.ts +2 -0
- package/dist-lib/lib/floriday-invoice-line.check.d.ts.map +1 -0
- package/dist-lib/lib/floriday-invoice-line.check.js +18 -0
- package/dist-lib/lib/floriday-status.d.ts +6 -0
- package/dist-lib/lib/floriday-status.d.ts.map +1 -1
- package/dist-lib/lib/floriday-status.js +26 -0
- package/dist-lib/lib/nl-datetime.check.d.ts +2 -0
- package/dist-lib/lib/nl-datetime.check.d.ts.map +1 -0
- package/dist-lib/lib/nl-datetime.check.js +14 -0
- package/dist-lib/lib/nl-datetime.d.ts +6 -0
- package/dist-lib/lib/nl-datetime.d.ts.map +1 -0
- package/dist-lib/lib/nl-datetime.js +39 -0
- package/dist-lib/lib/order-pickup.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-pickup.functions.js +4 -57
- package/dist-lib/lib/order-pickup.server.d.ts +38 -0
- package/dist-lib/lib/order-pickup.server.d.ts.map +1 -0
- package/dist-lib/lib/order-pickup.server.js +76 -0
- package/dist-lib/lib/pickup-seed.check.d.ts +2 -0
- package/dist-lib/lib/pickup-seed.check.d.ts.map +1 -0
- package/dist-lib/lib/pickup-seed.check.js +18 -0
- package/dist-lib/lib/salesorders-list.functions.d.ts +24 -1
- package/dist-lib/lib/salesorders-list.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.functions.js +11 -6
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +4 -4
- package/dist-lib/lib/salesorders-mapping.d.ts +4 -0
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.d.ts +7 -0
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.js +17 -5
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.d.ts +24 -1
- package/dist-lib/lib/useLocalSalesOrderDetailQuery.d.ts.map +1 -1
- package/dist-lib/lib/usePickupMoment.d.ts +44 -0
- package/dist-lib/lib/usePickupMoment.d.ts.map +1 -0
- package/dist-lib/lib/usePickupMoment.js +46 -0
- package/package.json +1 -1
|
@@ -32,4 +32,19 @@ export type BufferCarts = {
|
|
|
32
32
|
export declare function parseBufferCarts(raw: unknown): BufferCarts | null;
|
|
33
33
|
/** "3 × Stapelwagen, 1 × Deense container" — elke soort apart, nooit één soort voor alles. */
|
|
34
34
|
export declare function ladingdragerSummary(b: Pick<BufferCarts, "ladingdragers">): string;
|
|
35
|
+
/**
|
|
36
|
+
* Geprint/gepickt over de unieke karren van een groep. Telt niets zelf:
|
|
37
|
+
* totaal = karren van de Engine, geprint = karren met een geprint pickdocument.
|
|
38
|
+
* Gepickt staat niet per kar in het Engine-antwoord; alleen als alle orders
|
|
39
|
+
* volgens de Engine volledig (of helemaal niet) gepickt zijn, is het aantal
|
|
40
|
+
* zeker. Anders null (dan wordt "gepickt" niet getoond).
|
|
41
|
+
*/
|
|
42
|
+
export declare function bufferPickProgress(b: BufferCarts | null | undefined, members: Array<{
|
|
43
|
+
cartsTotal?: number | null;
|
|
44
|
+
cartsScanned?: number | null;
|
|
45
|
+
} | null | undefined>): {
|
|
46
|
+
cartsTotal: number;
|
|
47
|
+
cartsPrinted: number;
|
|
48
|
+
cartsScanned: number | null;
|
|
49
|
+
} | null;
|
|
35
50
|
//# sourceMappingURL=buffer-carts.d.ts.map
|
|
@@ -1 +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,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|
40
40
|
return b.ladingdragers.map((l) => `${l.aantal} × ${l.ladingdrager}`).join(", ");
|
|
41
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Geprint/gepickt over de unieke karren van een groep. Telt niets zelf:
|
|
44
|
+
* totaal = karren van de Engine, geprint = karren met een geprint pickdocument.
|
|
45
|
+
* Gepickt staat niet per kar in het Engine-antwoord; alleen als alle orders
|
|
46
|
+
* volgens de Engine volledig (of helemaal niet) gepickt zijn, is het aantal
|
|
47
|
+
* zeker. Anders null (dan wordt "gepickt" niet getoond).
|
|
48
|
+
*/
|
|
49
|
+
export function bufferPickProgress(b, members) {
|
|
50
|
+
if (!b || !(b.karren > 0))
|
|
51
|
+
return null;
|
|
52
|
+
const printed = b.carts.filter((c) => !!c.pickDocument?.printedAt).length;
|
|
53
|
+
const known = members.filter((m) => !!m && (m.cartsTotal ?? 0) > 0);
|
|
54
|
+
let scanned = null;
|
|
55
|
+
if (known.length > 0 && known.length === members.length) {
|
|
56
|
+
if (known.every((m) => (m.cartsScanned ?? 0) >= (m.cartsTotal ?? 0)))
|
|
57
|
+
scanned = b.karren;
|
|
58
|
+
else if (known.every((m) => (m.cartsScanned ?? 0) === 0))
|
|
59
|
+
scanned = 0;
|
|
60
|
+
}
|
|
61
|
+
return { cartsTotal: b.karren, cartsPrinted: printed, cartsScanned: scanned };
|
|
62
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer-pick-progress.check.d.ts","sourceRoot":"","sources":["../../src/lib/buffer-pick-progress.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { bufferPickProgress } from "./buffer-carts.js";
|
|
2
|
+
let fail = 0;
|
|
3
|
+
const eq = (n, a, b) => { const ok = JSON.stringify(a) === JSON.stringify(b); if (!ok)
|
|
4
|
+
fail++; console.log(`${ok ? "OK " : "FOUT"} ${n}: ${JSON.stringify(a)}`); };
|
|
5
|
+
const b = { bufferId: "x", orders: [], karren: 1, ladingdragers: [], dubbeleDocumenten: [],
|
|
6
|
+
carts: [{ cartId: "k1", seq: 1, total: 1, ladingdrager: null, carrierType: null, verouderd: false, verouderdReden: null, verouderdRedenen: null, pickDocument: null }] };
|
|
7
|
+
// FO-2601464 + FO-2601463: elk carts_total 1, carts_scanned 1, samen één kar.
|
|
8
|
+
eq("gedeelde kar → 0 van 1 geprint · 1 van 1 gepickt", bufferPickProgress(b, [{ cartsTotal: 1, cartsScanned: 1 }, { cartsTotal: 1, cartsScanned: 1 }]), { cartsTotal: 1, cartsPrinted: 0, cartsScanned: 1 });
|
|
9
|
+
eq("gemengd → gepickt onbekend", bufferPickProgress({ ...b, karren: 2 }, [{ cartsTotal: 1, cartsScanned: 1 }, { cartsTotal: 1, cartsScanned: 0 }])?.cartsScanned, null);
|
|
10
|
+
if (fail)
|
|
11
|
+
process.exit(1);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-order-customers.d.ts","sourceRoot":"","sources":["../../src/lib/create-order-customers.ts"],"names":[],"mappings":"AAGA,wBAAgB,iBAAiB,CAAC,CAAC,SAAS;IAAE,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAA;CAAE,EACtF,YAAY,EAAE,KAAK,CAAC;IAAE,cAAc,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,EACzE,MAAM,EAAE,CAAC,EAAE,GACV,CAAC,EAAE,CAiBL"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Boekhoudregels (Twinfield) die nog niet als klant bestaan.
|
|
2
|
+
// Ontdubbeld tegen ÁLLE klanten (ook inactieve) op debiteurnummer en naam,
|
|
3
|
+
// en binnen de boekhouding zelf op debiteurnummer (meerdere koppelingen).
|
|
4
|
+
export function twinfieldOnlyRows(allCustomers, twRows) {
|
|
5
|
+
const knownCodes = new Set(allCustomers.map((c) => String(c.twinfield_code ?? "").trim()).filter(Boolean));
|
|
6
|
+
const knownNames = new Set(allCustomers.map((c) => String(c.company_name ?? "").trim().toLowerCase()).filter(Boolean));
|
|
7
|
+
const seen = new Set();
|
|
8
|
+
const out = [];
|
|
9
|
+
for (const t of twRows) {
|
|
10
|
+
const code = String(t.twinfield_code ?? "").trim();
|
|
11
|
+
const name = String(t.name ?? "").trim().toLowerCase();
|
|
12
|
+
if (!code || knownCodes.has(code) || knownNames.has(name) || seen.has(code))
|
|
13
|
+
continue;
|
|
14
|
+
seen.add(code);
|
|
15
|
+
out.push(t);
|
|
16
|
+
}
|
|
17
|
+
return out;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-order-form.check.d.ts","sourceRoot":"","sources":["../../src/lib/create-order-form.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Draai: bun src/lib/create-order-form.check.ts (ook met TZ=UTC)
|
|
2
|
+
import { missingItems, lineCrates, lineTotal, dateWithWeekday } from "./create-order-form.js";
|
|
3
|
+
import { twinfieldOnlyRows } from "./create-order-customers.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 base = { customerId: "c", deliveryLocationId: "d", pickupLocationId: "p", isReservation: false, deliveryDate: "2026-11-03", validLineCount: 1, linesWithoutBelading: 0, stockBlocked: false, previewPending: false, previewBlockedReason: null };
|
|
8
|
+
eq("compleet → niets ontbreekt", missingItems(base), []);
|
|
9
|
+
eq("afhaallocatie ontbreekt", missingItems({ ...base, pickupLocationId: null }), ["Kies een afhaallocatie"]);
|
|
10
|
+
eq("reservering zonder datum mag", missingItems({ ...base, isReservation: true, deliveryDate: "" }), []);
|
|
11
|
+
eq("geen regels", missingItems({ ...base, validLineCount: 0 }), ["Voeg minimaal één product toe"]);
|
|
12
|
+
eq("voorraadtekort blokkeert", missingItems({ ...base, stockBlocked: true }), ["Pas de aantallen aan: onvoldoende voorraad"]);
|
|
13
|
+
eq("stuks: 480 planten, 24/fust → 20 fust", lineCrates(480, 24), 20);
|
|
14
|
+
eq("regeltotaal 480 × 0,85", lineTotal(480, 0.85), 408);
|
|
15
|
+
eq("weekdag", dateWithWeekday("2026-11-03"), "di 3 nov 2026");
|
|
16
|
+
const all = [{ twinfield_code: "1019", company_name: "Blokkentest BV" }, { twinfield_code: null, company_name: "Lokaal" }];
|
|
17
|
+
const tw = [
|
|
18
|
+
{ twinfield_code: "1019", name: "Blokkentest BV" },
|
|
19
|
+
{ twinfield_code: "1015", name: "Coelho Import" },
|
|
20
|
+
{ twinfield_code: "1015", name: "Coelho Import" },
|
|
21
|
+
];
|
|
22
|
+
eq("inactieve klant niet terug + Coelho één keer", twinfieldOnlyRows(all, tw).map((t) => t.twinfield_code), ["1015"]);
|
|
23
|
+
if (failed) {
|
|
24
|
+
console.error(`${failed} fout(en)`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
console.log("Alles OK");
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface FormState {
|
|
2
|
+
customerId: string | null;
|
|
3
|
+
deliveryLocationId: string | null;
|
|
4
|
+
pickupLocationId: string | null;
|
|
5
|
+
isReservation: boolean;
|
|
6
|
+
deliveryDate: string;
|
|
7
|
+
/** Aantal regels met product én aantal > 0. */
|
|
8
|
+
validLineCount: number;
|
|
9
|
+
/** Regels met product maar zonder (volledige) belading. */
|
|
10
|
+
linesWithoutBelading: number;
|
|
11
|
+
stockBlocked: boolean;
|
|
12
|
+
previewPending: boolean;
|
|
13
|
+
previewBlockedReason: string | null;
|
|
14
|
+
}
|
|
15
|
+
export declare function missingItems(s: FormState): string[];
|
|
16
|
+
/** Stuks = fusten × planten per fust; de opgeslagen hoeveelheid is al in planten. */
|
|
17
|
+
export declare function lineCrates(quantity: number | null, plantsPerCrate: number | null): number | null;
|
|
18
|
+
export declare function lineTotal(quantity: number | null, unitPrice: number | null): number;
|
|
19
|
+
/** "di 3 nov 2026" voor een kale datum (YYYY-MM-DD), zonder tijdzoneverschuiving. */
|
|
20
|
+
export declare function dateWithWeekday(d: string | null | undefined): string | null;
|
|
21
|
+
export declare const eur: (n: number) => string;
|
|
22
|
+
//# sourceMappingURL=create-order-form.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-order-form.d.ts","sourceRoot":"","sources":["../../src/lib/create-order-form.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,EAAE,CAcnD;AAED,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAGhG;AAED,wBAAgB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAInF;AAGD,qFAAqF;AACrF,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAQ3E;AAED,eAAO,MAAM,GAAG,GAAI,GAAG,MAAM,WAC6D,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Pure helpers voor het formulier "Nieuwe bestelling": ontbrekende punten,
|
|
2
|
+
// regelstuks/-totalen en datumweergave. Alleen weergave; de echte controles
|
|
3
|
+
// blijven bij het aanmaken (createManualOrder / verkoop_insert_manual_order).
|
|
4
|
+
export function missingItems(s) {
|
|
5
|
+
const out = [];
|
|
6
|
+
if (!s.customerId)
|
|
7
|
+
out.push("Kies een klant");
|
|
8
|
+
else if (!s.deliveryLocationId)
|
|
9
|
+
out.push("Kies een afleverlocatie");
|
|
10
|
+
if (!s.pickupLocationId)
|
|
11
|
+
out.push("Kies een afhaallocatie");
|
|
12
|
+
if (!s.isReservation && !s.deliveryDate)
|
|
13
|
+
out.push("Kies een leverdatum");
|
|
14
|
+
if (s.validLineCount === 0)
|
|
15
|
+
out.push("Voeg minimaal één product toe");
|
|
16
|
+
if (s.linesWithoutBelading > 0)
|
|
17
|
+
out.push(s.linesWithoutBelading === 1 ? "Kies een belading bij 1 regel" : `Kies een belading bij ${s.linesWithoutBelading} regels`);
|
|
18
|
+
if (s.stockBlocked)
|
|
19
|
+
out.push("Pas de aantallen aan: onvoldoende voorraad");
|
|
20
|
+
if (!s.isReservation && s.customerId && s.deliveryLocationId && s.pickupLocationId) {
|
|
21
|
+
if (s.previewPending)
|
|
22
|
+
out.push("Ophaalmoment wordt opgehaald");
|
|
23
|
+
else if (s.previewBlockedReason)
|
|
24
|
+
out.push(s.previewBlockedReason);
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
28
|
+
/** Stuks = fusten × planten per fust; de opgeslagen hoeveelheid is al in planten. */
|
|
29
|
+
export function lineCrates(quantity, plantsPerCrate) {
|
|
30
|
+
if (quantity == null || plantsPerCrate == null || plantsPerCrate <= 0)
|
|
31
|
+
return null;
|
|
32
|
+
return Math.ceil(quantity / plantsPerCrate);
|
|
33
|
+
}
|
|
34
|
+
export function lineTotal(quantity, unitPrice) {
|
|
35
|
+
const q = Number(quantity ?? 0);
|
|
36
|
+
const p = Number(unitPrice ?? 0);
|
|
37
|
+
return Number.isFinite(q) && Number.isFinite(p) ? Math.round(q * p * 100) / 100 : 0;
|
|
38
|
+
}
|
|
39
|
+
const NL = "Europe/Amsterdam";
|
|
40
|
+
/** "di 3 nov 2026" voor een kale datum (YYYY-MM-DD), zonder tijdzoneverschuiving. */
|
|
41
|
+
export function dateWithWeekday(d) {
|
|
42
|
+
if (!d || !/^\d{4}-\d{2}-\d{2}/.test(d))
|
|
43
|
+
return null;
|
|
44
|
+
const t = new Date(`${d.slice(0, 10)}T12:00:00Z`);
|
|
45
|
+
if (Number.isNaN(t.getTime()))
|
|
46
|
+
return null;
|
|
47
|
+
const f = new Intl.DateTimeFormat("nl-NL", { timeZone: NL, weekday: "short", day: "numeric", month: "short", year: "numeric" })
|
|
48
|
+
.formatToParts(t);
|
|
49
|
+
const get = (k) => f.find((p) => p.type === k)?.value?.replace(".", "") ?? "";
|
|
50
|
+
return `${get("weekday")} ${get("day")} ${get("month")} ${get("year")}`;
|
|
51
|
+
}
|
|
52
|
+
export const eur = (n) => `€ ${n.toLocaleString("nl-NL", { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
@@ -3,7 +3,16 @@ export declare const listCustomersForCreateOrder: import("@tanstack/start-client
|
|
|
3
3
|
userId: string;
|
|
4
4
|
claims: import("@supabase/auth-js").User;
|
|
5
5
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
6
|
-
items:
|
|
6
|
+
items: {
|
|
7
|
+
id: string;
|
|
8
|
+
company_name: string | null;
|
|
9
|
+
commercial_name: string | null;
|
|
10
|
+
city: string | null;
|
|
11
|
+
email: string | null;
|
|
12
|
+
twinfield_code: string | null;
|
|
13
|
+
source: string;
|
|
14
|
+
blocked: boolean;
|
|
15
|
+
}[];
|
|
7
16
|
}>>;
|
|
8
17
|
export declare const ensureCustomerFromTwinfield: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
9
18
|
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
@@ -20,6 +29,8 @@ export declare const listProductsForCreateOrder: import("@tanstack/start-client-
|
|
|
20
29
|
claims: import("@supabase/auth-js").User;
|
|
21
30
|
}, undefined, undefined, undefined>], undefined, Promise<{
|
|
22
31
|
items: {
|
|
32
|
+
image_url: string | null;
|
|
33
|
+
plant_height_cm: number | null;
|
|
23
34
|
id: string;
|
|
24
35
|
product: string;
|
|
25
36
|
article_code: string | null;
|
|
@@ -62,6 +73,15 @@ export declare const listDeliveryLocationsForCustomerCO: import("@tanstack/start
|
|
|
62
73
|
} | null;
|
|
63
74
|
}[];
|
|
64
75
|
}>>;
|
|
76
|
+
export declare const getLastPickupLocationCO: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
77
|
+
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
78
|
+
userId: string;
|
|
79
|
+
claims: import("@supabase/auth-js").User;
|
|
80
|
+
}, undefined, undefined, undefined>], (d: unknown) => {
|
|
81
|
+
customerId: string;
|
|
82
|
+
}, Promise<{
|
|
83
|
+
pickupLocationId: string | null;
|
|
84
|
+
}>>;
|
|
65
85
|
export declare const listPickupLocationsCO: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
66
86
|
supabase: import("../integrations/supabase/auth-middleware.js").AuthedSupabaseClient;
|
|
67
87
|
userId: 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","sourceR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CAEH,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"}
|
|
@@ -6,6 +6,7 @@ import { posOrNull, choosePacking } from "./packing-snapshot.js";
|
|
|
6
6
|
import { createServerFn } from "@tanstack/react-start";
|
|
7
7
|
import { shippedLockReason } from "./order-price-lock.js";
|
|
8
8
|
import { productNameForStorage } from "./product-name.js";
|
|
9
|
+
import { twinfieldOnlyRows } from "./create-order-customers.js";
|
|
9
10
|
import { z } from "zod";
|
|
10
11
|
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js";
|
|
11
12
|
// ─── Klanten ────────────────────────────────────────────────────────────────
|
|
@@ -16,37 +17,46 @@ import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js
|
|
|
16
17
|
export const listCustomersForCreateOrder = createServerFn({ method: "GET" })
|
|
17
18
|
.middleware([requireSupabaseAuth])
|
|
18
19
|
.handler(async ({ context }) => {
|
|
20
|
+
// Alle klanten (ook inactieve) laden voor de ontdubbeling van boekhoudregels;
|
|
21
|
+
// alleen actieve klanten komen in de lijst.
|
|
19
22
|
const [localRes, twRes] = await Promise.all([
|
|
20
23
|
context.supabase
|
|
21
24
|
.from("customers")
|
|
22
|
-
.select("id, company_name, email, twinfield_code, source")
|
|
23
|
-
.eq("is_active", true)
|
|
25
|
+
.select("id, company_name, commercial_name, city, email, twinfield_code, source, is_active, blocked")
|
|
24
26
|
.order("company_name")
|
|
25
|
-
.range(0,
|
|
27
|
+
.range(0, 9999),
|
|
26
28
|
Promise.resolve(context.supabase
|
|
27
29
|
.from("twinfield_customers_cache")
|
|
28
30
|
.select("twinfield_code, name, email")
|
|
29
31
|
.order("name")
|
|
30
32
|
.range(0, 4999)).catch(() => ({ data: [] })),
|
|
31
33
|
]);
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.
|
|
34
|
+
const all = (localRes.data ?? []);
|
|
35
|
+
const local = all
|
|
36
|
+
.filter((c) => c.is_active !== false)
|
|
37
|
+
.map((c) => ({
|
|
38
|
+
id: c.id,
|
|
39
|
+
company_name: c.company_name,
|
|
40
|
+
commercial_name: (c.commercial_name ?? null),
|
|
41
|
+
city: (c.city ?? null),
|
|
42
|
+
email: (c.email ?? null),
|
|
43
|
+
twinfield_code: (c.twinfield_code ?? null),
|
|
44
|
+
source: c.source,
|
|
45
|
+
blocked: c.blocked === true,
|
|
46
|
+
}));
|
|
47
|
+
const twOnly = twinfieldOnlyRows(all, (twRes.data ?? [])).map((t) => ({
|
|
42
48
|
id: `twinfield:${t.twinfield_code}`,
|
|
43
|
-
company_name: t.name ?? t.twinfield_code,
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
company_name: (t.name ?? t.twinfield_code),
|
|
50
|
+
commercial_name: null,
|
|
51
|
+
city: null,
|
|
52
|
+
email: (t.email ?? null),
|
|
46
53
|
twinfield_code: t.twinfield_code,
|
|
54
|
+
source: "twinfield",
|
|
55
|
+
blocked: false,
|
|
47
56
|
}));
|
|
57
|
+
const label = (c) => String(c.commercial_name || c.company_name || "");
|
|
48
58
|
return {
|
|
49
|
-
items: [...local, ...
|
|
59
|
+
items: [...local, ...twOnly].sort((a, b) => label(a).localeCompare(label(b), "nl")),
|
|
50
60
|
};
|
|
51
61
|
});
|
|
52
62
|
// Importeert (of hergebruikt) een Twinfield-klant als lokale customers-rij en
|
|
@@ -137,7 +147,7 @@ export const listProductsForCreateOrder = createServerFn({ method: "GET" })
|
|
|
137
147
|
.range(0, 9999),
|
|
138
148
|
context.supabase
|
|
139
149
|
.from("products")
|
|
140
|
-
.select("id, product, unit, sale_price, plants_per_crate, crates_per_layer, layers_per_cart, quantity, custom_fields, trade_item_key, floriday_trade_item_id")
|
|
150
|
+
.select("id, product, unit, sale_price, plants_per_crate, crates_per_layer, layers_per_cart, quantity, custom_fields, trade_item_key, floriday_trade_item_id, image_url, plant_height_cm")
|
|
141
151
|
.range(0, 4999),
|
|
142
152
|
]);
|
|
143
153
|
// Supabase geeft standaard max. 1000 rijen terug. Voor productgroepen kan de
|
|
@@ -469,7 +479,27 @@ export const listProductsForCreateOrder = createServerFn({ method: "GET" })
|
|
|
469
479
|
});
|
|
470
480
|
registerIdentity(id, name, articleCode);
|
|
471
481
|
}
|
|
472
|
-
|
|
482
|
+
// Foto en plantmaat uit products (image_url, plant_height_cm), gekoppeld
|
|
483
|
+
// via het eigen id, het Floriday-id of de draft/floriday-spiegelsleutels.
|
|
484
|
+
const visualByKey = new Map();
|
|
485
|
+
for (const p of Array.isArray(productsRes.data) ? productsRes.data : []) {
|
|
486
|
+
const img = typeof p.image_url === "string" && p.image_url.trim() ? p.image_url.trim() : null;
|
|
487
|
+
const h = Number(p.plant_height_cm);
|
|
488
|
+
const v = { image_url: img, plant_height_cm: Number.isFinite(h) && h > 0 ? h : null };
|
|
489
|
+
if (!v.image_url && v.plant_height_cm == null)
|
|
490
|
+
continue;
|
|
491
|
+
const cf = (p.custom_fields ?? {});
|
|
492
|
+
const keys = [p.id, p.floriday_trade_item_id, cf.draft_id, cf.floriday_id,
|
|
493
|
+
typeof p.trade_item_key === "string" && p.trade_item_key.startsWith("group:") ? p.trade_item_key.slice(6) : null];
|
|
494
|
+
for (const k of keys)
|
|
495
|
+
if (typeof k === "string" && k && !visualByKey.has(k))
|
|
496
|
+
visualByKey.set(k, v);
|
|
497
|
+
}
|
|
498
|
+
const items = Array.from(byId.values()).map((it) => ({
|
|
499
|
+
...it,
|
|
500
|
+
image_url: visualByKey.get(it.id)?.image_url ?? null,
|
|
501
|
+
plant_height_cm: visualByKey.get(it.id)?.plant_height_cm ?? null,
|
|
502
|
+
})).sort((a, b) => {
|
|
473
503
|
if (a.in_stock !== b.in_stock)
|
|
474
504
|
return a.in_stock ? -1 : 1;
|
|
475
505
|
return a.product.localeCompare(b.product, "nl");
|
|
@@ -526,6 +556,23 @@ export const listDeliveryLocationsForCustomerCO = createServerFn({ method: "POST
|
|
|
526
556
|
.maybeSingle();
|
|
527
557
|
return { items: created ? [created] : [] };
|
|
528
558
|
});
|
|
559
|
+
// ─── Laatst gebruikte afhaallocatie bij een klant (alleen lezen) ────────────
|
|
560
|
+
// Uit bestaande orders (custom_fields.pickup_location); geen nieuwe opslag.
|
|
561
|
+
// De UI neemt hem alleen over als die locatie nog in de actieve lijst staat.
|
|
562
|
+
export const getLastPickupLocationCO = createServerFn({ method: "POST" })
|
|
563
|
+
.middleware([requireSupabaseAuth])
|
|
564
|
+
.inputValidator((d) => z.object({ customerId: z.string().uuid() }).parse(d))
|
|
565
|
+
.handler(async ({ data, context }) => {
|
|
566
|
+
const { data: rows } = await context.supabase
|
|
567
|
+
.from("orders")
|
|
568
|
+
.select("custom_fields, created_at")
|
|
569
|
+
.eq("customer_id", data.customerId)
|
|
570
|
+
.not("custom_fields->>pickup_location", "is", null)
|
|
571
|
+
.order("created_at", { ascending: false })
|
|
572
|
+
.limit(1);
|
|
573
|
+
const v = rows?.[0]?.custom_fields?.pickup_location;
|
|
574
|
+
return { pickupLocationId: typeof v === "string" && v.trim() ? v.trim() : null };
|
|
575
|
+
});
|
|
529
576
|
// ─── Afhaallocaties (eigen tuinen) — Floriday warehouses ────────────────────
|
|
530
577
|
export const listPickupLocationsCO = createServerFn({ method: "GET" })
|
|
531
578
|
.middleware([requireSupabaseAuth])
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { formatDelivery } from "./delivery-format.js";
|
|
1
|
+
import { composeLocalDelivery, formatDelivery } from "./delivery-format.js";
|
|
2
2
|
let fail = 0;
|
|
3
3
|
const eq = (name, a, b) => {
|
|
4
4
|
const ok = JSON.stringify(a) === JSON.stringify(b);
|
|
@@ -21,7 +21,11 @@ eq("25 okt 01:30Z (winter) → 02:30", formatDelivery("2026-10-25T01:30:00Z", tr
|
|
|
21
21
|
eq("25 okt 23:30Z → ma 26 00:30", formatDelivery("2026-10-25T23:30:00Z", true), { date: "ma 26 okt", time: "00:30" });
|
|
22
22
|
eq("kale datum 25 okt", formatDelivery("2026-10-25", false), { date: "zo 25 okt", time: "" });
|
|
23
23
|
// Lokaal tijdstip zonder zone (eigen order met aanlevertijd) blijft gelijk aan nu.
|
|
24
|
-
eq("eigen order met aanlevertijd", formatDelivery("2026-10-26T08:00:00", true), { date: "ma 26 okt", time: "08:00" });
|
|
24
|
+
eq("eigen order met aanlevertijd", formatDelivery("2026-10-26T08:00:00", true, { wallClock: true }), { date: "ma 26 okt", time: "08:00" });
|
|
25
|
+
eq("kloktijd 25 okt 02:30 (wisseling)", formatDelivery("2026-10-25T02:30:00", true, { wallClock: true }), { date: "zo 25 okt", time: "02:30" });
|
|
26
|
+
eq("samenstelling eigen order", composeLocalDelivery("2026-10-26", "08:00"), { deliveryAt: "2026-10-26T08:00:00", deliveryHasTime: true, deliveryIsWallClock: true });
|
|
27
|
+
eq("eigen order zonder tijd", composeLocalDelivery("2026-10-26", null), { deliveryAt: "2026-10-26", deliveryHasTime: false, deliveryIsWallClock: false });
|
|
28
|
+
eq("tijdstip met zone is geen kloktijd", composeLocalDelivery("2026-10-26T07:00:00+00:00", "08:00").deliveryIsWallClock, false);
|
|
25
29
|
if (fail) {
|
|
26
30
|
console.error(`${fail} fout(en)`);
|
|
27
31
|
process.exit(1);
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare function formatDelivery(value: string | null | undefined, hasTime: boolean, opts?: {
|
|
2
2
|
year?: boolean;
|
|
3
|
+
wallClock?: boolean;
|
|
3
4
|
}): {
|
|
4
5
|
date: string;
|
|
5
6
|
time: string;
|
|
@@ -14,4 +15,17 @@ export declare function deliveryHasTimeFor(dto: {
|
|
|
14
15
|
deliveryHasTime?: boolean;
|
|
15
16
|
deliveryAt?: string;
|
|
16
17
|
}): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Levermoment van een eigen order (handmatig/aanbieding/mail): leverdatum +
|
|
20
|
+
* vastgelegde aanlevertijd. Eén samenstelling voor lijst en detail; alleen
|
|
21
|
+
* dan is de waarde een ingevulde Nederlandse kloktijd (wallClock).
|
|
22
|
+
*/
|
|
23
|
+
export declare function composeLocalDelivery(rawDeliveryDate: string, deliveryTime: string | null): {
|
|
24
|
+
deliveryAt: string;
|
|
25
|
+
deliveryHasTime: boolean;
|
|
26
|
+
deliveryIsWallClock: boolean;
|
|
27
|
+
};
|
|
28
|
+
export declare function deliveryIsWallClockFor(dto: {
|
|
29
|
+
deliveryIsWallClock?: boolean;
|
|
30
|
+
}): boolean;
|
|
17
31
|
//# sourceMappingURL=delivery-format.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delivery-format.d.ts","sourceRoot":"","sources":["../../src/lib/delivery-format.ts"],"names":[],"mappings":"AAQA,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,OAAO,EAAE,OAAO,EAChB,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAA;CAAO,
|
|
1
|
+
{"version":3,"file":"delivery-format.d.ts","sourceRoot":"","sources":["../../src/lib/delivery-format.ts"],"names":[],"mappings":"AAQA,wBAAgB,cAAc,CAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,OAAO,EAAE,OAAO,EAChB,IAAI,GAAE;IAAE,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,SAAS,CAAC,EAAE,OAAO,CAAA;CAAO,GACjD;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CA8BhC;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE;IAAE,eAAe,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAInG;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,eAAe,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,GAAG;IAC1F,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,OAAO,CAAC;IACzB,mBAAmB,EAAE,OAAO,CAAC;CAC9B,CAQA;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE;IAAE,mBAAmB,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,OAAO,CAEtF"}
|
|
@@ -9,6 +9,17 @@ export function formatDelivery(value, hasTime, opts = {}) {
|
|
|
9
9
|
const v = String(value ?? "").trim();
|
|
10
10
|
if (!v)
|
|
11
11
|
return { date: "—", time: "" };
|
|
12
|
+
if (hasTime && opts.wallClock) {
|
|
13
|
+
// Ingevulde Nederlandse kloktijd (leverdatum + aanlevertijd): niet omrekenen.
|
|
14
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})/.exec(v);
|
|
15
|
+
if (m) {
|
|
16
|
+
const d = new Date(Date.UTC(+m[1], +m[2] - 1, +m[3], 12));
|
|
17
|
+
return {
|
|
18
|
+
date: d.toLocaleDateString("nl-NL", { weekday: "short", day: "numeric", month: "short", ...(opts.year ? { year: "numeric" } : {}), timeZone: "UTC" }),
|
|
19
|
+
time: `${m[4]}:${m[5]}`,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
|
12
23
|
if (!hasTime) {
|
|
13
24
|
const m = /^(\d{4})-(\d{2})-(\d{2})/.exec(v);
|
|
14
25
|
if (!m)
|
|
@@ -40,3 +51,20 @@ export function deliveryHasTimeFor(dto) {
|
|
|
40
51
|
// Oude gecachte rijen zonder vlag: gedrag van vóór de vlag (kale datum = geen tijd).
|
|
41
52
|
return !/^\d{4}-\d{2}-\d{2}$/.test(String(dto.deliveryAt ?? "").trim());
|
|
42
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Levermoment van een eigen order (handmatig/aanbieding/mail): leverdatum +
|
|
56
|
+
* vastgelegde aanlevertijd. Eén samenstelling voor lijst en detail; alleen
|
|
57
|
+
* dan is de waarde een ingevulde Nederlandse kloktijd (wallClock).
|
|
58
|
+
*/
|
|
59
|
+
export function composeLocalDelivery(rawDeliveryDate, deliveryTime) {
|
|
60
|
+
const raw = String(rawDeliveryDate ?? "");
|
|
61
|
+
const composed = !!raw && !raw.includes("T") && !!deliveryTime;
|
|
62
|
+
return {
|
|
63
|
+
deliveryAt: composed ? `${raw.slice(0, 10)}T${deliveryTime}:00` : raw,
|
|
64
|
+
deliveryHasTime: raw.includes("T") || composed,
|
|
65
|
+
deliveryIsWallClock: composed,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
export function deliveryIsWallClockFor(dto) {
|
|
69
|
+
return dto.deliveryIsWallClock === true;
|
|
70
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floriday-invoice-line.check.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-invoice-line.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { floridayInvoiceLine } from "./floriday-status.js";
|
|
2
|
+
let fail = 0;
|
|
3
|
+
const eq = (name, a, b) => {
|
|
4
|
+
const ok = a === b;
|
|
5
|
+
if (!ok)
|
|
6
|
+
fail++;
|
|
7
|
+
console.log(`${ok ? "OK " : "FOUT"} ${name}: ${JSON.stringify(a)}${ok ? "" : ` ≠ ${JSON.stringify(b)}`}`);
|
|
8
|
+
};
|
|
9
|
+
// FO-2601462/63/64: COMMITTED, afgemeld 0 van 1 → geen extra regel.
|
|
10
|
+
eq("COMMITTED 0 van 1", floridayInvoiceLine("COMMITTED", 0, 1), null);
|
|
11
|
+
eq("DELIVERED 1 van 1", floridayInvoiceLine("DELIVERED", 1, 1), null);
|
|
12
|
+
eq("DELIVERED maar 0 van 1", floridayInvoiceLine("DELIVERED", 0, 1), "Afgemeld in Floriday");
|
|
13
|
+
eq("CANCELLED", floridayInvoiceLine("CANCELLED", 0, 1), "Geannuleerd in Floriday");
|
|
14
|
+
eq("geen status", floridayInvoiceLine(null, 0, 1), null);
|
|
15
|
+
if (fail) {
|
|
16
|
+
console.error(`${fail} fout(en)`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
@@ -45,4 +45,10 @@ export type NotReportedState = "waarschuwing" | "waarschuwing_onbekend" | "al_af
|
|
|
45
45
|
* bij onbekende stand valt het terug op ons eigen kenmerk. Alleen weergave.
|
|
46
46
|
*/
|
|
47
47
|
export declare function notReportedState(erp: OrderStage | undefined, floriday: FloridayStatusSummary["stage"] | null | undefined, floridayFulfilled: boolean): NotReportedState;
|
|
48
|
+
/**
|
|
49
|
+
* Floriday-regel in de factuurkaart: alleen uit de echte Floriday-status
|
|
50
|
+
* van de order (custom_fields.floriday_status), nooit afgeleid van onze
|
|
51
|
+
* eigen stand. null = niets extra's ten opzichte van "Afgemeld x van y".
|
|
52
|
+
*/
|
|
53
|
+
export declare function floridayInvoiceLine(raw: string | null | undefined, done: number, total: number): string | null;
|
|
48
54
|
//# sourceMappingURL=floriday-status.d.ts.map
|
|
@@ -1 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E,UAAU,GAAG,SAAS,GAAG,OAAO,CAQhH;AAED,6EAA6E;AAC7E,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,UAAU,GAAG,SAAS,EAAE,iBAAiB,EAAE,OAAO,GAAG,OAAO,CAErG;AAED,MAAM,MAAM,gBAAgB,GAAG,cAAc,GAAG,uBAAuB,GAAG,gBAAgB,GAAG,IAAI,CAAC;AAElG;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,UAAU,GAAG,SAAS,EAC3B,QAAQ,EAAE,qBAAqB,CAAC,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAC3D,iBAAiB,EAAE,OAAO,GACzB,gBAAgB,CAMlB;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAc9G"}
|
|
@@ -97,3 +97,29 @@ export function notReportedState(erp, floriday, floridayFulfilled) {
|
|
|
97
97
|
return null;
|
|
98
98
|
return floridayFulfilled ? null : "waarschuwing_onbekend";
|
|
99
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Floriday-regel in de factuurkaart: alleen uit de echte Floriday-status
|
|
102
|
+
* van de order (custom_fields.floriday_status), nooit afgeleid van onze
|
|
103
|
+
* eigen stand. null = niets extra's ten opzichte van "Afgemeld x van y".
|
|
104
|
+
*/
|
|
105
|
+
export function floridayInvoiceLine(raw, done, total) {
|
|
106
|
+
if (!raw || typeof raw !== "string")
|
|
107
|
+
return null;
|
|
108
|
+
const parts = raw.toUpperCase().split(/[^A-Z_]+/).filter(Boolean);
|
|
109
|
+
if (parts.length === 0)
|
|
110
|
+
return null;
|
|
111
|
+
const cancelled = (s) => s === "CANCELLED" || s === "CANCELED" || s === "EXPIRED" || s === "REJECTED";
|
|
112
|
+
const delivered = (s) => s === "DELIVERED" || s === "FULFILLED" || s === "COMPLETED";
|
|
113
|
+
if (parts.every(cancelled))
|
|
114
|
+
return "Geannuleerd in Floriday";
|
|
115
|
+
if (parts.some(cancelled))
|
|
116
|
+
return "Deels geannuleerd in Floriday";
|
|
117
|
+
const allDelivered = parts.every(delivered);
|
|
118
|
+
const someDelivered = parts.some(delivered);
|
|
119
|
+
// Zegt hetzelfde als "Afgemeld x van y" → weglaten.
|
|
120
|
+
if (allDelivered)
|
|
121
|
+
return total > 0 && done >= total ? null : "Afgemeld in Floriday";
|
|
122
|
+
if (someDelivered)
|
|
123
|
+
return total > 0 && done > 0 && done < total ? null : "Deels afgemeld in Floriday";
|
|
124
|
+
return total > 0 && done === 0 ? null : "Nog niet afgemeld in Floriday";
|
|
125
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nl-datetime.check.d.ts","sourceRoot":"","sources":["../../src/lib/nl-datetime.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { fmtNL, fmtNLDefault } from "./nl-datetime.js";
|
|
2
|
+
let fail = 0;
|
|
3
|
+
const eq = (n, a, b) => { const ok = a === b; if (!ok)
|
|
4
|
+
fail++; console.log(`${ok ? "OK " : "FOUT"} ${n}: ${JSON.stringify(a)}${ok ? "" : ` ≠ ${JSON.stringify(b)}`}`); };
|
|
5
|
+
// FO-2601462: order_date 2026-10-27T11:37:45Z → "Ontvangen op 27 okt 2026, 12:37"
|
|
6
|
+
eq("Ontvangen op", fmtNL("2026-10-27T11:37:45.874858Z", { day: "numeric", month: "short", year: "numeric", hour: "2-digit", minute: "2-digit" }), "27 okt 2026, 12:37");
|
|
7
|
+
// Gepickt 27 okt, 12:43 (timestamptz +00)
|
|
8
|
+
eq("Gepickt", fmtNL("2026-10-27T11:43:10+00:00", { day: "numeric", month: "short", hour: "2-digit", minute: "2-digit" }), "27 okt, 12:43");
|
|
9
|
+
eq("Bijgewerkt hh:mm", fmtNL("2026-10-30T12:05:00Z", { hour: "2-digit", minute: "2-digit" }), "13:05");
|
|
10
|
+
eq("zomertijd", fmtNL("2026-10-24T10:00:00Z", { hour: "2-digit", minute: "2-digit" }), "12:00");
|
|
11
|
+
eq("kale datum", fmtNL("2026-10-26", { weekday: "short", day: "numeric", month: "short" }), "ma 26 okt");
|
|
12
|
+
eq("standaard", fmtNLDefault("2026-10-27T11:37:50Z"), "27-10-2026, 12:37:50");
|
|
13
|
+
if (fail)
|
|
14
|
+
process.exit(1);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
type Opts = Intl.DateTimeFormatOptions;
|
|
2
|
+
export declare function fmtNL(value: string | number | Date | null | undefined, opts?: Opts): string | null;
|
|
3
|
+
/** Standaard: "27-10-2026, 12:37:50" (gelijk aan toLocaleString("nl-NL")). */
|
|
4
|
+
export declare const fmtNLDefault: (v: string | number | Date | null | undefined) => string | null;
|
|
5
|
+
export {};
|
|
6
|
+
//# sourceMappingURL=nl-datetime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nl-datetime.d.ts","sourceRoot":"","sources":["../../src/lib/nl-datetime.ts"],"names":[],"mappings":"AAaA,KAAK,IAAI,GAAG,IAAI,CAAC,qBAAqB,CAAC;AAEvC,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,EAAE,IAAI,GAAE,IAAS,GAAG,MAAM,GAAG,IAAI,CAoBtG;AAED,8EAA8E;AAC9E,eAAO,MAAM,YAAY,GAAI,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,kBAC+C,CAAC"}
|