@flowselections/floriday-verkoop-module 1.0.133 → 1.0.135
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/OrderInvoiceCard.d.ts +4 -0
- package/dist-lib/components/verkoop/OrderInvoiceCard.d.ts.map +1 -0
- package/dist-lib/components/verkoop/OrderInvoiceCard.js +57 -0
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +3 -2
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.js +2 -1
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +18 -1
- package/dist-lib/lib/erp-invoice-rpc.check.d.ts +2 -0
- package/dist-lib/lib/erp-invoice-rpc.check.d.ts.map +1 -0
- package/dist-lib/lib/erp-invoice-rpc.check.js +47 -0
- package/dist-lib/lib/erp-invoice-view.check.d.ts +2 -0
- package/dist-lib/lib/erp-invoice-view.check.d.ts.map +1 -0
- package/dist-lib/lib/erp-invoice-view.check.js +32 -0
- package/dist-lib/lib/erp-invoice-view.d.ts +50 -0
- package/dist-lib/lib/erp-invoice-view.d.ts.map +1 -0
- package/dist-lib/lib/erp-invoice-view.js +73 -0
- package/dist-lib/lib/module-version.d.ts +1 -1
- package/dist-lib/lib/module-version.js +1 -1
- package/dist-lib/lib/product-plannable.functions.d.ts.map +1 -1
- package/dist-lib/lib/product-plannable.functions.js +15 -5
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-mapping.js +2 -0
- package/dist-lib/lib/stock-product-link.check.d.ts +2 -0
- package/dist-lib/lib/stock-product-link.check.d.ts.map +1 -0
- package/dist-lib/lib/stock-product-link.check.js +32 -0
- package/dist-lib/lib/stock-product-link.d.ts +45 -0
- package/dist-lib/lib/stock-product-link.d.ts.map +1 -0
- package/dist-lib/lib/stock-product-link.js +79 -0
- package/dist-lib/lib/stock-product-link.server.d.ts +3 -0
- package/dist-lib/lib/stock-product-link.server.d.ts.map +1 -0
- package/dist-lib/lib/stock-product-link.server.js +24 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OrderInvoiceCard.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/OrderInvoiceCard.tsx"],"names":[],"mappings":"AAYA,wBAAgB,gBAAgB,CAAC,EAAE,OAAO,EAAE,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,sCA6EhE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { useQuery } from "@tanstack/react-query";
|
|
4
|
+
import { FileText } from "lucide-react";
|
|
5
|
+
import { supabase } from "../../integrations/supabase/client.js";
|
|
6
|
+
import { canOpenPdf, invoiceDisplay, loadInvoicePdfPath, loadOrderInvoices, rpcErrorKind } from "../../lib/erp-invoice-view.js";
|
|
7
|
+
// Factuurblok: leest alleen via de RPC's van Facturatie. Geen Facturatie,
|
|
8
|
+
// geen recht of geen facturen → het blok blijft weg. Andere fout → korte melding.
|
|
9
|
+
// supabase.rpc altijd als methode aanroepen (via de helpers), nooit losmaken.
|
|
10
|
+
const money = new Intl.NumberFormat("nl-NL", { style: "currency", currency: "EUR" });
|
|
11
|
+
export function OrderInvoiceCard({ orderId }) {
|
|
12
|
+
const [pdfError, setPdfError] = useState(null);
|
|
13
|
+
const [busy, setBusy] = useState(null);
|
|
14
|
+
const q = useQuery({
|
|
15
|
+
queryKey: ["erp-invoices-for-order", orderId],
|
|
16
|
+
retry: false,
|
|
17
|
+
staleTime: 60000,
|
|
18
|
+
queryFn: () => loadOrderInvoices(supabase, orderId),
|
|
19
|
+
});
|
|
20
|
+
if (q.data?.error) {
|
|
21
|
+
return (_jsxs("div", { className: "rounded-lg border bg-card p-4 text-sm text-muted-foreground", children: [_jsx("span", { className: "font-semibold text-foreground", children: "Factuur" }), " \u2014 facturen konden niet worden geladen."] }));
|
|
22
|
+
}
|
|
23
|
+
const rows = q.data?.rows ?? [];
|
|
24
|
+
if (rows.length === 0)
|
|
25
|
+
return null;
|
|
26
|
+
async function openPdf(r) {
|
|
27
|
+
setPdfError(null);
|
|
28
|
+
setBusy(r.id);
|
|
29
|
+
const win = window.open("", "_blank");
|
|
30
|
+
try {
|
|
31
|
+
const { data, error } = await loadInvoicePdfPath(supabase, r.id);
|
|
32
|
+
const path = typeof data === "string" ? data : null;
|
|
33
|
+
if (error || !canOpenPdf(r.source, path)) {
|
|
34
|
+
win?.close();
|
|
35
|
+
setPdfError(error && rpcErrorKind(error) === "forbidden" ? "Geen recht om deze PDF te openen." : "Geen PDF beschikbaar.");
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const { data: signed, error: sErr } = await supabase.storage.from("invoices").createSignedUrl(path, 300);
|
|
39
|
+
if (sErr || !signed?.signedUrl) {
|
|
40
|
+
win?.close();
|
|
41
|
+
setPdfError("PDF kon niet worden geopend.");
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (win)
|
|
45
|
+
win.location.href = signed.signedUrl;
|
|
46
|
+
else
|
|
47
|
+
window.open(signed.signedUrl, "_blank", "noopener");
|
|
48
|
+
}
|
|
49
|
+
finally {
|
|
50
|
+
setBusy(null);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return (_jsxs("div", { className: "rounded-lg border bg-card p-4", children: [_jsxs("div", { className: "mb-3 flex items-center gap-2 text-sm font-semibold", children: [_jsx(FileText, { className: "h-4 w-4 text-muted-foreground" }), " Factuur"] }), _jsx("ul", { className: "space-y-2", children: rows.map((r) => {
|
|
54
|
+
const d = invoiceDisplay(r);
|
|
55
|
+
return (_jsxs("li", { className: "flex flex-wrap items-center gap-x-4 gap-y-1 text-sm", children: [_jsx("span", { className: "font-medium", children: d.title }), _jsx("span", { className: "font-mono", children: d.number }), d.statusLabel && _jsxs("span", { className: "text-muted-foreground", children: ["Status: ", d.statusLabel] }), d.paymentLabel && _jsxs("span", { className: "text-muted-foreground", children: ["Betaling: ", d.paymentLabel] }), d.showPdf && d.total != null && _jsx("span", { children: money.format(d.total) }), d.showPdf && (_jsx("button", { type: "button", className: "ml-auto rounded-md border px-2 py-1 text-xs hover:bg-muted disabled:opacity-50", disabled: busy === r.id, onClick: () => openPdf(r), children: "PDF openen" }))] }, r.id));
|
|
56
|
+
}) }), pdfError && _jsx("p", { className: "mt-2 text-xs text-muted-foreground", children: pdfError })] }));
|
|
57
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SalesOrderDetailView.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrderDetailView.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"SalesOrderDetailView.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrderDetailView.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AA8JnE,wBAAgB,oBAAoB,CAAC,KAAK,EAAE;IAC1C,KAAK,EAAE,aAAa,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,+BAkBA"}
|
|
@@ -10,6 +10,7 @@ import { OrderKarindelingCard } from "./OrderKarindelingCard.js";
|
|
|
10
10
|
import { OrderLinePackingCard } from "./OrderLinePackingCard.js";
|
|
11
11
|
import { OrderAfleverbrievenCard } from "./OrderAfleverbrievenCard.js";
|
|
12
12
|
import { OrderShipmentsCard } from "./OrderShipmentsCard.js";
|
|
13
|
+
import { OrderInvoiceCard } from "./OrderInvoiceCard.js";
|
|
13
14
|
import { OrderControlStatusCard } from "./OrderControlStatusCard.js";
|
|
14
15
|
import { OrderCarrierPicker } from "./OrderCarrierPicker.js";
|
|
15
16
|
import { OrderPickupMomentPicker } from "./OrderPickupMomentPicker.js";
|
|
@@ -167,7 +168,7 @@ function SalesOrderDetailViewInner({ floridayLoading, order, sellerFallback, hid
|
|
|
167
168
|
beladingParts.push(lcShort);
|
|
168
169
|
const belading = beladingParts.length > 0 ? beladingParts.join(" - ") : "—";
|
|
169
170
|
const fsEntry = order.floridayStatus?.entries?.[0] ?? null;
|
|
170
|
-
const klantReferentie = pickStr(o.customerOrderId) ?? pickStr(fsEntry?.customerOrderId) ?? "—";
|
|
171
|
+
const klantReferentie = pickStr(o.customerOrderId) ?? pickStr(fsEntry?.customerOrderId) ?? pickStr(order.customerReference) ?? "—";
|
|
171
172
|
const floridayRef = pickStr(o.salesChannelOrderId) ??
|
|
172
173
|
pickStr(fsEntry?.salesChannelOrderId) ??
|
|
173
174
|
pickStr(o.batchReference) ??
|
|
@@ -304,5 +305,5 @@ function SalesOrderDetailViewInner({ floridayLoading, order, sellerFallback, hid
|
|
|
304
305
|
.join(" "),
|
|
305
306
|
resolvedAddresses.pickup.country,
|
|
306
307
|
].filter((v) => !!v && v.trim().length > 0)
|
|
307
|
-
: [], extra: resolvedAddresses?.pickup?.gln ?? null }) }), _jsx(Row, { label: "Vervoerder", children: _jsx(OrderCarrierPicker, { orderId: String(order.id), locked: !!order.isReservation }) }), _jsx(Row, { label: "Ophaalmoment", children: _jsx(OrderPickupMomentPicker, { orderId: String(order.id) }) })] }), _jsxs("div", { children: [_jsx(SectionTitle, { children: "Klant" }), _jsxs(Row, { label: "Naam", children: [_jsx("span", { className: "font-medium", children: customerName }), customerLegalName && (_jsx("div", { className: "text-xs text-muted-foreground", children: customerLegalName }))] }), !fs && (order.floridayIds?.length ?? 0) > 0 && (_jsx(FloridayStageLine, { status: null, stage: order.stage, floridayFulfilled: order.floridayFulfilled, isFloriday: true })), _jsx(Row, { label: "GLN", children: customerGln }), _jsx(Row, { label: "Administratienummer", children: customerAdmin }), _jsx(Row, { label: "Telefoonnummer", children: customerPhone })] })] }), _jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "rounded-md border border-border p-4", children: [_jsx("div", { className: "mb-3 text-sm font-semibold", children: "Prijs per stuk" }), _jsxs("div", { className: "space-y-2 text-sm", children: [_jsxs("div", { className: "flex justify-between", children: [_jsx("span", { className: "text-muted-foreground", children: "Product" }), _jsxs("span", { children: [oldProductPrice !== null && (_jsx("span", { className: "mr-2 text-destructive line-through", children: eurFlex.format(oldProductPrice) })), eurFlex.format(productUnit)] })] }), _jsxs("div", { className: "flex justify-between", children: [_jsx("span", { className: "text-muted-foreground", children: "Transportkosten" }), _jsx("span", { children: eurFlex.format(transportPerPiece) })] }), _jsxs("div", { className: "flex justify-between", children: [_jsx("span", { className: "text-muted-foreground", children: "Inkoopprijs" }), _jsx("span", { children: eurFlex.format(purchaseUnit) })] }), _jsxs("div", { className: "mt-2 flex justify-between border-t border-border pt-2 font-semibold", children: [_jsx("span", { children: "Totaal" }), _jsxs("span", { children: [_jsx("span", { className: "mr-2 text-xs font-normal text-muted-foreground", children: totalBreakdown ? `(${totalBreakdown})` : null }), eurFlex.format(totalAmount)] })] }), (order.missingPrice || (linesWithoutPrice > 0 && !fs)) && (_jsxs("div", { className: "mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs text-destructive", children: ["Geen prijs: ", linesWithoutPrice || "een of meer", " regel(s) zonder prijs. Vul de prijs in voordat de order wordt bevestigd."] }))] })] }), _jsxs("div", { className: "rounded-md border border-border p-4", children: [_jsx("div", { className: "mb-3 text-sm font-semibold", children: "Status" }), _jsxs("div", { className: "space-y-3 text-sm", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-muted-foreground", children: "Bestelling" }), _jsx("span", { className: `rounded-full px-2 py-0.5 text-xs font-medium ${orderStageBadgeClass(order.stage ?? "incoming")}`, children: bestellingLabel })] }), order.customerReference && (_jsxs("div", { className: "text-xs text-muted-foreground", children: ["Referentie klant: ", _jsx("span", { className: "font-medium text-foreground", children: order.customerReference })] })), order.floridayMissingLineKeyNotice && (_jsx("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs text-destructive", children: order.floridayMissingLineKeyNotice })), order.floridayExternalFulfilledAt ? (_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-muted-foreground", children: "Afhandeling" }), _jsxs("span", { className: "text-xs text-foreground", children: ["Afgehandeld in Floriday (niet via het ERP) \u00B7 ", formatMoment(order.floridayExternalFulfilledAt)] })] })) : (order.floridayExternalFulfilledIds?.length ?? 0) > 0 ? (_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-muted-foreground", children: "Afhandeling" }), _jsxs("span", { className: "text-xs text-foreground", children: [order.floridayExternalFulfilledIds.length, " bestelling(en) afgehandeld in Floriday; de rest loopt door"] })] })) : null, order.floridayFulfilled && (_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-muted-foreground", children: "Floriday" }), _jsx("span", { className: "rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground", title: "Administratief doorgegeven aan Floriday. Dit bepaalt de orderstatus niet.", children: "Doorgegeven aan Floriday" })] })), hasCorrection && (_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-muted-foreground", children: "Correctie" }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(CheckCircle2, { className: "h-4 w-4 text-emerald-600" }), "Correctie is verwerkt"] })] }))] })] })] })] }), _jsx(OrderLinePackingCard, { orderId: String(order.id) }), _jsx(OrderShipmentsCard, { order: order }), !hideKarindeling && _jsx(OrderKarindelingCard, { order: order }), o?.salesOrderId ? (_jsxs(_Fragment, { children: [_jsx(OrderControlStatusCard, { floridayId: String(o.salesOrderId), isControlled: order.status.isControlled, controlledAt: order.status.controlledAt }), _jsx(OrderAfleverbrievenCard, { salesOrderId: String(o.salesOrderId), orderNumber: order.orderNumber ?? undefined })] })) : null] }));
|
|
308
|
+
: [], extra: resolvedAddresses?.pickup?.gln ?? null }) }), _jsx(Row, { label: "Vervoerder", children: _jsx(OrderCarrierPicker, { orderId: String(order.id), locked: !!order.isReservation }) }), _jsx(Row, { label: "Ophaalmoment", children: _jsx(OrderPickupMomentPicker, { orderId: String(order.id) }) })] }), _jsxs("div", { children: [_jsx(SectionTitle, { children: "Klant" }), _jsxs(Row, { label: "Naam", children: [_jsx("span", { className: "font-medium", children: customerName }), customerLegalName && (_jsx("div", { className: "text-xs text-muted-foreground", children: customerLegalName }))] }), !fs && (order.floridayIds?.length ?? 0) > 0 && (_jsx(FloridayStageLine, { status: null, stage: order.stage, floridayFulfilled: order.floridayFulfilled, isFloriday: true })), _jsx(Row, { label: "GLN", children: customerGln }), _jsx(Row, { label: "Administratienummer", children: customerAdmin }), _jsx(Row, { label: "Telefoonnummer", children: customerPhone })] })] }), _jsxs("div", { className: "space-y-6", children: [_jsxs("div", { className: "rounded-md border border-border p-4", children: [_jsx("div", { className: "mb-3 text-sm font-semibold", children: "Prijs per stuk" }), _jsxs("div", { className: "space-y-2 text-sm", children: [_jsxs("div", { className: "flex justify-between", children: [_jsx("span", { className: "text-muted-foreground", children: "Product" }), _jsxs("span", { children: [oldProductPrice !== null && (_jsx("span", { className: "mr-2 text-destructive line-through", children: eurFlex.format(oldProductPrice) })), eurFlex.format(productUnit)] })] }), _jsxs("div", { className: "flex justify-between", children: [_jsx("span", { className: "text-muted-foreground", children: "Transportkosten" }), _jsx("span", { children: eurFlex.format(transportPerPiece) })] }), _jsxs("div", { className: "flex justify-between", children: [_jsx("span", { className: "text-muted-foreground", children: "Inkoopprijs" }), _jsx("span", { children: eurFlex.format(purchaseUnit) })] }), _jsxs("div", { className: "mt-2 flex justify-between border-t border-border pt-2 font-semibold", children: [_jsx("span", { children: "Totaal" }), _jsxs("span", { children: [_jsx("span", { className: "mr-2 text-xs font-normal text-muted-foreground", children: totalBreakdown ? `(${totalBreakdown})` : null }), eurFlex.format(totalAmount)] })] }), (order.missingPrice || (linesWithoutPrice > 0 && !fs)) && (_jsxs("div", { className: "mt-2 rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs text-destructive", children: ["Geen prijs: ", linesWithoutPrice || "een of meer", " regel(s) zonder prijs. Vul de prijs in voordat de order wordt bevestigd."] }))] })] }), _jsxs("div", { className: "rounded-md border border-border p-4", children: [_jsx("div", { className: "mb-3 text-sm font-semibold", children: "Status" }), _jsxs("div", { className: "space-y-3 text-sm", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-muted-foreground", children: "Bestelling" }), _jsx("span", { className: `rounded-full px-2 py-0.5 text-xs font-medium ${orderStageBadgeClass(order.stage ?? "incoming")}`, children: bestellingLabel })] }), order.customerReference && (_jsxs("div", { className: "text-xs text-muted-foreground", children: ["Referentie klant: ", _jsx("span", { className: "font-medium text-foreground", children: order.customerReference })] })), order.floridayMissingLineKeyNotice && (_jsx("div", { className: "rounded-md border border-destructive/40 bg-destructive/10 px-2 py-1 text-xs text-destructive", children: order.floridayMissingLineKeyNotice })), order.floridayExternalFulfilledAt ? (_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-muted-foreground", children: "Afhandeling" }), _jsxs("span", { className: "text-xs text-foreground", children: ["Afgehandeld in Floriday (niet via het ERP) \u00B7 ", formatMoment(order.floridayExternalFulfilledAt)] })] })) : (order.floridayExternalFulfilledIds?.length ?? 0) > 0 ? (_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-muted-foreground", children: "Afhandeling" }), _jsxs("span", { className: "text-xs text-foreground", children: [order.floridayExternalFulfilledIds.length, " bestelling(en) afgehandeld in Floriday; de rest loopt door"] })] })) : null, order.floridayFulfilled && (_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-muted-foreground", children: "Floriday" }), _jsx("span", { className: "rounded-full bg-muted px-2 py-0.5 text-xs font-medium text-muted-foreground", title: "Administratief doorgegeven aan Floriday. Dit bepaalt de orderstatus niet.", children: "Doorgegeven aan Floriday" })] })), hasCorrection && (_jsxs("div", { className: "flex items-center justify-between", children: [_jsx("div", { className: "text-muted-foreground", children: "Correctie" }), _jsxs("div", { className: "flex items-center gap-2", children: [_jsx(CheckCircle2, { className: "h-4 w-4 text-emerald-600" }), "Correctie is verwerkt"] })] }))] })] })] })] }), _jsx(OrderLinePackingCard, { orderId: String(order.id) }), _jsx(OrderShipmentsCard, { order: order }), _jsx(OrderInvoiceCard, { orderId: String(order.id) }), !hideKarindeling && _jsx(OrderKarindelingCard, { order: order }), o?.salesOrderId ? (_jsxs(_Fragment, { children: [_jsx(OrderControlStatusCard, { floridayId: String(o.salesOrderId), isControlled: order.status.isControlled, controlledAt: order.status.controlledAt }), _jsx(OrderAfleverbrievenCard, { salesOrderId: String(o.salesOrderId), orderNumber: order.orderNumber ?? undefined })] })) : null] }));
|
|
308
309
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SalesOrdersTable.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/SalesOrdersTable.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AAyBjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAkHnE,6EAA6E;AAC7E,wBAAgB,eAAe,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAG1D;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,OAAO,EACP,aAAa,EACb,aAAa,EACb,WAAW,EACX,cAAc,EACd,YAAY,EACZ,WAAW,EACX,iBAAiB,GAClB,EAAE;IACD,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IA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AAK,IAAI,CAAC;CAC7C,qBAuWA"}
|
|
@@ -129,7 +129,8 @@ export function SalesOrdersTable({ orders, loading, onSelectOrder, onDeleteOrder
|
|
|
129
129
|
.map((u) => `${u.name} (trade-item ${u.tradeItemId ?? "onbekend"})`)
|
|
130
130
|
.join("\n"), children: [_jsx(AlertTriangle, { className: "mt-0.5 h-3 w-3 shrink-0" }), _jsxs("span", { children: ["Floriday-artikel niet gekoppeld aan product:", " ", row.unlinkedProducts
|
|
131
131
|
.map((u) => `${u.name} (trade-item ${u.tradeItemId ?? "onbekend"})`)
|
|
132
|
-
.join(", ")] })] }))] }), _jsxs(TableCell, { children: [_jsx("div", { className: "font-medium text-foreground", children: row.karUnknown ? (_jsx("span", { className: "text-muted-foreground", children: "Karren onbekend" })) : row.engineCounts && row.karCount > 0 ? (_jsxs(_Fragment, { children: [formatLoadUnits(row.karCount, row.cartTypeName), row.karShared && isBuffer && (_jsx("span", { className: "ml-1 text-xs font-normal text-muted-foreground", children: "(gedeeld met gecombineerde order)" }))] })) : (_jsx("span", { className: "text-muted-foreground", children: "\u2014" })) }), _jsx(PlanCoverageBadge, { coverage: row.planCoverage }), _jsx(FloridayStageLine, { status: statusOf(row).status, loading: statusOf(row).loading, stage: row.stage, floridayFulfilled: isBuffer ? !row.notReportedToFloriday : row.floridayFulfilled, isFloriday: !!row.notReportedToFloriday || (row.floridayIds?.length ?? 0) > 0, notReportedCount: row.notReportedCount, bufferSize: bufferSize })] }), _jsxs(TableCell, { children: [_jsx("div", { className: "font-medium text-foreground", children: formatLoadUnits(row.fustCount, row.mixedPacking ? null : row.crateTypeName) }), row.mixedPacking && (row.articleCount ?? 0) > 1 && (_jsxs("div", { className: "text-xs text-muted-foreground", children: ["Gemengd (", row.articleCount, " artikelen)"] }))] }), _jsx(TableCell, { className: "text-sm text-foreground", children: row.carrierState === "geen" ? (_jsx("a", { href: "/afhandeling/vervoerders", onClick: (e) => e.stopPropagation(), className: "text-xs text-destructive underline", title: row.carrierReason ?? undefined, children: "Geen vervoerder \u2013 stel in bij Afhandeling \u2192 Vervoerders" })) : (_jsxs("div", { title: row.carrierReason ?? undefined, children: [_jsx("div", { children: row.carrierName || _jsx("span", { className: "text-muted-foreground", children: "onbekend" }) }), (row.carrierSource || row.carrierBadge) && (_jsxs("div", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [row.carrierSource &&
|
|
132
|
+
.join(", ")] })] }))] }), _jsxs(TableCell, { children: [_jsx("div", { className: "font-medium text-foreground", children: row.karUnknown ? (_jsx("span", { className: "text-muted-foreground", children: "Karren onbekend" })) : row.engineCounts && row.karCount > 0 ? (_jsxs(_Fragment, { children: [formatLoadUnits(row.karCount, row.cartTypeName), row.karShared && isBuffer && (_jsx("span", { className: "ml-1 text-xs font-normal text-muted-foreground", children: "(gedeeld met gecombineerde order)" }))] })) : (_jsx("span", { className: "text-muted-foreground", children: "\u2014" })) }), _jsx(PlanCoverageBadge, { coverage: row.planCoverage }), _jsx(FloridayStageLine, { status: statusOf(row).status, loading: statusOf(row).loading, stage: row.stage, floridayFulfilled: isBuffer ? !row.notReportedToFloriday : row.floridayFulfilled, isFloriday: !!row.notReportedToFloriday || (row.floridayIds?.length ?? 0) > 0, notReportedCount: row.notReportedCount, bufferSize: bufferSize })] }), _jsxs(TableCell, { children: [_jsx("div", { className: "font-medium text-foreground", children: formatLoadUnits(row.fustCount, row.mixedPacking ? null : row.crateTypeName) }), row.mixedPacking && (row.articleCount ?? 0) > 1 && (_jsxs("div", { className: "text-xs text-muted-foreground", children: ["Gemengd (", row.articleCount, " artikelen)"] }))] }), _jsx(TableCell, { className: "text-sm text-foreground", children: row.carrierState === "geen" ? (_jsx("a", { href: "/afhandeling/vervoerders", onClick: (e) => e.stopPropagation(), className: "text-xs text-destructive underline", title: row.carrierReason ?? undefined, children: "Geen vervoerder \u2013 stel in bij Afhandeling \u2192 Vervoerders" })) : (_jsxs("div", { title: row.carrierReason ?? undefined, children: [_jsx("div", { children: row.carrierName || _jsx("span", { className: "text-muted-foreground", children: "onbekend" }) }), (row.carrierSource || row.carrierBadge) && (_jsxs("div", { className: "flex items-center gap-1 text-xs text-muted-foreground", children: [row.carrierSource &&
|
|
133
|
+
row.carrierSource.trim().toLowerCase() !== (row.carrierBadge ?? "").trim().toLowerCase() && (_jsx("span", { children: row.carrierSource })), row.carrierBadge && (_jsx("span", { className: "rounded border border-border bg-muted px-1 text-[10px] uppercase tracking-wide", children: row.carrierBadge }))] }))] })) }), _jsx(TableCell, { children: _jsx(StatusTag, { order: row }) }), showRevenue && (_jsxs(TableCell, { className: "font-medium text-foreground", children: ["\u20AC ", Math.round(row.revenue ?? 0).toLocaleString("nl-NL")] })), _jsxs(TableCell, { children: [_jsx("div", { className: "text-sm text-foreground", children: ordered.date }), _jsx("div", { className: "text-xs text-muted-foreground", children: isBuffer
|
|
133
134
|
? `${bufferSize} orders`
|
|
134
135
|
: row.orderNumber || ordered.time })] }), _jsx(TableCell, { onClick: (e) => e.stopPropagation(), children: _jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { className: "inline-flex h-8 w-8 items-center justify-center rounded-md text-muted-foreground hover:bg-accent hover:text-foreground", children: _jsx(MoreVertical, { className: "h-4 w-4" }) }), _jsxs(DropdownMenuContent, { align: "end", children: [_jsx(DropdownMenuItem, { disabled: isBuffer || !row.isLocal, onClick: () => !isBuffer && row.isLocal && onEditOrder?.(row), title: isBuffer
|
|
135
136
|
? "Een gecombineerde order kun je niet in één keer bewerken."
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,2BAA2B;;;;;;GA+CpC,CAAC;AAIL,eAAO,MAAM,2BAA2B;;;;0CAElB,OAAO;;;;GAoDzB,CAAC;AAWL,eAAO,MAAM,0BAA0B;;;;;;YA+D7B,MAAM;iBACD,MAAM;sBACD,MAAM,GAAG,IAAI;cACrB,MAAM;oBACA,M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rder = createServerFn({ method: "POST" })
|
|
|
811
811
|
// een niet-misleidend `article_number` en een duidelijke `source` in
|
|
812
812
|
// `custom_fields` (zodat de voorraadmodule ze veilig kan negeren of
|
|
813
813
|
// opruimen).
|
|
814
|
+
// Lege belading aanvullen uit de primaire verpakking van het gekoppelde
|
|
815
|
+
// voorraadartikel (eerst products.id, anders products.floriday_trade_item_id).
|
|
816
|
+
{
|
|
817
|
+
const { loadStockLinks } = await import("./stock-product-link.server.js");
|
|
818
|
+
const { fillLineFromStock } = await import("./stock-product-link.js");
|
|
819
|
+
const links = await loadStockLinks(supabaseAdmin, data.lines.map((l) => l.product_id));
|
|
820
|
+
data.lines = data.lines.map((l) => fillLineFromStock(l, links.get(l.product_id)));
|
|
821
|
+
}
|
|
814
822
|
const productIds = Array.from(new Set(data.lines.map((l) => l.product_id)));
|
|
815
823
|
const [existingProductsRes, draftsRes, floridayRes, groupsRes] = await Promise.all([
|
|
816
824
|
supabaseAdmin.from("products").select("id").in("id", productIds),
|
|
@@ -1648,6 +1656,11 @@ export const getEffectivePrices = createServerFn({ method: "POST" })
|
|
|
1648
1656
|
.parse(input))
|
|
1649
1657
|
.handler(async ({ data, context }) => {
|
|
1650
1658
|
const out = {};
|
|
1659
|
+
// Terugval op de verkoopprijs van het voorraadartikel: dit formulier maakt
|
|
1660
|
+
// alleen handmatige orders (HO/AO/MO); Floriday-orders komen hier nooit.
|
|
1661
|
+
const { loadStockLinks } = await import("./stock-product-link.server.js");
|
|
1662
|
+
const { fallbackPrice } = await import("./stock-product-link.js");
|
|
1663
|
+
const links = await loadStockLinks(context.supabase, data.lines.map((l) => l.productId));
|
|
1651
1664
|
for (const l of data.lines) {
|
|
1652
1665
|
const { data: rows, error } = await context.supabase.rpc("local_effective_price", {
|
|
1653
1666
|
_customer_id: data.customerId,
|
|
@@ -1657,7 +1670,11 @@ export const getEffectivePrices = createServerFn({ method: "POST" })
|
|
|
1657
1670
|
});
|
|
1658
1671
|
const r = Array.isArray(rows) ? rows[0] : rows;
|
|
1659
1672
|
const price = Number(r?.net_price);
|
|
1660
|
-
|
|
1673
|
+
if (!error && Number.isFinite(price) && price > 0) {
|
|
1674
|
+
out[l.productId] = { price, source: r?.source ?? null };
|
|
1675
|
+
continue;
|
|
1676
|
+
}
|
|
1677
|
+
out[l.productId] = fallbackPrice("manual", null, links.get(l.productId));
|
|
1661
1678
|
}
|
|
1662
1679
|
return out;
|
|
1663
1680
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erp-invoice-rpc.check.d.ts","sourceRoot":"","sources":["../../src/lib/erp-invoice-rpc.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Draai: bun src/lib/erp-invoice-rpc.check.ts
|
|
2
|
+
// Roept de ECHTE Supabase-client aan (fetch vervangen door een stub), geen losse mock van rpc.
|
|
3
|
+
import { createClient } from "@supabase/supabase-js";
|
|
4
|
+
import { loadOrderInvoices, loadInvoicePdfPath } from "./erp-invoice-view.js";
|
|
5
|
+
let failed = 0;
|
|
6
|
+
function check(name, ok, info = "") {
|
|
7
|
+
if (!ok)
|
|
8
|
+
failed++;
|
|
9
|
+
console.log(`${ok ? "OK " : "FOUT"} ${name}${info ? `: ${info}` : ""}`);
|
|
10
|
+
}
|
|
11
|
+
const calls = [];
|
|
12
|
+
let reply = { status: 200, body: [] };
|
|
13
|
+
const stubFetch = (async (input) => {
|
|
14
|
+
calls.push(String(typeof input === "string" ? input : input.url));
|
|
15
|
+
return new Response(JSON.stringify(reply.body), { status: reply.status, headers: { "content-type": "application/json" } });
|
|
16
|
+
});
|
|
17
|
+
const client = createClient("http://stub.invalid", "stub-key", { global: { fetch: stubFetch }, auth: { persistSession: false } });
|
|
18
|
+
reply = { status: 200, body: [{ id: "12", invoice_number: "FS-2026-00001" }] };
|
|
19
|
+
const a = await loadOrderInvoices(client, "00000000-0000-0000-0000-000000000001");
|
|
20
|
+
check("echte client bereikt /rpc/erp_invoices_for_order", calls.some((u) => u.includes("/rest/v1/rpc/erp_invoices_for_order")), calls.join(","));
|
|
21
|
+
check("rij terug", a.rows.length === 1 && a.error === null, JSON.stringify(a));
|
|
22
|
+
reply = { status: 200, body: "invoices/x.pdf" };
|
|
23
|
+
const p = await loadInvoicePdfPath(client, "12");
|
|
24
|
+
check("pdf-pad via echte client", calls.some((u) => u.includes("/rpc/erp_invoice_pdf_path")) && p.data === "invoices/x.pdf", JSON.stringify(p));
|
|
25
|
+
reply = { status: 404, body: { code: "PGRST202", message: "Could not find the function" } };
|
|
26
|
+
const m = await loadOrderInvoices(client, "x");
|
|
27
|
+
check("functie bestaat niet → verbergen", m.hidden && !m.error);
|
|
28
|
+
reply = { status: 403, body: { code: "42501", message: "permission denied" } };
|
|
29
|
+
const f = await loadOrderInvoices(client, "x");
|
|
30
|
+
check("42501 → verbergen", f.hidden && !f.error);
|
|
31
|
+
reply = { status: 500, body: { code: "XX000", message: "kapot" } };
|
|
32
|
+
const o = await loadOrderInvoices(client, "x");
|
|
33
|
+
check("andere fout → melding", !o.hidden && !!o.error, JSON.stringify(o));
|
|
34
|
+
// Bewijs dat de test kan falen: losgemaakte methode verliest `this`.
|
|
35
|
+
const detached = client.rpc;
|
|
36
|
+
let threw = false;
|
|
37
|
+
try {
|
|
38
|
+
await detached("erp_invoices_for_order", {});
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
threw = true;
|
|
42
|
+
}
|
|
43
|
+
check("losgemaakte rpc faalt (test kan falen)", threw);
|
|
44
|
+
if (failed) {
|
|
45
|
+
console.error(`${failed} fout(en)`);
|
|
46
|
+
process.exit(1);
|
|
47
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erp-invoice-view.check.d.ts","sourceRoot":"","sources":["../../src/lib/erp-invoice-view.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Draai: bun src/lib/erp-invoice-view.check.ts
|
|
2
|
+
import { canOpenPdf, invoiceDisplay, paymentLabel, rpcErrorKind } from "./erp-invoice-view.js";
|
|
3
|
+
let failed = 0;
|
|
4
|
+
function check(name, got, want) {
|
|
5
|
+
const g = JSON.stringify(got), w = JSON.stringify(want);
|
|
6
|
+
const ok = g === w;
|
|
7
|
+
if (!ok)
|
|
8
|
+
failed++;
|
|
9
|
+
console.log(`${ok ? "OK " : "FOUT"} ${name}: ${g}${ok ? "" : ` (verwacht ${w})`}`);
|
|
10
|
+
}
|
|
11
|
+
const erp = { id: "1", invoice_number: "FS-2026-00001", kind: "factuur", source: "erp", status: "definitief", twinfield_status: null, payment_status: "onbekend", total: "121.00", invoice_date: null };
|
|
12
|
+
const tw = { ...erp, source: "twinfield_klassiek", total: "50", payment_status: "open" };
|
|
13
|
+
check("onbekend → Onbekend", paymentLabel("onbekend"), "Onbekend");
|
|
14
|
+
check("ERP toont betaalstatus Onbekend", invoiceDisplay(erp).paymentLabel, "Onbekend");
|
|
15
|
+
check("ERP totaal", invoiceDisplay(erp).total, 121);
|
|
16
|
+
check("credit", invoiceDisplay({ ...erp, kind: "credit" }).title, "Creditfactuur");
|
|
17
|
+
check("Twinfield: titel", invoiceDisplay(tw).title, "Factuur in Twinfield");
|
|
18
|
+
check("Twinfield: geen bedrag", invoiceDisplay(tw).total, null);
|
|
19
|
+
check("Twinfield: geen betaalstatus", invoiceDisplay(tw).paymentLabel, null);
|
|
20
|
+
check("Twinfield: geen PDF", canOpenPdf("twinfield_klassiek", "a/b.pdf"), false);
|
|
21
|
+
check("Twinfield concept", invoiceDisplay({ ...tw, twinfield_status: "concept" }).title, "Concept in Twinfield");
|
|
22
|
+
check("Twinfield vervallen", invoiceDisplay({ ...tw, status: "vervallen" }).title, "Vervallen");
|
|
23
|
+
check("PDF-pad null", canOpenPdf("erp", null), false);
|
|
24
|
+
check("PDF-pad aanwezig", canOpenPdf("erp", "x.pdf"), true);
|
|
25
|
+
check("PGRST202 → missing", rpcErrorKind({ code: "PGRST202" }), "missing");
|
|
26
|
+
check("404 → missing", rpcErrorKind({ status: 404 }), "missing");
|
|
27
|
+
check("42501 → forbidden", rpcErrorKind({ code: "42501" }), "forbidden");
|
|
28
|
+
if (failed) {
|
|
29
|
+
console.error(`${failed} controle(s) mislukt`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
console.log("Alle controles geslaagd");
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export type ErpInvoiceRow = {
|
|
2
|
+
id: string;
|
|
3
|
+
invoice_number: string | null;
|
|
4
|
+
kind: string | null;
|
|
5
|
+
source: string | null;
|
|
6
|
+
status: string | null;
|
|
7
|
+
twinfield_status: string | null;
|
|
8
|
+
payment_status: string | null;
|
|
9
|
+
total: number | string | null;
|
|
10
|
+
invoice_date: string | null;
|
|
11
|
+
};
|
|
12
|
+
export type InvoiceDisplay = {
|
|
13
|
+
title: string;
|
|
14
|
+
number: string;
|
|
15
|
+
statusLabel: string | null;
|
|
16
|
+
paymentLabel: string | null;
|
|
17
|
+
total: number | null;
|
|
18
|
+
showPdf: boolean;
|
|
19
|
+
};
|
|
20
|
+
/** Fout van Facturatie-RPC: altijd verbergen (geen Facturatie, geen recht, of anders). */
|
|
21
|
+
export declare function rpcErrorKind(err: {
|
|
22
|
+
code?: string;
|
|
23
|
+
message?: string;
|
|
24
|
+
status?: number;
|
|
25
|
+
} | null | undefined): "missing" | "forbidden" | "other";
|
|
26
|
+
export declare function paymentLabel(s: string | null | undefined): string;
|
|
27
|
+
export declare function invoiceDisplay(r: ErpInvoiceRow): InvoiceDisplay;
|
|
28
|
+
export declare function canOpenPdf(source: string | null | undefined, path: string | null | undefined): boolean;
|
|
29
|
+
type RpcResult = {
|
|
30
|
+
data: unknown;
|
|
31
|
+
error: {
|
|
32
|
+
code?: string;
|
|
33
|
+
message?: string;
|
|
34
|
+
status?: number;
|
|
35
|
+
} | null;
|
|
36
|
+
};
|
|
37
|
+
/** Minimaal wat we van de Supabase-client nodig hebben; altijd als methode aanroepen (client.rpc(...)), nooit losmaken. */
|
|
38
|
+
export type RpcClient = {
|
|
39
|
+
rpc: (fn: any, args?: any) => PromiseLike<RpcResult> | any;
|
|
40
|
+
};
|
|
41
|
+
export type InvoiceLoad = {
|
|
42
|
+
rows: ErpInvoiceRow[];
|
|
43
|
+
hidden: boolean;
|
|
44
|
+
error: string | null;
|
|
45
|
+
};
|
|
46
|
+
/** Leest facturen van een order. missing/forbidden → verbergen; andere fout → melding. */
|
|
47
|
+
export declare function loadOrderInvoices(client: RpcClient, orderId: string): Promise<InvoiceLoad>;
|
|
48
|
+
export declare function loadInvoicePdfPath(client: RpcClient, invoiceId: string): Promise<RpcResult>;
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=erp-invoice-view.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"erp-invoice-view.d.ts","sourceRoot":"","sources":["../../src/lib/erp-invoice-view.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,aAAa,GAAG;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IAC9B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,KAAK,EAAE,MAAM,GAAG,IAAI,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AahG;AAED,wBAAsB,kBAAkB,CAAC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC,CAEjG"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Weergave van facturen uit Facturatie (alleen lezen, client-safe).
|
|
2
|
+
// Contract: RPC erp_invoices_for_order / erp_invoice_pdf_path (Facturatie 1.0.63).
|
|
3
|
+
/** Fout van Facturatie-RPC: altijd verbergen (geen Facturatie, geen recht, of anders). */
|
|
4
|
+
export function rpcErrorKind(err) {
|
|
5
|
+
if (!err)
|
|
6
|
+
return "other";
|
|
7
|
+
const msg = String(err.message ?? "").toLowerCase();
|
|
8
|
+
if (err.code === "PGRST202" || err.code === "42883" || err.status === 404 || msg.includes("does not exist") || msg.includes("could not find the function"))
|
|
9
|
+
return "missing";
|
|
10
|
+
if (err.code === "42501" || err.status === 403)
|
|
11
|
+
return "forbidden";
|
|
12
|
+
return "other";
|
|
13
|
+
}
|
|
14
|
+
const PAYMENT = {
|
|
15
|
+
onbekend: "Onbekend",
|
|
16
|
+
open: "Open",
|
|
17
|
+
deels_betaald: "Deels betaald",
|
|
18
|
+
betaald: "Betaald",
|
|
19
|
+
vervallen: "Vervallen",
|
|
20
|
+
};
|
|
21
|
+
export function paymentLabel(s) {
|
|
22
|
+
const k = String(s ?? "").trim().toLowerCase();
|
|
23
|
+
if (!k)
|
|
24
|
+
return "Onbekend";
|
|
25
|
+
return PAYMENT[k] ?? k.charAt(0).toUpperCase() + k.slice(1).replace(/_/g, " ");
|
|
26
|
+
}
|
|
27
|
+
function cap(s) {
|
|
28
|
+
return s.charAt(0).toUpperCase() + s.slice(1).replace(/_/g, " ");
|
|
29
|
+
}
|
|
30
|
+
export function invoiceDisplay(r) {
|
|
31
|
+
const number = r.invoice_number ?? "—";
|
|
32
|
+
const isCredit = r.kind === "credit";
|
|
33
|
+
if (r.source === "twinfield_klassiek") {
|
|
34
|
+
let title = isCredit ? "Creditfactuur in Twinfield" : "Factuur in Twinfield";
|
|
35
|
+
if (r.status === "vervallen")
|
|
36
|
+
title = "Vervallen";
|
|
37
|
+
else if (r.twinfield_status === "concept")
|
|
38
|
+
title = "Concept in Twinfield";
|
|
39
|
+
return { title, number, statusLabel: null, paymentLabel: null, total: null, showPdf: false };
|
|
40
|
+
}
|
|
41
|
+
const t = r.total == null || r.total === "" ? null : Number(r.total);
|
|
42
|
+
return {
|
|
43
|
+
title: isCredit ? "Creditfactuur" : "Factuur",
|
|
44
|
+
number,
|
|
45
|
+
statusLabel: r.status ? cap(r.status) : null,
|
|
46
|
+
paymentLabel: paymentLabel(r.payment_status),
|
|
47
|
+
total: t != null && Number.isFinite(t) ? t : null,
|
|
48
|
+
showPdf: true,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
export function canOpenPdf(source, path) {
|
|
52
|
+
return source !== "twinfield_klassiek" && !!path && String(path).trim() !== "";
|
|
53
|
+
}
|
|
54
|
+
/** Leest facturen van een order. missing/forbidden → verbergen; andere fout → melding. */
|
|
55
|
+
export async function loadOrderInvoices(client, orderId) {
|
|
56
|
+
let res;
|
|
57
|
+
try {
|
|
58
|
+
res = (await client.rpc("erp_invoices_for_order", { p_order_id: orderId }));
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
return { rows: [], hidden: false, error: e instanceof Error ? e.message : String(e) };
|
|
62
|
+
}
|
|
63
|
+
if (res.error) {
|
|
64
|
+
const k = rpcErrorKind(res.error);
|
|
65
|
+
if (k === "missing" || k === "forbidden")
|
|
66
|
+
return { rows: [], hidden: true, error: null };
|
|
67
|
+
return { rows: [], hidden: false, error: res.error.message ?? res.error.code ?? "onbekende fout" };
|
|
68
|
+
}
|
|
69
|
+
return { rows: Array.isArray(res.data) ? res.data : [], hidden: false, error: null };
|
|
70
|
+
}
|
|
71
|
+
export async function loadInvoicePdfPath(client, invoiceId) {
|
|
72
|
+
return (await client.rpc("erp_invoice_pdf_path", { p_invoice_id: invoiceId }));
|
|
73
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const MODULE_VERSION = "1.0.
|
|
1
|
+
export declare const MODULE_VERSION = "1.0.135";
|
|
2
2
|
//# sourceMappingURL=module-version.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"product-plannable.functions.d.ts","sourceRoot":"","sources":["../../src/lib/product-plannable.functions.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB;;;;8CAET,OAAO;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"product-plannable.functions.d.ts","sourceRoot":"","sources":["../../src/lib/product-plannable.functions.ts"],"names":[],"mappings":"AAYA,eAAO,MAAM,sBAAsB;;;;8CAET,OAAO;;;;;;;;;;;;;;;;;;;GA2F7B,CAAC"}
|
|
@@ -40,7 +40,17 @@ export const getProductPlannability = createServerFn({ method: "POST" })
|
|
|
40
40
|
if (!data.productIds.length)
|
|
41
41
|
return { impossible, missing, impossibleByLine, missingByLine, available: true, oordeelAvailable: true, perLine: false };
|
|
42
42
|
const sb = context.supabase;
|
|
43
|
-
|
|
43
|
+
// Engine kent het voorraadartikel; vertaal trade-item-id → products.id
|
|
44
|
+
// (zelfde koppeling als Engine 1.0.215) en zet de uitkomst terug.
|
|
45
|
+
const { loadStockLinks } = await import("./stock-product-link.server.js");
|
|
46
|
+
const links = await loadStockLinks(sb, data.productIds);
|
|
47
|
+
const toStock = (id) => links.get(id)?.stockProductId ?? id;
|
|
48
|
+
const back = new Map();
|
|
49
|
+
for (const id of data.productIds)
|
|
50
|
+
back.set(toStock(id), id);
|
|
51
|
+
const fromStock = (id) => back.get(id) ?? id;
|
|
52
|
+
data = { ...data, productIds: Array.from(new Set(data.productIds.map(toStock))) };
|
|
53
|
+
const regels = (data.regels ?? []).map((r) => ({ ...r, productId: toStock(r.productId) }));
|
|
44
54
|
const [oordeel, maten, perRegel] = await Promise.all([
|
|
45
55
|
sb.rpc("logistics_product_oordeel_many", { p_product_ids: data.productIds }),
|
|
46
56
|
sb.rpc("logistics_product_maten", { p_product_ids: data.productIds }),
|
|
@@ -75,21 +85,21 @@ export const getProductPlannability = createServerFn({ method: "POST" })
|
|
|
75
85
|
if (!oordeel.error) {
|
|
76
86
|
for (const r of (oordeel.data ?? [])) {
|
|
77
87
|
if (r?.product_id && String(r.oordeel ?? "").toLowerCase() === "onmogelijk")
|
|
78
|
-
impossible[String(r.product_id)] = typeof r.tekst === "string" && r.tekst.trim() ? r.tekst.trim() : "De Engine noemt dit product onmogelijk.";
|
|
88
|
+
impossible[fromStock(String(r.product_id))] = typeof r.tekst === "string" && r.tekst.trim() ? r.tekst.trim() : "De Engine noemt dit product onmogelijk.";
|
|
79
89
|
}
|
|
80
90
|
}
|
|
81
91
|
// Terugval (oudere Engine): het productoordeel gaat over de standaardbelading
|
|
82
92
|
// van het artikel en geldt daarom alleen voor regels die die standaard gebruiken.
|
|
83
93
|
if (!perLine) {
|
|
84
94
|
for (const r of regels) {
|
|
85
|
-
if (r.isDefault && impossible[r.productId])
|
|
86
|
-
impossibleByLine[r.key] = impossible[r.productId];
|
|
95
|
+
if (r.isDefault && impossible[fromStock(r.productId)])
|
|
96
|
+
impossibleByLine[r.key] = impossible[fromStock(r.productId)];
|
|
87
97
|
}
|
|
88
98
|
}
|
|
89
99
|
if (!maten.error) {
|
|
90
100
|
for (const r of (maten.data ?? [])) {
|
|
91
101
|
if (r?.product_id && typeof r.missing_reason === "string" && r.missing_reason.trim())
|
|
92
|
-
missing[String(r.product_id)] = r.missing_reason.trim();
|
|
102
|
+
missing[fromStock(String(r.product_id))] = r.missing_reason.trim();
|
|
93
103
|
}
|
|
94
104
|
}
|
|
95
105
|
return { impossible, missing, impossibleByLine, missingByLine, available: !maten.error, oordeelAvailable: !oordeel.error, perLine };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"salesorders-mapping.d.ts","sourceRoot":"","sources":["../../src/lib/salesorders-mapping.ts"],"names":[],"mappings":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 @@ export function ordersToCsv(orders) {
|
|
|
305
306
|
o.quantity.unitPrice.toFixed(2),
|
|
306
307
|
o.revenue.toFixed(2),
|
|
307
308
|
o.customer.name,
|
|
309
|
+
o.customerReference ?? "",
|
|
308
310
|
o.customer.postalCode,
|
|
309
311
|
o.customer.city,
|
|
310
312
|
o.deliveryAt,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stock-product-link.check.d.ts","sourceRoot":"","sources":["../../src/lib/stock-product-link.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Draai: bun src/lib/stock-product-link.check.ts
|
|
2
|
+
import { fallbackPrice, fillLineFromStock, linkStockProducts } from "./stock-product-link.js";
|
|
3
|
+
let failed = 0;
|
|
4
|
+
function check(name, got, want) {
|
|
5
|
+
const g = JSON.stringify(got), w = JSON.stringify(want);
|
|
6
|
+
if (g !== w)
|
|
7
|
+
failed++;
|
|
8
|
+
console.log(`${g === w ? "OK " : "FOUT"} ${name}: ${g}${g === w ? "" : ` (verwacht ${w})`}`);
|
|
9
|
+
}
|
|
10
|
+
const TI = "ea7776dd-0000-0000-0000-000000000000";
|
|
11
|
+
const STOCK = "27612767-0000-0000-0000-000000000000";
|
|
12
|
+
const products = [
|
|
13
|
+
{ id: TI, sale_price: 1.4, floriday_trade_item_id: null, is_mirror: true },
|
|
14
|
+
{ id: STOCK, sale_price: 1.25, floriday_trade_item_id: TI, is_mirror: false },
|
|
15
|
+
];
|
|
16
|
+
const packs = [{ product_id: STOCK, is_primary: true, sort_order: 0, vbn_package_code: 18, load_carrier: "DANISH_TROLLEY", pieces_per_package: 12, packages_per_layer: 5, layers_per_load_carrier: 8 }];
|
|
17
|
+
const link = linkStockProducts([TI], products, packs).get(TI);
|
|
18
|
+
check("trade-item-id → voorraadartikel via floriday_trade_item_id", link?.stockProductId, STOCK);
|
|
19
|
+
check("primaire belading", link?.primary, { vbn_package_code: "18", load_carrier_type: "DANISH_TROLLEY", plants_per_crate: 12, crates_per_layer: 5, layers_per_cart: 8 });
|
|
20
|
+
check("products.id eerst", linkStockProducts([STOCK], products, packs).get(STOCK)?.stockProductId, STOCK);
|
|
21
|
+
const line = fillLineFromStock({ vbn_package_code: null, load_carrier_type: null, packing_source: null }, link);
|
|
22
|
+
check("lege regel krijgt belading", [line.vbn_package_code, line.load_carrier_type, line.plants_per_crate, line.packing_source], ["18", "DANISH_TROLLEY", 12, "product_primary"]);
|
|
23
|
+
const chosen = fillLineFromStock({ vbn_package_code: "575", load_carrier_type: "AUCTION_TROLLEY", plants_per_crate: 6, packing_source: "chosen" }, link);
|
|
24
|
+
check("gekozen belading blijft", [chosen.vbn_package_code, chosen.load_carrier_type, chosen.plants_per_crate], ["575", "AUCTION_TROLLEY", 6]);
|
|
25
|
+
check("handmatig zonder prijsgroep → artikelprijs", fallbackPrice("manual", null, link), { price: 1.25, source: "artikel" });
|
|
26
|
+
check("prijsgroep gaat voor", fallbackPrice("manual", 2, link), { price: 2, source: "prijsgroep" });
|
|
27
|
+
check("Floriday-order nooit artikelprijs", fallbackPrice("floriday", null, link), null);
|
|
28
|
+
if (failed) {
|
|
29
|
+
console.error(`${failed} fout(en)`);
|
|
30
|
+
process.exit(1);
|
|
31
|
+
}
|
|
32
|
+
console.log("Alle controles geslaagd");
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type ProductRow = {
|
|
2
|
+
id: string;
|
|
3
|
+
sale_price: number | string | null;
|
|
4
|
+
floriday_trade_item_id: string | null;
|
|
5
|
+
is_mirror: boolean;
|
|
6
|
+
};
|
|
7
|
+
export type PackingRow = {
|
|
8
|
+
product_id: string;
|
|
9
|
+
is_primary: boolean | null;
|
|
10
|
+
sort_order: number | null;
|
|
11
|
+
vbn_package_code: string | number | null;
|
|
12
|
+
load_carrier: string | null;
|
|
13
|
+
pieces_per_package: number | null;
|
|
14
|
+
packages_per_layer: number | null;
|
|
15
|
+
layers_per_load_carrier: number | null;
|
|
16
|
+
};
|
|
17
|
+
export type StockLink = {
|
|
18
|
+
stockProductId: string;
|
|
19
|
+
salePrice: number | null;
|
|
20
|
+
primary: {
|
|
21
|
+
vbn_package_code: string | null;
|
|
22
|
+
load_carrier_type: string | null;
|
|
23
|
+
plants_per_crate: number | null;
|
|
24
|
+
crates_per_layer: number | null;
|
|
25
|
+
layers_per_cart: number | null;
|
|
26
|
+
} | null;
|
|
27
|
+
};
|
|
28
|
+
export declare function primaryPacking(packs: PackingRow[]): StockLink["primary"];
|
|
29
|
+
/** Per gevraagd product_id het voorraadartikel (of niets). */
|
|
30
|
+
export declare function linkStockProducts(ids: string[], products: ProductRow[], packings: PackingRow[]): Map<string, StockLink>;
|
|
31
|
+
/** Vult lege beladingvelden van een regel aan met de primaire verpakking; gekozen waarden blijven. */
|
|
32
|
+
export declare function fillLineFromStock<T extends {
|
|
33
|
+
vbn_package_code?: string | null;
|
|
34
|
+
load_carrier_type?: string | null;
|
|
35
|
+
plants_per_crate?: number;
|
|
36
|
+
crates_per_layer?: number;
|
|
37
|
+
layers_per_cart?: number;
|
|
38
|
+
packing_source?: "product_primary" | "customer" | "chosen" | null;
|
|
39
|
+
}>(line: T, link: StockLink | undefined): T;
|
|
40
|
+
/** Prijs-terugval: alleen voor handmatige orders (HO/AO/MO), nooit Floriday. */
|
|
41
|
+
export declare function fallbackPrice(orderKind: "manual" | "floriday", groupPrice: number | null, link: StockLink | undefined): {
|
|
42
|
+
price: number;
|
|
43
|
+
source: string;
|
|
44
|
+
} | null;
|
|
45
|
+
//# sourceMappingURL=stock-product-link.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stock-product-link.d.ts","sourceRoot":"","sources":["../../src/lib/stock-product-link.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACnC,sBAAsB,EAAE,MAAM,GAAG,IAAI,C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AC;IACpE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAC/E,cAAc,CAAC,EAAE,iBAAiB,GAAG,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAC;CACnE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,CAAC,CAa1C;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,SAAS,EAAE,QAAQ,GAAG,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAIhK"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// Koppeling orderregel → voorraadartikel (client-safe, pure logica).
|
|
2
|
+
// Contract gelijk aan Engine 1.0.215 (logistics_ladingdrager_voor_regel):
|
|
3
|
+
// 1) products.id = order_items.product_id
|
|
4
|
+
// 2) anders products.floriday_trade_item_id = order_items.product_id
|
|
5
|
+
// Een spiegelrij (custom_fields.source = 'sales-module-*-mirror') zonder
|
|
6
|
+
// primaire verpakking telt niet als voorraadartikel bij stap 1.
|
|
7
|
+
// Verpakkingen hangen aan products.id (product_packings.product_id).
|
|
8
|
+
const pos = (v) => {
|
|
9
|
+
const n = Number(v);
|
|
10
|
+
return Number.isFinite(n) && n > 0 ? n : null;
|
|
11
|
+
};
|
|
12
|
+
export function primaryPacking(packs) {
|
|
13
|
+
if (!packs.length)
|
|
14
|
+
return null;
|
|
15
|
+
const p = [...packs].sort((a, b) => (b.is_primary ? 1 : 0) - (a.is_primary ? 1 : 0) || (a.sort_order ?? 0) - (b.sort_order ?? 0))[0];
|
|
16
|
+
const vbn = p.vbn_package_code == null ? "" : String(p.vbn_package_code).trim();
|
|
17
|
+
return {
|
|
18
|
+
vbn_package_code: vbn || null,
|
|
19
|
+
load_carrier_type: (p.load_carrier ?? "").trim() || null,
|
|
20
|
+
plants_per_crate: pos(p.pieces_per_package),
|
|
21
|
+
crates_per_layer: pos(p.packages_per_layer),
|
|
22
|
+
layers_per_cart: pos(p.layers_per_load_carrier),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** Per gevraagd product_id het voorraadartikel (of niets). */
|
|
26
|
+
export function linkStockProducts(ids, products, packings) {
|
|
27
|
+
const packsBy = new Map();
|
|
28
|
+
for (const p of packings) {
|
|
29
|
+
const l = packsBy.get(p.product_id) ?? [];
|
|
30
|
+
l.push(p);
|
|
31
|
+
packsBy.set(p.product_id, l);
|
|
32
|
+
}
|
|
33
|
+
const byId = new Map(products.map((p) => [p.id, p]));
|
|
34
|
+
const byTradeItem = new Map();
|
|
35
|
+
for (const p of products)
|
|
36
|
+
if (p.floriday_trade_item_id && !p.is_mirror)
|
|
37
|
+
byTradeItem.set(p.floriday_trade_item_id, p);
|
|
38
|
+
const mk = (p) => ({ stockProductId: p.id, salePrice: pos(p.sale_price), primary: primaryPacking(packsBy.get(p.id) ?? []) });
|
|
39
|
+
const out = new Map();
|
|
40
|
+
for (const id of ids) {
|
|
41
|
+
const direct = byId.get(id);
|
|
42
|
+
if (direct && !(direct.is_mirror && !(packsBy.get(direct.id)?.length))) {
|
|
43
|
+
out.set(id, mk(direct));
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const viaTi = byTradeItem.get(id);
|
|
47
|
+
if (viaTi) {
|
|
48
|
+
out.set(id, mk(viaTi));
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
if (direct)
|
|
52
|
+
out.set(id, mk(direct));
|
|
53
|
+
}
|
|
54
|
+
return out;
|
|
55
|
+
}
|
|
56
|
+
/** Vult lege beladingvelden van een regel aan met de primaire verpakking; gekozen waarden blijven. */
|
|
57
|
+
export function fillLineFromStock(line, link) {
|
|
58
|
+
const p = link?.primary;
|
|
59
|
+
if (!p)
|
|
60
|
+
return line;
|
|
61
|
+
const own = line.packing_source === "chosen" || line.packing_source === "customer";
|
|
62
|
+
return {
|
|
63
|
+
...line,
|
|
64
|
+
vbn_package_code: (line.vbn_package_code ?? "").trim() || p.vbn_package_code,
|
|
65
|
+
load_carrier_type: (line.load_carrier_type ?? "").trim() || p.load_carrier_type,
|
|
66
|
+
plants_per_crate: line.plants_per_crate ?? (own ? undefined : p.plants_per_crate ?? undefined),
|
|
67
|
+
crates_per_layer: line.crates_per_layer ?? (own ? undefined : p.crates_per_layer ?? undefined),
|
|
68
|
+
layers_per_cart: line.layers_per_cart ?? (own ? undefined : p.layers_per_cart ?? undefined),
|
|
69
|
+
packing_source: line.packing_source ?? "product_primary",
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/** Prijs-terugval: alleen voor handmatige orders (HO/AO/MO), nooit Floriday. */
|
|
73
|
+
export function fallbackPrice(orderKind, groupPrice, link) {
|
|
74
|
+
if (groupPrice != null && groupPrice > 0)
|
|
75
|
+
return { price: groupPrice, source: "prijsgroep" };
|
|
76
|
+
if (orderKind !== "manual")
|
|
77
|
+
return null;
|
|
78
|
+
return link?.salePrice ? { price: link.salePrice, source: "artikel" } : null;
|
|
79
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stock-product-link.server.d.ts","sourceRoot":"","sources":["../../src/lib/stock-product-link.server.ts"],"names":[],"mappings":"AACA,OAAO,EAAuD,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE3G,wBAAsB,cAAc,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAmB5F"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Leest products + product_packings en koppelt via stock-product-link.ts.
|
|
2
|
+
import { linkStockProducts } from "./stock-product-link.js";
|
|
3
|
+
export async function loadStockLinks(sb, ids) {
|
|
4
|
+
const uniq = Array.from(new Set(ids.filter(Boolean)));
|
|
5
|
+
if (!uniq.length)
|
|
6
|
+
return new Map();
|
|
7
|
+
const [a, b] = await Promise.all([
|
|
8
|
+
sb.from("products").select("id, sale_price, floriday_trade_item_id, custom_fields").in("id", uniq),
|
|
9
|
+
sb.from("products").select("id, sale_price, floriday_trade_item_id, custom_fields").in("floriday_trade_item_id", uniq),
|
|
10
|
+
]);
|
|
11
|
+
const seen = new Map();
|
|
12
|
+
for (const r of [...(a.data ?? []), ...(b.data ?? [])]) {
|
|
13
|
+
const src = String(r?.custom_fields?.source ?? "");
|
|
14
|
+
seen.set(r.id, { id: r.id, sale_price: r.sale_price, floriday_trade_item_id: r.floriday_trade_item_id ?? null, is_mirror: /^sales-module-.*-mirror$/.test(src) });
|
|
15
|
+
}
|
|
16
|
+
const products = Array.from(seen.values());
|
|
17
|
+
if (!products.length)
|
|
18
|
+
return new Map();
|
|
19
|
+
const { data: packs } = await sb
|
|
20
|
+
.from("product_packings")
|
|
21
|
+
.select("product_id, is_primary, sort_order, vbn_package_code, load_carrier, pieces_per_package, packages_per_layer, layers_per_load_carrier")
|
|
22
|
+
.in("product_id", products.map((p) => p.id));
|
|
23
|
+
return linkStockProducts(uniq, products, (packs ?? []));
|
|
24
|
+
}
|