@flowselections/floriday-verkoop-module 1.0.155 → 1.0.157
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 +8 -6
- package/dist-lib/components/verkoop/OrderTransportCard.d.ts +3 -1
- package/dist-lib/components/verkoop/OrderTransportCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderTransportCard.js +8 -6
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +5 -2
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts +6 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.js +10 -4
- package/dist-lib/components/verkoop/SearchableSelect.js +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +30 -18
- package/dist-lib/components/verkoop/klok/KlokOrderPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/klok/KlokOrderPage.js +38 -17
- package/dist-lib/components/verkoop/klok/KlokOrdersList.d.ts +1 -1
- package/dist-lib/components/verkoop/klok/KlokOrdersList.d.ts.map +1 -1
- package/dist-lib/components/verkoop/klok/KlokOrdersList.js +2 -1
- package/dist-lib/components/verkoop/klok/KlokPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/klok/KlokPage.js +26 -5
- package/dist-lib/lib/create-order-form.d.ts +23 -0
- package/dist-lib/lib/create-order-form.d.ts.map +1 -1
- package/dist-lib/lib/create-order-form.js +35 -0
- package/dist-lib/lib/create-order.functions.d.ts +1 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +12 -3
- package/dist-lib/lib/klok-form.d.ts +12 -0
- package/dist-lib/lib/klok-form.d.ts.map +1 -1
- package/dist-lib/lib/klok-form.js +76 -0
- package/dist-lib/lib/klok-labels.d.ts +13 -0
- package/dist-lib/lib/klok-labels.d.ts.map +1 -1
- package/dist-lib/lib/klok-labels.js +22 -0
- package/dist-lib/lib/klok-payload.d.ts +34 -0
- package/dist-lib/lib/klok-payload.d.ts.map +1 -0
- package/dist-lib/lib/klok-payload.js +38 -0
- package/dist-lib/lib/klok.server.d.ts +4 -33
- package/dist-lib/lib/klok.server.d.ts.map +1 -1
- package/dist-lib/lib/klok.server.js +6 -38
- package/dist-lib/lib/order-transport.functions.d.ts +1 -0
- package/dist-lib/lib/order-transport.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-transport.server.d.ts +1 -0
- package/dist-lib/lib/order-transport.server.d.ts.map +1 -1
- package/dist-lib/lib/order-transport.server.js +5 -3
- package/dist-lib/lib/own-transport.d.ts +29 -0
- package/dist-lib/lib/own-transport.d.ts.map +1 -1
- package/dist-lib/lib/own-transport.js +33 -0
- package/package.json +5 -4
|
@@ -7,8 +7,8 @@ import { Button, DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMe
|
|
|
7
7
|
import { ArrowLeft, ChevronDown, Eye, Package, Plus, Repeat, Save, Send, Trash2, X } from "lucide-react";
|
|
8
8
|
import { listProductsForCreateOrder } from "../../../lib/create-order.functions.js";
|
|
9
9
|
import { deleteKlokOrder, getKlokArtikelen, getKlokLijsten, getKlokOrder, listKlokSjablonen, repeatKlokOrder, resendKlokOrder, saveKlokConcept, saveKlokSjabloon, sendKlokOrder, refreshKlokStatus, } from "../../../lib/klok.functions.js";
|
|
10
|
-
import { klokOntbreekt, LEGE_KOP, neemPrijsOver } from "../../../lib/klok-form.js";
|
|
11
|
-
import { KLOK_LIJST_LEEG_TEXT, klokIsVerstuurd, klokKanVerwijderen, klokTellers, tellersTekst, volgendeVeildag, } from "../../../lib/klok-labels.js";
|
|
10
|
+
import { klokFoutLijst, klokOntbreekt, klokOntbreektVelden, LEGE_KOP, neemPrijsOver } from "../../../lib/klok-form.js";
|
|
11
|
+
import { KLOK_LIJST_LEEG_TEXT, klokIsVerstuurd, klokKanVerwijderen, klokTellers, tellersTekst, volgendeVeildag, klokLijstWeergave, klokLocatieKnoppen, prijsTekst, } from "../../../lib/klok-labels.js";
|
|
12
12
|
import { fmtNL } from "../../../lib/nl-datetime.js";
|
|
13
13
|
import { amsterdamYmd, ymdString } from "../../../lib/period-range.js";
|
|
14
14
|
import { SearchableSelect } from "../SearchableSelect.js";
|
|
@@ -65,7 +65,10 @@ export function KlokOrderPage() {
|
|
|
65
65
|
const [meerOpen, setMeerOpen] = useState({});
|
|
66
66
|
const [bewerken, setBewerken] = useState(false);
|
|
67
67
|
const [bezig, setBezig] = useState(null);
|
|
68
|
-
const [fout,
|
|
68
|
+
const [fout, setFoutTekst] = useState(null);
|
|
69
|
+
const [fouten, setFouten] = useState([]);
|
|
70
|
+
const setFout = (t) => { setFoutTekst(t); if (!t)
|
|
71
|
+
setFouten([]); };
|
|
69
72
|
const [voorbeeld, setVoorbeeld] = useState(false);
|
|
70
73
|
const [bevestigWijzig, setBevestigWijzig] = useState(false);
|
|
71
74
|
const [sjabloonNaam, setSjabloonNaam] = useState(null);
|
|
@@ -131,19 +134,30 @@ export function KlokOrderPage() {
|
|
|
131
134
|
});
|
|
132
135
|
}, [klokId, voorkeur, locaties.length, verzend.length]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
133
136
|
const gebruikt = voorkeur?.gebruikte_veillocaties ?? [];
|
|
134
|
-
const
|
|
135
|
-
const locatieMeer = locaties.filter((l) => !locatieKnoppen.includes(l));
|
|
136
|
-
const toonKnoppen = locatieKnoppen.length ? locatieKnoppen : locaties.slice(0, 3);
|
|
137
|
-
const toonMeer = locatieKnoppen.length ? locatieMeer : locaties.slice(3);
|
|
137
|
+
const { knoppen: toonKnoppen, meer: toonMeer } = klokLocatieKnoppen(locaties, gebruikt, kop.veillocatie_id);
|
|
138
138
|
const groepOpties = groepen
|
|
139
139
|
.filter((g) => !kop.veillocatie_id || g.auctionLocationId === kop.veillocatie_id)
|
|
140
|
-
.map((g) => ({ value: String(g.auctionGroupCode), label:
|
|
140
|
+
.map((g) => ({ value: String(g.auctionGroupCode), label: String(g.auctionGroupCode), hint: g.lastArticleName ? `laatst: ${g.lastArticleName}` : null, search: `${g.auctionGroupCode} ${g.lastArticleName ?? ""}` }));
|
|
141
141
|
const products = productsQ.data?.items ?? [];
|
|
142
142
|
const productOpties = (alleenVoorraad) => products
|
|
143
143
|
.filter((p) => p.source !== "group" && (!alleenVoorraad || Number(p.available_stock) > 0))
|
|
144
144
|
.map((p) => ({ value: String(p.id), label: String(p.product ?? ""), hint: p.available_stock != null ? `${p.available_stock} beschikbaar` : null, image: p.image_url ?? null }));
|
|
145
145
|
const tellers = klokTellers(regels);
|
|
146
146
|
const ontbreekt = klokOntbreekt(kop, regels);
|
|
147
|
+
// Rood na een mislukte poging: velden uit de foutlijst plus wat nog ontbreekt.
|
|
148
|
+
const foutVelden = useMemo(() => {
|
|
149
|
+
const set = new Set();
|
|
150
|
+
if (!fouten.length)
|
|
151
|
+
return set;
|
|
152
|
+
for (const f of fouten)
|
|
153
|
+
if (f.veld)
|
|
154
|
+
set.add(f.veld);
|
|
155
|
+
for (const v of klokOntbreektVelden(kop, regels))
|
|
156
|
+
set.add(v);
|
|
157
|
+
return set;
|
|
158
|
+
}, [fouten, kop, regels]);
|
|
159
|
+
const rood = (veld) => (foutVelden.has(veld) ? " border-destructive ring-1 ring-destructive" : "");
|
|
160
|
+
const regelRood = (key, deel) => foutVelden.has(`regel:${key}:${deel}`);
|
|
147
161
|
const totaal = regels.reduce((s, r) => s + (Number(r.fusten) || 0) * (Number(r.stuks_per_fust) || 0) * (Number(r.min_prijs) || 0), 0);
|
|
148
162
|
function locFields(l) {
|
|
149
163
|
return { veillocatie_id: l.id, veillocatie_naam: l.displayName ?? l.name, veillocatie_gln: l.gln ?? null, veillocatie_org_id: l.organizationId ?? null };
|
|
@@ -229,7 +243,8 @@ export function KlokOrderPage() {
|
|
|
229
243
|
await qc.invalidateQueries({ queryKey: ["klok-orders"] });
|
|
230
244
|
await qc.invalidateQueries({ queryKey: ["klok-order", id] });
|
|
231
245
|
if (!res.ok) {
|
|
232
|
-
|
|
246
|
+
setFoutTekst(res.reden ?? "Versturen is niet gelukt.");
|
|
247
|
+
setFouten(res.fouten?.length ? res.fouten : klokFoutLijst([], res.reden ?? "Versturen is niet gelukt.", regels));
|
|
233
248
|
if (!klokId)
|
|
234
249
|
navigate({ to: "/floriday-verkoop/klok/$klokId", params: { klokId: id }, replace: true });
|
|
235
250
|
return;
|
|
@@ -268,7 +283,8 @@ export function KlokOrderPage() {
|
|
|
268
283
|
setBewerken(false);
|
|
269
284
|
}
|
|
270
285
|
else {
|
|
271
|
-
|
|
286
|
+
setFoutTekst(res.reden ?? "Opnieuw versturen is niet gelukt.");
|
|
287
|
+
setFouten(res.fouten?.length ? res.fouten : klokFoutLijst([], res.reden ?? "Opnieuw versturen is niet gelukt.", regels));
|
|
272
288
|
}
|
|
273
289
|
}
|
|
274
290
|
catch (e) {
|
|
@@ -342,23 +358,28 @@ export function KlokOrderPage() {
|
|
|
342
358
|
if (klokId && !row) {
|
|
343
359
|
return (_jsxs("main", { className: "flex w-full flex-col gap-4 p-4 sm:p-6", children: [_jsx("p", { className: "text-sm text-muted-foreground", children: "Deze veilbrief bestaat niet (meer)." }), _jsx(Button, { variant: "outline", onClick: () => navigate({ to: "/floriday-verkoop/klok" }), children: "Terug naar Klok" })] }));
|
|
344
360
|
}
|
|
345
|
-
const
|
|
361
|
+
const lijstStand = klokLijstWeergave(lijstenQ.isLoading, lijsten?.gereed);
|
|
362
|
+
const laden = lijstStand === "laden";
|
|
363
|
+
const leegTekst = lijstStand === "geen_koppeling" ? KLOK_LIJST_LEEG_TEXT : null;
|
|
346
364
|
const verkochtStuks = resultaten.filter((r) => !r.doorgedraaid).reduce((s, r) => s + Number(r.stuks || 0), 0);
|
|
347
365
|
const verkochtBedrag = resultaten.filter((r) => !r.doorgedraaid).reduce((s, r) => s + Number(r.bedrag || 0), 0);
|
|
348
366
|
const doorStuks = resultaten.filter((r) => r.doorgedraaid).reduce((s, r) => s + Number(r.stuks || 0), 0);
|
|
349
|
-
return (_jsxs("main", { className: "flex w-full min-w-0 flex-col gap-4 overflow-x-clip p-4 pb-40 sm:p-6 sm:pb-32", children: [_jsxs("header", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx(Button, { variant: "ghost", size: "sm", className: "h-9 w-9 p-0", "aria-label": "Terug", onClick: () => navigate({ to: "/floriday-verkoop/klok" }), children: _jsx(ArrowLeft, { className: "h-4 w-4" }) }), _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "truncate text-xl font-bold tracking-tight sm:text-2xl", children: row ? `Veilbrief ${row.klok_nummer}` : "Klokorder (veilbrief)" }), row && (_jsxs("div", { className: "flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground", children: [_jsx(KlokStatusBadge, { status: status, detail: row.status_detail }), row.status_detail && _jsx("span", { children: row.status_detail }), orderQ.data?.orderNumber && _jsxs("span", { children: ["Order ", orderQ.data.orderNumber] })] }))] })] }), row && (_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: onHerhalen, children: [_jsx(Repeat, { className: "mr-2 h-4 w-4" }), " Herhalen"] }), klokKanVerwijderen(status) && !bewerken && (_jsxs(Button, { variant: "outline", size: "sm", onClick: onVerwijderen, disabled: !!bezig || !!blokkade, title: blokkade ?? undefined, children: [_jsx(Trash2, { className: "mr-2 h-4 w-4" }), " Verwijderen"] })), klokKanVerwijderen(status) && !bewerken && (_jsx(Button, { size: "sm", onClick: () => setBewerken(true), disabled: !!blokkade, title: blokkade ?? undefined, children: "Wijzigen en opnieuw versturen" }))] }))] }), _jsx(KlokNotice, {}), fout && (_jsxs("div", { role: "alert", className: "flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive-soft px-3 py-2 text-sm text-destructive-soft-foreground", children: [_jsx("span", { className: "min-w-0 flex-1", children: fout }), _jsx("button", { type: "button", "aria-label": "Sluiten", onClick: () => setFout(null), children: _jsx(X, { className: "h-4 w-4" }) })] })), row?.laatste_fout && !fout && (_jsx("div", { className: "rounded-lg border border-border bg-warning-soft px-3 py-2 text-sm text-warning-soft-foreground", children: row.laatste_fout })), _jsx("section", { className: "rounded-xl border border-border bg-card p-4 shadow-sm sm:p-5", children: _jsxs("div", { className: "grid gap-4 [@container(min-width:48rem)]:grid-cols-2 md:grid-cols-2", children: [_jsxs("div", { className: "md:col-span-2", children: [_jsxs("div", { className: "mb-1.5 text-sm font-medium", children: ["Veillocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), locaties.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: leegTekst ?? lijsten?.locaties?.message ?? lijsten?.locaties?.error ?? (kop.veillocatie_naam || "Geen veillocaties gevonden.") })) : (_jsxs("div", { className: "flex flex-wrap gap-2", children: [toonKnoppen.map((l) => (_jsx(Button, { type: "button", variant: kop.veillocatie_id === l.id ? "default" : "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: alleenLezen, onClick: () => setKop((k) => ({ ...k, ...locFields(l), veilgroep: k.veillocatie_id === l.id ? k.veilgroep : null })), children: l.displayName ?? l.name }, l.id))), toonMeer.length > 0 && !alleenLezen && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "ghost", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", children: ["Meer ", _jsx(ChevronDown, { className: "ml-1 h-4 w-4" })] }) }), _jsx(DropdownMenuContent, { children: toonMeer.map((l) => (_jsx(DropdownMenuItem, { onClick: () => setKop((k) => ({ ...k, ...locFields(l), veilgroep: null })), children: l.displayName ?? l.name }, l.id))) })] }))] }))] }), _jsxs("label", { className: "block", children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Veildatum ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { type: "date", value: kop.veildatum ?? "", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11", onChange: (e) => setKop((k) => ({ ...k, veildatum: e.target.value || null })) }), kop.veildatum && _jsx("span", { className: "mt-1 block text-xs text-muted-foreground", children: fmtNL(kop.veildatum, { weekday: "long", day: "numeric", month: "long" }) })] }), _jsxs("div", { children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Veilgroep ", _jsx("span", { className: "text-destructive", children: "*" })] }), eigenGroep || groepOpties.length === 0 ? (_jsxs("div", { className: "flex gap-2", children: [_jsx(Input, { inputMode: "numeric", placeholder: groepOpties.length === 0 && leegTekst ? leegTekst : "Veilgroep (cijfers)", value: kop.veilgroep ?? "", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11", onChange: (e) => setKop((k) => ({ ...k, veilgroep: e.target.value.replace(/\D/g, "") || null })) }), groepOpties.length > 0 && !alleenLezen && _jsx(Button, { variant: "ghost", size: "sm", className: "h-9", onClick: () => setEigenGroep(false), children: "Kies uit lijst" })] })) : (_jsxs("div", { className: "flex gap-2", children: [_jsx(SearchableSelect, { value: kop.veilgroep, options: groepOpties, placeholder: "Zoek veilgroep", allowClear: true, clearLabel: "\u2014 Geen \u2014", disabled: alleenLezen, className: "min-h-9 flex-1 [@media(pointer:coarse)]:min-h-11", onChange: (v) => setKop((k) => ({ ...k, veilgroep: v })) }), !alleenLezen && _jsx(Button, { variant: "ghost", size: "sm", className: "h-9", onClick: () => setEigenGroep(true), children: "Zelf invullen" })] }))] }), verzend.length > 1 && (_jsxs("div", { children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Verzendlocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(SearchableSelect, { value: kop.verzendlocatie_id, disabled: alleenLezen, allowClear: false, options: verzend.map((v) => ({ value: v.id, label: v.name, badge: v.isDefault ? "Standaard" : v.isExternal ? "Extern" : null })), className: "min-h-9 w-full [@media(pointer:coarse)]:min-h-11", onChange: (v) => setKop((k) => ({ ...k, verzendlocatie_id: v, verzendlocatie_naam: verzend.find((x) => x.id === v)?.name ?? null })) })] })), verzend.length === 0 && !kop.verzendlocatie_id && leegTekst && (_jsxs("div", { children: [_jsx("span", { className: "mb-1.5 block text-sm font-medium", children: "Verzendlocatie" }), _jsx("p", { className: "text-sm text-muted-foreground", children: leegTekst })] })), _jsxs("div", { children: [_jsx("span", { className: "mb-1.5 block text-sm font-medium", children: "Vervoer" }), _jsx("div", { className: "flex gap-2", children: VERVOER.map((v) => (_jsx(Button, { type: "button", size: "sm", variant: kop.vervoer === v.id ? "default" : "outline", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setKop((k) => ({ ...k, vervoer: v.id })), children: v.label }, v.id))) })] })] }) }), _jsxs("section", { className: "rounded-xl border border-border bg-card shadow-sm", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3 sm:px-5", children: [_jsx("h2", { className: "text-sm font-semibold", children: "Regels" }), !alleenLezen && (_jsxs("div", { className: "flex flex-wrap gap-2", children: [sjablonen.length > 0 && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", children: ["Kies sjabloon ", _jsx(ChevronDown, { className: "ml-1 h-4 w-4" })] }) }), _jsx(DropdownMenuContent, { children: sjablonen.map((s) => _jsx(DropdownMenuItem, { onClick: () => kiesSjabloon(s), children: s.naam }, s.id)) })] })), _jsx(Button, { variant: "outline", size: "sm", disabled: !kop.veillocatie_id, onClick: () => setSjabloonNaam(""), children: "Opslaan als sjabloon" })] }))] }), _jsx("ul", { className: "divide-y divide-border", children: regels.map((r, i) => {
|
|
367
|
+
return (_jsxs("main", { className: "flex w-full min-w-0 flex-col gap-4 overflow-x-clip p-4 pb-40 sm:p-6 sm:pb-32", children: [_jsxs("header", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "flex min-w-0 items-center gap-2", children: [_jsx(Button, { variant: "ghost", size: "sm", className: "h-9 w-9 p-0", "aria-label": "Terug", onClick: () => navigate({ to: "/floriday-verkoop/klok" }), children: _jsx(ArrowLeft, { className: "h-4 w-4" }) }), _jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "truncate text-xl font-bold tracking-tight sm:text-2xl", children: row ? `Veilbrief ${row.klok_nummer}` : "Klokorder (veilbrief)" }), row && (_jsxs("div", { className: "flex flex-wrap items-center gap-x-3 text-xs text-muted-foreground", children: [_jsx(KlokStatusBadge, { status: status, detail: row.status_detail }), row.status_detail && _jsx("span", { children: row.status_detail }), orderQ.data?.orderNumber && _jsxs("span", { children: ["Order ", orderQ.data.orderNumber] })] }))] })] }), row && (_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsxs(Button, { variant: "outline", size: "sm", onClick: onHerhalen, children: [_jsx(Repeat, { className: "mr-2 h-4 w-4" }), " Herhalen"] }), klokKanVerwijderen(status) && !bewerken && (_jsxs(Button, { variant: "outline", size: "sm", onClick: onVerwijderen, disabled: !!bezig || !!blokkade, title: blokkade ?? undefined, children: [_jsx(Trash2, { className: "mr-2 h-4 w-4" }), " Verwijderen"] })), klokKanVerwijderen(status) && !bewerken && (_jsx(Button, { size: "sm", onClick: () => setBewerken(true), disabled: !!blokkade, title: blokkade ?? undefined, children: "Wijzigen en opnieuw versturen" }))] }))] }), _jsx(KlokNotice, {}), fout && (_jsxs("div", { role: "alert", className: "flex items-start gap-2 rounded-lg border border-destructive/30 bg-destructive-soft px-3 py-2 text-sm text-destructive-soft-foreground", children: [fouten.length > 1 || (fouten.length === 1 && fouten[0].tekst !== fout) ? (_jsxs("div", { className: "min-w-0 flex-1", children: [_jsx("p", { className: "font-medium", children: fouten.length === 1 ? "Er is 1 punt om op te lossen:" : `Er zijn ${fouten.length} punten om op te lossen:` }), _jsx("ul", { className: "mt-1 list-disc space-y-0.5 pl-5", children: fouten.map((f, i) => _jsx("li", { children: f.tekst }, i)) })] })) : (_jsx("span", { className: "min-w-0 flex-1", children: fout })), _jsx("button", { type: "button", "aria-label": "Sluiten", onClick: () => setFout(null), children: _jsx(X, { className: "h-4 w-4" }) })] })), row?.laatste_fout && !fout && (_jsx("div", { className: "rounded-lg border border-border bg-warning-soft px-3 py-2 text-sm text-warning-soft-foreground", children: row.laatste_fout })), _jsx("section", { className: "rounded-xl border border-border bg-card p-4 shadow-sm sm:p-5", children: _jsxs("div", { className: "grid gap-4 [@container(min-width:48rem)]:grid-cols-2 md:grid-cols-2", children: [_jsxs("div", { className: "md:col-span-2 rounded-lg" + (foutVelden.has("veillocatie") ? " p-1 ring-1 ring-destructive" : ""), children: [_jsxs("div", { className: "mb-1.5 text-sm font-medium", children: ["Veillocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), laden ? (_jsxs("div", { className: "flex gap-2", children: [_jsx(Skeleton, { className: "h-9 w-28" }), _jsx(Skeleton, { className: "h-9 w-28" }), _jsx(Skeleton, { className: "h-9 w-28" })] })) : locaties.length === 0 ? (_jsx("p", { className: "text-sm text-muted-foreground", children: leegTekst ?? lijsten?.locaties?.message ?? lijsten?.locaties?.error ?? (kop.veillocatie_naam || "Geen veillocaties gevonden.") })) : (_jsxs("div", { className: "flex flex-wrap gap-2", children: [toonKnoppen.map((l) => (_jsx(Button, { type: "button", variant: kop.veillocatie_id === l.id ? "default" : "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: alleenLezen, onClick: () => setKop((k) => ({ ...k, ...locFields(l), veilgroep: k.veillocatie_id === l.id ? k.veilgroep : null })), children: l.displayName ?? l.name }, l.id))), toonMeer.length > 0 && !alleenLezen && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "ghost", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", children: ["Meer ", _jsx(ChevronDown, { className: "ml-1 h-4 w-4" })] }) }), _jsx(DropdownMenuContent, { children: toonMeer.map((l) => (_jsx(DropdownMenuItem, { onClick: () => setKop((k) => ({ ...k, ...locFields(l), veilgroep: null })), children: l.displayName ?? l.name }, l.id))) })] }))] }))] }), _jsxs("label", { className: "block", children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Veildatum ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { type: "date", value: kop.veildatum ?? "", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11" + rood("veildatum"), onChange: (e) => setKop((k) => ({ ...k, veildatum: e.target.value || null })) }), kop.veildatum && _jsx("span", { className: "mt-1 block text-xs text-muted-foreground", children: fmtNL(kop.veildatum, { weekday: "long", day: "numeric", month: "long" }) })] }), _jsxs("div", { children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Veilgroep ", _jsx("span", { className: "text-destructive", children: "*" })] }), laden ? (_jsx(Skeleton, { className: "h-9 w-full" })) : eigenGroep || groepOpties.length === 0 ? (_jsxs("div", { className: "flex gap-2", children: [_jsx(Input, { inputMode: "numeric", placeholder: groepOpties.length === 0 && leegTekst ? leegTekst : "Veilgroep (cijfers)", value: kop.veilgroep ?? "", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11" + rood("veilgroep"), onChange: (e) => setKop((k) => ({ ...k, veilgroep: e.target.value.replace(/\D/g, "") || null })) }), groepOpties.length > 0 && !alleenLezen && _jsx(Button, { variant: "ghost", size: "sm", className: "h-9", onClick: () => setEigenGroep(false), children: "Kies uit lijst" })] })) : (_jsxs("div", { className: "flex gap-2", children: [_jsx(SearchableSelect, { value: kop.veilgroep, options: groepOpties, placeholder: "Zoek veilgroep", allowClear: true, clearLabel: "\u2014 Geen \u2014", disabled: alleenLezen, className: "min-h-9 flex-1 [@media(pointer:coarse)]:min-h-11" + rood("veilgroep"), onChange: (v) => setKop((k) => ({ ...k, veilgroep: v })) }), !alleenLezen && _jsx(Button, { variant: "ghost", size: "sm", className: "h-9", onClick: () => setEigenGroep(true), children: "Zelf invullen" })] }))] }), laden && (_jsxs("div", { children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Verzendlocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Skeleton, { className: "h-9 w-full" })] })), !laden && verzend.length > 1 && (_jsxs("div", { children: [_jsxs("span", { className: "mb-1.5 block text-sm font-medium", children: ["Verzendlocatie ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(SearchableSelect, { value: kop.verzendlocatie_id, disabled: alleenLezen, allowClear: false, options: verzend.map((v) => ({ value: v.id, label: v.name, badge: v.isDefault ? "Standaard" : v.isExternal ? "Extern" : null })), className: "min-h-9 w-full [@media(pointer:coarse)]:min-h-11" + rood("verzendlocatie"), onChange: (v) => setKop((k) => ({ ...k, verzendlocatie_id: v, verzendlocatie_naam: verzend.find((x) => x.id === v)?.name ?? null })) })] })), !laden && verzend.length === 0 && !kop.verzendlocatie_id && leegTekst && (_jsxs("div", { children: [_jsx("span", { className: "mb-1.5 block text-sm font-medium", children: "Verzendlocatie" }), _jsx("p", { className: "text-sm text-muted-foreground", children: leegTekst })] })), _jsxs("div", { children: [_jsx("span", { className: "mb-1.5 block text-sm font-medium", children: "Vervoer" }), _jsx("div", { className: "flex gap-2", children: VERVOER.map((v) => (_jsx(Button, { type: "button", size: "sm", variant: kop.vervoer === v.id ? "default" : "outline", disabled: alleenLezen, className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setKop((k) => ({ ...k, vervoer: v.id })), children: v.label }, v.id))) })] })] }) }), _jsxs("section", { className: "rounded-xl border border-border bg-card shadow-sm", children: [_jsxs("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-3 sm:px-5", children: [_jsx("h2", { className: "text-sm font-semibold", children: "Regels" }), !alleenLezen && (_jsxs("div", { className: "flex flex-wrap gap-2", children: [sjablonen.length > 0 && (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", children: ["Kies sjabloon ", _jsx(ChevronDown, { className: "ml-1 h-4 w-4" })] }) }), _jsx(DropdownMenuContent, { children: sjablonen.map((s) => _jsx(DropdownMenuItem, { onClick: () => kiesSjabloon(s), children: s.naam }, s.id)) })] })), _jsx(Button, { variant: "outline", size: "sm", disabled: !kop.veillocatie_id, onClick: () => setSjabloonNaam(""), children: "Opslaan als sjabloon" })] }))] }), _jsx("ul", { className: "divide-y divide-border", children: regels.map((r, i) => {
|
|
350
368
|
const km = kenmerken[r.key];
|
|
351
|
-
return (_jsxs("li", { className: "space-y-3 px-4 py-4 sm:px-5", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsx("span", { className: "mt-2 w-6 shrink-0 text-xs text-muted-foreground tabular-nums", children: i + 1 }), _jsx("div", { className: "min-w-0 flex-1", children: alleenLezen ? (_jsx("div", { className: "py-1.5 text-sm font-medium", children: r.product_name || "—" })) : (_jsx(SearchableSelect, { value: r.product_id, options: productOpties(false), showImages: true, placeholder: "Kies artikel", allowClear: false, className: "min-h-9 w-full [@media(pointer:coarse)]:min-h-11", onChange: (v) => kiesProduct(r.key, v) })) }), !alleenLezen && (_jsx(Button, { variant: "ghost", size: "sm", className: "h-9 w-9 shrink-0 p-0 [@media(pointer:coarse)]:h-11 [@media(pointer:coarse)]:w-11", "aria-label": "Regel verwijderen", onClick: () => setRegels((rs) => (rs.length > 1 ? rs.filter((x) => x.key !== r.key) : [legeRegel()])), children: _jsx(Trash2, { className: "h-4 w-4" }) }))] }), _jsxs("div", { className: "grid grid-cols-2 gap-3 pl-8 sm:grid-cols-3 lg:grid-cols-6", children: [_jsx(NumField, { label: "Fusten", req: true, value: r.fusten, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { fusten: v }) }), _jsx(NumField, { label: "Stuks/fust", req: true, value: r.stuks_per_fust, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { stuks_per_fust: v }) }), _jsx(NumField, { label: "Fust/laag", value: r.fust_per_laag, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { fust_per_laag: v }) }), _jsx(NumField, { label: "Lagen/kar", value: r.lagen_per_kar, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { lagen_per_kar: v }) }), _jsxs("div", { children: [_jsx(NumField, { label: "Minimumprijs", req: true, value: r.min_prijs, disabled: alleenLezen, inputMode: "decimal", muted: !r.prijs_bevestigd, onChange: (v) => setRegel(r.key, { min_prijs: v, prijs_bevestigd: true, prijs_at: null }) }), !r.prijs_bevestigd && r.min_prijs != null && !alleenLezen && (_jsx("button", { type: "button", className: "mt-1 text-xs font-medium text-primary hover:underline", onClick: () => setRegel(r.key, { prijs_bevestigd: true }), children: "Voorstel bevestigen" }))] }), _jsx(NumField, { label: "Klokvoorverkoop", value: r.voorverkoop_prijs, disabled: alleenLezen, inputMode: "decimal", onChange: (v) => setRegel(r.key, { voorverkoop_prijs: v }) })] }), _jsxs("div", { className: "pl-8", children: [_jsxs("button", { type: "button", className: "text-xs font-medium text-muted-foreground hover:text-foreground", onClick: () => setMeerOpen((m) => ({ ...m, [r.key]: !m[r.key] })), children: [meerOpen[r.key] ? "Minder" : "Meer", ": opmerking, kwaliteit en keurcodes"] }), meerOpen[r.key] && (_jsxs("div", { className: "mt-3 grid gap-3 sm:grid-cols-2", children: [_jsxs("label", { className: "block sm:col-span-2", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Opmerking voor de veiling" }), _jsx(Input, { value: r.veil_opmerking ?? "", disabled: alleenLezen, onChange: (e) => setRegel(r.key, { veil_opmerking: e.target.value || null }) })] }), _jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Kwaliteit (S98)" }), _jsxs("select", { className: "h-9 w-full rounded-lg border border-input bg-background px-2 text-sm [@media(pointer:coarse)]:h-11", value: r.kwaliteit ?? "", disabled: alleenLezen, onChange: (e) => setRegel(r.key, { kwaliteit: e.target.value || null }), children: [_jsx("option", { value: "", children: km?.kwaliteit ? `Artikel: ${km.kwaliteit}` : kwaliteitCodes.length ? "Kenmerk van het artikel" : (leegTekst ?? "Kenmerk van het artikel") }), kwaliteitCodes.filter((c) => c?.vbnCode === "S98").map((c) => (_jsxs("option", { value: c.vbnValueCode, children: [c.vbnValueCode, c.description ? ` · ${c.description}` : ""] }, c.vbnValueCode)))] })] }), _jsxs("div", { children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Keurcodes (K01/K02, P01/P02)" }), _jsx(KeurcodeVeld, { codes: kwaliteitCodes.filter((c) => /^(K01|K02|P01|P02)$/.test(String(c?.vbnCode))), waarde: r.keurcodes, voorinvulling: km?.keurcodes ?? [], leegTekst: leegTekst, disabled: alleenLezen, onChange: (v) => setRegel(r.key, { keurcodes: v }) })] })] }))] })] }, r.key));
|
|
369
|
+
return (_jsxs("li", { className: "space-y-3 px-4 py-4 sm:px-5", children: [_jsxs("div", { className: "flex items-start gap-2", children: [_jsx("span", { className: "mt-2 w-6 shrink-0 text-xs text-muted-foreground tabular-nums", children: i + 1 }), _jsx("div", { className: "min-w-0 flex-1", children: alleenLezen ? (_jsx("div", { className: "py-1.5 text-sm font-medium", children: r.product_name || "—" })) : (_jsx(SearchableSelect, { value: r.product_id, options: productOpties(false), showImages: true, placeholder: "Kies artikel", allowClear: false, className: "min-h-9 w-full [@media(pointer:coarse)]:min-h-11" + (regelRood(r.key, "artikel") || regelRood(r.key, "fust") ? " border-destructive ring-1 ring-destructive" : ""), onChange: (v) => kiesProduct(r.key, v) })) }), !alleenLezen && (_jsx(Button, { variant: "ghost", size: "sm", className: "h-9 w-9 shrink-0 p-0 [@media(pointer:coarse)]:h-11 [@media(pointer:coarse)]:w-11", "aria-label": "Regel verwijderen", onClick: () => setRegels((rs) => (rs.length > 1 ? rs.filter((x) => x.key !== r.key) : [legeRegel()])), children: _jsx(Trash2, { className: "h-4 w-4" }) }))] }), _jsxs("div", { className: "grid grid-cols-2 gap-3 pl-8 sm:grid-cols-3 lg:grid-cols-6", children: [_jsx(NumField, { label: "Fusten", req: true, fout: regelRood(r.key, "fusten"), value: r.fusten, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { fusten: v }) }), _jsx(NumField, { label: "Stuks/fust", req: true, fout: regelRood(r.key, "stuks"), value: r.stuks_per_fust, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { stuks_per_fust: v }) }), _jsx(NumField, { label: "Fust/laag", value: r.fust_per_laag, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { fust_per_laag: v }) }), _jsx(NumField, { label: "Lagen/kar", value: r.lagen_per_kar, disabled: alleenLezen, inputMode: "numeric", onChange: (v) => setRegel(r.key, { lagen_per_kar: v }) }), _jsxs("div", { children: [_jsx(NumField, { label: "Minimumprijs", req: true, fout: regelRood(r.key, "prijs"), value: r.min_prijs, disabled: alleenLezen, inputMode: "decimal", muted: !r.prijs_bevestigd, onChange: (v) => setRegel(r.key, { min_prijs: v, prijs_bevestigd: true, prijs_at: null }) }), !r.prijs_bevestigd && r.min_prijs != null && !alleenLezen && (_jsx("button", { type: "button", className: "mt-1 text-xs font-medium text-primary hover:underline", onClick: () => setRegel(r.key, { prijs_bevestigd: true }), children: "Voorstel bevestigen" }))] }), _jsx(NumField, { label: "Klokvoorverkoop", value: r.voorverkoop_prijs, disabled: alleenLezen, inputMode: "decimal", onChange: (v) => setRegel(r.key, { voorverkoop_prijs: v }) })] }), _jsxs("div", { className: "pl-8", children: [_jsxs("button", { type: "button", className: "text-xs font-medium text-muted-foreground hover:text-foreground", onClick: () => setMeerOpen((m) => ({ ...m, [r.key]: !m[r.key] })), children: [meerOpen[r.key] ? "Minder" : "Meer", ": opmerking, kwaliteit en keurcodes"] }), meerOpen[r.key] && (_jsxs("div", { className: "mt-3 grid gap-3 sm:grid-cols-2", children: [_jsxs("label", { className: "block sm:col-span-2", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Opmerking voor de veiling" }), _jsx(Input, { value: r.veil_opmerking ?? "", disabled: alleenLezen, onChange: (e) => setRegel(r.key, { veil_opmerking: e.target.value || null }) })] }), _jsxs("label", { className: "block", children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Kwaliteit (S98)" }), _jsxs("select", { className: "h-9 w-full rounded-lg border border-input bg-background px-2 text-sm [@media(pointer:coarse)]:h-11", value: r.kwaliteit ?? "", disabled: alleenLezen, onChange: (e) => setRegel(r.key, { kwaliteit: e.target.value || null }), children: [_jsx("option", { value: "", children: km?.kwaliteit ? `Artikel: ${km.kwaliteit}` : kwaliteitCodes.length ? "Kenmerk van het artikel" : (leegTekst ?? "Kenmerk van het artikel") }), kwaliteitCodes.filter((c) => c?.vbnCode === "S98").map((c) => (_jsxs("option", { value: c.vbnValueCode, children: [c.vbnValueCode, c.description ? ` · ${c.description}` : ""] }, c.vbnValueCode)))] })] }), _jsxs("div", { children: [_jsx("span", { className: "mb-1 block text-xs text-muted-foreground", children: "Keurcodes (K01/K02, P01/P02)" }), _jsx(KeurcodeVeld, { codes: kwaliteitCodes.filter((c) => /^(K01|K02|P01|P02)$/.test(String(c?.vbnCode))), waarde: r.keurcodes, voorinvulling: km?.keurcodes ?? [], leegTekst: leegTekst, disabled: alleenLezen, onChange: (v) => setRegel(r.key, { keurcodes: v }) })] })] }))] })] }, r.key));
|
|
352
370
|
}) }), !alleenLezen && (_jsxs("div", { className: "flex flex-wrap gap-2 border-t border-border px-4 py-3 sm:px-5", children: [_jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setRegels((rs) => [...rs, legeRegel()]), children: [_jsx(Plus, { className: "mr-2 h-4 w-4" }), " Artikel toevoegen"] }), _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", children: [_jsx(Package, { className: "mr-2 h-4 w-4" }), " Uit voorraad"] }) }), _jsxs(DropdownMenuContent, { className: "max-h-80 overflow-y-auto", children: [productOpties(true).length === 0 && _jsx(DropdownMenuItem, { disabled: true, children: "Geen artikelen op voorraad" }), productOpties(true).slice(0, 100).map((o) => (_jsxs(DropdownMenuItem, { onClick: () => { const n = legeRegel(); setRegels((rs) => [...rs.filter((x) => x.product_id || x.product_name), n]); void kiesProduct(n.key, o.value); }, children: [_jsx("span", { className: "min-w-0 flex-1 truncate", children: o.label }), _jsx("span", { className: "ml-3 text-xs text-muted-foreground", children: o.hint })] }, o.value)))] })] })] }))] }), resultaten.length > 0 && (_jsxs("section", { className: "rounded-xl border border-border bg-card p-4 shadow-sm sm:p-5", children: [_jsx("h2", { className: "mb-3 text-sm font-semibold", children: "Verkocht" }), _jsxs("table", { className: "w-full text-sm", children: [_jsx("thead", { children: _jsxs("tr", { className: "text-left text-[11px] font-semibold uppercase tracking-wider text-muted-foreground", children: [_jsx("th", { className: "py-1", children: "Koper" }), _jsx("th", { className: "py-1", children: "Stuks" }), _jsx("th", { className: "py-1", children: "Prijs" }), _jsx("th", { className: "py-1", children: "Bedrag" })] }) }), _jsx("tbody", { className: "divide-y divide-border", children: resultaten.filter((x) => !x.doorgedraaid).map((x) => (_jsxs("tr", { children: [_jsx("td", { className: "py-2", children: x.koper_naam }), _jsx("td", { className: "py-2 tabular-nums", children: Number(x.stuks || 0).toLocaleString("nl-NL") }), _jsx("td", { className: "py-2 tabular-nums", children: x.prijs != null ? eur(Number(x.prijs)) : "—" }), _jsx("td", { className: "py-2 tabular-nums", children: x.bedrag != null ? eur(Number(x.bedrag)) : "—" })] }, x.id))) })] }), _jsxs("div", { className: "mt-3 flex flex-wrap gap-x-6 gap-y-1 border-t border-border pt-3 text-sm", children: [_jsxs("span", { children: ["Totaal: ", _jsxs("strong", { className: "tabular-nums", children: [verkochtStuks.toLocaleString("nl-NL"), " stuks \u00B7 ", eur(verkochtBedrag)] })] }), _jsxs("span", { className: "text-muted-foreground", children: ["Doorgedraaid: ", _jsxs("span", { className: "tabular-nums", children: [doorStuks.toLocaleString("nl-NL"), " stuks"] })] })] })] })), !alleenLezen && (_jsx("div", { className: "sticky bottom-0 z-20 -mx-4 border-t border-border bg-background/95 px-4 pt-3 pb-[calc(0.75rem+env(safe-area-inset-bottom))] backdrop-blur sm:-mx-6 sm:px-6", children: _jsxs("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "text-sm tabular-nums", children: [_jsx("span", { className: "font-medium", children: tellersTekst(tellers) }), totaal > 0 && _jsxs("span", { className: "ml-2 text-muted-foreground", children: ["\u00B7 min. ", eur(totaal)] }), ontbreekt.length > 0 && _jsxs("span", { className: "ml-2 text-xs text-muted-foreground", title: ontbreekt.join(", "), children: ["\u00B7 ", ontbreekt.length, " ontbreekt nog"] })] }), _jsxs("div", { className: "flex flex-wrap gap-2", children: [_jsxs(Button, { variant: "ghost", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => setVoorbeeld(true), children: [_jsx(Eye, { className: "mr-2 h-4 w-4" }), " Voorbeeld"] }), bewerken ? (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", onClick: () => { setBewerken(false); geladen.current = null; qc.invalidateQueries({ queryKey: ["klok-order", klokId] }); }, children: "Annuleren" }), _jsxs(Button, { size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => setBevestigWijzig(true), children: [_jsx(Send, { className: "mr-2 h-4 w-4" }), " Opnieuw versturen"] })] })) : (_jsxs(_Fragment, { children: [_jsxs(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig, onClick: onOpslaan, children: [_jsx(Save, { className: "mr-2 h-4 w-4" }), " Opslaan als concept"] }), _jsx(Button, { variant: "outline", size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => onVersturen(true), children: "Versturen en nieuwe" }), _jsxs(Button, { size: "sm", className: "h-9 [@media(pointer:coarse)]:h-11", disabled: !!bezig || !!blokkade || ontbreekt.length > 0, title: blokkade ?? (ontbreekt.length ? `Nog nodig: ${ontbreekt.join(", ")}` : undefined), onClick: () => onVersturen(false), children: [_jsx(Send, { className: "mr-2 h-4 w-4" }), " ", bezig === "send" ? "Bezig…" : "Versturen naar veiling"] })] }))] })] }) })), voorbeeld && (_jsxs(Dialoog, { titel: "Voorbeeld veilbrief", onClose: () => setVoorbeeld(false), children: [_jsxs("dl", { className: "grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm", children: [_jsx("dt", { className: "text-muted-foreground", children: "Veillocatie" }), _jsx("dd", { children: kop.veillocatie_naam ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Veildatum" }), _jsx("dd", { children: kop.veildatum ? fmtNL(kop.veildatum, { weekday: "short", day: "numeric", month: "short" }) : "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Veilgroep" }), _jsx("dd", { children: kop.veilgroep ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Verzendlocatie" }), _jsx("dd", { children: kop.verzendlocatie_naam ?? "—" }), _jsx("dt", { className: "text-muted-foreground", children: "Vervoer" }), _jsx("dd", { children: VERVOER.find((v) => v.id === kop.vervoer)?.label })] }), _jsx("ul", { className: "mt-3 divide-y divide-border text-sm", children: regels.filter((r) => r.product_name).map((r) => (_jsxs("li", { className: "flex justify-between gap-3 py-1.5", children: [_jsx("span", { className: "min-w-0 truncate", children: r.product_name }), _jsxs("span", { className: "shrink-0 tabular-nums text-muted-foreground", children: [r.fusten ?? 0, " \u00D7 ", r.stuks_per_fust ?? 0, " \u00B7 min. ", r.min_prijs != null ? eur(r.min_prijs) : "—"] })] }, r.key))) }), _jsx("p", { className: "mt-3 text-sm font-medium tabular-nums", children: tellersTekst(tellers) }), ontbreekt.length > 0 && _jsxs("p", { className: "mt-2 text-sm text-muted-foreground", children: ["Ontbreekt nog: ", ontbreekt.join(", ")] })] })), bevestigWijzig && (_jsxs(Dialoog, { titel: "Wijzigen en opnieuw versturen?", onClose: () => setBevestigWijzig(false), children: [_jsx("p", { className: "text-sm text-muted-foreground", children: "De huidige veilbrief wordt bij de veiling verwijderd en opnieuw verstuurd. Doorgaan?" }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setBevestigWijzig(false), children: "Annuleren" }), _jsx(Button, { onClick: onWijzigEnVerstuur, disabled: !!bezig, children: "Doorgaan" })] })] })), sjabloonNaam != null && (_jsxs(Dialoog, { titel: "Opslaan als sjabloon", onClose: () => setSjabloonNaam(null), children: [_jsxs("label", { className: "block text-sm", children: [_jsxs("span", { className: "mb-1 block", children: ["Naam ", _jsx("span", { className: "text-destructive", children: "*" })] }), _jsx(Input, { autoFocus: true, value: sjabloonNaam, maxLength: 80, onChange: (e) => setSjabloonNaam(e.target.value) })] }), _jsxs("p", { className: "mt-2 text-xs text-muted-foreground", children: ["Voor ", kop.veillocatie_naam, ". Prijzen ouder dan 14 dagen worden later als voorstel getoond."] }), _jsxs("div", { className: "mt-5 flex justify-end gap-2", children: [_jsx(Button, { variant: "ghost", onClick: () => setSjabloonNaam(null), children: "Annuleren" }), _jsx(Button, { onClick: bewaarSjabloon, disabled: !sjabloonNaam.trim(), children: "Opslaan" })] })] }))] }));
|
|
353
371
|
}
|
|
354
|
-
function NumField({ label, value, onChange, disabled, req, inputMode, muted }) {
|
|
355
|
-
|
|
372
|
+
function NumField({ label, value, onChange, disabled, req, inputMode, muted, fout }) {
|
|
373
|
+
// Bedragen altijd met twee decimalen ("0,50"); hele getallen zonder.
|
|
374
|
+
const toon = (v) => (v == null ? "" : inputMode === "decimal" ? prijsTekst(v) : String(v));
|
|
375
|
+
const [txt, setTxt] = useState(toon(value));
|
|
356
376
|
useEffect(() => {
|
|
357
377
|
const cur = num(txt);
|
|
358
378
|
if (cur !== value)
|
|
359
|
-
setTxt(
|
|
379
|
+
setTxt(toon(value));
|
|
360
380
|
}, [value]); // eslint-disable-line react-hooks/exhaustive-deps
|
|
361
|
-
return (_jsxs("label", { className: "block", children: [_jsxs("span", { className: "mb-1 block text-xs text-muted-foreground", children: [label, req && _jsx("span", { className: "text-destructive", children: " *" })] }), _jsx(Input, { inputMode: inputMode, value: txt, disabled: disabled, className: "h-9 tabular-nums [@media(pointer:coarse)]:h-11 " + (muted ? "text-muted-foreground" : ""),
|
|
381
|
+
return (_jsxs("label", { className: "block", children: [_jsxs("span", { className: "mb-1 block text-xs text-muted-foreground", children: [label, req && _jsx("span", { className: "text-destructive", children: " *" })] }), _jsx(Input, { inputMode: inputMode, value: txt, disabled: disabled, "aria-invalid": fout || undefined, className: "h-9 tabular-nums [@media(pointer:coarse)]:h-11 " + (muted ? "text-muted-foreground" : "") + (fout ? " border-destructive ring-1 ring-destructive" : ""), onBlur: () => { if (inputMode === "decimal" && value != null)
|
|
382
|
+
setTxt(toon(value)); }, onChange: (e) => { setTxt(e.target.value); onChange(num(e.target.value)); } })] }));
|
|
362
383
|
}
|
|
363
384
|
function KeurcodeVeld({ codes, waarde, voorinvulling, leegTekst, disabled, onChange }) {
|
|
364
385
|
const groepen = ["K01", "K02", "P01", "P02"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare function useKlokOrders(from: string | null, to: string | null): import("@tanstack/react-query").UseQueryResult<{
|
|
1
|
+
export declare function useKlokOrders(from: string | null, to: string | null, enabled?: boolean): import("@tanstack/react-query").UseQueryResult<{
|
|
2
2
|
orders: any;
|
|
3
3
|
resultaten: any;
|
|
4
4
|
}, Error>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KlokOrdersList.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokOrdersList.tsx"],"names":[],"mappings":"AAqBA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI;;;
|
|
1
|
+
{"version":3,"file":"KlokOrdersList.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokOrdersList.tsx"],"names":[],"mappings":"AAqBA,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,EAAE,EAAE,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,UAAO;;;UAQnF;AAKD,wBAAgB,cAAc,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,OAAO,CAAA;CAAE,+BA4L5H"}
|
|
@@ -11,10 +11,11 @@ import { fmtNL } from "../../../lib/nl-datetime.js";
|
|
|
11
11
|
import { amsterdamYmd, ymdString } from "../../../lib/period-range.js";
|
|
12
12
|
import { EmptyState } from "../v3/EmptyState.js";
|
|
13
13
|
import { KlokStatusBadge } from "./KlokStatusBadge.js";
|
|
14
|
-
export function useKlokOrders(from, to) {
|
|
14
|
+
export function useKlokOrders(from, to, enabled = true) {
|
|
15
15
|
const fetchList = useServerFn(listKlokOrders);
|
|
16
16
|
return useQuery({
|
|
17
17
|
queryKey: ["klok-orders", from, to],
|
|
18
|
+
enabled,
|
|
18
19
|
queryFn: () => fetchList({ data: { from, to } }),
|
|
19
20
|
placeholderData: (p) => p,
|
|
20
21
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KlokPage.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"KlokPage.d.ts","sourceRoot":"","sources":["../../../../src/components/verkoop/klok/KlokPage.tsx"],"names":[],"mappings":"AAuBA,wBAAgB,QAAQ,gCAiKvB"}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo, useState } from "react";
|
|
2
|
+
import { useEffect, useMemo, useState } from "react";
|
|
3
3
|
import { useNavigate } from "@tanstack/react-router";
|
|
4
4
|
import { Button } from "@flowselections/core";
|
|
5
5
|
import { AlertTriangle, Coins, Euro, FileText, Gavel, Layers, Package, Plus, Trash2, TrendingUp, Users } from "lucide-react";
|
|
6
|
-
import {
|
|
6
|
+
import { amsterdamYmd, defaultPeriod, periodRange, ymdString } from "../../../lib/period-range.js";
|
|
7
|
+
import { fmtNL } from "../../../lib/nl-datetime.js";
|
|
8
|
+
import { Clock } from "lucide-react";
|
|
9
|
+
import { SalesOrdersFilters } from "../SalesOrdersFilters.js";
|
|
7
10
|
import { klokTellers } from "../../../lib/klok-labels.js";
|
|
8
11
|
import { KpiTile } from "../v3/KpiTile.js";
|
|
9
12
|
import { KlokNotice } from "./KlokNotice.js";
|
|
@@ -19,14 +22,32 @@ const eur = (n) => `€ ${n.toLocaleString("nl-NL", { minimumFractionDigits: 2,
|
|
|
19
22
|
export function KlokPage() {
|
|
20
23
|
const navigate = useNavigate();
|
|
21
24
|
const [tab, setTab] = useState("veilbrieven");
|
|
22
|
-
const [
|
|
23
|
-
const
|
|
25
|
+
const [filters, setFilters] = useState(() => defaultPeriod());
|
|
26
|
+
const [alle, setAlle] = useState(false);
|
|
27
|
+
const r = alle ? null : periodRange(filters);
|
|
24
28
|
const from = r?.startDate ?? null;
|
|
25
29
|
const to = r?.endDate ?? null;
|
|
26
30
|
const q = useKlokOrders(from, to);
|
|
31
|
+
const bijgewerkt = q.dataUpdatedAt ? fmtNL(new Date(q.dataUpdatedAt).toISOString(), { hour: "2-digit", minute: "2-digit" }) : null;
|
|
27
32
|
const orders = (q.data?.orders ?? []);
|
|
28
33
|
const resultaten = (q.data?.resultaten ?? []);
|
|
29
34
|
const vandaag = ymdString(amsterdamYmd());
|
|
35
|
+
// Sneltoets N: nieuwe veilbrief (zelfde als "Nieuwe order" op Verkooporders), niet tijdens typen.
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
const onKey = (e) => {
|
|
38
|
+
if (e.key !== "n" && e.key !== "N")
|
|
39
|
+
return;
|
|
40
|
+
if (e.metaKey || e.ctrlKey || e.altKey || e.defaultPrevented)
|
|
41
|
+
return;
|
|
42
|
+
const t = e.target;
|
|
43
|
+
if (t && (t.isContentEditable || /^(INPUT|TEXTAREA|SELECT)$/.test(t.tagName) || t.closest("[role=dialog],[role=menu],[role=listbox]")))
|
|
44
|
+
return;
|
|
45
|
+
e.preventDefault();
|
|
46
|
+
void navigate({ to: "/floriday-verkoop/klok/nieuw" });
|
|
47
|
+
};
|
|
48
|
+
window.addEventListener("keydown", onKey);
|
|
49
|
+
return () => window.removeEventListener("keydown", onKey);
|
|
50
|
+
}, [navigate]);
|
|
30
51
|
const kpi = useMemo(() => {
|
|
31
52
|
const vandaagRows = orders.filter((o) => o.veildatum === vandaag && o.status !== "concept" && o.status !== "verwijderd");
|
|
32
53
|
const stuks = orders.filter((o) => o.status !== "verwijderd").reduce((s, o) => s + klokTellers(o.regels ?? []).stuks, 0);
|
|
@@ -52,7 +73,7 @@ export function KlokPage() {
|
|
|
52
73
|
top: Array.from(kopers.values()).sort((a, b) => b.bedrag - a.bedrag).slice(0, 5),
|
|
53
74
|
};
|
|
54
75
|
}, [orders, resultaten, vandaag]);
|
|
55
|
-
return (_jsxs("main", { className: "flex w-full min-w-0 flex-col gap-4 overflow-x-clip p-4 pb-24 sm:p-6", children: [_jsxs("header", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-xl font-bold tracking-tight sm:text-2xl", children: "Klok" }),
|
|
76
|
+
return (_jsxs("main", { className: "flex w-full min-w-0 flex-col gap-4 overflow-x-clip p-4 pb-24 sm:p-6", children: [_jsxs("header", { className: "flex flex-wrap items-center justify-between gap-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-xl font-bold tracking-tight sm:text-2xl", children: "Klok" }), _jsxs("p", { className: "flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground", "aria-live": "polite", children: [_jsx("span", { children: "Veilbrieven, aanvoer en resultaat" }), bijgewerkt && (_jsxs("span", { className: "inline-flex items-center gap-1", children: [_jsx(Clock, { className: "h-3.5 w-3.5", "aria-hidden": true }), "Bijgewerkt ", bijgewerkt] }))] })] }), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(SalesOrdersFilters, { value: filters, onChange: setFilters, part: "period", alle: { active: alle, onChange: setAlle } }), _jsxs(Button, { size: "sm", onClick: () => navigate({ to: "/floriday-verkoop/klok/nieuw" }), children: [_jsx(Plus, { className: "mr-2 h-4 w-4" }), " Nieuwe veilbrief", _jsx("kbd", { "aria-hidden": true, className: "ml-2 hidden rounded border border-primary-foreground/30 bg-primary-foreground/15 px-1.5 font-mono text-[10px] leading-4 text-primary-foreground sm:inline-block", children: "N" })] })] })] }), _jsx(KlokNotice, {}), tab === "veilbrieven" && (_jsxs("section", { className: "grid grid-cols-2 gap-3 lg:grid-cols-4", children: [_jsx(KpiTile, { title: "Vandaag aangevoerd", value: kpi.vandaag, sub: "veilbrieven voor vandaag", icon: _jsx(Gavel, {}), loading: q.isLoading }), _jsx(KpiTile, { title: "Concepten", value: kpi.concepten, sub: "nog niet verstuurd", icon: _jsx(FileText, {}), loading: q.isLoading }), _jsx(KpiTile, { title: "Fout", value: kpi.fout, sub: "vraagt actie", icon: _jsx(AlertTriangle, {}), tone: kpi.fout > 0 ? "warning" : "default", loading: q.isLoading }), _jsx(KpiTile, { title: "Stuks", value: kpi.stuks.toLocaleString("nl-NL"), sub: "in deze periode", icon: _jsx(Layers, {}), loading: q.isLoading })] })), tab === "resultaat" && (_jsxs("section", { className: "grid grid-cols-2 gap-3 lg:grid-cols-4", children: [_jsx(KpiTile, { title: "Opbrengst", value: eur(kpi.opbrengst), sub: "in deze periode", icon: _jsx(Euro, {}), loading: q.isLoading }), _jsx(KpiTile, { title: "Stuks verkocht", value: kpi.verkocht.toLocaleString("nl-NL"), icon: _jsx(Package, {}), loading: q.isLoading }), _jsx(KpiTile, { title: "Gem. prijs", value: eur(kpi.gem), sub: "per stuk", icon: _jsx(Coins, {}), loading: q.isLoading }), _jsx(KpiTile, { title: "Doordraai", value: `${kpi.doorPct.toFixed(1).replace(".", ",")}%`, icon: _jsx(Trash2, {}), tone: kpi.doorPct > 0 ? "warning" : "default", loading: q.isLoading })] })), _jsx("div", { role: "tablist", "aria-label": "Klok", className: "flex items-center gap-2 overflow-x-auto pb-1", children: TABS.map((t) => {
|
|
56
77
|
const Icon = t.icon;
|
|
57
78
|
const active = tab === t.id;
|
|
58
79
|
return (_jsxs("button", { type: "button", role: "tab", "aria-selected": active, onClick: () => setTab(t.id), className: "flex h-9 items-center gap-2 whitespace-nowrap rounded-lg border px-3 text-sm focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring " +
|
|
@@ -9,6 +9,8 @@ export interface FormState {
|
|
|
9
9
|
/** Regels met product maar zonder (volledige) belading. */
|
|
10
10
|
linesWithoutBelading: number;
|
|
11
11
|
stockBlocked: boolean;
|
|
12
|
+
/** Regels met product maar zonder prijs > 0 (en 0 niet bewust bevestigd). */
|
|
13
|
+
linesWithoutPrice?: number;
|
|
12
14
|
previewPending: boolean;
|
|
13
15
|
previewBlockedReason: string | null;
|
|
14
16
|
}
|
|
@@ -60,6 +62,18 @@ export type OrderprijsUitkomst = {
|
|
|
60
62
|
} | {
|
|
61
63
|
ok: false;
|
|
62
64
|
};
|
|
65
|
+
export declare const PRIJS_ONBEKEND_TEXT = "Geen prijs bekend; vul zelf een prijs in";
|
|
66
|
+
/** Prijs uit klanten_orderprijs die echt bekend is: net_price 0 betekent "geen prijs bekend" (artikel zonder verkoopprijs). */
|
|
67
|
+
export declare function bekendePrijs(p: Orderprijs | null | undefined): {
|
|
68
|
+
unit_price: number | null;
|
|
69
|
+
price_source: string | null;
|
|
70
|
+
};
|
|
71
|
+
/** Regel blokkeert aanmaken tot er een prijs > 0 is, of de gebruiker 0 bewust bevestigt. */
|
|
72
|
+
export declare function regelMistPrijs(l: {
|
|
73
|
+
product_id: string | null;
|
|
74
|
+
unit_price: number | null;
|
|
75
|
+
price_zero_ok?: boolean;
|
|
76
|
+
}): boolean;
|
|
63
77
|
export declare const PRIJS_FOUT_TEXT = "Prijs ophalen lukt niet; vul hem zelf in of probeer het opnieuw.";
|
|
64
78
|
/** "Prijsgroep: Groothandel", "Klantprijs", "Klantkorting", "Standaardprijs". */
|
|
65
79
|
export declare function prijsBronLabel(p: Pick<Orderprijs, "bron" | "price_group_name"> | null | undefined): string | null;
|
|
@@ -67,5 +81,14 @@ export declare function prijsBronLabel(p: Pick<Orderprijs, "bron" | "price_group
|
|
|
67
81
|
export declare function parseOrderprijs(rows: unknown): Orderprijs | null;
|
|
68
82
|
/** Sleutel waarop een automatische prijs opnieuw wordt opgehaald. */
|
|
69
83
|
export declare function prijsSleutel(customerId: string | null, productId: string | null, datum: string, aantal: number | null): string | null;
|
|
84
|
+
/**
|
|
85
|
+
* Servercontrole handmatige order (createManualOrder): elke regel prijs > 0, of 0 met vinkje "Prijs 0 is juist".
|
|
86
|
+
* Eerste overtreding → "Vul een prijs in bij {artikel}."; alles goed → null.
|
|
87
|
+
*/
|
|
88
|
+
export declare function prijsRegelFout(lines: {
|
|
89
|
+
product_name?: string | null;
|
|
90
|
+
unit_price?: number | null;
|
|
91
|
+
price_zero_ok?: boolean;
|
|
92
|
+
}[]): string | null;
|
|
70
93
|
export {};
|
|
71
94
|
//# sourceMappingURL=create-order-form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-order-form.d.ts","sourceRoot":"","sources":["../../src/lib/create-order-form.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,aAAa,EAAE,OAAO,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,+CAA+C;IAC/C,cAAc,EAAE,MAAM,CAAC;IACvB,2DAA2D;IAC3D,oBAAoB,EAAE,MAAM,CAAC;IAC7B,YAAY,EAAE,OAAO,CAAC;IACtB,cAAc,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"create-order-form.d.ts","sourceRoot":"","sources":["../../src/lib/create-order-form.ts"],"names":[],"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,6EAA6E;IAC7E,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,OAAO,CAAC;IACxB,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC;AAED,wBAAgB,YAAY,CAAC,CAAC,EAAE,SAAS,GAAG,MAAM,EAAE,CAenD;AAED,qFAAqF;AACrF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,cAAc,EAAE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AAM,GAAG,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,IAAI,CAGrI;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,aAAa,CAAC,EAAE,OAAO,CAAA;CAAE,EAAE,GAAG,MAAM,GAAG,IAAI,CAU5I"}
|
|
@@ -15,6 +15,8 @@ export function missingItems(s) {
|
|
|
15
15
|
out.push("Voeg minimaal één product toe");
|
|
16
16
|
if (s.linesWithoutBelading > 0)
|
|
17
17
|
out.push(s.linesWithoutBelading === 1 ? "Kies een belading bij 1 regel" : `Kies een belading bij ${s.linesWithoutBelading} regels`);
|
|
18
|
+
if ((s.linesWithoutPrice ?? 0) > 0)
|
|
19
|
+
out.push(s.linesWithoutPrice === 1 ? "Vul een prijs in bij 1 regel" : `Vul een prijs in bij ${s.linesWithoutPrice} regels`);
|
|
18
20
|
if (s.stockBlocked)
|
|
19
21
|
out.push("Pas de aantallen aan: onvoldoende voorraad");
|
|
20
22
|
if (!s.isReservation && s.customerId && s.deliveryLocationId && s.pickupLocationId) {
|
|
@@ -79,6 +81,22 @@ export function attentionItems(s) {
|
|
|
79
81
|
out.push(`${n(s.linesOverStock)} meer dan beschikbaar`);
|
|
80
82
|
return out;
|
|
81
83
|
}
|
|
84
|
+
export const PRIJS_ONBEKEND_TEXT = "Geen prijs bekend; vul zelf een prijs in";
|
|
85
|
+
/** Prijs uit klanten_orderprijs die echt bekend is: net_price 0 betekent "geen prijs bekend" (artikel zonder verkoopprijs). */
|
|
86
|
+
export function bekendePrijs(p) {
|
|
87
|
+
if (!p || !(p.net_price > 0))
|
|
88
|
+
return { unit_price: null, price_source: null };
|
|
89
|
+
return { unit_price: p.net_price, price_source: prijsBronLabel(p) };
|
|
90
|
+
}
|
|
91
|
+
/** Regel blokkeert aanmaken tot er een prijs > 0 is, of de gebruiker 0 bewust bevestigt. */
|
|
92
|
+
export function regelMistPrijs(l) {
|
|
93
|
+
if (!l.product_id)
|
|
94
|
+
return false;
|
|
95
|
+
const p = Number(l.unit_price);
|
|
96
|
+
if (l.unit_price != null && p > 0)
|
|
97
|
+
return false;
|
|
98
|
+
return !(l.price_zero_ok && l.unit_price != null && p === 0);
|
|
99
|
+
}
|
|
82
100
|
export const PRIJS_FOUT_TEXT = "Prijs ophalen lukt niet; vul hem zelf in of probeer het opnieuw.";
|
|
83
101
|
/** "Prijsgroep: Groothandel", "Klantprijs", "Klantkorting", "Standaardprijs". */
|
|
84
102
|
export function prijsBronLabel(p) {
|
|
@@ -114,3 +132,20 @@ export function prijsSleutel(customerId, productId, datum, aantal) {
|
|
|
114
132
|
return null;
|
|
115
133
|
return `${customerId}|${productId}|${datum}|${aantal ?? ""}`;
|
|
116
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Servercontrole handmatige order (createManualOrder): elke regel prijs > 0, of 0 met vinkje "Prijs 0 is juist".
|
|
137
|
+
* Eerste overtreding → "Vul een prijs in bij {artikel}."; alles goed → null.
|
|
138
|
+
*/
|
|
139
|
+
export function prijsRegelFout(lines) {
|
|
140
|
+
for (let i = 0; i < lines.length; i++) {
|
|
141
|
+
const l = lines[i];
|
|
142
|
+
const p = l.unit_price == null ? NaN : Number(l.unit_price);
|
|
143
|
+
if (p > 0)
|
|
144
|
+
continue;
|
|
145
|
+
if (p === 0 && l.price_zero_ok === true)
|
|
146
|
+
continue;
|
|
147
|
+
const naam = String(l.product_name ?? "").trim() || `regel ${i + 1}`;
|
|
148
|
+
return `Vul een prijs in bij ${naam}.`;
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
@@ -164,6 +164,7 @@ export declare const createManualOrder: import("@tanstack/start-client-core").Op
|
|
|
164
164
|
quantity: number;
|
|
165
165
|
unit?: string | null | undefined;
|
|
166
166
|
unit_price?: number | undefined;
|
|
167
|
+
price_zero_ok?: boolean | undefined;
|
|
167
168
|
plants_per_crate?: number | undefined;
|
|
168
169
|
crates_per_layer?: number | undefined;
|
|
169
170
|
layers_per_cart?: number | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,2BAA2B;;;;;;YAwBpB,MAAM;sBACc,MAAM,GAAG,IAAI;yBACG,MAAM,GAAG,IAAI;cACnC,MAAM,GAAG,IAAI;eACX,MAAM,GAAG,IAAI;wBACK,MAAM,GAAG,IAAI;gBACvC,MAAM;;;GAkB9B,CAAC;AAIL,eAAO,MAAM,2BAA2B;;;;0CAElB,OAAO;;;;GAoDzB,CAAC;AAWL,eAAO,MAAM,0BAA0B;;;;;;;;YA+D7B,MAAM;iBACD,MAAM;sBACD,MAAM,GAAG,IAAI;cACrB,MAAM;oBACA,MAAM,GAAG,IAAI;0BACP,MAAM,GAAG,IAAI;0BACb,MAAM,GAAG,IAAI;yBACd,MAAM,GAAG,IAAI;wBACd,MAAM;wBACN,MAAM;yBACL,MAAM;kBACb,OAAO;gBACT,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS;;GA6TpD,CAAC;AAGL,eAAO,MAAM,kCAAkC;;;;0CAEzB,OAAO;;;;;;;;;;;;;;;;;;;;;;GAkDzB,CAAC;AAOL,eAAO,MAAM,uBAAuB;;;;0CAEd,OAAO;;;;GAWzB,CAAC;AAKL,eAAO,MAAM,qBAAqB;;;;;;;;;;YAuCI,MAAM;;;;;GAIxC,CAAC;AAGL,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;GAanC,CAAC;AASL,eAAO,MAAM,8BAA8B;;;;8CAEjB,OAAO;;;;GAU7B,CAAC;AASL,eAAO,MAAM,mBAAmB;;;;;;;;0BAgBuB,MAAM;0BAAoB,MAAM;yBAAmB,MAAM;;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AO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAuUL,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;AAML,eAAO,MAAM,cAAc;;;;8CAED,OAAO;;;;;;;;;;;;;MA+B7B,CAAC;AAML,eAAO,MAAM,2BAA2B;;;;8CAEd,OAAO;;;;gBAIgC,MAAM,EAAE;GAoCrE,CAAC"}
|
|
@@ -724,6 +724,8 @@ const LineInput = z.object({
|
|
|
724
724
|
quantity: z.number().int().positive(), // aantal PLANTEN (== fusten * plants_per_crate)
|
|
725
725
|
unit: z.string().max(50).nullable().optional(),
|
|
726
726
|
unit_price: z.number().nonnegative().optional(),
|
|
727
|
+
// Gebruiker bevestigt bewust prijs 0 op deze regel ("Prijs 0 is juist").
|
|
728
|
+
price_zero_ok: z.boolean().optional(),
|
|
727
729
|
// Packing-info uit voorraadmodule; nodig om ontbrekende products-rij aan te maken
|
|
728
730
|
plants_per_crate: z.number().int().positive().optional(),
|
|
729
731
|
crates_per_layer: z.number().int().positive().optional(),
|
|
@@ -799,8 +801,9 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
799
801
|
.inputValidator((input) => CreateManualOrderInput.parse(input))
|
|
800
802
|
.handler(async ({ data, context }) => {
|
|
801
803
|
{
|
|
802
|
-
|
|
803
|
-
const
|
|
804
|
+
// Prijs 0 alleen met het vinkje "Prijs 0 is juist" per regel (confirmZeroPrice blijft alleen voor oude aanroepers in het schema).
|
|
805
|
+
const { prijsRegelFout } = await import("./create-order-form.js");
|
|
806
|
+
const refusal = prijsRegelFout(data.lines);
|
|
804
807
|
if (refusal)
|
|
805
808
|
throw stockError(refusal);
|
|
806
809
|
}
|
|
@@ -1035,8 +1038,14 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
1035
1038
|
...(lateSignup ? { late_signup_override: lateSignup } : {}),
|
|
1036
1039
|
...(ownTransportInfo ? { own_transport: ownTransportInfo } : {}),
|
|
1037
1040
|
...(data.customerReference ? { customer_reference: data.customerReference } : {}),
|
|
1041
|
+
// Per regel vastgelegd welke prijs 0 bewust is bevestigd (verkoop_insert_manual_order neemt geen regelvelden buiten de vaste kolommen over).
|
|
1038
1042
|
...(data.lines.some((l) => !(Number(l.unit_price) > 0))
|
|
1039
|
-
? { zero_price_confirmed: {
|
|
1043
|
+
? { zero_price_confirmed: {
|
|
1044
|
+
by: context.userId ?? "server",
|
|
1045
|
+
at: new Date().toISOString(),
|
|
1046
|
+
lines: data.lines.filter((l) => !(Number(l.unit_price) > 0)).length,
|
|
1047
|
+
items: data.lines.filter((l) => !(Number(l.unit_price) > 0)).map((l) => ({ product_id: l.product_id, product_name: l.product_name, price_zero_ok: l.price_zero_ok === true })),
|
|
1048
|
+
} }
|
|
1040
1049
|
: {}),
|
|
1041
1050
|
is_reservation: !!data.isReservation,
|
|
1042
1051
|
load_carrier_type: loadCarrierType,
|
|
@@ -44,4 +44,16 @@ export declare const LEGE_KOP: KlokKop;
|
|
|
44
44
|
export declare function klokOntbreekt(kop: KlokKop, regels: KlokRegel[]): string[];
|
|
45
45
|
/** Prijs overnemen uit een eerdere veilbrief/sjabloon: oud = voorstel. */
|
|
46
46
|
export declare function neemPrijsOver(r: KlokRegel, now?: Date): KlokRegel;
|
|
47
|
+
/** Geheel getal uit tekst of getal ("28" → 28); anders null. Floriday eist gehele getallen. */
|
|
48
|
+
export declare function alsGeheelGetal(v: unknown): number | null;
|
|
49
|
+
/** Veld op het scherm: "veillocatie" | "veildatum" | "veilgroep" | "verzendlocatie" | "regel:<key>:<deel>". */
|
|
50
|
+
export type KlokVeld = string;
|
|
51
|
+
export interface KlokFout {
|
|
52
|
+
tekst: string;
|
|
53
|
+
veld: KlokVeld | null;
|
|
54
|
+
}
|
|
55
|
+
/** Weigering van Floriday als lijst: één regel per fout, met het veld waar hij bij hoort. */
|
|
56
|
+
export declare function klokFoutLijst(errors: unknown[] | undefined, reason: string | undefined, regels: KlokRegel[]): KlokFout[];
|
|
57
|
+
/** Velden die rood moeten bij "Ontbreekt nog" (zelfde teksten als klokOntbreekt). */
|
|
58
|
+
export declare function klokOntbreektVelden(kop: KlokKop, regels: KlokRegel[]): Set<KlokVeld>;
|
|
47
59
|
//# sourceMappingURL=klok-form.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"klok-form.d.ts","sourceRoot":"","sources":["../../src/lib/klok-form.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,GAAG,cAAc,CAAC;AAE5D,MAAM,WAAW,OAAO;IACtB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,iBA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 @@ export function klokOntbreekt(kop, regels) {
|
|
|
36
36
|
out.push(`${n}: fusten`);
|
|
37
37
|
if (!(Number(r.stuks_per_fust) > 0))
|
|
38
38
|
out.push(`${n}: stuks per fust`);
|
|
39
|
+
if (r.trade_item_id && alsGeheelGetal(r.vbn_package_code) == null)
|
|
40
|
+
out.push(`${n}: fust (geen geldig fustnummer)`);
|
|
39
41
|
if (!(Number(r.min_prijs) > 0))
|
|
40
42
|
out.push(`${n}: minimumprijs`);
|
|
41
43
|
else if (!r.prijs_bevestigd)
|
|
@@ -49,3 +51,77 @@ export function neemPrijsOver(r, now = new Date()) {
|
|
|
49
51
|
return { ...r, prijs_bevestigd: false };
|
|
50
52
|
return { ...r, prijs_bevestigd: !klokPrijsVerouderd(r.prijs_at, now) };
|
|
51
53
|
}
|
|
54
|
+
/** Geheel getal uit tekst of getal ("28" → 28); anders null. Floriday eist gehele getallen. */
|
|
55
|
+
export function alsGeheelGetal(v) {
|
|
56
|
+
if (v == null)
|
|
57
|
+
return null;
|
|
58
|
+
const s = String(v).trim();
|
|
59
|
+
if (!/^\d+$/.test(s))
|
|
60
|
+
return null;
|
|
61
|
+
const n = Number(s);
|
|
62
|
+
return Number.isSafeInteger(n) ? n : null;
|
|
63
|
+
}
|
|
64
|
+
const KOPVELDEN = [
|
|
65
|
+
[/veilgroep|auctionGroup/i, "veilgroep"],
|
|
66
|
+
[/veillocatie|auctionLocation/i, "veillocatie"],
|
|
67
|
+
[/veildatum|auctionDate/i, "veildatum"],
|
|
68
|
+
[/verzendlocatie|despatchWarehouse/i, "verzendlocatie"],
|
|
69
|
+
];
|
|
70
|
+
function regelDeel(t) {
|
|
71
|
+
if (/minimumprijs|minimumPrice|prijs/i.test(t))
|
|
72
|
+
return "prijs";
|
|
73
|
+
if (/stuks|piecesPerPackage/i.test(t))
|
|
74
|
+
return "stuks";
|
|
75
|
+
if (/fusten|numberOfPackages|aantal/i.test(t))
|
|
76
|
+
return "fusten";
|
|
77
|
+
if (/fust|vbnPackageCode|packing/i.test(t))
|
|
78
|
+
return "fust";
|
|
79
|
+
return "artikel";
|
|
80
|
+
}
|
|
81
|
+
/** Weigering van Floriday als lijst: één regel per fout, met het veld waar hij bij hoort. */
|
|
82
|
+
export function klokFoutLijst(errors, reason, regels) {
|
|
83
|
+
const out = [];
|
|
84
|
+
for (const e of errors ?? []) {
|
|
85
|
+
const o = e;
|
|
86
|
+
const tekst = typeof o === "string" ? o : String(o?.message ?? o?.reason ?? "");
|
|
87
|
+
if (!tekst)
|
|
88
|
+
continue;
|
|
89
|
+
const pad = typeof o === "object" && o ? String(o.path ?? o.field ?? "") : "";
|
|
90
|
+
const hooi = `${pad} ${tekst}`;
|
|
91
|
+
let veld = null;
|
|
92
|
+
const m = /lines?\[?\.?(\d+)/i.exec(pad);
|
|
93
|
+
let regelIdx = m ? Number(m[1]) : -1;
|
|
94
|
+
if (regelIdx < 0)
|
|
95
|
+
regelIdx = regels.findIndex((r) => r.product_name && tekst.includes(r.product_name));
|
|
96
|
+
if (regelIdx < 0) {
|
|
97
|
+
const rm = /regel\s+(\d+)/i.exec(tekst);
|
|
98
|
+
if (rm)
|
|
99
|
+
regelIdx = Number(rm[1]) - 1;
|
|
100
|
+
}
|
|
101
|
+
if (regelIdx >= 0 && regels[regelIdx])
|
|
102
|
+
veld = `regel:${regels[regelIdx].key}:${regelDeel(hooi)}`;
|
|
103
|
+
else
|
|
104
|
+
veld = KOPVELDEN.find(([re]) => re.test(hooi))?.[1] ?? null;
|
|
105
|
+
out.push({ tekst, veld });
|
|
106
|
+
}
|
|
107
|
+
if (!out.length && reason)
|
|
108
|
+
out.push({ tekst: reason, veld: KOPVELDEN.find(([re]) => re.test(reason))?.[1] ?? null });
|
|
109
|
+
return out;
|
|
110
|
+
}
|
|
111
|
+
/** Velden die rood moeten bij "Ontbreekt nog" (zelfde teksten als klokOntbreekt). */
|
|
112
|
+
export function klokOntbreektVelden(kop, regels) {
|
|
113
|
+
const s = new Set();
|
|
114
|
+
for (const t of klokOntbreekt(kop, regels)) {
|
|
115
|
+
const rm = /^Regel (\d+): (.*)$/.exec(t);
|
|
116
|
+
if (rm) {
|
|
117
|
+
const r = regels[Number(rm[1]) - 1];
|
|
118
|
+
if (r)
|
|
119
|
+
s.add(`regel:${r.key}:${regelDeel(rm[2])}`);
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
const k = KOPVELDEN.find(([re]) => re.test(t));
|
|
123
|
+
if (k)
|
|
124
|
+
s.add(k[1]);
|
|
125
|
+
}
|
|
126
|
+
return s;
|
|
127
|
+
}
|