@flowselections/floriday-verkoop-module 1.0.118 → 1.0.121
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/components/verkoop/CreateOrderPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/CreateOrderPage.js +39 -26
- package/dist-lib/components/verkoop/FloridayStageLine.d.ts.map +1 -1
- package/dist-lib/components/verkoop/FloridayStageLine.js +4 -2
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +9 -3
- package/dist-lib/components/verkoop/SearchableSelect.d.ts +2 -0
- package/dist-lib/components/verkoop/SearchableSelect.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SearchableSelect.js +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +64 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/carrier-resolve.d.ts.map +1 -1
- package/dist-lib/lib/carrier-resolve.js +4 -1
- package/dist-lib/lib/create-order.functions.d.ts +1 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +44 -29
- package/dist-lib/lib/floriday-write-mode.d.ts +2 -0
- package/dist-lib/lib/floriday-write-mode.d.ts.map +1 -0
- package/dist-lib/lib/floriday-write-mode.functions.d.ts +9 -0
- package/dist-lib/lib/floriday-write-mode.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-write-mode.functions.js +17 -0
- package/dist-lib/lib/floriday-write-mode.js +11 -0
- package/dist-lib/lib/module-version.d.ts +1 -1
- package/dist-lib/lib/module-version.js +1 -1
- package/dist-lib/lib/order-cancel.server.d.ts.map +1 -1
- package/dist-lib/lib/order-cancel.server.js +11 -10
- package/dist-lib/lib/order-shipments.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-shipments.functions.js +2 -1
- package/dist-lib/lib/plan-coverage.server.d.ts +9 -0
- package/dist-lib/lib/plan-coverage.server.d.ts.map +1 -1
- package/dist-lib/lib/plan-coverage.server.js +20 -0
- package/dist-lib/lib/salesorders-list.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.functions.js +6 -0
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +4 -0
- package/dist-lib/lib/salesorders-mapping.d.ts +4 -0
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.js +6 -0
- package/dist-lib/lib/stock-errors.check.d.ts +2 -0
- package/dist-lib/lib/stock-errors.check.d.ts.map +1 -0
- package/dist-lib/lib/stock-errors.check.js +15 -0
- package/dist-lib/lib/stock-errors.d.ts +6 -0
- package/dist-lib/lib/stock-errors.d.ts.map +1 -0
- package/dist-lib/lib/stock-errors.js +15 -0
- package/dist-lib/lib/testronde-1119.check.d.ts +2 -0
- package/dist-lib/lib/testronde-1119.check.d.ts.map +1 -0
- package/dist-lib/lib/testronde-1119.check.js +20 -0
- package/dist-lib/lib/useFloridayWriteMode.d.ts +3 -0
- package/dist-lib/lib/useFloridayWriteMode.d.ts.map +1 -0
- package/dist-lib/lib/useFloridayWriteMode.js +15 -0
- package/dist-lib/lib/zero-price-write-mode.check.d.ts +2 -0
- package/dist-lib/lib/zero-price-write-mode.check.d.ts.map +1 -0
- package/dist-lib/lib/zero-price-write-mode.check.js +18 -0
- package/dist-lib/lib/zero-price.d.ts +9 -0
- package/dist-lib/lib/zero-price.d.ts.map +1 -0
- package/dist-lib/lib/zero-price.js +9 -0
- package/package.json +1 -1
- package/schema/verkoop.sql +14 -3
|
@@ -381,6 +381,12 @@ export const getSalesOrderDetail = createServerFn({ method: "POST" })
|
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
bufferId = ownRow?.buffer_id ?? null;
|
|
384
|
+
if (bufferId && ownRow?.id) {
|
|
385
|
+
const { loadBufferCarts } = await import("./plan-coverage.server.js");
|
|
386
|
+
const b = await loadBufferCarts(supabase, String(ownRow.id));
|
|
387
|
+
dto.bufferCartCount = b.count;
|
|
388
|
+
dto.bufferCartTypeName = b.typeName;
|
|
389
|
+
}
|
|
384
390
|
// Totaalregel: actieve orderregels (stuks × prijs per stuk).
|
|
385
391
|
const activeItems = (ownRow?.order_items ?? []).filter((it) => !it?.quarantined_at);
|
|
386
392
|
if (activeItems.length) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stock-errors.check.d.ts","sourceRoot":"","sources":["../../src/lib/stock-errors.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Draaien: bun src/lib/stock-errors.check.ts
|
|
2
|
+
import { stockError, stockErrorText } from "./stock-errors.js";
|
|
3
|
+
let fail = 0;
|
|
4
|
+
const eq = (name, got, want) => {
|
|
5
|
+
const ok = got === want;
|
|
6
|
+
if (!ok)
|
|
7
|
+
fail++;
|
|
8
|
+
console.log(`${ok ? "ok " : "FOUT"} ${name}: ${JSON.stringify(got)}`);
|
|
9
|
+
};
|
|
10
|
+
eq("VR001", stockError("VR001: multiple active connections").message, "Er zijn meerdere actieve Floriday-koppelingen; kies er één in de instellingen.");
|
|
11
|
+
eq("VR002", stockError("ERROR: VR002 no active connection").message, "De gekozen Floriday-omgeving heeft geen actieve koppeling.");
|
|
12
|
+
eq("onbekende fout ongewijzigd", stockError("iets anders").message, "iets anders");
|
|
13
|
+
eq("geen valse treffer VR0012", stockErrorText("VR0012"), null);
|
|
14
|
+
if (fail)
|
|
15
|
+
process.exit(1);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare const STOCK_ERROR_TEXT: Record<string, string>;
|
|
2
|
+
/** Geeft de gewone tekst voor VR001/VR002 terug, anders null. */
|
|
3
|
+
export declare function stockErrorText(msgOrCode: string | null | undefined): string | null;
|
|
4
|
+
/** Maakt een Error; bij VR001/VR002 met de gewone tekst. */
|
|
5
|
+
export declare function stockError(msg: string): Error;
|
|
6
|
+
//# sourceMappingURL=stock-errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stock-errors.d.ts","sourceRoot":"","sources":["../../src/lib/stock-errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAGnD,CAAC;AAEF,iEAAiE;AACjE,wBAAgB,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAGlF;AAED,4DAA4D;AAC5D,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,KAAK,CAE7C"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Foutcodes van Voorraad (1.0.107+) in gewone taal. Alleen weergave: verandert
|
|
2
|
+
// niets aan voorraad of orders. Onbekende fouten blijven ongewijzigd.
|
|
3
|
+
export const STOCK_ERROR_TEXT = {
|
|
4
|
+
VR001: "Er zijn meerdere actieve Floriday-koppelingen; kies er één in de instellingen.",
|
|
5
|
+
VR002: "De gekozen Floriday-omgeving heeft geen actieve koppeling.",
|
|
6
|
+
};
|
|
7
|
+
/** Geeft de gewone tekst voor VR001/VR002 terug, anders null. */
|
|
8
|
+
export function stockErrorText(msgOrCode) {
|
|
9
|
+
const m = String(msgOrCode ?? "").match(/\bVR00[12]\b/);
|
|
10
|
+
return m ? STOCK_ERROR_TEXT[m[0]] : null;
|
|
11
|
+
}
|
|
12
|
+
/** Maakt een Error; bij VR001/VR002 met de gewone tekst. */
|
|
13
|
+
export function stockError(msg) {
|
|
14
|
+
return new Error(stockErrorText(msg) ?? msg);
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"testronde-1119.check.d.ts","sourceRoot":"","sources":["../../src/lib/testronde-1119.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Controles 1.0.119: vervoerder uit Engine-antwoord, prijs € 0, bufferkarren.
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import { normalizeResolvedMany } from "./carrier-resolve.js";
|
|
4
|
+
import { zeroPriceRefusal } from "./zero-price.js";
|
|
5
|
+
import { combinedCartCount } from "./plan-coverage.js";
|
|
6
|
+
const m = normalizeResolvedMany([
|
|
7
|
+
{ order_id: "a", resultaat: { carrier_id: "c1", carrier_name: "Houtman", bron: "handmatig", reden: "Handmatig gekozen" } },
|
|
8
|
+
{ order_id: "b", resultaat: { carrier_id: "c2", carrier_name: "Testvervoerder", bron: "favoriet" } },
|
|
9
|
+
]);
|
|
10
|
+
assert.equal(m.get("a")?.state, "ok");
|
|
11
|
+
assert.equal(m.get("a")?.carrierName, "Houtman");
|
|
12
|
+
assert.equal(m.get("a")?.source, "handmatig");
|
|
13
|
+
assert.equal(m.get("b")?.badge, "favoriet");
|
|
14
|
+
assert.ok(zeroPriceRefusal([{ unit_price: 0 }], false));
|
|
15
|
+
assert.ok(zeroPriceRefusal([{ unit_price: null }], undefined));
|
|
16
|
+
assert.equal(zeroPriceRefusal([{ unit_price: 0 }], true), null);
|
|
17
|
+
assert.equal(zeroPriceRefusal([{ unit_price: 0.5 }], false), null);
|
|
18
|
+
const cov = (n) => ({ state: "ingedeeld", carts: [], pickRows: [], bufferCartCount: n, cartCount: 3, shared: true });
|
|
19
|
+
assert.equal(combinedCartCount([cov(3), cov(3), cov(3)]), 3);
|
|
20
|
+
console.log("testronde 1.0.119: ok");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useFloridayWriteMode.d.ts","sourceRoot":"","sources":["../../src/lib/useFloridayWriteMode.ts"],"names":[],"mappings":"AAIA,8EAA8E;AAC9E,wBAAgB,yBAAyB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAUzE"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { useQuery } from "@tanstack/react-query";
|
|
2
|
+
import { useServerFn } from "@tanstack/react-start";
|
|
3
|
+
import { getFloridayWriteMode } from "./floriday-write-mode.functions.js";
|
|
4
|
+
/** Eén gedeelde opvraag per scherm; alleen nodig als er een melding staat. */
|
|
5
|
+
export function useFloridayReadOnlyReason(enabled) {
|
|
6
|
+
const fn = useServerFn(getFloridayWriteMode);
|
|
7
|
+
const q = useQuery({
|
|
8
|
+
queryKey: ["floriday-write-mode"],
|
|
9
|
+
queryFn: () => fn(),
|
|
10
|
+
enabled,
|
|
11
|
+
staleTime: 60000,
|
|
12
|
+
retry: false,
|
|
13
|
+
});
|
|
14
|
+
return q.data?.reason ?? null;
|
|
15
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zero-price-write-mode.check.d.ts","sourceRoot":"","sources":["../../src/lib/zero-price-write-mode.check.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Draaien: bun src/lib/zero-price-write-mode.check.ts
|
|
2
|
+
import { zeroPriceRefusal } from "./zero-price.js";
|
|
3
|
+
import { readOnlyReason } from "./floriday-write-mode.js";
|
|
4
|
+
let fail = 0;
|
|
5
|
+
const eq = (name, got, want) => {
|
|
6
|
+
const ok = JSON.stringify(got) === JSON.stringify(want);
|
|
7
|
+
if (!ok)
|
|
8
|
+
fail++;
|
|
9
|
+
console.log(`${ok ? "ok " : "FOUT"} ${name}: ${JSON.stringify(got)}`);
|
|
10
|
+
};
|
|
11
|
+
eq("€ 0 zonder bevestiging geweigerd", zeroPriceRefusal([{ unit_price: 0 }], false) !== null, true);
|
|
12
|
+
eq("€ 0 met bevestiging toegestaan", zeroPriceRefusal([{ unit_price: 0 }], true), null);
|
|
13
|
+
eq("prijs > 0 zonder bevestiging toegestaan", zeroPriceRefusal([{ unit_price: 0.5 }], false), null);
|
|
14
|
+
eq("alleen-lezen toont reden", readOnlyReason({ read_only: true, reason: "Onderhoud" }), "Onderhoud");
|
|
15
|
+
eq("niet alleen-lezen: geen oorzaak", readOnlyReason({ read_only: false, reason: "x" }), null);
|
|
16
|
+
eq("onbekend antwoord: geen oorzaak", readOnlyReason(null), null);
|
|
17
|
+
if (fail)
|
|
18
|
+
process.exit(1);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const ZERO_PRICE_REFUSAL = "Er staan regels met prijs \u20AC 0. Bevestig eerst dat \u20AC 0 klopt, of vul de prijs in. Er is niets bewaard.";
|
|
2
|
+
export declare function zeroPriceLineCount(lines: {
|
|
3
|
+
unit_price?: number | null;
|
|
4
|
+
}[]): number;
|
|
5
|
+
/** Geeft de weigering terug, of null als aanmaken mag. */
|
|
6
|
+
export declare function zeroPriceRefusal(lines: {
|
|
7
|
+
unit_price?: number | null;
|
|
8
|
+
}[], confirmed: boolean | undefined): string | null;
|
|
9
|
+
//# sourceMappingURL=zero-price.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zero-price.d.ts","sourceRoot":"","sources":["../../src/lib/zero-price.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,kBAAkB,oHAC0E,CAAC;AAE1G,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,GAAG,MAAM,CAElF;AAED,0DAA0D;AAC1D,wBAAgB,gBAAgB,CAAC,KAAK,EAAE;IAAE,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,EAAE,SAAS,EAAE,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAEvH"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Prijs € 0 op een orderregel mag alleen na uitdrukkelijke bevestiging.
|
|
2
|
+
export const ZERO_PRICE_REFUSAL = "Er staan regels met prijs € 0. Bevestig eerst dat € 0 klopt, of vul de prijs in. Er is niets bewaard.";
|
|
3
|
+
export function zeroPriceLineCount(lines) {
|
|
4
|
+
return lines.filter((l) => !(Number(l.unit_price) > 0)).length;
|
|
5
|
+
}
|
|
6
|
+
/** Geeft de weigering terug, of null als aanmaken mag. */
|
|
7
|
+
export function zeroPriceRefusal(lines, confirmed) {
|
|
8
|
+
return zeroPriceLineCount(lines) > 0 && confirmed !== true ? ZERO_PRICE_REFUSAL : null;
|
|
9
|
+
}
|
package/package.json
CHANGED
package/schema/verkoop.sql
CHANGED
|
@@ -1620,6 +1620,7 @@ DECLARE
|
|
|
1620
1620
|
v_carrier_warning text := NULL;
|
|
1621
1621
|
v_carrier_fallback boolean := false;
|
|
1622
1622
|
v_carrier_err text;
|
|
1623
|
+
v_zero int := 0;
|
|
1623
1624
|
BEGIN
|
|
1624
1625
|
PERFORM public.verkoop_assert_caller('keten_genest'); -- verkoop-poort
|
|
1625
1626
|
-- Toegang: zie verkoop-poort hierboven.
|
|
@@ -1658,15 +1659,22 @@ BEGIN
|
|
|
1658
1659
|
BEGIN
|
|
1659
1660
|
v_qty := nullif(v_line->>'quantity_plants', '')::int;
|
|
1660
1661
|
v_qty_crates := nullif(v_line->>'quantity_crates', '')::int;
|
|
1661
|
-
v_price := (v_line->>'unit_price')::numeric;
|
|
1662
|
+
v_price := nullif(trim(coalesce(v_line->>'unit_price','')), '')::numeric;
|
|
1662
1663
|
v_ppc := nullif(greatest(coalesce(nullif(v_pack->>'plants_per_crate', '')::numeric, 0), 0), 0)::int;
|
|
1663
1664
|
v_cpl := nullif(greatest(coalesce(nullif(v_pack->>'crates_per_layer', '')::numeric, 0), 0), 0)::int;
|
|
1664
1665
|
v_lpc := nullif(greatest(coalesce(nullif(v_pack->>'layers_per_cart', '')::numeric, 0), 0), 0)::int;
|
|
1665
1666
|
EXCEPTION WHEN others THEN
|
|
1666
1667
|
RETURN jsonb_build_object('ok', false, 'reason', format('Regel %s: aantal, prijs of verpakking ongeldig.', v_n));
|
|
1667
1668
|
END;
|
|
1668
|
-
IF v_price IS NULL
|
|
1669
|
-
RETURN jsonb_build_object('ok', false, 'reason', format('Regel %s: prijs
|
|
1669
|
+
IF v_price IS NULL THEN
|
|
1670
|
+
RETURN jsonb_build_object('ok', false, 'reason', format('Regel %s: prijs ontbreekt.', v_n));
|
|
1671
|
+
ELSIF v_price < 0 THEN
|
|
1672
|
+
RETURN jsonb_build_object('ok', false, 'reason', format('Regel %s: prijs mag niet negatief zijn.', v_n));
|
|
1673
|
+
ELSIF v_price = 0 THEN
|
|
1674
|
+
IF coalesce(v_line->>'zero_price_confirmed', '') <> 'true' THEN
|
|
1675
|
+
RETURN jsonb_build_object('ok', false, 'reason', format('Regel %s: prijs € 0 moet je bevestigen (zero_price_confirmed).', v_n));
|
|
1676
|
+
END IF;
|
|
1677
|
+
v_zero := v_zero + 1;
|
|
1670
1678
|
END IF;
|
|
1671
1679
|
v_pj := NULL;
|
|
1672
1680
|
SELECT to_jsonb(p.*) INTO v_pj FROM public.products p WHERE p.id = nullif(v_line->>'product_id', '')::uuid;
|
|
@@ -1785,6 +1793,9 @@ BEGIN
|
|
|
1785
1793
|
IF p_own_transport THEN
|
|
1786
1794
|
v_cf := v_cf || jsonb_build_object('own_transport', jsonb_build_object('by', coalesce(p_accepted_by, p_customer_id::text), 'at', now()));
|
|
1787
1795
|
END IF;
|
|
1796
|
+
IF v_zero > 0 THEN
|
|
1797
|
+
v_cf := v_cf || jsonb_build_object('zero_price_confirmed', jsonb_build_object('by', coalesce(v_uid::text, 'server'), 'at', now(), 'lines', v_zero));
|
|
1798
|
+
END IF;
|
|
1788
1799
|
IF v_stickers <> '{}'::jsonb THEN v_cf := v_cf || jsonb_build_object('line_stickers', v_stickers); END IF;
|
|
1789
1800
|
|
|
1790
1801
|
INSERT INTO public.orders (customer_id, customer_name, order_date, delivery_date, is_reservation,
|