@flowselections/e-mail-installatie-techniek 1.0.8 → 1.5.1
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/README.md +72 -0
- package/dist-lib/components/WerkbonPostvakInstelling.d.ts +2 -0
- package/dist-lib/components/WerkbonPostvakInstelling.d.ts.map +1 -0
- package/dist-lib/components/WerkbonPostvakInstelling.js +81 -0
- package/dist-lib/components/mail/CompetentiePicker.d.ts +9 -0
- package/dist-lib/components/mail/CompetentiePicker.d.ts.map +1 -0
- package/dist-lib/components/mail/CompetentiePicker.js +49 -0
- package/dist-lib/components/mail/MailPane.d.ts.map +1 -1
- package/dist-lib/components/mail/MailPane.js +13 -9
- package/dist-lib/components/mail/WerkbonProposalDialog.d.ts.map +1 -1
- package/dist-lib/components/mail/WerkbonProposalDialog.js +32 -4
- package/dist-lib/components/mail/WerkbonProposalForm.d.ts +3 -1
- package/dist-lib/components/mail/WerkbonProposalForm.d.ts.map +1 -1
- package/dist-lib/components/mail/WerkbonProposalForm.js +48 -21
- package/dist-lib/hooks/useAutoAnalyse.d.ts.map +1 -1
- package/dist-lib/hooks/useAutoAnalyse.js +36 -25
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +4 -0
- package/dist-lib/integrations/supabase/previewAuthStorage.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/previewAuthStorage.js +2 -1
- package/dist-lib/integrations/supabase/types.d.ts +25490 -10759
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.js +1 -0
- package/dist-lib/lib/aantal-paginate.test.d.ts +2 -0
- package/dist-lib/lib/aantal-paginate.test.d.ts.map +1 -0
- package/dist-lib/lib/aantal-paginate.test.js +39 -0
- package/dist-lib/lib/aantal.d.ts +2 -0
- package/dist-lib/lib/aantal.d.ts.map +1 -0
- package/dist-lib/lib/aantal.js +10 -0
- package/dist-lib/lib/ai-material-match.d.ts +8 -0
- package/dist-lib/lib/ai-material-match.d.ts.map +1 -0
- package/dist-lib/lib/ai-material-match.js +14 -0
- package/dist-lib/lib/ai-material-match.test.d.ts +2 -0
- package/dist-lib/lib/ai-material-match.test.d.ts.map +1 -0
- package/dist-lib/lib/ai-material-match.test.js +21 -0
- package/dist-lib/lib/competenties.d.ts +12 -0
- package/dist-lib/lib/competenties.d.ts.map +1 -0
- package/dist-lib/lib/competenties.functions.d.ts +13 -0
- package/dist-lib/lib/competenties.functions.d.ts.map +1 -0
- package/dist-lib/lib/competenties.functions.js +22 -0
- package/dist-lib/lib/competenties.js +24 -0
- package/dist-lib/lib/competenties.test.d.ts +2 -0
- package/dist-lib/lib/competenties.test.d.ts.map +1 -0
- package/dist-lib/lib/competenties.test.js +15 -0
- package/dist-lib/lib/klant-match.d.ts +38 -0
- package/dist-lib/lib/klant-match.d.ts.map +1 -0
- package/dist-lib/lib/klant-match.js +88 -0
- package/dist-lib/lib/klant-match.test.d.ts +2 -0
- package/dist-lib/lib/klant-match.test.d.ts.map +1 -0
- package/dist-lib/lib/klant-match.test.js +76 -0
- package/dist-lib/lib/klanten.functions.d.ts.map +1 -1
- package/dist-lib/lib/klanten.functions.js +44 -51
- package/dist-lib/lib/paginate.d.ts +10 -0
- package/dist-lib/lib/paginate.d.ts.map +1 -0
- package/dist-lib/lib/paginate.js +18 -0
- package/dist-lib/lib/rekenregels-gelijk.test.d.ts +2 -0
- package/dist-lib/lib/rekenregels-gelijk.test.d.ts.map +1 -0
- package/dist-lib/lib/rekenregels-gelijk.test.js +63 -0
- package/dist-lib/lib/rekenregels.d.ts +44 -0
- package/dist-lib/lib/rekenregels.d.ts.map +1 -0
- package/dist-lib/lib/rekenregels.js +159 -0
- package/dist-lib/lib/rekenregels.test.d.ts +2 -0
- package/dist-lib/lib/rekenregels.test.d.ts.map +1 -0
- package/dist-lib/lib/rekenregels.test.js +74 -0
- package/dist-lib/lib/werkbon-approve-rows.d.ts +64 -0
- package/dist-lib/lib/werkbon-approve-rows.d.ts.map +1 -0
- package/dist-lib/lib/werkbon-approve-rows.js +56 -0
- package/dist-lib/lib/werkbon-approve-rows.test.d.ts +2 -0
- package/dist-lib/lib/werkbon-approve-rows.test.d.ts.map +1 -0
- package/dist-lib/lib/werkbon-approve-rows.test.js +103 -0
- package/dist-lib/lib/werkbon-postvak-settings.d.ts +16 -0
- package/dist-lib/lib/werkbon-postvak-settings.d.ts.map +1 -0
- package/dist-lib/lib/werkbon-postvak-settings.functions.d.ts +14 -0
- package/dist-lib/lib/werkbon-postvak-settings.functions.d.ts.map +1 -0
- package/dist-lib/lib/werkbon-postvak-settings.functions.js +24 -0
- package/dist-lib/lib/werkbon-postvak-settings.js +61 -0
- package/dist-lib/lib/werkbon-proposals.functions.d.ts +34 -0
- package/dist-lib/lib/werkbon-proposals.functions.d.ts.map +1 -1
- package/dist-lib/lib/werkbon-proposals.functions.js +150 -86
- package/package.json +131 -7
- package/supabase/werkbon-postvak-installatie.sql +761 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rekenregels-gelijk.test.d.ts","sourceRoot":"","sources":["../../src/lib/rekenregels-gelijk.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { pakketBedrag, parseBedragNaarCenten } from "./rekenregels";
|
|
3
|
+
// Kopie van de parser vóór 1.3.0, alleen voor de gelijkheidstest.
|
|
4
|
+
function oudeParser(invoer, negOk = false) {
|
|
5
|
+
let s = invoer.trim().replace(/\s|€/g, "");
|
|
6
|
+
if (s === "")
|
|
7
|
+
return null;
|
|
8
|
+
let neg = false;
|
|
9
|
+
if (s.startsWith("-")) {
|
|
10
|
+
neg = true;
|
|
11
|
+
s = s.slice(1);
|
|
12
|
+
}
|
|
13
|
+
if (!/^[0-9.,]+$/.test(s) || !/[0-9]/.test(s))
|
|
14
|
+
return null;
|
|
15
|
+
const last = Math.max(s.lastIndexOf(","), s.lastIndexOf("."));
|
|
16
|
+
let heel = s;
|
|
17
|
+
let dec = "";
|
|
18
|
+
if (last >= 0) {
|
|
19
|
+
const achter = s.slice(last + 1);
|
|
20
|
+
if (achter.length >= 1 && achter.length <= 2 && /^[0-9]+$/.test(achter)) {
|
|
21
|
+
heel = s.slice(0, last);
|
|
22
|
+
dec = achter;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
heel = heel.replace(/[.,]/g, "");
|
|
26
|
+
if (heel === "" && dec === "")
|
|
27
|
+
return null;
|
|
28
|
+
const cent = Number(heel || "0") * 100 + Number(dec.padEnd(2, "0") || "0");
|
|
29
|
+
if (neg && cent !== 0 && !negOk)
|
|
30
|
+
return null;
|
|
31
|
+
return neg ? -cent : cent;
|
|
32
|
+
}
|
|
33
|
+
describe("parseBedragNaarCenten — gelijke regels voor alle modules", () => {
|
|
34
|
+
it.each([
|
|
35
|
+
["€ 12,50", 1250],
|
|
36
|
+
["12,50 €", 1250],
|
|
37
|
+
["€12,50", 1250],
|
|
38
|
+
["12,50\u00A0€", 1250],
|
|
39
|
+
["\u00A012,50", 1250],
|
|
40
|
+
["+5", 500],
|
|
41
|
+
["-0", 0],
|
|
42
|
+
["-0,00", 0],
|
|
43
|
+
])("%s → %i", (inp, out) => expect(parseBedragNaarCenten(inp)).toBe(out));
|
|
44
|
+
it.each(["12,,50", "12..50", "1.2.3", "1.23,45"])("%s → null", (inp) => expect(parseBedragNaarCenten(inp)).toBeNull());
|
|
45
|
+
it("blok B-voorbeelden geven hetzelfde als de oude parser", () => {
|
|
46
|
+
const voorbeelden = [
|
|
47
|
+
"12,50", "12.50", "1.250,00", "1,250.00", "1250", "1.250", "", "abc", "-5",
|
|
48
|
+
"12.5", "3", "0,99", "250", "1.000.000", "0,5", "€ 1.250,00",
|
|
49
|
+
];
|
|
50
|
+
for (const v of voorbeelden)
|
|
51
|
+
expect(parseBedragNaarCenten(v)).toBe(oudeParser(v));
|
|
52
|
+
expect(parseBedragNaarCenten("-5", { negatiefToegestaan: true })).toBe(oudeParser("-5", true));
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
describe("pakketBedrag — kwartierMinuten leeg of <= 0 gebruikt 15", () => {
|
|
56
|
+
const basis = { soort: "basis", aantal: 1, extraMinuten: 31, eenheidsprijsCent: 9500, kwartierprijsCent: 1500 };
|
|
57
|
+
const met15 = pakketBedrag({ ...basis, kwartierMinuten: 15 });
|
|
58
|
+
it.each([0, -5, Number.NaN, undefined])("kwartierMinuten %s", (km) => expect(pakketBedrag({ ...basis, kwartierMinuten: km })).toEqual(met15));
|
|
59
|
+
it("geldige waarde blijft ongewijzigd", () => {
|
|
60
|
+
expect(pakketBedrag({ ...basis, kwartierMinuten: 10 }).kwartieren).toBe(3);
|
|
61
|
+
expect(met15.bedragCent).toBe(9500 + 2 * 1500);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export declare function parseBedragNaarCenten(invoer: string | number, opties?: {
|
|
2
|
+
negatiefToegestaan?: boolean;
|
|
3
|
+
}): number | null;
|
|
4
|
+
export declare function lokaleDatum(tijdstip: string | Date, tijdzone: string): string;
|
|
5
|
+
export declare function vandaagLokaal(tijdzone: string, nu?: Date): string;
|
|
6
|
+
export declare function plusDagen(datum: string, dagen: number): string;
|
|
7
|
+
export declare function maandGrenzen(jaar: number, maand: number, tijdzone: string): {
|
|
8
|
+
van: string;
|
|
9
|
+
tot: string;
|
|
10
|
+
};
|
|
11
|
+
export declare function pakketBedrag(i: {
|
|
12
|
+
soort: string;
|
|
13
|
+
aantal: number;
|
|
14
|
+
extraMinuten: number;
|
|
15
|
+
eenheidsprijsCent: number;
|
|
16
|
+
kwartierprijsCent: number;
|
|
17
|
+
kwartierMinuten: number;
|
|
18
|
+
}): {
|
|
19
|
+
aantal: number;
|
|
20
|
+
extraMinuten: number;
|
|
21
|
+
kwartieren: number;
|
|
22
|
+
bedragCent: number;
|
|
23
|
+
arbeidMinuten: number;
|
|
24
|
+
};
|
|
25
|
+
export declare function reisPakketAantal(i: {
|
|
26
|
+
minutenHeenEnTerug: number;
|
|
27
|
+
pakketMinuten: number;
|
|
28
|
+
restgrensMinuten?: number;
|
|
29
|
+
minimumBijRit?: number;
|
|
30
|
+
}): number;
|
|
31
|
+
export declare function rondMinutenAf(minuten: number, stapMinuten?: number, omhoogVanafMinuten?: number): number;
|
|
32
|
+
export declare function verdeelContracturen(uren: number, dagen: number[], slotMinuten: number): {
|
|
33
|
+
dag: number;
|
|
34
|
+
slots: number;
|
|
35
|
+
}[];
|
|
36
|
+
export declare function mandaatBelegdCent(i: {
|
|
37
|
+
pakketten: Array<{
|
|
38
|
+
bedragCent: number;
|
|
39
|
+
}>;
|
|
40
|
+
materialenCent: number;
|
|
41
|
+
extraKostenCent: number;
|
|
42
|
+
}): number;
|
|
43
|
+
export declare function mandaatStatus(belegdCent: number, budgetCent: number | null | undefined, waarschuwingsgrens?: number): "geen mandaat" | "over" | "waarschuwing" | "ok";
|
|
44
|
+
//# sourceMappingURL=rekenregels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rekenregels.d.ts","sourceRoot":"","sources":["../../src/lib/rekenregels.ts"],"names":[],"mappings":"AAKA,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,MAAM,CAAC,EAAE;IAAE,kBAAkB,CAAC,EAAE,OAAO,CAAA;CAAE,GACxC,MAAM,GAAG,IAAI,CA4Cf;AAaD,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,CAI7E;AAED,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,GAAE,IAAiB,GAAG,MAAM,CAE7E;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAI9D;AAoBD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAIxG;AAGD,wBAAgB,YAAY,CAAC,CAAC,EAAE;IAC9B,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IACpD,iBAAiB,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAC;CAC/E;;;;;;EAUA;AAGD,wBAAgB,gBAAgB,CAAC,CAAC,EAAE;IAClC,kBAAkB,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAClD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACnD,GAAG,MAAM,CAOT;AAGD,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,SAAK,EAAE,kBAAkB,SAAI,GAAG,MAAM,CAK/F;AAGD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,WAAW,EAAE,MAAM;;;IAMrF;AAGD,wBAAgB,iBAAiB,CAAC,CAAC,EAAE;IACnC,SAAS,EAAE,KAAK,CAAC;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAAC,cAAc,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,MAAM,CAAC;CAC3F,GAAG,MAAM,CAGT;AAED,wBAAgB,aAAa,CAC3B,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,kBAAkB,SAAM,GAClF,cAAc,GAAG,MAAM,GAAG,cAAc,GAAG,IAAI,CAMjD"}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// Gedeelde rekenregels (blok B). In deze module worden alleen
|
|
2
|
+
// parseBedragNaarCenten en vandaagLokaal gebruikt; de rest staat er voor
|
|
3
|
+
// gedeeld gebruik en vervangt geen bestaande berekeningen.
|
|
4
|
+
// 1. Bedrag → gehele centen. null bij leeg/ongeldig/negatief (tenzij toegestaan).
|
|
5
|
+
export function parseBedragNaarCenten(invoer, opties) {
|
|
6
|
+
const negOk = opties?.negatiefToegestaan === true;
|
|
7
|
+
if (typeof invoer === "number") {
|
|
8
|
+
if (!Number.isFinite(invoer))
|
|
9
|
+
return null;
|
|
10
|
+
if (invoer < 0 && !negOk)
|
|
11
|
+
return null;
|
|
12
|
+
return Math.round(invoer * 100);
|
|
13
|
+
}
|
|
14
|
+
if (typeof invoer !== "string")
|
|
15
|
+
return null;
|
|
16
|
+
let s = invoer.trim().replace(/[\s\u00A0\u202F€]/g, "");
|
|
17
|
+
if (s === "")
|
|
18
|
+
return null;
|
|
19
|
+
let neg = false;
|
|
20
|
+
if (s.startsWith("-")) {
|
|
21
|
+
neg = true;
|
|
22
|
+
s = s.slice(1);
|
|
23
|
+
}
|
|
24
|
+
else if (s.startsWith("+")) {
|
|
25
|
+
s = s.slice(1);
|
|
26
|
+
}
|
|
27
|
+
if (!/^[0-9.,]+$/.test(s) || !/[0-9]/.test(s))
|
|
28
|
+
return null;
|
|
29
|
+
// Twee scheidingstekens naast elkaar is ongeldig ("12,,50", "12..50").
|
|
30
|
+
if (/[.,]{2}/.test(s))
|
|
31
|
+
return null;
|
|
32
|
+
// Duizendtalgroepen: alles vóór het decimaalteken moet 1-3 cijfers + groepen van 3 zijn.
|
|
33
|
+
{
|
|
34
|
+
const l = Math.max(s.lastIndexOf(","), s.lastIndexOf("."));
|
|
35
|
+
const na = l >= 0 ? s.slice(l + 1) : "";
|
|
36
|
+
const isDec = l >= 0 && na.length >= 1 && na.length <= 2;
|
|
37
|
+
const voor = isDec ? s.slice(0, l) : s;
|
|
38
|
+
if (/[.,]/.test(voor) && !/^[0-9]{1,3}([.,][0-9]{3})+$/.test(voor))
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
const last = Math.max(s.lastIndexOf(","), s.lastIndexOf("."));
|
|
42
|
+
let heel = s;
|
|
43
|
+
let dec = "";
|
|
44
|
+
if (last >= 0) {
|
|
45
|
+
const achter = s.slice(last + 1);
|
|
46
|
+
if (achter.length >= 1 && achter.length <= 2 && /^[0-9]+$/.test(achter)) {
|
|
47
|
+
heel = s.slice(0, last);
|
|
48
|
+
dec = achter;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
heel = heel.replace(/[.,]/g, "");
|
|
52
|
+
if (heel === "" && dec === "")
|
|
53
|
+
return null;
|
|
54
|
+
const cent = Number(heel || "0") * 100 + Number(dec.padEnd(2, "0") || "0");
|
|
55
|
+
if (!Number.isFinite(cent))
|
|
56
|
+
return null;
|
|
57
|
+
if (neg && cent !== 0 && !negOk)
|
|
58
|
+
return null;
|
|
59
|
+
return neg && cent !== 0 ? -cent : cent;
|
|
60
|
+
}
|
|
61
|
+
// 2. Datums
|
|
62
|
+
function delen(d, tijdzone) {
|
|
63
|
+
const f = new Intl.DateTimeFormat("en-CA", {
|
|
64
|
+
timeZone: tijdzone, year: "numeric", month: "2-digit", day: "2-digit",
|
|
65
|
+
hour: "2-digit", minute: "2-digit", second: "2-digit", hourCycle: "h23",
|
|
66
|
+
});
|
|
67
|
+
const p = {};
|
|
68
|
+
for (const x of f.formatToParts(d))
|
|
69
|
+
p[x.type] = x.value;
|
|
70
|
+
return p;
|
|
71
|
+
}
|
|
72
|
+
export function lokaleDatum(tijdstip, tijdzone) {
|
|
73
|
+
const d = typeof tijdstip === "string" ? new Date(tijdstip) : tijdstip;
|
|
74
|
+
const p = delen(d, tijdzone);
|
|
75
|
+
return `${p.year}-${p.month}-${p.day}`;
|
|
76
|
+
}
|
|
77
|
+
export function vandaagLokaal(tijdzone, nu = new Date()) {
|
|
78
|
+
return lokaleDatum(nu, tijdzone);
|
|
79
|
+
}
|
|
80
|
+
export function plusDagen(datum, dagen) {
|
|
81
|
+
const [y, m, d] = datum.split("-").map(Number);
|
|
82
|
+
const t = new Date(Date.UTC(y, m - 1, d + dagen));
|
|
83
|
+
return t.toISOString().slice(0, 10);
|
|
84
|
+
}
|
|
85
|
+
function offsetMinuten(utcMs, tijdzone) {
|
|
86
|
+
const p = delen(new Date(utcMs), tijdzone);
|
|
87
|
+
const alsUtc = Date.UTC(+p.year, +p.month - 1, +p.day, +p.hour, +p.minute, +p.second);
|
|
88
|
+
return Math.round((alsUtc - utcMs) / 60000);
|
|
89
|
+
}
|
|
90
|
+
function middernachtIso(jaar, maand, tijdzone) {
|
|
91
|
+
const basis = Date.UTC(jaar, maand - 1, 1);
|
|
92
|
+
let off = offsetMinuten(basis, tijdzone);
|
|
93
|
+
off = offsetMinuten(basis - off * 60000, tijdzone);
|
|
94
|
+
const sign = off >= 0 ? "+" : "-";
|
|
95
|
+
const a = Math.abs(off);
|
|
96
|
+
const hh = String(Math.floor(a / 60)).padStart(2, "0");
|
|
97
|
+
const mm = String(a % 60).padStart(2, "0");
|
|
98
|
+
const dt = new Date(basis).toISOString().slice(0, 10);
|
|
99
|
+
return `${dt}T00:00:00${sign}${hh}:${mm}`;
|
|
100
|
+
}
|
|
101
|
+
export function maandGrenzen(jaar, maand, tijdzone) {
|
|
102
|
+
const volgJaar = maand === 12 ? jaar + 1 : jaar;
|
|
103
|
+
const volgMaand = maand === 12 ? 1 : maand + 1;
|
|
104
|
+
return { van: middernachtIso(jaar, maand, tijdzone), tot: middernachtIso(volgJaar, volgMaand, tijdzone) };
|
|
105
|
+
}
|
|
106
|
+
// 3. Pakketbedrag
|
|
107
|
+
export function pakketBedrag(i) {
|
|
108
|
+
const basis = i.soort === "basis";
|
|
109
|
+
const aantal = basis ? 1 : Math.max(1, Number(i.aantal) || 0);
|
|
110
|
+
const km = Number(i.kwartierMinuten);
|
|
111
|
+
const kwartierMinuten = Number.isFinite(km) && km > 0 ? km : 15;
|
|
112
|
+
const kwartieren = basis
|
|
113
|
+
? Math.floor(Math.max(0, i.extraMinuten) / kwartierMinuten) : 0;
|
|
114
|
+
const extraMinuten = kwartieren * kwartierMinuten;
|
|
115
|
+
const bedragCent = Math.round(aantal * i.eenheidsprijsCent) + kwartieren * i.kwartierprijsCent;
|
|
116
|
+
return { aantal, extraMinuten, kwartieren, bedragCent, arbeidMinuten: extraMinuten };
|
|
117
|
+
}
|
|
118
|
+
// 4. Reispakketten
|
|
119
|
+
export function reisPakketAantal(i) {
|
|
120
|
+
const rg = i.restgrensMinuten ?? 6;
|
|
121
|
+
const min = i.minimumBijRit ?? 1;
|
|
122
|
+
if (i.pakketMinuten <= 0 || i.minutenHeenEnTerug <= 0)
|
|
123
|
+
return 0;
|
|
124
|
+
const volle = Math.floor(i.minutenHeenEnTerug / i.pakketMinuten);
|
|
125
|
+
const rest = i.minutenHeenEnTerug % i.pakketMinuten;
|
|
126
|
+
return Math.max(min, volle + (rest >= rg ? 1 : 0));
|
|
127
|
+
}
|
|
128
|
+
// 5. Afronden van het totaal
|
|
129
|
+
export function rondMinutenAf(minuten, stapMinuten = 15, omhoogVanafMinuten = 8) {
|
|
130
|
+
if (stapMinuten <= 0)
|
|
131
|
+
return minuten;
|
|
132
|
+
const volle = Math.floor(minuten / stapMinuten);
|
|
133
|
+
const rest = minuten - volle * stapMinuten;
|
|
134
|
+
return (volle + (rest >= omhoogVanafMinuten ? 1 : 0)) * stapMinuten;
|
|
135
|
+
}
|
|
136
|
+
// 6. Contracturen verdelen
|
|
137
|
+
export function verdeelContracturen(uren, dagen, slotMinuten) {
|
|
138
|
+
if (!dagen.length || slotMinuten <= 0)
|
|
139
|
+
return [];
|
|
140
|
+
const totaal = Math.round((uren * 60) / slotMinuten);
|
|
141
|
+
const basis = Math.floor(totaal / dagen.length);
|
|
142
|
+
const rest = totaal % dagen.length;
|
|
143
|
+
return dagen.map((dag, i) => ({ dag, slots: basis + (i < rest ? 1 : 0) }));
|
|
144
|
+
}
|
|
145
|
+
// 7. Mandaat
|
|
146
|
+
export function mandaatBelegdCent(i) {
|
|
147
|
+
const p = (Array.isArray(i.pakketten) ? i.pakketten : []).reduce((s, x) => s + (x.bedragCent || 0), 0);
|
|
148
|
+
return p + (i.materialenCent || 0) + (i.extraKostenCent || 0);
|
|
149
|
+
}
|
|
150
|
+
export function mandaatStatus(belegdCent, budgetCent, waarschuwingsgrens = 0.8) {
|
|
151
|
+
if (!budgetCent)
|
|
152
|
+
return "geen mandaat";
|
|
153
|
+
const r = belegdCent / budgetCent;
|
|
154
|
+
if (r > 1)
|
|
155
|
+
return "over";
|
|
156
|
+
if (r >= waarschuwingsgrens)
|
|
157
|
+
return "waarschuwing";
|
|
158
|
+
return "ok";
|
|
159
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rekenregels.test.d.ts","sourceRoot":"","sources":["../../src/lib/rekenregels.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { maandGrenzen, mandaatBelegdCent, mandaatStatus, pakketBedrag, parseBedragNaarCenten, plusDagen, reisPakketAantal, rondMinutenAf, vandaagLokaal, verdeelContracturen, } from "./rekenregels";
|
|
3
|
+
describe("parseBedragNaarCenten", () => {
|
|
4
|
+
it.each([
|
|
5
|
+
["12,50", 1250],
|
|
6
|
+
["12.50", 1250],
|
|
7
|
+
["1.250,00", 125000],
|
|
8
|
+
["1,250.00", 125000],
|
|
9
|
+
["1250", 125000],
|
|
10
|
+
["1.250", 125000],
|
|
11
|
+
])("%s → %i", (inp, out) => expect(parseBedragNaarCenten(inp)).toBe(out));
|
|
12
|
+
it("leeg, ongeldig of negatief → null", () => {
|
|
13
|
+
expect(parseBedragNaarCenten("")).toBeNull();
|
|
14
|
+
expect(parseBedragNaarCenten("abc")).toBeNull();
|
|
15
|
+
expect(parseBedragNaarCenten("-5")).toBeNull();
|
|
16
|
+
expect(parseBedragNaarCenten("-5", { negatiefToegestaan: true })).toBe(-500);
|
|
17
|
+
});
|
|
18
|
+
it("geeft voor gewone invoer hetzelfde als de oude parser", () => {
|
|
19
|
+
const oud = (t) => Math.round(Number(t.replace(",", ".")) * 100);
|
|
20
|
+
for (const t of ["12,50", "12.5", "3", "0,99", "250"])
|
|
21
|
+
expect(parseBedragNaarCenten(t)).toBe(oud(t));
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
describe("datums", () => {
|
|
25
|
+
it("plusDagen", () => expect(plusDagen("2026-03-20", 10)).toBe("2026-03-30"));
|
|
26
|
+
it("vandaagLokaal om 00:30 Amsterdam", () => {
|
|
27
|
+
// 04-11-2026 00:30 lokale tijd = 03-11-2026 23:30 UTC
|
|
28
|
+
expect(vandaagLokaal("Europe/Amsterdam", new Date("2026-11-03T23:30:00Z"))).toBe("2026-11-04");
|
|
29
|
+
});
|
|
30
|
+
it("maandGrenzen met offset", () => {
|
|
31
|
+
expect(maandGrenzen(2026, 3, "Europe/Amsterdam")).toEqual({
|
|
32
|
+
van: "2026-03-01T00:00:00+01:00",
|
|
33
|
+
tot: "2026-04-01T00:00:00+02:00",
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
describe("pakketBedrag", () => {
|
|
38
|
+
it("voorbeeld basis", () => {
|
|
39
|
+
const r = pakketBedrag({
|
|
40
|
+
soort: "basis", aantal: 2, extraMinuten: 20,
|
|
41
|
+
eenheidsprijsCent: 9500, kwartierprijsCent: 1500, kwartierMinuten: 15,
|
|
42
|
+
});
|
|
43
|
+
expect(r.aantal).toBe(1);
|
|
44
|
+
expect(r.extraMinuten).toBe(15);
|
|
45
|
+
expect(r.bedragCent).toBe(11000);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe("reisPakketAantal", () => {
|
|
49
|
+
it.each([[6, 1], [20, 1], [37, 3], [38, 3], [74, 5]])("%i min → %i", (m, n) => expect(reisPakketAantal({ minutenHeenEnTerug: m, pakketMinuten: 15 })).toBe(n));
|
|
50
|
+
it("0 bij geen rit", () => expect(reisPakketAantal({ minutenHeenEnTerug: 0, pakketMinuten: 15 })).toBe(0));
|
|
51
|
+
});
|
|
52
|
+
describe("rondMinutenAf", () => {
|
|
53
|
+
it("grenzen bij stap 15 en omhoog vanaf 8", () => {
|
|
54
|
+
expect(rondMinutenAf(7)).toBe(0);
|
|
55
|
+
expect(rondMinutenAf(8)).toBe(15);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe("verdeelContracturen", () => {
|
|
59
|
+
it("38 uur ma–vr in slots van 30 min", () => {
|
|
60
|
+
const r = verdeelContracturen(38, [1, 2, 3, 4, 5], 30);
|
|
61
|
+
expect(r.map((x) => x.slots)).toEqual([16, 15, 15, 15, 15]);
|
|
62
|
+
expect(r.reduce((s, x) => s + x.slots, 0)).toBe(76);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
describe("mandaat", () => {
|
|
66
|
+
it("som en status", () => {
|
|
67
|
+
const b = mandaatBelegdCent({ pakketten: [{ bedragCent: 11000 }], materialenCent: 500, extraKostenCent: 0 });
|
|
68
|
+
expect(b).toBe(11500);
|
|
69
|
+
expect(mandaatStatus(b, 0)).toBe("geen mandaat");
|
|
70
|
+
expect(mandaatStatus(b, 10000)).toBe("over");
|
|
71
|
+
expect(mandaatStatus(8000, 10000)).toBe("waarschuwing");
|
|
72
|
+
expect(mandaatStatus(7000, 10000)).toBe("ok");
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface ApproveSourceLine {
|
|
2
|
+
line_type: string;
|
|
3
|
+
package_id?: string | null;
|
|
4
|
+
quantity?: number | null;
|
|
5
|
+
extra_quarters?: number | null;
|
|
6
|
+
description?: string | null;
|
|
7
|
+
article_number?: string | null;
|
|
8
|
+
unit?: string | null;
|
|
9
|
+
}
|
|
10
|
+
export interface ApproveSourceProposal {
|
|
11
|
+
id: string;
|
|
12
|
+
event_id: string;
|
|
13
|
+
customer_id: string | null;
|
|
14
|
+
work_address: string | null;
|
|
15
|
+
room_number: string | null;
|
|
16
|
+
complaint_description: string | null;
|
|
17
|
+
technician_task_description: string | null;
|
|
18
|
+
deadline_date: string | null;
|
|
19
|
+
estimated_duration_minutes: number | null;
|
|
20
|
+
estimated_days: number | null;
|
|
21
|
+
technician_id: string | null;
|
|
22
|
+
externe_referentie: string | null;
|
|
23
|
+
budget_mandate_cents: number | null;
|
|
24
|
+
internal_notes: string | null;
|
|
25
|
+
lines: ApproveSourceLine[];
|
|
26
|
+
}
|
|
27
|
+
export declare function buildWerkbonRow(p: ApproveSourceProposal): {
|
|
28
|
+
customer_id: string | null;
|
|
29
|
+
work_address: string | null;
|
|
30
|
+
room_number: string | null;
|
|
31
|
+
complaint_description: string | null;
|
|
32
|
+
technician_task_description: string | null;
|
|
33
|
+
deadline_date: string | null;
|
|
34
|
+
estimated_duration_minutes: number | null;
|
|
35
|
+
estimated_days: number | null;
|
|
36
|
+
technician_id: string | null;
|
|
37
|
+
assigned_user_id: string | null;
|
|
38
|
+
externe_referentie: string | null;
|
|
39
|
+
budget_mandate_cents: number;
|
|
40
|
+
internal_notes: string | null;
|
|
41
|
+
status: string;
|
|
42
|
+
planning_status: string;
|
|
43
|
+
source_type: string;
|
|
44
|
+
source_email_meta: {
|
|
45
|
+
event_id: string;
|
|
46
|
+
proposal_id: string;
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
export declare function buildPackageRows(lines: ApproveSourceLine[]): {
|
|
50
|
+
package_id: string;
|
|
51
|
+
quantity: number;
|
|
52
|
+
extra_minutes: number;
|
|
53
|
+
}[];
|
|
54
|
+
export declare function buildMaterialRows(lines: ApproveSourceLine[]): {
|
|
55
|
+
description: string;
|
|
56
|
+
article_number: string | null;
|
|
57
|
+
quantity: number;
|
|
58
|
+
unit: string;
|
|
59
|
+
source: string;
|
|
60
|
+
}[];
|
|
61
|
+
export declare function isValidEmail(value: unknown): boolean;
|
|
62
|
+
export declare const CONFLICT_MESSAGE = "Dit is intussen door iemand anders gewijzigd. Ververs de pagina.";
|
|
63
|
+
export declare function isConflict(expected: string | null | undefined, current: string | null | undefined): boolean;
|
|
64
|
+
//# sourceMappingURL=werkbon-approve-rows.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"werkbon-approve-rows.d.ts","sourceRoot":"","sources":["../../src/lib/werkbon-approve-rows.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,2BAA2B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3C,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,0BAA0B,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,KAAK,EAAE,iBAAiB,EAAE,CAAC;CAC5B;AAED,wBAAgB,eAAe,CAAC,CAAC,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;;EAoBvD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,EAAE;gBAKzB,MAAM;;;IAIvC;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,EAAE;;;;;;IAW3D;AAID,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAEpD;AAED,eAAO,MAAM,gBAAgB,qEAAqE,CAAC;AAEnG,wBAAgB,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAG3G"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
// Pure opbouw van de rijen die bij "Werkbon aanmaken" worden geschreven.
|
|
2
|
+
// Exact dezelfde kolommen en waarden als de eerdere losse inserts; de RPC
|
|
3
|
+
// werkbon_proposal_approve schrijft ze in één transactie weg.
|
|
4
|
+
export function buildWerkbonRow(p) {
|
|
5
|
+
return {
|
|
6
|
+
customer_id: p.customer_id,
|
|
7
|
+
work_address: p.work_address,
|
|
8
|
+
room_number: p.room_number,
|
|
9
|
+
complaint_description: p.complaint_description,
|
|
10
|
+
technician_task_description: p.technician_task_description,
|
|
11
|
+
deadline_date: p.deadline_date,
|
|
12
|
+
estimated_duration_minutes: p.estimated_duration_minutes,
|
|
13
|
+
estimated_days: p.estimated_days,
|
|
14
|
+
technician_id: p.technician_id,
|
|
15
|
+
assigned_user_id: p.technician_id,
|
|
16
|
+
externe_referentie: p.externe_referentie,
|
|
17
|
+
budget_mandate_cents: p.budget_mandate_cents ?? 0,
|
|
18
|
+
internal_notes: p.internal_notes,
|
|
19
|
+
status: p.technician_id ? "planned_visible" : "unassigned",
|
|
20
|
+
planning_status: "unscheduled",
|
|
21
|
+
source_type: "email",
|
|
22
|
+
source_email_meta: { event_id: p.event_id, proposal_id: p.id },
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export function buildPackageRows(lines) {
|
|
26
|
+
const list = Array.isArray(lines) ? lines : [];
|
|
27
|
+
return list
|
|
28
|
+
.filter((l) => l.line_type === "package" && l.package_id)
|
|
29
|
+
.map((l) => ({
|
|
30
|
+
package_id: l.package_id,
|
|
31
|
+
quantity: l.quantity ?? 1,
|
|
32
|
+
extra_minutes: Math.max(0, Math.round(Number(l.extra_quarters ?? 0))) * 15,
|
|
33
|
+
}));
|
|
34
|
+
}
|
|
35
|
+
export function buildMaterialRows(lines) {
|
|
36
|
+
const list = Array.isArray(lines) ? lines : [];
|
|
37
|
+
return list
|
|
38
|
+
.filter((l) => l.line_type === "material" && (l.description || l.article_number))
|
|
39
|
+
.map((l) => ({
|
|
40
|
+
description: l.description || l.article_number || "Materiaal",
|
|
41
|
+
article_number: l.article_number || null,
|
|
42
|
+
quantity: l.quantity ?? 1,
|
|
43
|
+
unit: l.unit || "st",
|
|
44
|
+
source: "email",
|
|
45
|
+
}));
|
|
46
|
+
}
|
|
47
|
+
const EMAIL_RE = /^[^\s@<>(),;:"]+@[^\s@<>(),;:"]+\.[a-z]{2,}$/i;
|
|
48
|
+
export function isValidEmail(value) {
|
|
49
|
+
return typeof value === "string" && EMAIL_RE.test(value.trim());
|
|
50
|
+
}
|
|
51
|
+
export const CONFLICT_MESSAGE = "Dit is intussen door iemand anders gewijzigd. Ververs de pagina.";
|
|
52
|
+
export function isConflict(expected, current) {
|
|
53
|
+
if (!expected || !current)
|
|
54
|
+
return false;
|
|
55
|
+
return new Date(expected).getTime() !== new Date(current).getTime();
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"werkbon-approve-rows.test.d.ts","sourceRoot":"","sources":["../../src/lib/werkbon-approve-rows.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { buildWerkbonRow, buildPackageRows, buildMaterialRows, isValidEmail, isConflict, } from "./werkbon-approve-rows";
|
|
3
|
+
// Kopie van de oude inline-opbouw uit approveWerkbonProposal (vóór 1.1.0).
|
|
4
|
+
function legacy(current) {
|
|
5
|
+
const werkbon = {
|
|
6
|
+
customer_id: current.customer_id,
|
|
7
|
+
work_address: current.work_address,
|
|
8
|
+
room_number: current.room_number,
|
|
9
|
+
complaint_description: current.complaint_description,
|
|
10
|
+
technician_task_description: current.technician_task_description,
|
|
11
|
+
deadline_date: current.deadline_date,
|
|
12
|
+
estimated_duration_minutes: current.estimated_duration_minutes,
|
|
13
|
+
estimated_days: current.estimated_days,
|
|
14
|
+
technician_id: current.technician_id,
|
|
15
|
+
assigned_user_id: current.technician_id,
|
|
16
|
+
externe_referentie: current.externe_referentie,
|
|
17
|
+
budget_mandate_cents: current.budget_mandate_cents ?? 0,
|
|
18
|
+
internal_notes: current.internal_notes,
|
|
19
|
+
status: current.technician_id ? "planned_visible" : "unassigned",
|
|
20
|
+
planning_status: "unscheduled",
|
|
21
|
+
source_type: "email",
|
|
22
|
+
source_email_meta: { event_id: current.event_id, proposal_id: current.id },
|
|
23
|
+
};
|
|
24
|
+
const packages = current.lines
|
|
25
|
+
.filter((l) => l.line_type === "package" && l.package_id)
|
|
26
|
+
.map((l) => ({
|
|
27
|
+
package_id: l.package_id,
|
|
28
|
+
quantity: l.quantity ?? 1,
|
|
29
|
+
extra_minutes: Math.max(0, Math.round(Number(l.extra_quarters ?? 0))) * 15,
|
|
30
|
+
}));
|
|
31
|
+
const materials = current.lines
|
|
32
|
+
.filter((l) => l.line_type === "material" && (l.description || l.article_number))
|
|
33
|
+
.map((l) => ({
|
|
34
|
+
description: l.description || l.article_number || "Materiaal",
|
|
35
|
+
article_number: l.article_number || null,
|
|
36
|
+
quantity: l.quantity ?? 1,
|
|
37
|
+
unit: l.unit || "st",
|
|
38
|
+
source: "email",
|
|
39
|
+
}));
|
|
40
|
+
return { werkbon, packages, materials };
|
|
41
|
+
}
|
|
42
|
+
const base = {
|
|
43
|
+
id: "p1",
|
|
44
|
+
event_id: "e1",
|
|
45
|
+
customer_id: "c1",
|
|
46
|
+
work_address: "Straat 1, 1234 AB Plaats",
|
|
47
|
+
room_number: null,
|
|
48
|
+
complaint_description: "Lekkage",
|
|
49
|
+
technician_task_description: "Repareren",
|
|
50
|
+
deadline_date: "2026-11-20",
|
|
51
|
+
estimated_duration_minutes: 90,
|
|
52
|
+
estimated_days: 1,
|
|
53
|
+
technician_id: null,
|
|
54
|
+
externe_referentie: "REF",
|
|
55
|
+
budget_mandate_cents: null,
|
|
56
|
+
internal_notes: null,
|
|
57
|
+
lines: [
|
|
58
|
+
{ line_type: "package", package_id: "pk1", quantity: null, extra_quarters: 2.4 },
|
|
59
|
+
{ line_type: "package", package_id: null, quantity: 3 },
|
|
60
|
+
{ line_type: "package", package_id: "pk2", quantity: 2, extra_quarters: -1 },
|
|
61
|
+
{ line_type: "material", description: "", article_number: "A1", quantity: null, unit: "" },
|
|
62
|
+
{ line_type: "material", description: "Kraan", article_number: "", quantity: 2, unit: "st" },
|
|
63
|
+
{ line_type: "material", description: "", article_number: "", quantity: 1, unit: "st" },
|
|
64
|
+
],
|
|
65
|
+
};
|
|
66
|
+
describe("rijen voor werkbon aanmaken: oud = nieuw", () => {
|
|
67
|
+
for (const variant of [base, { ...base, technician_id: "t1", budget_mandate_cents: 5000 }]) {
|
|
68
|
+
it(`zelfde uitkomst (monteur: ${variant.technician_id ?? "geen"})`, () => {
|
|
69
|
+
const old = legacy(variant);
|
|
70
|
+
expect(buildWerkbonRow(variant)).toEqual(old.werkbon);
|
|
71
|
+
expect(buildPackageRows(variant.lines)).toEqual(old.packages);
|
|
72
|
+
expect(buildMaterialRows(variant.lines)).toEqual(old.materials);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
it("extra kwartieren worden minuten (2,4 → 30, negatief → 0)", () => {
|
|
76
|
+
expect(buildPackageRows(base.lines).map((r) => r.extra_minutes)).toEqual([30, 0]);
|
|
77
|
+
});
|
|
78
|
+
it("geen monteur → unassigned, wel monteur → planned_visible", () => {
|
|
79
|
+
expect(buildWerkbonRow(base).status).toBe("unassigned");
|
|
80
|
+
expect(buildWerkbonRow({ ...base, technician_id: "t" }).status).toBe("planned_visible");
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
describe("e-mailadres orderbevestiging", () => {
|
|
84
|
+
it("geldig", () => {
|
|
85
|
+
expect(isValidEmail("jan@bedrijf.nl")).toBe(true);
|
|
86
|
+
});
|
|
87
|
+
it("leeg of ongeldig", () => {
|
|
88
|
+
for (const v of ["", " ", "jan", "jan@", "jan@bedrijf", "a b@c.nl", null]) {
|
|
89
|
+
expect(isValidEmail(v)).toBe(false);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
describe("gelijktijdig bewerken", () => {
|
|
94
|
+
it("zelfde tijdstempel is geen conflict", () => {
|
|
95
|
+
expect(isConflict("2026-11-09T12:00:00+00:00", "2026-11-09T12:00:00.000Z")).toBe(false);
|
|
96
|
+
});
|
|
97
|
+
it("ander tijdstempel is een conflict", () => {
|
|
98
|
+
expect(isConflict("2026-11-09T12:00:00Z", "2026-11-09T12:00:01Z")).toBe(true);
|
|
99
|
+
});
|
|
100
|
+
it("zonder tijdstempel nooit blokkeren", () => {
|
|
101
|
+
expect(isConflict(null, "2026-11-09T12:00:00Z")).toBe(false);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface PostvakSettings {
|
|
2
|
+
optimistic_lock_enabled: boolean;
|
|
3
|
+
confirmation_require_valid_email: boolean;
|
|
4
|
+
customer_match_in_db: boolean;
|
|
5
|
+
customer_match_fuzzy: boolean;
|
|
6
|
+
customer_match_similarity: number;
|
|
7
|
+
analyse_claim_ttl_seconds: number;
|
|
8
|
+
timezone: string;
|
|
9
|
+
ai_local_date: boolean;
|
|
10
|
+
competenties_enabled: boolean;
|
|
11
|
+
ai_materials_catalog_only: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare const DEFAULT_POSTVAK_SETTINGS: PostvakSettings;
|
|
14
|
+
export declare function normalizePostvakSettings(row: unknown): PostvakSettings;
|
|
15
|
+
export declare function readPostvakSettings(client: any): Promise<PostvakSettings>;
|
|
16
|
+
//# sourceMappingURL=werkbon-postvak-settings.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"werkbon-postvak-settings.d.ts","sourceRoot":"","sources":["../../src/lib/werkbon-postvak-settings.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,eAAe;IAC9B,uBAAuB,EAAE,OAAO,CAAC;IACjC,gCAAgC,EAAE,OAAO,CAAC;IAC1C,oBAAoB,EAAE,OAAO,CAAC;IAC9B,oBAAoB,EAAE,OAAO,CAAC;IAC9B,yBAAyB,EAAE,MAAM,CAAC;IAClC,yBAAyB,EAAE,MAAM,CAAC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;IACvB,oBAAoB,EAAE,OAAO,CAAC;IAC9B,yBAAyB,EAAE,OAAO,CAAC;CACpC;AAED,eAAO,MAAM,wBAAwB,EAAE,eAWtC,CAAC;AAYF,wBAAgB,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CAoBtE;AAED,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,GAAG,GAAG,OAAO,CAAC,eAAe,CAAC,CAgB/E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type PostvakSettings } from "./werkbon-postvak-settings";
|
|
2
|
+
export type { PostvakSettings } from "./werkbon-postvak-settings";
|
|
3
|
+
export { DEFAULT_POSTVAK_SETTINGS } from "./werkbon-postvak-settings";
|
|
4
|
+
export declare const getPostvakSettings: import("@tanstack/start-client-core").OptionalFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
5
|
+
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
6
|
+
userId: string;
|
|
7
|
+
claims: import("@supabase/auth-js").UserMetadata;
|
|
8
|
+
}, undefined, undefined, undefined>], undefined, Promise<PostvakSettings>>;
|
|
9
|
+
export declare const savePostvakSettings: import("@tanstack/start-client-core").RequiredFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
10
|
+
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
11
|
+
userId: string;
|
|
12
|
+
claims: import("@supabase/auth-js").UserMetadata;
|
|
13
|
+
}, undefined, undefined, undefined>], (data: Partial<PostvakSettings>) => PostvakSettings, Promise<PostvakSettings>>;
|
|
14
|
+
//# sourceMappingURL=werkbon-postvak-settings.functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"werkbon-postvak-settings.functions.d.ts","sourceRoot":"","sources":["../../src/lib/werkbon-postvak-settings.functions.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAC;AAEpC,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAEtE,eAAO,MAAM,kBAAkB;;;;0EAI3B,CAAC;AAGL,eAAO,MAAM,mBAAmB;;;;6CAEP,OAAO,CAAC,eAAe,CAAC,+CAW7C,CAAC"}
|