@flowselections/floriday-verkoop-module 1.0.137 → 1.0.138
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/verkoop/EditLocalOrderDialog.d.ts.map +1 -1
- package/dist-lib/components/verkoop/EditLocalOrderDialog.js +10 -2
- package/dist-lib/components/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +7 -2
- package/dist-lib/lib/create-order.functions.d.ts +6 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +79 -29
- package/dist-lib/lib/module-version.d.ts +1 -1
- package/dist-lib/lib/module-version.js +1 -1
- package/dist-lib/lib/order-price-lock.check.d.ts +2 -0
- package/dist-lib/lib/order-price-lock.check.d.ts.map +1 -0
- package/dist-lib/lib/order-price-lock.check.js +27 -0
- package/dist-lib/lib/order-price-lock.d.ts +21 -0
- package/dist-lib/lib/order-price-lock.d.ts.map +1 -0
- package/dist-lib/lib/order-price-lock.js +28 -0
- package/dist-lib/lib/order-price-lock.server.d.ts +2 -0
- package/dist-lib/lib/order-price-lock.server.d.ts.map +1 -0
- package/dist-lib/lib/order-price-lock.server.js +21 -0
- package/dist-lib/lib/own-transport.d.ts +11 -0
- package/dist-lib/lib/own-transport.d.ts.map +1 -0
- package/dist-lib/lib/own-transport.js +10 -0
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +3 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditLocalOrderDialog.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/EditLocalOrderDialog.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EditLocalOrderDialog.d.ts","sourceRoot":"","sources":["../../../src/components/verkoop/EditLocalOrderDialog.tsx"],"names":[],"mappings":"AAgDA,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,IAAI,EACJ,YAAY,GACb,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,CAAC,CAAC,EAAE,OAAO,KAAK,IAAI,CAAC;CACpC,sCAsmBA"}
|
|
@@ -23,6 +23,7 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
23
23
|
const [isReservation, setIsReservation] = useState(false);
|
|
24
24
|
const [items, setItems] = useState([]);
|
|
25
25
|
const [canEditProducts, setCanEditProducts] = useState(true);
|
|
26
|
+
const [priceLock, setPriceLock] = useState(null);
|
|
26
27
|
const [removedIds, setRemovedIds] = useState([]);
|
|
27
28
|
const [newItems, setNewItems] = useState([]);
|
|
28
29
|
useEffect(() => {
|
|
@@ -40,6 +41,7 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
40
41
|
setDeliveryDate((r.deliveryDate ?? "").slice(0, 10));
|
|
41
42
|
setIsReservation(!!r.isReservation);
|
|
42
43
|
setCanEditProducts(r.canEditProducts !== false);
|
|
44
|
+
setPriceLock(r.priceLock ?? null);
|
|
43
45
|
setItems(r.items.map((it) => ({
|
|
44
46
|
id: it.id,
|
|
45
47
|
productId: it.productId ?? null,
|
|
@@ -48,6 +50,7 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
48
50
|
unit: it.unit,
|
|
49
51
|
plantsPerCrate: pos(it.plantsPerCrate),
|
|
50
52
|
needsSticker: it.needsSticker === true,
|
|
53
|
+
unitPrice: it.unitPrice == null ? null : Number(it.unitPrice),
|
|
51
54
|
minQuantity: Number(it.minQuantity ?? 0),
|
|
52
55
|
shippedQuantity: Number(it.shippedQuantity ?? 0),
|
|
53
56
|
plannedQuantity: Number(it.plannedQuantity ?? 0),
|
|
@@ -207,6 +210,11 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
207
210
|
items: items
|
|
208
211
|
.filter((i) => !removedIds.includes(i.id))
|
|
209
212
|
.map((i) => ({ itemId: i.id, quantity: Math.round(i.quantity) })),
|
|
213
|
+
prices: priceLock
|
|
214
|
+
? undefined
|
|
215
|
+
: items
|
|
216
|
+
.filter((i) => !removedIds.includes(i.id) && i.unitPrice != null && Number.isFinite(i.unitPrice) && i.unitPrice >= 0)
|
|
217
|
+
.map((i) => ({ itemId: i.id, unitPrice: Number(i.unitPrice) })),
|
|
210
218
|
removeItemIds: removedIds.length ? removedIds : undefined,
|
|
211
219
|
newItems: newItems.length
|
|
212
220
|
? newItems.map((n) => ({
|
|
@@ -245,11 +253,11 @@ export function EditLocalOrderDialog({ orderId, open, onOpenChange, }) {
|
|
|
245
253
|
setSaving(false);
|
|
246
254
|
}
|
|
247
255
|
};
|
|
248
|
-
return (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4", onClick: () => !saving && onOpenChange(false), children: _jsxs("div", { className: "flex w-full max-w-4xl max-h-[90vh] flex-col rounded-lg border border-border bg-card shadow-lg", onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "shrink-0 p-6 pb-4", children: [_jsx("h2", { className: "text-lg font-semibold text-foreground", children: "Bestelling bewerken" }), _jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Pas de leverdatum en het aantal planten of fusten per regel aan. Voorraad en karindeling worden automatisch bijgewerkt." })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-6 pb-4 min-h-0", children: [loading ? (_jsx("div", { className: "text-sm text-muted-foreground", children: "Laden\u2026" })) : error ? (_jsx("div", { className: "rounded border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive", children: error })) : (_jsxs("div", { className: "space-y-4", children: [!isReservation && (_jsxs("div", { children: [_jsx("label", { className: "mb-1 block text-sm font-medium text-foreground", children: "Leverdatum" }), _jsx(Input, { type: "date", value: deliveryDate, onChange: (e) => setDeliveryDate(e.target.value) })] })), isReservation && (_jsx("div", { className: "rounded border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground", children: "Dit is een reservering \u2014 er is nog geen leverdatum. Voeg een bezorgmoment toe om (deels) uit te leveren." })), _jsxs("div", { children: [_jsx("div", { className: "mb-2 text-sm font-medium text-foreground", children: "Regels" }), _jsxs("div", { className: "grid grid-cols-12 gap-2 px-1 text-xs text-muted-foreground", children: [_jsx("div", { className: "col-span-5", children: "Product" }), _jsx("div", { className: "col-span-1 text-center", children: "Sticker" }), _jsx("div", { className: "col-span-3", children: "Planten" }), _jsx("div", { className: "col-span-3", children: "Fusten" })] }), _jsxs("div", { className: "mt-1 space-y-2", children: [items.map((it, idx) => {
|
|
256
|
+
return (_jsx("div", { className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4", onClick: () => !saving && onOpenChange(false), children: _jsxs("div", { className: "flex w-full max-w-4xl max-h-[90vh] flex-col rounded-lg border border-border bg-card shadow-lg", onClick: (e) => e.stopPropagation(), children: [_jsxs("div", { className: "shrink-0 p-6 pb-4", children: [_jsx("h2", { className: "text-lg font-semibold text-foreground", children: "Bestelling bewerken" }), _jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: "Pas de leverdatum en het aantal planten of fusten per regel aan. Voorraad en karindeling worden automatisch bijgewerkt." })] }), _jsxs("div", { className: "flex-1 overflow-y-auto px-6 pb-4 min-h-0", children: [loading ? (_jsx("div", { className: "text-sm text-muted-foreground", children: "Laden\u2026" })) : error ? (_jsx("div", { className: "rounded border border-destructive/30 bg-destructive/5 p-3 text-sm text-destructive", children: error })) : (_jsxs("div", { className: "space-y-4", children: [!isReservation && (_jsxs("div", { children: [_jsx("label", { className: "mb-1 block text-sm font-medium text-foreground", children: "Leverdatum" }), _jsx(Input, { type: "date", value: deliveryDate, onChange: (e) => setDeliveryDate(e.target.value) })] })), isReservation && (_jsx("div", { className: "rounded border border-border bg-muted/40 px-3 py-2 text-xs text-muted-foreground", children: "Dit is een reservering \u2014 er is nog geen leverdatum. Voeg een bezorgmoment toe om (deels) uit te leveren." })), _jsxs("div", { children: [_jsx("div", { className: "mb-2 text-sm font-medium text-foreground", children: "Regels" }), _jsxs("div", { className: "grid grid-cols-12 gap-2 px-1 text-xs text-muted-foreground", children: [_jsx("div", { className: "col-span-5", children: "Product" }), _jsx("div", { className: "col-span-1 text-center", children: "Sticker" }), _jsx("div", { className: "col-span-3", children: "Planten" }), _jsx("div", { className: "col-span-3", children: "Fusten" })] }), _jsxs("div", { className: "mt-1 space-y-2", children: [priceLock && _jsxs("div", { className: "text-xs text-muted-foreground", children: ["Prijs wijzigen kan niet: ", priceLock] }), items.map((it, idx) => {
|
|
249
257
|
const ppc = it.plantsPerCrate;
|
|
250
258
|
const fusten = ppc !== null ? Math.ceil(it.quantity / ppc) : 0;
|
|
251
259
|
const removed = removedIds.includes(it.id);
|
|
252
|
-
return (_jsxs("div", { className: `grid grid-cols-12 items-start gap-2 rounded border border-border p-2 ${removed ? "opacity-50" : ""}`, children: [_jsxs("div", { className: "col-span-4 min-w-0 text-sm", children: [_jsx("div", { className: `truncate font-medium text-foreground ${removed ? "line-through" : ""}`, children: it.productName }), ppc === null ? (_jsx("div", { className: "text-xs text-destructive", children: "Belading onbekend \u2014 deze regel kan niet opgeslagen worden" })) : (_jsxs("div", { className: "text-xs text-muted-foreground", children: [ppc, " planten per fust"] })), it.minQuantity > 0 && (_jsxs("div", { className: "text-xs text-primary", children: ["min. ", it.minQuantity, " (reeds ", it.shippedQuantity, " geleverd, ", it.plannedQuantity, " gepland)"] })), it.productId && shortageByProduct.has(it.productId) && (_jsx("div", { className: `text-xs ${stockBlocked ? "text-destructive" : "text-amber-600"}`, children: (() => {
|
|
260
|
+
return (_jsxs("div", { className: `grid grid-cols-12 items-start gap-2 rounded border border-border p-2 ${removed ? "opacity-50" : ""}`, children: [_jsxs("div", { className: "col-span-4 min-w-0 text-sm", children: [_jsx("div", { className: `truncate font-medium text-foreground ${removed ? "line-through" : ""}`, children: it.productName }), ppc === null ? (_jsx("div", { className: "text-xs text-destructive", children: "Belading onbekend \u2014 deze regel kan niet opgeslagen worden" })) : (_jsxs("div", { className: "text-xs text-muted-foreground", children: [ppc, " planten per fust"] })), _jsxs("label", { className: "mt-1 flex items-center gap-1 text-xs text-muted-foreground", children: ["Prijs per stuk \u20AC", _jsx(Input, { type: "number", min: 0, step: 0.01, className: "h-7 w-24", "aria-label": "Prijs per stuk", value: it.unitPrice ?? "", disabled: removed || !!priceLock, title: priceLock ?? undefined, onChange: (e) => setItems((prev) => prev.map((p, i) => (i === idx ? { ...p, unitPrice: e.target.value === "" ? null : Number(e.target.value) } : p))) })] }), it.minQuantity > 0 && (_jsxs("div", { className: "text-xs text-primary", children: ["min. ", it.minQuantity, " (reeds ", it.shippedQuantity, " geleverd, ", it.plannedQuantity, " gepland)"] })), it.productId && shortageByProduct.has(it.productId) && (_jsx("div", { className: `text-xs ${stockBlocked ? "text-destructive" : "text-amber-600"}`, children: (() => {
|
|
253
261
|
const s = shortageByProduct.get(it.productId);
|
|
254
262
|
return `${s.product}: besteld ${s.wanted}, beschikbaar ${s.available}, tekort ${s.missing}`;
|
|
255
263
|
})() }))] }), _jsx("div", { className: "col-span-1 flex h-10 items-center justify-center", children: _jsx("input", { type: "checkbox", className: "h-4 w-4 accent-primary", "aria-label": "Sticker nodig", checked: it.needsSticker, disabled: removed, onChange: (e) => setItems((prev) => prev.map((p, i) => (i === idx ? { ...p, needsSticker: e.target.checked } : p))) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: ppc ?? 1, value: it.quantity, disabled: removed, onChange: (e) => setPlants(idx, Number(e.target.value)) }) }), _jsx("div", { className: "col-span-3", children: _jsx(Input, { type: "number", min: 0, step: 1, value: ppc === null ? "" : fusten, disabled: removed || ppc === null, onChange: (e) => setFusten(idx, Number(e.target.value)) }) }), _jsx("div", { className: "col-span-1 flex justify-end", children: canEditProducts && (_jsx(Button, { variant: "ghost", size: "sm", title: removed ? "Verwijderen ongedaan maken" : "Regel verwijderen", onClick: () => setRemovedIds((prev) => prev.includes(it.id)
|
|
@@ -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;AA+JnE,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"}
|
|
@@ -11,6 +11,7 @@ import { OrderLinePackingCard } from "./OrderLinePackingCard.js";
|
|
|
11
11
|
import { OrderAfleverbrievenCard } from "./OrderAfleverbrievenCard.js";
|
|
12
12
|
import { OrderShipmentsCard } from "./OrderShipmentsCard.js";
|
|
13
13
|
import { OrderInvoiceCard } from "./OrderInvoiceCard.js";
|
|
14
|
+
import { orderUuid } from "../../lib/order-price-lock.js";
|
|
14
15
|
import { OrderControlStatusCard } from "./OrderControlStatusCard.js";
|
|
15
16
|
import { OrderCarrierPicker } from "./OrderCarrierPicker.js";
|
|
16
17
|
import { OrderPickupMomentPicker } from "./OrderPickupMomentPicker.js";
|
|
@@ -231,7 +232,11 @@ function SalesOrderDetailViewInner({ floridayLoading, order, sellerFallback, hid
|
|
|
231
232
|
pickStr(o.incoterm) ??
|
|
232
233
|
(fe ? "niet opgegeven" : "—");
|
|
233
234
|
const productUnit = Number(o.calculatedFields?.totalPricePerPiece?.value ?? o.pricePerPiece?.value ?? order.quantity.unitPrice) || 0;
|
|
234
|
-
|
|
235
|
+
// Echte inkoopprijs alleen als Floriday die levert; anders "—" (geen terugval op verkoopprijs).
|
|
236
|
+
const purchaseRaw = o.pricePerPiece?.value;
|
|
237
|
+
const hasPurchase = purchaseRaw != null && Number.isFinite(Number(purchaseRaw));
|
|
238
|
+
const purchaseUnit = hasPurchase ? Number(purchaseRaw) : productUnit;
|
|
239
|
+
const invoiceOrderId = orderUuid(order.orderRowId ?? (String(order.id).startsWith("local:") ? order.id : null));
|
|
235
240
|
const transportPerPiece = Number(o.deliveryPricePerPiece ?? Math.max(0, productUnit - purchaseUnit)) || 0;
|
|
236
241
|
const priceLines = (order.priceLines ?? []).filter((l) => l.pieces > 0);
|
|
237
242
|
const linesTotal = priceLines.reduce((sum, l) => sum + l.pieces * l.unitPrice, 0);
|
|
@@ -305,5 +310,5 @@ function SalesOrderDetailViewInner({ floridayLoading, order, sellerFallback, hid
|
|
|
305
310
|
.join(" "),
|
|
306
311
|
resolvedAddresses.pickup.country,
|
|
307
312
|
].filter((v) => !!v && v.trim().length > 0)
|
|
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:
|
|
313
|
+
: [], 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: hasPurchase ? 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 }), invoiceOrderId && _jsx(OrderInvoiceCard, { orderId: invoiceOrderId }), !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] }));
|
|
309
314
|
}
|
|
@@ -222,6 +222,7 @@ export declare const getLocalOrderForEdit: import("@tanstack/start-client-core")
|
|
|
222
222
|
status: string | null;
|
|
223
223
|
planLockedAt: string | null;
|
|
224
224
|
canEditProducts: boolean;
|
|
225
|
+
priceLock: string | null;
|
|
225
226
|
items: {
|
|
226
227
|
id: string;
|
|
227
228
|
productId: string | null;
|
|
@@ -230,6 +231,7 @@ export declare const getLocalOrderForEdit: import("@tanstack/start-client-core")
|
|
|
230
231
|
unit: string | null;
|
|
231
232
|
plantsPerCrate: number | null;
|
|
232
233
|
needsSticker: boolean;
|
|
234
|
+
unitPrice: number | null;
|
|
233
235
|
shippedQuantity: number;
|
|
234
236
|
plannedQuantity: number;
|
|
235
237
|
minQuantity: number;
|
|
@@ -247,6 +249,10 @@ export declare const updateLocalOrder: import("@tanstack/start-client-core").Opt
|
|
|
247
249
|
itemId: string;
|
|
248
250
|
quantity: number;
|
|
249
251
|
}[] | undefined;
|
|
252
|
+
prices?: {
|
|
253
|
+
itemId: string;
|
|
254
|
+
unitPrice: number;
|
|
255
|
+
}[] | undefined;
|
|
250
256
|
removeItemIds?: string[] | undefined;
|
|
251
257
|
newItems?: {
|
|
252
258
|
productId: string;
|
|
@@ -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,MAAM,GAAG,IAAI;0BACP,MAAM,GAAG,IAAI;0BACb,MAAM,GAAG,IAAI;yBACd,MAAM,GAAG,IAAI;wBACd,MAAM;wBACN,MAAM;yBACL,MAAM;kBACb,OAAO;gBACT,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS;;GA2SpD,CAAC;AAGL,eAAO,MAAM,kCAAkC;;;;0CAEzB,OAAO;;;;;;;;;;;;;;;;;;;;;;GAkDzB,CAAC;AAKL,eAAO,MAAM,qBAAqB;;;;;;YAoBI,MAAM;;;GAIxC,CAAC;AAGL,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;GAanC,CAAC;AASL,eAAO,MAAM,8BAA8B;;;;8CAEjB,OAAO;;;;GAU7B,CAAC;AASL,eAAO,MAAM,mBAAmB;;;;;;;;0BAgBuB,MAAM;0BAAoB,MAAM;yBAAmB,MAAM;;;GA8C5G,CAAC;AAGL,eAAO,MAAM,kBAAkB;;;;;;GAU3B,CAAC;AAkFL,eAAO,MAAM,iBAAiB;;;;8CAEJ,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
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,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,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AAO;;;;gBAIgC,MAAM,EAAE;GAoCrE,CAAC"}
|
|
@@ -752,6 +752,16 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
752
752
|
// Alleen voor de terugval bij een oude Engine (custom_fields.carrier).
|
|
753
753
|
let fallbackCarrierId = null;
|
|
754
754
|
let ownTransportInfo = null;
|
|
755
|
+
// Eigen vervoer: vastleggen als de Engine-vervoerder met soort eigen_vervoer
|
|
756
|
+
// (carriers.carrier_kind), zodat de Engine geen favoriet kiest en niet
|
|
757
|
+
// bundelt met vervoerdersorders. Ontbreekt die, dan geen vervoerder.
|
|
758
|
+
let ownCarrierId = null;
|
|
759
|
+
if (ownTransport) {
|
|
760
|
+
const { data: oc } = await context.supabase
|
|
761
|
+
.from("carriers").select("id").eq("carrier_kind", "eigen_vervoer").is("archived_at", null)
|
|
762
|
+
.order("name", { ascending: true }).limit(1).maybeSingle();
|
|
763
|
+
ownCarrierId = oc?.id ?? null;
|
|
764
|
+
}
|
|
755
765
|
let momentKey = null;
|
|
756
766
|
let deliveryTime = null;
|
|
757
767
|
let lateSignup = null;
|
|
@@ -922,8 +932,8 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
922
932
|
const orderPayload = {
|
|
923
933
|
// Vervoerder via de Engine in dezelfde transactie (logistics_set_order_carrier);
|
|
924
934
|
// geen custom_fields.carrier meer, behalve als terugval bij een oude Engine.
|
|
925
|
-
manual_carrier_id: carrierId,
|
|
926
|
-
fallback_carrier_id: fallbackCarrierId,
|
|
935
|
+
manual_carrier_id: carrierId ?? ownCarrierId,
|
|
936
|
+
fallback_carrier_id: fallbackCarrierId ?? ownCarrierId,
|
|
927
937
|
set_by_user_id: context.userId ?? null,
|
|
928
938
|
customer_name: data.customerName,
|
|
929
939
|
customer_id: data.customerId,
|
|
@@ -1181,6 +1191,8 @@ const UpdateLocalOrderInput = z.object({
|
|
|
1181
1191
|
quantity: z.number().int().positive(),
|
|
1182
1192
|
}))
|
|
1183
1193
|
.optional(),
|
|
1194
|
+
// Prijs per bestaande regel (alleen HO/AO/MO, niet na een definitieve factuur).
|
|
1195
|
+
prices: z.array(z.object({ itemId: z.string().uuid(), unitPrice: z.number().min(0).max(1000000) })).max(500).optional(),
|
|
1184
1196
|
// Regels verwijderen — alleen zolang de order niet in het Pickstation is
|
|
1185
1197
|
// geprint (orders.plan_locked_at is leeg).
|
|
1186
1198
|
removeItemIds: z.array(z.string().uuid()).optional(),
|
|
@@ -1224,7 +1236,7 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
|
1224
1236
|
}
|
|
1225
1237
|
const { data: items, error: iErr } = await context.supabase
|
|
1226
1238
|
.from("order_items")
|
|
1227
|
-
.select("id, product_id, product_name, quantity, unit, needs_sticker, plants_per_crate, products(plants_per_crate)")
|
|
1239
|
+
.select("id, product_id, product_name, quantity, unit, needs_sticker, unit_price, plants_per_crate, products(plants_per_crate)")
|
|
1228
1240
|
.eq("order_id", data.orderId)
|
|
1229
1241
|
.is("quarantined_at", null)
|
|
1230
1242
|
.order("id");
|
|
@@ -1365,6 +1377,17 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
|
1365
1377
|
status: order.status,
|
|
1366
1378
|
planLockedAt: order.plan_locked_at ?? null,
|
|
1367
1379
|
canEditProducts: !order.plan_locked_at,
|
|
1380
|
+
// Prijs wijzigen: null = mag; anders de reden (definitieve factuur / Twinfield).
|
|
1381
|
+
priceLock: await (async () => {
|
|
1382
|
+
try {
|
|
1383
|
+
const { supabaseAdmin } = await import("../integrations/supabase/client.server.js");
|
|
1384
|
+
const { loadPriceLock } = await import("./order-price-lock.server.js");
|
|
1385
|
+
return await loadPriceLock(context.supabase, supabaseAdmin, order.id, false);
|
|
1386
|
+
}
|
|
1387
|
+
catch (e) {
|
|
1388
|
+
return `Factuurstand onbekend: ${e?.message ?? "fout"}`;
|
|
1389
|
+
}
|
|
1390
|
+
})(),
|
|
1368
1391
|
items: rows.map((it) => {
|
|
1369
1392
|
// Eerst de vastgelegde verpakking van de regel zelf; onbekend = null.
|
|
1370
1393
|
let ppc = posOrNull(it.plants_per_crate) ?? posOrNull(it.products?.plants_per_crate);
|
|
@@ -1390,6 +1413,7 @@ export const getLocalOrderForEdit = createServerFn({ method: "POST" })
|
|
|
1390
1413
|
unit: it.unit,
|
|
1391
1414
|
plantsPerCrate: ppc,
|
|
1392
1415
|
needsSticker: it.needs_sticker === true,
|
|
1416
|
+
unitPrice: it.unit_price == null ? null : Number(it.unit_price),
|
|
1393
1417
|
shippedQuantity: shipped,
|
|
1394
1418
|
plannedQuantity: planned,
|
|
1395
1419
|
minQuantity: shipped + planned,
|
|
@@ -1423,7 +1447,7 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1423
1447
|
// voorraadcontrole, herberekening of nieuwe planning.
|
|
1424
1448
|
const { data: currentRows, error: cErr } = await supabaseAdmin
|
|
1425
1449
|
.from("order_items")
|
|
1426
|
-
.select("id, quantity, needs_sticker")
|
|
1450
|
+
.select("id, quantity, needs_sticker, unit_price")
|
|
1427
1451
|
.eq("order_id", data.orderId);
|
|
1428
1452
|
if (cErr)
|
|
1429
1453
|
throw stockError(cErr.message);
|
|
@@ -1431,6 +1455,14 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1431
1455
|
r.id,
|
|
1432
1456
|
{ quantity: Number(r.quantity ?? 0), needsSticker: r.needs_sticker === true },
|
|
1433
1457
|
]));
|
|
1458
|
+
const priceById = new Map((currentRows ?? []).map((r) => [r.id, Number(r.unit_price ?? 0)]));
|
|
1459
|
+
const priceChanges = (data.prices ?? []).filter((p) => priceById.has(p.itemId) && !removeIds.includes(p.itemId) && Math.abs((priceById.get(p.itemId) ?? 0) - p.unitPrice) > 0.00001);
|
|
1460
|
+
if (priceChanges.length > 0) {
|
|
1461
|
+
const { loadPriceLock } = await import("./order-price-lock.server.js");
|
|
1462
|
+
const lock = await loadPriceLock(context.supabase, supabaseAdmin, data.orderId, false);
|
|
1463
|
+
if (lock)
|
|
1464
|
+
throw stockError(lock);
|
|
1465
|
+
}
|
|
1434
1466
|
const changedItems = (data.items ?? []).filter((i) => {
|
|
1435
1467
|
const cur = currentById.get(i.itemId);
|
|
1436
1468
|
return !cur || cur.quantity !== i.quantity;
|
|
@@ -1445,7 +1477,7 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1445
1477
|
String(data.deliveryDate).slice(0, 10) !== String(order.delivery_date ?? "").slice(0, 10);
|
|
1446
1478
|
if (!dateChanged)
|
|
1447
1479
|
data.deliveryDate = undefined;
|
|
1448
|
-
const realChange = changedItems.length > 0 || removeIds.length > 0 || newItems.length > 0 || dateChanged;
|
|
1480
|
+
const realChange = priceChanges.length > 0 || changedItems.length > 0 || removeIds.length > 0 || newItems.length > 0 || dateChanged;
|
|
1449
1481
|
// Producten wijzigen mag alleen zolang er nog niets is geprint in het
|
|
1450
1482
|
// Pickstation (orders.plan_locked_at).
|
|
1451
1483
|
if ((removeIds.length > 0 || newItems.length > 0) && order.plan_locked_at) {
|
|
@@ -1564,32 +1596,42 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1564
1596
|
if (newDate !== String(order.delivery_date ?? "").slice(0, 10) && cf?.delivery_location) {
|
|
1565
1597
|
const { loadDeparturePreview, deliveryTimeForMoment } = await import("./departure-preview.server.js");
|
|
1566
1598
|
const { decidePreview } = await import("./departure-preview.js");
|
|
1567
|
-
const
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
if (d.kind === "blocked")
|
|
1575
|
-
throw stockError(d.reason);
|
|
1576
|
-
// Vervoerder al vertrokken: ook bij wijzigen nooit doorlaten.
|
|
1577
|
-
if (d.kind === "departed") {
|
|
1578
|
-
throw stockError(d.firstDate ? `${d.reason} De eerstvolgende leverdatum is ${d.firstDate}.` : d.reason);
|
|
1599
|
+
const { resolveCarrierOne } = await import("./carrier-resolve.server.js");
|
|
1600
|
+
const { ownTransportDateDecision } = await import("./own-transport.js");
|
|
1601
|
+
const resolved = await resolveCarrierOne(context.supabase, data.orderId, { id: cf?.carrier ?? null, name: null });
|
|
1602
|
+
const ownDec = ownTransportDateDecision({ ownTransport: !!cf?.own_transport, carrierKind: resolved.carrierKind });
|
|
1603
|
+
if (ownDec.skipDeparture) {
|
|
1604
|
+
newMoment = null;
|
|
1605
|
+
newDeliveryTime = null;
|
|
1579
1606
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1607
|
+
else {
|
|
1608
|
+
const preview = await loadDeparturePreview(context.supabase, {
|
|
1609
|
+
carrierId: resolved.carrierId ?? cf?.carrier ?? null,
|
|
1610
|
+
deliveryLocation: String(cf.delivery_location),
|
|
1611
|
+
deliveryDate: newDate,
|
|
1612
|
+
momentKey: null,
|
|
1613
|
+
});
|
|
1614
|
+
const d = decidePreview(preview);
|
|
1615
|
+
if (d.kind === "blocked")
|
|
1616
|
+
throw stockError(d.reason);
|
|
1617
|
+
// Vervoerder al vertrokken: ook bij wijzigen nooit doorlaten.
|
|
1618
|
+
if (d.kind === "departed") {
|
|
1619
|
+
throw stockError(d.firstDate ? `${d.reason} De eerstvolgende leverdatum is ${d.firstDate}.` : d.reason);
|
|
1620
|
+
}
|
|
1621
|
+
if (d.kind === "late") {
|
|
1622
|
+
if (!data.acceptLateSignup) {
|
|
1623
|
+
throw stockError(d.firstDate ? `${d.reason} De eerste haalbare leverdatum is ${d.firstDate}.` : d.reason);
|
|
1624
|
+
}
|
|
1625
|
+
const by = context.claims?.email ?? null;
|
|
1626
|
+
lateOverride = {
|
|
1627
|
+
by_user_id: context.userId ?? null, by_email: by, by_name: by,
|
|
1628
|
+
at: new Date().toISOString(), delivery_date: newDate,
|
|
1629
|
+
signup_deadline: preview?.chosen?.signupDeadline ?? null, reason: d.reason, source: "manual",
|
|
1630
|
+
};
|
|
1583
1631
|
}
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
by_user_id: context.userId ?? null, by_email: by, by_name: by,
|
|
1587
|
-
at: new Date().toISOString(), delivery_date: newDate,
|
|
1588
|
-
signup_deadline: preview?.chosen?.signupDeadline ?? null, reason: d.reason, source: "manual",
|
|
1589
|
-
};
|
|
1632
|
+
newMoment = d.momentKey;
|
|
1633
|
+
newDeliveryTime = await deliveryTimeForMoment(context.supabase, resolved.carrierId ?? cf?.carrier ?? null, newMoment);
|
|
1590
1634
|
}
|
|
1591
|
-
newMoment = d.momentKey;
|
|
1592
|
-
newDeliveryTime = await deliveryTimeForMoment(context.supabase, cf?.carrier ?? null, newMoment);
|
|
1593
1635
|
}
|
|
1594
1636
|
const { error: uErr } = await supabaseAdmin.from("orders")
|
|
1595
1637
|
.update({
|
|
@@ -1613,7 +1655,15 @@ export const updateLocalOrder = createServerFn({ method: "POST" })
|
|
|
1613
1655
|
throw stockError(`Aantal bijwerken faalde: ${iErr.message}`);
|
|
1614
1656
|
}
|
|
1615
1657
|
}
|
|
1616
|
-
|
|
1658
|
+
for (const pc of priceChanges) {
|
|
1659
|
+
const { error: pErr } = await supabaseAdmin.from("order_items")
|
|
1660
|
+
.update({ unit_price: pc.unitPrice })
|
|
1661
|
+
.eq("id", pc.itemId)
|
|
1662
|
+
.eq("order_id", data.orderId);
|
|
1663
|
+
if (pErr)
|
|
1664
|
+
throw stockError(`Prijs bijwerken faalde: ${pErr.message}`);
|
|
1665
|
+
}
|
|
1666
|
+
if ((data.items?.length ?? 0) > 0 || removeIds.length > 0 || newItems.length > 0 || priceChanges.length > 0) {
|
|
1617
1667
|
// Hertellen ordertotaal op basis van items × unit_price.
|
|
1618
1668
|
const { data: itemsAll } = await supabaseAdmin
|
|
1619
1669
|
.from("order_items")
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const MODULE_VERSION = "1.0.
|
|
1
|
+
export declare const MODULE_VERSION = "1.0.138";
|
|
2
2
|
//# sourceMappingURL=module-version.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-price-lock.check.d.ts","sourceRoot":"","sources":["../../src/lib/order-price-lock.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Draai: bun src/lib/order-price-lock.check.ts
|
|
2
|
+
import { orderUuid, priceLockReason, PRICE_LOCK_ERP_TEXT, PRICE_LOCK_FLORIDAY_TEXT, PRICE_LOCK_TWINFIELD_TEXT } from "./order-price-lock.js";
|
|
3
|
+
import { ownTransportDateDecision } from "./own-transport.js";
|
|
4
|
+
let failed = 0;
|
|
5
|
+
function check(name, got, want) {
|
|
6
|
+
const ok = JSON.stringify(got) === JSON.stringify(want);
|
|
7
|
+
if (!ok)
|
|
8
|
+
failed++;
|
|
9
|
+
console.log(`${ok ? "OK " : "FOUT"} ${name}: ${JSON.stringify(got)}${ok ? "" : ` (verwacht ${JSON.stringify(want)})`}`);
|
|
10
|
+
}
|
|
11
|
+
check("Floriday-order geweigerd", priceLockReason({ isFloriday: true, erpInvoices: [], links: [] }), PRICE_LOCK_FLORIDAY_TEXT);
|
|
12
|
+
check("definitieve ERP-factuur → eerst crediteren", priceLockReason({ isFloriday: false, erpInvoices: [{ invoice_number: "FS-1", kind: "factuur", status: "definitief" }], links: [] }), PRICE_LOCK_ERP_TEXT);
|
|
13
|
+
check("gecrediteerd → toegestaan", priceLockReason({ isFloriday: false, erpInvoices: [{ invoice_number: "FS-1", kind: "factuur", status: "definitief" }, { invoice_number: "FS-2", kind: "credit", status: "definitief" }], links: [] }), null);
|
|
14
|
+
check("ERP-concept → toegestaan", priceLockReason({ isFloriday: false, erpInvoices: [{ invoice_number: null, kind: "factuur", status: "concept" }], links: [] }), null);
|
|
15
|
+
check("oude Twinfield-concept 40 (AO-2601453)", priceLockReason({ isFloriday: false, erpInvoices: [], links: [{ status: "sent", invoice_number: "40" }] }), PRICE_LOCK_TWINFIELD_TEXT);
|
|
16
|
+
check("link met ERP-nummer is geen Twinfield", priceLockReason({ isFloriday: false, erpInvoices: [{ invoice_number: "FS-1", kind: "factuur", status: "concept" }], links: [{ status: "sent", invoice_number: "FS-1" }] }), null);
|
|
17
|
+
check("zonder Facturatie → toegestaan", priceLockReason({ isFloriday: false, erpInvoices: null, links: null }), null);
|
|
18
|
+
check("local:-id → uuid", orderUuid("local:6f1c2b9e-1111-4222-8333-944455556666"), "6f1c2b9e-1111-4222-8333-944455556666");
|
|
19
|
+
check("Floriday-id zonder uuid → null", orderUuid("FO-2601463"), null);
|
|
20
|
+
check("eigen vervoer: geen vertrekcontrole", ownTransportDateDecision({ ownTransport: true, carrierKind: "extern" }), { skipDeparture: true, clearMoment: true });
|
|
21
|
+
check("klant haalt op: geen vertrekcontrole", ownTransportDateDecision({ ownTransport: false, carrierKind: "klant_haalt_op" }), { skipDeparture: true, clearMoment: true });
|
|
22
|
+
check("externe vervoerder: wel controle", ownTransportDateDecision({ ownTransport: false, carrierKind: "extern" }), { skipDeparture: false, clearMoment: false });
|
|
23
|
+
if (failed) {
|
|
24
|
+
console.error(`${failed} fout(en)`);
|
|
25
|
+
process.exit(1);
|
|
26
|
+
}
|
|
27
|
+
console.log("Alles OK");
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const PRICE_LOCK_ERP_TEXT = "Er staat al een definitieve factuur; eerst crediteren.";
|
|
2
|
+
export declare const PRICE_LOCK_TWINFIELD_TEXT = "Er staat al een factuur in Twinfield; verwijder of crediteer die eerst.";
|
|
3
|
+
export declare const PRICE_LOCK_FLORIDAY_TEXT = "Bij Floriday-orders blijft de prijs uit Floriday staan.";
|
|
4
|
+
export type PriceLockInput = {
|
|
5
|
+
isFloriday: boolean;
|
|
6
|
+
/** null = Facturatie niet aanwezig (functie of tabel ontbreekt). */
|
|
7
|
+
erpInvoices: Array<{
|
|
8
|
+
invoice_number: string | null;
|
|
9
|
+
kind: string | null;
|
|
10
|
+
status: string | null;
|
|
11
|
+
}> | null;
|
|
12
|
+
/** null = koppeltabel niet aanwezig. */
|
|
13
|
+
links: Array<{
|
|
14
|
+
status: string | null;
|
|
15
|
+
invoice_number: string | null;
|
|
16
|
+
}> | null;
|
|
17
|
+
};
|
|
18
|
+
export declare function priceLockReason(i: PriceLockInput): string | null;
|
|
19
|
+
/** "local:<uuid>" of "<uuid>" → uuid; anders null. */
|
|
20
|
+
export declare function orderUuid(id: unknown): string | null;
|
|
21
|
+
//# sourceMappingURL=order-price-lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-price-lock.d.ts","sourceRoot":"","sources":["../../src/lib/order-price-lock.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,2DAA2D,CAAC;AAC5F,eAAO,MAAM,yBAAyB,4EAA4E,CAAC;AACnH,eAAO,MAAM,wBAAwB,4DAA4D,CAAC;AAElG,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,oEAAoE;IACpE,WAAW,EAAE,KAAK,CAAC;QAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;IACzG,wCAAwC;IACxC,KAAK,EAAE,KAAK,CAAC;QAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,CAAC,GAAG,IAAI,CAAC;CAC/E,CAAC;AAIF,wBAAgB,eAAe,CAAC,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,IAAI,CAehE;AAED,sDAAsD;AACtD,wBAAgB,SAAS,CAAC,EAAE,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAGpD"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Mag de prijs van een bestaande order nog gewijzigd worden? (client-safe, puur)
|
|
2
|
+
// Alleen HO/AO/MO; Floriday-orders houden de prijs uit Floriday.
|
|
3
|
+
export const PRICE_LOCK_ERP_TEXT = "Er staat al een definitieve factuur; eerst crediteren.";
|
|
4
|
+
export const PRICE_LOCK_TWINFIELD_TEXT = "Er staat al een factuur in Twinfield; verwijder of crediteer die eerst.";
|
|
5
|
+
export const PRICE_LOCK_FLORIDAY_TEXT = "Bij Floriday-orders blijft de prijs uit Floriday staan.";
|
|
6
|
+
const FINAL = new Set(["definitief", "geboekt"]);
|
|
7
|
+
export function priceLockReason(i) {
|
|
8
|
+
if (i.isFloriday)
|
|
9
|
+
return PRICE_LOCK_FLORIDAY_TEXT;
|
|
10
|
+
if (i.erpInvoices) {
|
|
11
|
+
const finals = i.erpInvoices.filter((r) => (r.kind ?? "factuur") !== "credit" && FINAL.has(String(r.status ?? "").toLowerCase())).length;
|
|
12
|
+
const credits = i.erpInvoices.filter((r) => r.kind === "credit" && FINAL.has(String(r.status ?? "").toLowerCase())).length;
|
|
13
|
+
if (finals > credits)
|
|
14
|
+
return PRICE_LOCK_ERP_TEXT;
|
|
15
|
+
}
|
|
16
|
+
if (i.links && i.erpInvoices) {
|
|
17
|
+
const known = new Set(i.erpInvoices.map((r) => String(r.invoice_number ?? "").trim()).filter(Boolean));
|
|
18
|
+
const legacy = i.links.some((l) => l.status === "sent" && !!String(l.invoice_number ?? "").trim() && !known.has(String(l.invoice_number).trim()));
|
|
19
|
+
if (legacy)
|
|
20
|
+
return PRICE_LOCK_TWINFIELD_TEXT;
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
/** "local:<uuid>" of "<uuid>" → uuid; anders null. */
|
|
25
|
+
export function orderUuid(id) {
|
|
26
|
+
const s = String(id ?? "").replace(/^local:/, "").trim();
|
|
27
|
+
return /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s) ? s : null;
|
|
28
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"order-price-lock.server.d.ts","sourceRoot":"","sources":["../../src/lib/order-price-lock.server.ts"],"names":[],"mappings":"AAIA,wBAAsB,aAAa,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAY7H"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Leest factuurstand voor de prijsvergrendeling (alleen lezen). Shell zonder Facturatie → null.
|
|
2
|
+
import { rpcErrorKind } from "./erp-invoice-view.js";
|
|
3
|
+
import { priceLockReason } from "./order-price-lock.js";
|
|
4
|
+
export async function loadPriceLock(userClient, admin, orderId, isFloriday) {
|
|
5
|
+
if (isFloriday)
|
|
6
|
+
return priceLockReason({ isFloriday, erpInvoices: null, links: null });
|
|
7
|
+
let erp = null;
|
|
8
|
+
const r = await userClient.rpc("erp_invoices_for_order", { p_order_id: orderId });
|
|
9
|
+
if (r.error) {
|
|
10
|
+
const kind = rpcErrorKind(r.error);
|
|
11
|
+
if (kind !== "missing")
|
|
12
|
+
throw new Error(`Factuurstand lezen faalde: ${r.error.message}`);
|
|
13
|
+
}
|
|
14
|
+
else
|
|
15
|
+
erp = Array.isArray(r.data) ? r.data : [];
|
|
16
|
+
let links = null;
|
|
17
|
+
const l = await admin.from("order_invoice_links").select("status, invoice_number").eq("order_id", orderId);
|
|
18
|
+
if (!l.error)
|
|
19
|
+
links = l.data ?? [];
|
|
20
|
+
return priceLockReason({ isFloriday, erpInvoices: erp, links });
|
|
21
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const OWN_CARRIER_KINDS: Set<string>;
|
|
2
|
+
export declare function isOwnTransportKind(kind: string | null | undefined): boolean;
|
|
3
|
+
/** Bij eigen vervoer of zelf ophalen: geen vertrekcontrole en geen ophaalmoment. */
|
|
4
|
+
export declare function ownTransportDateDecision(p: {
|
|
5
|
+
ownTransport: boolean;
|
|
6
|
+
carrierKind: string | null | undefined;
|
|
7
|
+
}): {
|
|
8
|
+
skipDeparture: boolean;
|
|
9
|
+
clearMoment: boolean;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=own-transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"own-transport.d.ts","sourceRoot":"","sources":["../../src/lib/own-transport.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,iBAAiB,aAA+C,CAAC;AAE9E,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAE3E;AAED,oFAAoF;AACpF,wBAAgB,wBAAwB,CAAC,CAAC,EAAE;IAAE,YAAY,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAA;CAAE;;;EAG5G"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Eigen vervoer / zelf ophalen (client-safe, puur). De soort komt van carriers.carrier_kind (Engine-gegevens).
|
|
2
|
+
export const OWN_CARRIER_KINDS = new Set(["eigen_vervoer", "klant_haalt_op"]);
|
|
3
|
+
export function isOwnTransportKind(kind) {
|
|
4
|
+
return OWN_CARRIER_KINDS.has(String(kind ?? "").toLowerCase());
|
|
5
|
+
}
|
|
6
|
+
/** Bij eigen vervoer of zelf ophalen: geen vertrekcontrole en geen ophaalmoment. */
|
|
7
|
+
export function ownTransportDateDecision(p) {
|
|
8
|
+
const own = p.ownTransport || isOwnTransportKind(p.carrierKind);
|
|
9
|
+
return { skipDeparture: own, clearMoment: own };
|
|
10
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"salesorders-list.server.d.ts","sourceRoot":"","sources":["../../src/lib/salesorders-list.server.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAEvB,MAAM,uBAAuB,CAA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E,mBAAmB,CAAC,EACzC,KAAK,EAAE,MAAM,GAAG,IAAI,GACnB,qBAAqB,CAIvB"}
|
|
@@ -1194,6 +1194,9 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
1194
1194
|
const idFor = (o) => o.id.startsWith("local:")
|
|
1195
1195
|
? o.id.slice("local:".length)
|
|
1196
1196
|
: (localRowByFoId.get(o.id)?.id ? String(localRowByFoId.get(o.id).id) : null);
|
|
1197
|
+
// orders.id per zichtbare order (ook bij Floriday-orders), voor het factuurblok.
|
|
1198
|
+
for (const o of visible)
|
|
1199
|
+
o.orderRowId = idFor(o);
|
|
1197
1200
|
const ids = visible.map(idFor).filter((v) => !!v);
|
|
1198
1201
|
if (ids.length) {
|
|
1199
1202
|
// Ophaalmoment uit de Engine (nooit zelf rekenen).
|