@flowselections/floriday-verkoop-module 1.0.138 → 1.0.139
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 +24 -22
- package/dist-lib/components/verkoop/FloridaySyncSettings.d.ts +2 -0
- package/dist-lib/components/verkoop/FloridaySyncSettings.d.ts.map +1 -0
- package/dist-lib/components/verkoop/FloridaySyncSettings.js +48 -0
- package/dist-lib/components/verkoop/OrderKarindelingCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderKarindelingCard.js +32 -5
- package/dist-lib/components/verkoop/OrderShipmentsCard.d.ts.map +1 -1
- package/dist-lib/components/verkoop/OrderShipmentsCard.js +2 -3
- package/dist-lib/components/verkoop/SalesOrderDetailPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailPage.js +12 -2
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts +3 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersFilters.js +13 -51
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts +17 -3
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.js +168 -116
- package/dist-lib/components/verkoop/VerkoopOrdersPage.d.ts.map +1 -1
- package/dist-lib/components/verkoop/VerkoopOrdersPage.js +203 -89
- package/dist-lib/components/verkoop/v3/CustomerName.d.ts +9 -0
- package/dist-lib/components/verkoop/v3/CustomerName.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/CustomerName.js +16 -0
- package/dist-lib/components/verkoop/v3/HoverTip.d.ts +15 -0
- package/dist-lib/components/verkoop/v3/HoverTip.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/HoverTip.js +24 -0
- package/dist-lib/components/verkoop/v3/KpiTile.d.ts +13 -0
- package/dist-lib/components/verkoop/v3/KpiTile.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/KpiTile.js +8 -0
- package/dist-lib/components/verkoop/v3/OrderProgress.d.ts +7 -0
- package/dist-lib/components/verkoop/v3/OrderProgress.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/OrderProgress.js +127 -0
- package/dist-lib/components/verkoop/v3/RowMenu.d.ts +13 -0
- package/dist-lib/components/verkoop/v3/RowMenu.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/RowMenu.js +17 -0
- package/dist-lib/components/verkoop/v3/SourceIcon.d.ts +17 -0
- package/dist-lib/components/verkoop/v3/SourceIcon.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/SourceIcon.js +45 -0
- package/dist-lib/components/verkoop/v3/floriday-logo.d.ts +2 -0
- package/dist-lib/components/verkoop/v3/floriday-logo.d.ts.map +1 -0
- package/dist-lib/components/verkoop/v3/floriday-logo.js +2 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +2 -0
- package/dist-lib/integrations/supabase/types.d.ts +431 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/buffer-carts.check.d.ts +2 -0
- package/dist-lib/lib/buffer-carts.check.d.ts.map +1 -0
- package/dist-lib/lib/buffer-carts.check.js +23 -0
- package/dist-lib/lib/buffer-carts.d.ts +35 -0
- package/dist-lib/lib/buffer-carts.d.ts.map +1 -0
- package/dist-lib/lib/buffer-carts.functions.d.ts +12 -0
- package/dist-lib/lib/buffer-carts.functions.d.ts.map +1 -0
- package/dist-lib/lib/buffer-carts.functions.js +18 -0
- package/dist-lib/lib/buffer-carts.js +41 -0
- package/dist-lib/lib/create-order.functions.d.ts +1 -0
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +8 -1
- package/dist-lib/lib/floriday-public.functions.d.ts +1 -1
- package/dist-lib/lib/motion.d.ts +13 -0
- package/dist-lib/lib/motion.d.ts.map +1 -0
- package/dist-lib/lib/motion.js +36 -0
- package/dist-lib/lib/order-price-lock.check.js +21 -5
- package/dist-lib/lib/order-price-lock.d.ts +14 -6
- package/dist-lib/lib/order-price-lock.d.ts.map +1 -1
- package/dist-lib/lib/order-price-lock.js +40 -8
- package/dist-lib/lib/order-price-lock.server.d.ts.map +1 -1
- package/dist-lib/lib/order-price-lock.server.js +10 -0
- package/dist-lib/lib/order-progress.check.d.ts +2 -0
- package/dist-lib/lib/order-progress.check.d.ts.map +1 -0
- package/dist-lib/lib/order-progress.check.js +83 -0
- package/dist-lib/lib/order-progress.d.ts +154 -0
- package/dist-lib/lib/order-progress.d.ts.map +1 -0
- package/dist-lib/lib/order-progress.js +171 -0
- package/dist-lib/lib/order-progress.server.d.ts +41 -0
- package/dist-lib/lib/order-progress.server.d.ts.map +1 -0
- package/dist-lib/lib/order-progress.server.js +136 -0
- package/dist-lib/lib/order-status.js +2 -2
- package/dist-lib/lib/period-range.check.d.ts +2 -0
- package/dist-lib/lib/period-range.check.d.ts.map +1 -0
- package/dist-lib/lib/period-range.check.js +63 -0
- package/dist-lib/lib/period-range.d.ts +66 -0
- package/dist-lib/lib/period-range.d.ts.map +1 -0
- package/dist-lib/lib/period-range.js +213 -0
- package/dist-lib/lib/plan-coverage.d.ts +17 -0
- package/dist-lib/lib/plan-coverage.d.ts.map +1 -1
- package/dist-lib/lib/plan-coverage.js +24 -0
- package/dist-lib/lib/salesorders-list.functions.d.ts +4 -2
- package/dist-lib/lib/salesorders-list.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.functions.js +5 -1
- package/dist-lib/lib/salesorders-list.server.d.ts +6 -1
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +81 -18
- package/dist-lib/lib/salesorders-mapping.d.ts +18 -0
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-mapping.js +19 -58
- package/dist-lib/lib/session-error.check.d.ts +2 -0
- package/dist-lib/lib/session-error.check.d.ts.map +1 -0
- package/dist-lib/lib/session-error.check.js +17 -0
- package/dist-lib/lib/session-error.d.ts +2 -0
- package/dist-lib/lib/session-error.d.ts.map +1 -0
- package/dist-lib/lib/session-error.js +10 -0
- package/dist-lib/lib/useBufferCarts.d.ts +6 -0
- package/dist-lib/lib/useBufferCarts.d.ts.map +1 -0
- package/dist-lib/lib/useBufferCarts.js +15 -0
- package/dist-lib/lib/useSalesOrdersQuery.d.ts +11 -2
- package/dist-lib/lib/useSalesOrdersQuery.d.ts.map +1 -1
- package/dist-lib/lib/useSalesOrdersQuery.js +75 -52
- package/package.json +3 -3
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
export declare const PERIOD_TZ = "Europe/Amsterdam";
|
|
2
|
+
export interface Ymd {
|
|
3
|
+
y: number;
|
|
4
|
+
m: number;
|
|
5
|
+
d: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const ymdString: (v: Ymd) => string;
|
|
8
|
+
export declare function parseYmd(s: string | null | undefined): Ymd | null;
|
|
9
|
+
/** Kalenderdatum (Amsterdam) van een tijdstip. */
|
|
10
|
+
export declare function amsterdamYmd(at?: Date): Ymd;
|
|
11
|
+
/** Tijdstip (UTC) van 00:00 Amsterdamse tijd op de gegeven datum. */
|
|
12
|
+
export declare function amsterdamMidnight(v: Ymd): Date;
|
|
13
|
+
export declare function addDays(v: Ymd, days: number): Ymd;
|
|
14
|
+
/** ISO-weeknummer en -jaar van een kalenderdatum. */
|
|
15
|
+
export declare function isoWeekOf(v: Ymd): {
|
|
16
|
+
week: number;
|
|
17
|
+
year: number;
|
|
18
|
+
};
|
|
19
|
+
/** Aantal ISO-weken in een jaar (52 of 53). */
|
|
20
|
+
export declare function isoWeeksInYear(year: number): number;
|
|
21
|
+
/** Maandag van ISO-week `week` in ISO-jaar `year`. */
|
|
22
|
+
export declare function isoWeekMonday(week: number, year: number): Ymd;
|
|
23
|
+
export type PeriodKind = "day" | "week" | "month" | "last7" | "last30" | "custom";
|
|
24
|
+
export interface PeriodInput {
|
|
25
|
+
period?: PeriodKind;
|
|
26
|
+
day?: string;
|
|
27
|
+
week?: number;
|
|
28
|
+
year?: number;
|
|
29
|
+
month?: number;
|
|
30
|
+
monthYear?: number;
|
|
31
|
+
customFrom?: string;
|
|
32
|
+
customTo?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface PeriodRange {
|
|
35
|
+
/** Eerste kalenderdag (inclusief). */
|
|
36
|
+
startDate: string;
|
|
37
|
+
/** Eerste dag ná de periode (exclusief). */
|
|
38
|
+
endDate: string;
|
|
39
|
+
/** Tijdstip 00:00 Amsterdam van startDate, als ISO (UTC). */
|
|
40
|
+
since: string;
|
|
41
|
+
/** Tijdstip 00:00 Amsterdam van endDate, als ISO (UTC) — exclusief. */
|
|
42
|
+
until: string;
|
|
43
|
+
}
|
|
44
|
+
export declare function dayRange(v: Ymd): PeriodRange;
|
|
45
|
+
export declare function weekRange(week: number, year: number): PeriodRange;
|
|
46
|
+
export declare function monthRangeAms(month0: number, year: number): PeriodRange;
|
|
47
|
+
/** Periode → halfopen interval. Onvolledige invoer → null (geen venster). */
|
|
48
|
+
export declare function periodRange(f: PeriodInput, now?: Date): PeriodRange | null;
|
|
49
|
+
/** Een periode stap vooruit of terug (dag, week of maand). */
|
|
50
|
+
export declare function shiftPeriod(f: PeriodInput, delta: number, now?: Date): PeriodInput;
|
|
51
|
+
/** Standaardperiode bij openen: huidige week, op leverdatum. */
|
|
52
|
+
export declare function defaultPeriod(now?: Date): PeriodInput & {
|
|
53
|
+
dateField: "delivery";
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* Periode uit zoekparameters lezen. Ongeldig of onleesbaar → standaard,
|
|
57
|
+
* zonder fout.
|
|
58
|
+
*/
|
|
59
|
+
export declare function periodFromSearch(s: Record<string, unknown> | null | undefined, now?: Date): PeriodInput & {
|
|
60
|
+
dateField: "ordered" | "delivery";
|
|
61
|
+
};
|
|
62
|
+
/** Periode → zoekparameters (korte, leesbare Nederlandse sleutels). */
|
|
63
|
+
export declare function periodToSearch(f: PeriodInput & {
|
|
64
|
+
dateField?: "ordered" | "delivery";
|
|
65
|
+
}): Record<string, string | undefined>;
|
|
66
|
+
//# sourceMappingURL=period-range.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"period-range.d.ts","sourceRoot":"","sources":["../../src/lib/period-range.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,SAAS,qBAAqB,CAAC;AAE5C,MAAM,WAAW,GAAG;IAClB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAGD,eAAO,MAAM,SAAS,GAAI,GAAG,GAAG,WAAqC,CAAC;AAEtE,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,GAAG,GAAG,IAAI,CAOjE;AAED,kDAAkD;AAClD,wBAAgB,YAAY,CAAC,EAAE,GAAE,IAAiB,GAAG,GAAG,CASvD;AAmBD,qEAAqE;AACrE,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,GAAG,GAAG,IAAI,CAM9C;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAGjD;AAED,qDAAqD;AACrD,wBAAgB,SAAS,CAAC,CAAC,EAAE,GAAG,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAQhE;AAED,+CAA+C;AAC/C,wBAAgB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEnD;AAED,sDAAsD;AACtD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,GAAG,CAI7D;AAED,MA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GAGG;AACH,wBAAgB,gBAAgB,CAC9B,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,SAAS,EAC7C,GAAG,GAAE,IAAiB,GACrB,WAAW,GAAG;IAAE,SAAS,EAAE,SAAS,GAAG,UAAU,CAAA;CAAE,CAiCrD;AAED,uEAAuE;AACvE,wBAAgB,cAAc,CAAC,CAAC,EAAE,WAAW,GAAG;IAAE,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAiB1H"}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// Periodes voor de orderlijst: altijd halfopen intervallen [start, eind) in
|
|
2
|
+
// tijdzone Europe/Amsterdam. Een dag loopt van 00:00 tot de volgende dag
|
|
3
|
+
// 00:00 (exclusief), een week van maandag 00:00 tot de volgende maandag
|
|
4
|
+
// 00:00, een maand van de 1e 00:00 tot de 1e van de volgende maand. ISO-
|
|
5
|
+
// weeknummers (week 1 bevat 4 januari). Zomer-/wintertijd zit in de omrekening.
|
|
6
|
+
export const PERIOD_TZ = "Europe/Amsterdam";
|
|
7
|
+
const pad = (n) => String(n).padStart(2, "0");
|
|
8
|
+
export const ymdString = (v) => `${v.y}-${pad(v.m)}-${pad(v.d)}`;
|
|
9
|
+
export function parseYmd(s) {
|
|
10
|
+
const m = /^(\d{4})-(\d{2})-(\d{2})$/.exec(String(s ?? "").trim());
|
|
11
|
+
if (!m)
|
|
12
|
+
return null;
|
|
13
|
+
const v = { y: Number(m[1]), m: Number(m[2]), d: Number(m[3]) };
|
|
14
|
+
const check = new Date(Date.UTC(v.y, v.m - 1, v.d));
|
|
15
|
+
if (check.getUTCFullYear() !== v.y || check.getUTCMonth() !== v.m - 1 || check.getUTCDate() !== v.d)
|
|
16
|
+
return null;
|
|
17
|
+
return v;
|
|
18
|
+
}
|
|
19
|
+
/** Kalenderdatum (Amsterdam) van een tijdstip. */
|
|
20
|
+
export function amsterdamYmd(at = new Date()) {
|
|
21
|
+
const parts = new Intl.DateTimeFormat("en-CA", {
|
|
22
|
+
timeZone: PERIOD_TZ,
|
|
23
|
+
year: "numeric",
|
|
24
|
+
month: "2-digit",
|
|
25
|
+
day: "2-digit",
|
|
26
|
+
}).formatToParts(at);
|
|
27
|
+
const get = (t) => Number(parts.find((p) => p.type === t)?.value);
|
|
28
|
+
return { y: get("year"), m: get("month"), d: get("day") };
|
|
29
|
+
}
|
|
30
|
+
/** Verschil Amsterdam − UTC in minuten op tijdstip `ms`. */
|
|
31
|
+
function offsetMinutes(ms) {
|
|
32
|
+
const parts = new Intl.DateTimeFormat("en-US", {
|
|
33
|
+
timeZone: PERIOD_TZ,
|
|
34
|
+
hourCycle: "h23",
|
|
35
|
+
year: "numeric",
|
|
36
|
+
month: "2-digit",
|
|
37
|
+
day: "2-digit",
|
|
38
|
+
hour: "2-digit",
|
|
39
|
+
minute: "2-digit",
|
|
40
|
+
second: "2-digit",
|
|
41
|
+
}).formatToParts(new Date(ms));
|
|
42
|
+
const get = (t) => Number(parts.find((p) => p.type === t)?.value);
|
|
43
|
+
const asUtc = Date.UTC(get("year"), get("month") - 1, get("day"), get("hour"), get("minute"), get("second"));
|
|
44
|
+
return Math.round((asUtc - Math.floor(ms / 1000) * 1000) / 60000);
|
|
45
|
+
}
|
|
46
|
+
/** Tijdstip (UTC) van 00:00 Amsterdamse tijd op de gegeven datum. */
|
|
47
|
+
export function amsterdamMidnight(v) {
|
|
48
|
+
const guess = Date.UTC(v.y, v.m - 1, v.d);
|
|
49
|
+
let ms = guess - offsetMinutes(guess) * 60000;
|
|
50
|
+
// Tweede ronde: rond een klokwisseling kan de eerste schatting 1 uur verschuiven.
|
|
51
|
+
ms = guess - offsetMinutes(ms) * 60000;
|
|
52
|
+
return new Date(ms);
|
|
53
|
+
}
|
|
54
|
+
export function addDays(v, days) {
|
|
55
|
+
const dt = new Date(Date.UTC(v.y, v.m - 1, v.d + days));
|
|
56
|
+
return { y: dt.getUTCFullYear(), m: dt.getUTCMonth() + 1, d: dt.getUTCDate() };
|
|
57
|
+
}
|
|
58
|
+
/** ISO-weeknummer en -jaar van een kalenderdatum. */
|
|
59
|
+
export function isoWeekOf(v) {
|
|
60
|
+
const dt = new Date(Date.UTC(v.y, v.m - 1, v.d));
|
|
61
|
+
const dow = (dt.getUTCDay() + 6) % 7; // ma=0
|
|
62
|
+
dt.setUTCDate(dt.getUTCDate() - dow + 3); // donderdag van die week
|
|
63
|
+
const year = dt.getUTCFullYear();
|
|
64
|
+
const yearStart = Date.UTC(year, 0, 1);
|
|
65
|
+
const week = Math.ceil(((dt.getTime() - yearStart) / 86400000 + 1) / 7);
|
|
66
|
+
return { week, year };
|
|
67
|
+
}
|
|
68
|
+
/** Aantal ISO-weken in een jaar (52 of 53). */
|
|
69
|
+
export function isoWeeksInYear(year) {
|
|
70
|
+
return isoWeekOf({ y: year, m: 12, d: 28 }).week;
|
|
71
|
+
}
|
|
72
|
+
/** Maandag van ISO-week `week` in ISO-jaar `year`. */
|
|
73
|
+
export function isoWeekMonday(week, year) {
|
|
74
|
+
const jan4 = { y: year, m: 1, d: 4 };
|
|
75
|
+
const dow = (new Date(Date.UTC(year, 0, 4)).getUTCDay() + 6) % 7;
|
|
76
|
+
return addDays(jan4, -dow + (week - 1) * 7);
|
|
77
|
+
}
|
|
78
|
+
function rangeOf(start, endExclusive) {
|
|
79
|
+
return {
|
|
80
|
+
startDate: ymdString(start),
|
|
81
|
+
endDate: ymdString(endExclusive),
|
|
82
|
+
since: amsterdamMidnight(start).toISOString(),
|
|
83
|
+
until: amsterdamMidnight(endExclusive).toISOString(),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export function dayRange(v) {
|
|
87
|
+
return rangeOf(v, addDays(v, 1));
|
|
88
|
+
}
|
|
89
|
+
export function weekRange(week, year) {
|
|
90
|
+
const mon = isoWeekMonday(week, year);
|
|
91
|
+
return rangeOf(mon, addDays(mon, 7));
|
|
92
|
+
}
|
|
93
|
+
export function monthRangeAms(month0, year) {
|
|
94
|
+
const start = { y: year, m: month0 + 1, d: 1 };
|
|
95
|
+
const end = month0 === 11 ? { y: year + 1, m: 1, d: 1 } : { y: year, m: month0 + 2, d: 1 };
|
|
96
|
+
return rangeOf(start, end);
|
|
97
|
+
}
|
|
98
|
+
/** Periode → halfopen interval. Onvolledige invoer → null (geen venster). */
|
|
99
|
+
export function periodRange(f, now = new Date()) {
|
|
100
|
+
const today = amsterdamYmd(now);
|
|
101
|
+
switch (f.period) {
|
|
102
|
+
case "day": {
|
|
103
|
+
const v = parseYmd(f.day);
|
|
104
|
+
return v ? dayRange(v) : null;
|
|
105
|
+
}
|
|
106
|
+
case "month":
|
|
107
|
+
if (f.month === undefined || f.monthYear === undefined)
|
|
108
|
+
return null;
|
|
109
|
+
return monthRangeAms(f.month, f.monthYear);
|
|
110
|
+
case "last7":
|
|
111
|
+
case "last30": {
|
|
112
|
+
const days = f.period === "last7" ? 7 : 30;
|
|
113
|
+
const end = addDays(today, 1);
|
|
114
|
+
return rangeOf(addDays(end, -days), end);
|
|
115
|
+
}
|
|
116
|
+
case "custom": {
|
|
117
|
+
const a = parseYmd(f.customFrom);
|
|
118
|
+
const b = parseYmd(f.customTo);
|
|
119
|
+
return a && b ? rangeOf(a, addDays(b, 1)) : null;
|
|
120
|
+
}
|
|
121
|
+
default:
|
|
122
|
+
if (f.week && f.year)
|
|
123
|
+
return weekRange(f.week, f.year);
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
/** Een periode stap vooruit of terug (dag, week of maand). */
|
|
128
|
+
export function shiftPeriod(f, delta, now = new Date()) {
|
|
129
|
+
const today = amsterdamYmd(now);
|
|
130
|
+
if (f.period === "day") {
|
|
131
|
+
const v = parseYmd(f.day) ?? today;
|
|
132
|
+
return { ...f, day: ymdString(addDays(v, delta)) };
|
|
133
|
+
}
|
|
134
|
+
if (f.period === "month") {
|
|
135
|
+
const m0 = f.month ?? today.m - 1;
|
|
136
|
+
const y0 = f.monthYear ?? today.y;
|
|
137
|
+
const total = y0 * 12 + m0 + delta;
|
|
138
|
+
return { ...f, month: ((total % 12) + 12) % 12, monthYear: Math.floor(total / 12) };
|
|
139
|
+
}
|
|
140
|
+
const cur = isoWeekOf(today);
|
|
141
|
+
const w = f.week ?? cur.week;
|
|
142
|
+
const y = f.year ?? cur.year;
|
|
143
|
+
const mon = addDays(isoWeekMonday(w, y), delta * 7);
|
|
144
|
+
const next = isoWeekOf(mon);
|
|
145
|
+
return { ...f, period: "week", week: next.week, year: next.year };
|
|
146
|
+
}
|
|
147
|
+
/** Standaardperiode bij openen: huidige week, op leverdatum. */
|
|
148
|
+
export function defaultPeriod(now = new Date()) {
|
|
149
|
+
const w = isoWeekOf(amsterdamYmd(now));
|
|
150
|
+
return { period: "week", week: w.week, year: w.year, dateField: "delivery" };
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Periode uit zoekparameters lezen. Ongeldig of onleesbaar → standaard,
|
|
154
|
+
* zonder fout.
|
|
155
|
+
*/
|
|
156
|
+
export function periodFromSearch(s, now = new Date()) {
|
|
157
|
+
const def = defaultPeriod(now);
|
|
158
|
+
if (!s)
|
|
159
|
+
return def;
|
|
160
|
+
const str = (k) => (typeof s[k] === "string" ? s[k] : typeof s[k] === "number" ? String(s[k]) : "");
|
|
161
|
+
const dateField = str("datum") === "besteld" ? "ordered" : "delivery";
|
|
162
|
+
const p = str("periode");
|
|
163
|
+
if (p === "dag") {
|
|
164
|
+
const v = parseYmd(str("dag"));
|
|
165
|
+
return v ? { period: "day", day: ymdString(v), dateField } : { ...def, dateField };
|
|
166
|
+
}
|
|
167
|
+
if (p === "maand") {
|
|
168
|
+
const m = /^(\d{4})-(\d{2})$/.exec(str("maand"));
|
|
169
|
+
const mm = m ? Number(m[2]) : 0;
|
|
170
|
+
if (m && mm >= 1 && mm <= 12)
|
|
171
|
+
return { period: "month", month: mm - 1, monthYear: Number(m[1]), dateField };
|
|
172
|
+
return { ...def, dateField };
|
|
173
|
+
}
|
|
174
|
+
if (p === "7d" || p === "30d")
|
|
175
|
+
return { period: p === "7d" ? "last7" : "last30", dateField };
|
|
176
|
+
if (p === "eigen") {
|
|
177
|
+
const a = parseYmd(str("van"));
|
|
178
|
+
const b = parseYmd(str("tot"));
|
|
179
|
+
if (a && b && ymdString(a) <= ymdString(b))
|
|
180
|
+
return { period: "custom", customFrom: ymdString(a), customTo: ymdString(b), dateField };
|
|
181
|
+
return { ...def, dateField };
|
|
182
|
+
}
|
|
183
|
+
if (p === "week" || !p) {
|
|
184
|
+
const m = /^(\d{4})-W(\d{1,2})$/.exec(str("week"));
|
|
185
|
+
if (m) {
|
|
186
|
+
const y = Number(m[1]);
|
|
187
|
+
const w = Number(m[2]);
|
|
188
|
+
if (w >= 1 && w <= isoWeeksInYear(y))
|
|
189
|
+
return { period: "week", week: w, year: y, dateField };
|
|
190
|
+
}
|
|
191
|
+
return { ...def, dateField };
|
|
192
|
+
}
|
|
193
|
+
return { ...def, dateField };
|
|
194
|
+
}
|
|
195
|
+
/** Periode → zoekparameters (korte, leesbare Nederlandse sleutels). */
|
|
196
|
+
export function periodToSearch(f) {
|
|
197
|
+
const base = { datum: f.dateField === "ordered" ? "besteld" : "geleverd" };
|
|
198
|
+
const clear = { periode: undefined, dag: undefined, week: undefined, maand: undefined, van: undefined, tot: undefined };
|
|
199
|
+
switch (f.period) {
|
|
200
|
+
case "day":
|
|
201
|
+
return { ...clear, ...base, periode: "dag", dag: f.day };
|
|
202
|
+
case "month":
|
|
203
|
+
return { ...clear, ...base, periode: "maand", maand: `${f.monthYear}-${pad((f.month ?? 0) + 1)}` };
|
|
204
|
+
case "last7":
|
|
205
|
+
return { ...clear, ...base, periode: "7d" };
|
|
206
|
+
case "last30":
|
|
207
|
+
return { ...clear, ...base, periode: "30d" };
|
|
208
|
+
case "custom":
|
|
209
|
+
return { ...clear, ...base, periode: "eigen", van: f.customFrom, tot: f.customTo };
|
|
210
|
+
default:
|
|
211
|
+
return { ...clear, ...base, periode: "week", week: `${f.year}-W${pad(f.week ?? 1)}` };
|
|
212
|
+
}
|
|
213
|
+
}
|
|
@@ -41,8 +41,25 @@ export interface PlanCoverageCart {
|
|
|
41
41
|
lagen: number | null;
|
|
42
42
|
/** vulgraadPct: vulgraad in procenten (heel getal); null = niet geleverd. */
|
|
43
43
|
vulgraad: number | null;
|
|
44
|
+
/** Engine 1.0.220: hoofdreden waarom de kar verouderd is; null = niet geleverd. */
|
|
45
|
+
verouderdReden: string | null;
|
|
46
|
+
/** Engine 1.0.220: alle redenen [{code, tekst}]; null = niet geleverd (oudere Engine). */
|
|
47
|
+
verouderdRedenen: VerouderdReden[] | null;
|
|
44
48
|
lines: PlanCoverageLine[];
|
|
45
49
|
}
|
|
50
|
+
export type VerouderdReden = {
|
|
51
|
+
code: string | null;
|
|
52
|
+
tekst: string;
|
|
53
|
+
};
|
|
54
|
+
/** Leest verouderdRedenen defensief; geen lijst → null (oudere Engine). */
|
|
55
|
+
export declare function parseVerouderdRedenen(v: unknown): VerouderdReden[] | null;
|
|
56
|
+
/** Te tonen redenen per kar: de lijst als die er is, anders de hoofdreden. Tekst altijd van de Engine. */
|
|
57
|
+
export declare function verouderdRegels(c: {
|
|
58
|
+
verouderdReden?: string | null;
|
|
59
|
+
verouderdRedenen?: VerouderdReden[] | null;
|
|
60
|
+
}): VerouderdReden[];
|
|
61
|
+
/** Code bepaalt alleen de kleur: rood = printen geblokkeerd, grijs = alleen melding, oranje = rest. */
|
|
62
|
+
export declare function verouderdToon(code: string | null): "blok" | "melding" | "let_op";
|
|
46
63
|
export interface PlanCoveragePickRow {
|
|
47
64
|
queueItemId: string | null;
|
|
48
65
|
documentNumber: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plan-coverage.d.ts","sourceRoot":"","sources":["../../src/lib/plan-coverage.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,iBAAiB,GACz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AAI,CASxE"}
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
// Indelingsstatus per order zoals de Logistiek Engine die levert via
|
|
2
2
|
// public.logistics_order_plan_coverage. Alleen types en een veilige parser —
|
|
3
3
|
// browser-veilig, geen databasecode. Deze module telt nooit zelf karren.
|
|
4
|
+
/** Leest verouderdRedenen defensief; geen lijst → null (oudere Engine). */
|
|
5
|
+
export function parseVerouderdRedenen(v) {
|
|
6
|
+
if (!Array.isArray(v))
|
|
7
|
+
return null;
|
|
8
|
+
return v
|
|
9
|
+
.map((r) => ({ code: typeof r?.code === "string" ? r.code : null, tekst: typeof r?.tekst === "string" ? r.tekst.trim() : "" }))
|
|
10
|
+
.filter((r) => r.tekst.length > 0);
|
|
11
|
+
}
|
|
12
|
+
/** Te tonen redenen per kar: de lijst als die er is, anders de hoofdreden. Tekst altijd van de Engine. */
|
|
13
|
+
export function verouderdRegels(c) {
|
|
14
|
+
if (c.verouderdRedenen && c.verouderdRedenen.length > 0)
|
|
15
|
+
return c.verouderdRedenen;
|
|
16
|
+
return c.verouderdReden ? [{ code: null, tekst: c.verouderdReden }] : [];
|
|
17
|
+
}
|
|
18
|
+
/** Code bepaalt alleen de kleur: rood = printen geblokkeerd, grijs = alleen melding, oranje = rest. */
|
|
19
|
+
export function verouderdToon(code) {
|
|
20
|
+
if (code === "quarantaine" || code === "leeg" || code === "aantal")
|
|
21
|
+
return "blok";
|
|
22
|
+
if (code === "te_veel_lagen")
|
|
23
|
+
return "melding";
|
|
24
|
+
return "let_op";
|
|
25
|
+
}
|
|
4
26
|
/** Acties die deze module kan uitvoeren; alleen tonen als de Engine ze meegeeft. "Alles herindelen" bestaat bewust niet. */
|
|
5
27
|
export const ENGINE_ACTIES = { herindelen_niet_geprint: "Niet-geprinte karren herindelen" };
|
|
6
28
|
/** Alleen bekende Engine-acties; onbekende/ontbrekende worden genegeerd. */
|
|
@@ -173,6 +195,8 @@ export function parsePlanCoverage(raw) {
|
|
|
173
195
|
capaciteit: intOrNull(c.maxLayers),
|
|
174
196
|
lagen: numOrNull(c.layersUsed),
|
|
175
197
|
vulgraad: intOrNull(c.vulgraadPct),
|
|
198
|
+
verouderdReden: str(c.verouderdReden),
|
|
199
|
+
verouderdRedenen: parseVerouderdRedenen(c.verouderdRedenen),
|
|
176
200
|
lines: (Array.isArray(c.lines) ? c.lines : []).map((l) => ({
|
|
177
201
|
orderItemId: str(l?.orderItemId),
|
|
178
202
|
productId: str(l?.productId),
|
|
@@ -3,12 +3,14 @@ export declare const listSalesOrders: import("@tanstack/start-client-core").Opti
|
|
|
3
3
|
userId: string;
|
|
4
4
|
claims: import("@supabase/auth-js").User;
|
|
5
5
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
6
|
-
dateField: "
|
|
7
|
-
tab: "picked" | "shipped" | "incoming" | "topick" | "cancelled" | "backlog" | "all" | "not_reported";
|
|
6
|
+
dateField: "delivery" | "ordered";
|
|
7
|
+
tab: "picked" | "shipped" | "incoming" | "topick" | "cancelled" | "invoiced" | "backlog" | "all" | "not_reported" | "problem";
|
|
8
8
|
page: number;
|
|
9
9
|
pageSize: number;
|
|
10
10
|
since?: string | undefined;
|
|
11
11
|
until?: string | undefined;
|
|
12
|
+
sinceDate?: string | undefined;
|
|
13
|
+
untilDate?: string | undefined;
|
|
12
14
|
search?: string | undefined;
|
|
13
15
|
status?: string | undefined;
|
|
14
16
|
all?: boolean | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"salesorders-list.functions.d.ts","sourceRoot":"","sources":["../../src/lib/salesorders-list.functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"salesorders-list.functions.d.ts","sourceRoot":"","sources":["../../src/lib/salesorders-list.functions.ts"],"names":[],"mappings":"AA4DA,eAAO,MAAM,eAAe;;;;8CAEF,OAAO;;;;;;;;;;;;;2DAQ7B,CAAC;AAML,eAAO,MAAM,wBAAwB;;;;8CAEX,OAAO;;;;;;;;GA+B7B,CAAC;AAEL;;;GAGG;AACH,eAAO,MAAM,0BAA0B;;;;8CAEb,OAAO;;;;;;;;GAiB7B,CAAC"}
|
|
@@ -6,11 +6,14 @@ import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware.js
|
|
|
6
6
|
const listInput = z.object({
|
|
7
7
|
since: z.string().optional(),
|
|
8
8
|
until: z.string().optional(),
|
|
9
|
+
/** Kalenderdagen (Amsterdam) voor tekstdatums: [sinceDate, untilDate). */
|
|
10
|
+
sinceDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
11
|
+
untilDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
|
9
12
|
dateField: z.enum(["ordered", "delivery"]).default("ordered"),
|
|
10
13
|
search: z.string().optional(),
|
|
11
14
|
status: z.string().optional(),
|
|
12
15
|
tab: z
|
|
13
|
-
.enum(["all", "incoming", "topick", "backlog", "picked", "shipped", "cancelled", "not_reported"])
|
|
16
|
+
.enum(["all", "incoming", "topick", "backlog", "picked", "shipped", "cancelled", "not_reported", "invoiced", "problem"])
|
|
14
17
|
.default("all"),
|
|
15
18
|
page: z.number().int().min(1).default(1),
|
|
16
19
|
pageSize: z.number().int().min(1).max(200).default(20),
|
|
@@ -22,6 +25,7 @@ const STEP_DESC = {
|
|
|
22
25
|
"3b_5_referentie": "verzendmomenten en referentiedata",
|
|
23
26
|
"9_12_dto": "rijen opbouwen",
|
|
24
27
|
"12_engine": "Engine-overzicht, achterstand, beoordelingen",
|
|
28
|
+
"12i_factuur_pick": "factuurstand (Facturatie) en pickvoortgang (Engine)",
|
|
25
29
|
"13_filter": "filteren en pagina kiezen",
|
|
26
30
|
"14a_vertrek": "ophaalmoment (Engine)",
|
|
27
31
|
"14b_vervoerder": "vervoerder (Engine)",
|
|
@@ -2,11 +2,14 @@ import type { SupabaseClient } from "@supabase/supabase-js";
|
|
|
2
2
|
import { type SalesOrderDTO, type SalesOrdersTotals } from "./salesorders-mapping.js";
|
|
3
3
|
import { type FloridayStatusEntry, type FloridayStatusSummary } from "./floriday-status.js";
|
|
4
4
|
import { type OrderStage } from "./order-status.js";
|
|
5
|
+
import { type ProgressFeatures } from "./order-progress.js";
|
|
5
6
|
/** "backlog" is géén status: het is een aparte weergave van "Te picken". */
|
|
6
|
-
export type StatusTab = "all" | OrderStage | "backlog" | "not_reported";
|
|
7
|
+
export type StatusTab = "all" | OrderStage | "backlog" | "not_reported" | "invoiced" | "problem";
|
|
7
8
|
export interface ListParams {
|
|
8
9
|
since?: string;
|
|
9
10
|
until?: string;
|
|
11
|
+
sinceDate?: string;
|
|
12
|
+
untilDate?: string;
|
|
10
13
|
dateField: "ordered" | "delivery";
|
|
11
14
|
search?: string;
|
|
12
15
|
status?: string;
|
|
@@ -32,6 +35,8 @@ export interface ListResult {
|
|
|
32
35
|
truncated: boolean;
|
|
33
36
|
/** Meting per stap (ms) en aantal database-aanroepen. */
|
|
34
37
|
timing?: ListTiming;
|
|
38
|
+
/** Welke leesfuncties van Facturatie/Engine beschikbaar waren. */
|
|
39
|
+
features: ProgressFeatures;
|
|
35
40
|
}
|
|
36
41
|
export declare function invalidateReferenceCache(): void;
|
|
37
42
|
export interface ListTiming {
|
|
@@ -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,CAAC;AAK/B,OAAO,EAAiB,KAAK,mBAAmB,EAAE,KAAK,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAGxG,OAAO,EAAkC,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"salesorders-list.server.d.ts","sourceRoot":"","sources":["../../src/lib/salesorders-list.server.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,E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C;IAChC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,yDAAyD;IACzD,MAAM,CAAC,EAAE,UAAU,CAAC;IACpB,kEAAkE;IAClE,QAAQ,EAAE,gBAAgB,CAAC;CAC5B;AAqHD,wBAAgB,wBAAwB,SAIvC;AAkBD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CACvC;AAoDD;+EAC+E;AAC/E,wBAAgB,iBAAiB,CAAC,UAAU,EAAE,CAAC,MAAM,GAAG,IAAI,CAAC,EAAE,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAgB3G;AA8BD,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,UAAU,EAClB,kBAAkB,GAAE,cAAyB,GAC5C,OAAO,CAAC,UAAU,CAAC,CA8wCrB;AA0DD,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,MAAM,EAAE,EACb,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,mBAAmB,CAAC,EACzC,KAAK,EAAE,MAAM,GAAG,IAAI,GACnB,qBAAqB,CAIvB"}
|
|
@@ -16,6 +16,8 @@ import { combinedCartCount, mergeSummaries, summarize } from "./plan-coverage.js
|
|
|
16
16
|
import { resolveOrderNumbers } from "./order-numbers.server.js";
|
|
17
17
|
import { mergeStages, resolveOrderStage } from "./order-status.js";
|
|
18
18
|
import { loadBacklogFlags } from "./order-backlog.server.js";
|
|
19
|
+
import { detectSource, hasProblem, invoiceRoute, isInvoicedDone, toProgressMember, } from "./order-progress.js";
|
|
20
|
+
import { loadInvoiceStatuses, loadPickProgress } from "./order-progress.server.js";
|
|
19
21
|
const FO_CAP = 20000;
|
|
20
22
|
const LOCAL_CAP = 5000;
|
|
21
23
|
const PROPOSAL_CAP = 2000;
|
|
@@ -339,14 +341,14 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
339
341
|
.order("created_at", { ascending: false })
|
|
340
342
|
.limit(LOCAL_CAP);
|
|
341
343
|
if (params.since && params.until) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
344
|
+
// order_date/delivery_date zijn tekst 'JJJJ-MM-DD': vergelijk met
|
|
345
|
+
// kalenderdagen (Amsterdam), halfopen. Een volledige ISO-tijd als grens
|
|
346
|
+
// liet '2026-10-26' toch door ('2026-10-26' < '2026-10-26T…').
|
|
347
|
+
const from = params.sinceDate ?? params.since.slice(0, 10);
|
|
348
|
+
const to = params.untilDate ?? params.until.slice(0, 10);
|
|
349
|
+
localQ = localQ
|
|
350
|
+
.gte(params.dateField === "delivery" ? "delivery_date" : "order_date", from)
|
|
351
|
+
.lt(params.dateField === "delivery" ? "delivery_date" : "order_date", to);
|
|
350
352
|
}
|
|
351
353
|
const localRes = await localQ;
|
|
352
354
|
if (localRes.error)
|
|
@@ -374,10 +376,12 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
374
376
|
.in("order_id", localIds.slice(0, 1000));
|
|
375
377
|
for (const s of (shipRows ?? [])) {
|
|
376
378
|
const key = String(s.order_id);
|
|
377
|
-
const prev = shipmentStateByOrder.get(key) ?? { shipped: false, picked: false };
|
|
379
|
+
const prev = shipmentStateByOrder.get(key) ?? { shipped: false, picked: false, shippedAt: null };
|
|
378
380
|
const st = String(s.status ?? "").toLowerCase();
|
|
379
381
|
if (s.shipped_at || st === "verzonden" || st === "shipped")
|
|
380
382
|
prev.shipped = true;
|
|
383
|
+
if (s.shipped_at && (!prev.shippedAt || String(s.shipped_at) > prev.shippedAt))
|
|
384
|
+
prev.shippedAt = String(s.shipped_at);
|
|
381
385
|
if (st === "gepickt" || st === "picked" || st === "gecontroleerd")
|
|
382
386
|
prev.picked = true;
|
|
383
387
|
shipmentStateByOrder.set(key, prev);
|
|
@@ -638,6 +642,19 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
638
642
|
isReservation: localRow ? !!localRow.is_reservation : false,
|
|
639
643
|
});
|
|
640
644
|
dto.invoiceState = localRow ? invoiceStateLabel(localRow) : null;
|
|
645
|
+
// Weergave: bron, klant-id, orders.id, factuurroute en verzendmoment.
|
|
646
|
+
dto.source = detectSource({
|
|
647
|
+
rowKind: "floriday",
|
|
648
|
+
orderSource: localRow?.order_source ?? "floriday",
|
|
649
|
+
cfSource: (localRow?.custom_fields ?? {})?.source ?? null,
|
|
650
|
+
});
|
|
651
|
+
dto.customerId = localRow?.customer_id ? String(localRow.customer_id) : null;
|
|
652
|
+
dto.orderRowId = localRow?.id ? String(localRow.id) : null;
|
|
653
|
+
dto.invoiceRoute = invoiceRoute({
|
|
654
|
+
floridaySalesOrderId: localRow?.floriday_sales_order_id ?? String(r.floriday_id ?? ""),
|
|
655
|
+
orderSource: localRow?.order_source ?? "floriday",
|
|
656
|
+
});
|
|
657
|
+
dto.shippedAt = shipState?.shippedAt ?? null;
|
|
641
658
|
dto.invoiceNote = localRow?.invoice_ready_note ?? null;
|
|
642
659
|
dto.floridayFulfilled = Boolean((localRow?.custom_fields ?? {})?.floriday_fulfilled);
|
|
643
660
|
dto.notReportedToFloriday = isNotReportedLocally(dto.stage, dto.floridayFulfilled);
|
|
@@ -800,6 +817,11 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
800
817
|
: undefined;
|
|
801
818
|
localOrders.push({
|
|
802
819
|
id: `local:${r.id}`,
|
|
820
|
+
source: detectSource({ rowKind: "order", orderSource: r.order_source ?? null, cfSource: cf?.source ?? null }),
|
|
821
|
+
customerId: customerId || null,
|
|
822
|
+
orderRowId: String(r.id),
|
|
823
|
+
invoiceRoute: invoiceRoute({ floridaySalesOrderId: r.floriday_sales_order_id ?? null, orderSource: r.order_source ?? null }),
|
|
824
|
+
shippedAt: shipmentStateByOrder.get(String(r.id))?.shippedAt ?? null,
|
|
803
825
|
mixedDeliveryDates: Boolean(r.custom_fields?.floriday_mixed_delivery_dates),
|
|
804
826
|
unlinkedProducts: unlinkedFloridayProducts(r),
|
|
805
827
|
orderNumber: centralOrderNumber(r.order_number),
|
|
@@ -1120,6 +1142,23 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
1120
1142
|
});
|
|
1121
1143
|
await Promise.all([overviewTask, dismissalsTask, backlogTask]);
|
|
1122
1144
|
t.mark("12_engine");
|
|
1145
|
+
// 12i) Factuurstand (Facturatie) voor alle orders in de periode (nodig voor
|
|
1146
|
+
// de telling "Gefactureerd"), per 500 id's, hooguit 1,5 s. Pickvoortgang
|
|
1147
|
+
// komt pas na het pagineren, alleen voor de zichtbare rijen (14e).
|
|
1148
|
+
const features = { erpInvoices: false, pickProgress: false };
|
|
1149
|
+
if (!params.all && !params.localOrderId && all.length) {
|
|
1150
|
+
await t.time("12i_factuur", async () => {
|
|
1151
|
+
const ids = Array.from(new Set(all.map((o) => o.orderRowId).filter((v) => !!v)));
|
|
1152
|
+
const res = await loadInvoiceStatuses(supabase, ids);
|
|
1153
|
+
features.erpInvoices = res.available;
|
|
1154
|
+
warnings.push(...res.warnings);
|
|
1155
|
+
if (res.available)
|
|
1156
|
+
for (const o of all)
|
|
1157
|
+
if (o.orderRowId)
|
|
1158
|
+
o.erpInvoice = res.invoices.get(o.orderRowId) ?? null;
|
|
1159
|
+
});
|
|
1160
|
+
}
|
|
1161
|
+
const membersOf = (g) => g.map((m) => toProgressMember(m));
|
|
1123
1162
|
// 13) Filteren (zoek + status), tellen, pagineren — op samengevouwen rijen.
|
|
1124
1163
|
const search = (params.search ?? "").trim().toLowerCase();
|
|
1125
1164
|
const matchesSearch = (members) => !search ||
|
|
@@ -1142,6 +1181,10 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
1142
1181
|
const isBacklogGroup = (members) => stageOf(members) === "topick" && members.some((m) => m.backlog);
|
|
1143
1182
|
// Verzonden in het ERP, nog niet afgemeld bij Floriday (eigen kenmerk).
|
|
1144
1183
|
const isNotReportedGroup = (members) => members.some((m) => m.notReportedToFloriday);
|
|
1184
|
+
// Gefactureerd: elke order klaar volgens zijn eigen route (ERP "verstuurd",
|
|
1185
|
+
// Floriday volledig afgemeld). Probleem: een blokkade (zie memberProblems).
|
|
1186
|
+
const isInvoicedGroup = (members) => stageOf(members) !== "cancelled" && isInvoicedDone(membersOf(members), features);
|
|
1187
|
+
const isProblemGroup = (members) => stageOf(members) !== "cancelled" && hasProblem(membersOf(members));
|
|
1145
1188
|
const matchesTab = (members) => {
|
|
1146
1189
|
if (params.tab === "all")
|
|
1147
1190
|
return true;
|
|
@@ -1149,12 +1192,12 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
1149
1192
|
return isBacklogGroup(members);
|
|
1150
1193
|
if (params.tab === "not_reported")
|
|
1151
1194
|
return isNotReportedGroup(members);
|
|
1152
|
-
if (
|
|
1153
|
-
return
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
return
|
|
1195
|
+
if (params.tab === "invoiced")
|
|
1196
|
+
return isInvoicedGroup(members);
|
|
1197
|
+
if (params.tab === "problem")
|
|
1198
|
+
return isProblemGroup(members);
|
|
1199
|
+
// "Te picken" toont alle te picken orders, ook te laat.
|
|
1200
|
+
return stageOf(members) === params.tab;
|
|
1158
1201
|
};
|
|
1159
1202
|
const withoutTab = groups.filter((g) => matchesSearch(g) && matchesStatusFilter(g));
|
|
1160
1203
|
const filteredGroups = withoutTab.filter(matchesTab);
|
|
@@ -1167,14 +1210,18 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
1167
1210
|
shipped: 0,
|
|
1168
1211
|
cancelled: 0,
|
|
1169
1212
|
not_reported: 0,
|
|
1213
|
+
invoiced: 0,
|
|
1214
|
+
problem: 0,
|
|
1170
1215
|
};
|
|
1171
1216
|
for (const g of withoutTab) {
|
|
1172
1217
|
if (isNotReportedGroup(g))
|
|
1173
1218
|
statusCounts.not_reported++;
|
|
1174
|
-
if (isBacklogGroup(g))
|
|
1219
|
+
if (isBacklogGroup(g))
|
|
1175
1220
|
statusCounts.backlog++;
|
|
1176
|
-
|
|
1177
|
-
|
|
1221
|
+
if (isInvoicedGroup(g))
|
|
1222
|
+
statusCounts.invoiced++;
|
|
1223
|
+
if (isProblemGroup(g))
|
|
1224
|
+
statusCounts.problem++;
|
|
1178
1225
|
// Onbekende achterstand valt hier vanzelf terug onder "Te picken".
|
|
1179
1226
|
statusCounts[stageOf(g)]++;
|
|
1180
1227
|
}
|
|
@@ -1199,6 +1246,19 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
1199
1246
|
o.orderRowId = idFor(o);
|
|
1200
1247
|
const ids = visible.map(idFor).filter((v) => !!v);
|
|
1201
1248
|
if (ids.length) {
|
|
1249
|
+
// Pickvoortgang alleen voor de zichtbare rijen (incl. bufferleden), max 1,5 s.
|
|
1250
|
+
if (!params.localOrderId)
|
|
1251
|
+
enrichTasks.push(t.time("14e_pickvoortgang", async () => {
|
|
1252
|
+
const res = await loadPickProgress(supabase, ids);
|
|
1253
|
+
features.pickProgress = res.available;
|
|
1254
|
+
warnings.push(...res.warnings);
|
|
1255
|
+
if (res.available)
|
|
1256
|
+
for (const o of visible) {
|
|
1257
|
+
const oid = idFor(o);
|
|
1258
|
+
if (oid)
|
|
1259
|
+
o.pickProgress = res.pick.get(oid) ?? null;
|
|
1260
|
+
}
|
|
1261
|
+
}));
|
|
1202
1262
|
// Ophaalmoment uit de Engine (nooit zelf rekenen).
|
|
1203
1263
|
enrichTasks.push(t.time("14a_vertrek", async () => {
|
|
1204
1264
|
try {
|
|
@@ -1347,6 +1407,8 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
1347
1407
|
const ids = Array.from(new Set(g.flatMap((m) => m.floridayStatusIds ?? [])));
|
|
1348
1408
|
if (ids.length)
|
|
1349
1409
|
row.floridayStatusIds = ids;
|
|
1410
|
+
// Statusiconen: per order in de rij (na de verrijking, dus met vervoerder).
|
|
1411
|
+
row.progressMembers = membersOf(g);
|
|
1350
1412
|
return row;
|
|
1351
1413
|
});
|
|
1352
1414
|
// Totalen over de volledige gefilterde set (alle orders in elke buffer).
|
|
@@ -1363,6 +1425,7 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
1363
1425
|
warnings,
|
|
1364
1426
|
truncated,
|
|
1365
1427
|
timing,
|
|
1428
|
+
features,
|
|
1366
1429
|
};
|
|
1367
1430
|
}
|
|
1368
1431
|
// Belading per productgroep: vaste referentiedata, 10 min in het servergeheugen.
|