@flowselections/floriday-afhandeling-module 1.0.25 → 1.0.26
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/afhandeling/CapacityWarning.d.ts +10 -0
- package/dist-lib/components/afhandeling/CapacityWarning.d.ts.map +1 -0
- package/dist-lib/components/afhandeling/CapacityWarning.js +12 -0
- package/dist-lib/components/afhandeling/ControlePage.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/ControlePage.js +7 -2
- package/dist-lib/components/afhandeling/DagDetailDialog.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/DagDetailDialog.js +158 -62
- package/dist-lib/components/afhandeling/LeveringenPage.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/LeveringenPage.js +2 -10
- package/dist-lib/components/afhandeling/PickAgendaView.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/PickAgendaView.js +4 -11
- package/dist-lib/components/afhandeling/VervoerdersPage.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/VervoerdersPage.js +2 -5
- package/dist-lib/components/afhandeling/VerzetOrderDialog.d.ts +14 -0
- package/dist-lib/components/afhandeling/VerzetOrderDialog.d.ts.map +1 -0
- package/dist-lib/components/afhandeling/VerzetOrderDialog.js +203 -0
- package/dist-lib/components/afhandeling/WeekAgendaView.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/WeekAgendaView.js +7 -3
- package/dist-lib/components/pickstation/PickstationPage.d.ts.map +1 -1
- package/dist-lib/components/pickstation/PickstationPage.js +1 -0
- package/dist-lib/components/settings/VervoerdersSettingsCard.d.ts.map +1 -1
- package/dist-lib/components/settings/VervoerdersSettingsCard.js +2 -5
- package/dist-lib/hooks/useCapacityCheck.d.ts +10 -0
- package/dist-lib/hooks/useCapacityCheck.d.ts.map +1 -0
- package/dist-lib/hooks/useCapacityCheck.js +22 -0
- package/dist-lib/hooks/useEngineTasks.d.ts +14 -0
- package/dist-lib/hooks/useEngineTasks.d.ts.map +1 -0
- package/dist-lib/hooks/useEngineTasks.js +49 -0
- package/dist-lib/hooks/useOrderPlanning.d.ts +8 -2
- package/dist-lib/hooks/useOrderPlanning.d.ts.map +1 -1
- package/dist-lib/hooks/useOrderPlanning.js +95 -93
- package/dist-lib/index.d.ts +0 -3
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +1 -5
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +9010 -5433
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +9010 -5433
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +9010 -5433
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +9184 -5544
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/afhandelingSettings.functions.d.ts +7186 -32
- package/dist-lib/lib/afhandelingSettings.functions.d.ts.map +1 -1
- package/dist-lib/lib/carriers.functions.d.ts +17965 -80
- package/dist-lib/lib/carriers.functions.d.ts.map +1 -1
- package/dist-lib/lib/cartAssignments.functions.d.ts +17965 -80
- package/dist-lib/lib/cartAssignments.functions.d.ts.map +1 -1
- package/dist-lib/lib/cartControl.functions.d.ts +35962 -170
- package/dist-lib/lib/cartControl.functions.d.ts.map +1 -1
- package/dist-lib/lib/cartControl.functions.js +103 -13
- package/dist-lib/lib/floriday.functions.d.ts +9010 -5433
- package/dist-lib/lib/floriday.functions.d.ts.map +1 -1
- package/dist-lib/lib/logisticsEngine/capacity.d.ts +19 -0
- package/dist-lib/lib/logisticsEngine/capacity.d.ts.map +1 -0
- package/dist-lib/lib/logisticsEngine/capacity.js +91 -0
- package/dist-lib/lib/logisticsEngine/engine.d.ts +99 -0
- package/dist-lib/lib/logisticsEngine/engine.d.ts.map +1 -0
- package/dist-lib/lib/logisticsEngine/engine.js +102 -0
- package/dist-lib/lib/logisticsEngine/reschedule.d.ts +65 -0
- package/dist-lib/lib/logisticsEngine/reschedule.d.ts.map +1 -0
- package/dist-lib/lib/logisticsEngine/reschedule.js +86 -0
- package/dist-lib/lib/logisticsEngine/staffPlanning.d.ts +37 -0
- package/dist-lib/lib/logisticsEngine/staffPlanning.d.ts.map +1 -0
- package/dist-lib/lib/logisticsEngine/staffPlanning.js +100 -0
- package/dist-lib/lib/serverFnError.d.ts +10 -0
- package/dist-lib/lib/serverFnError.d.ts.map +1 -0
- package/dist-lib/lib/serverFnError.js +29 -0
- package/dist-lib/lib/serverRoutes/index.d.ts +0 -1
- package/dist-lib/lib/serverRoutes/index.d.ts.map +1 -1
- package/dist-lib/lib/serverRoutes/index.js +0 -1
- package/dist-lib/lib/timezone.d.ts +27 -0
- package/dist-lib/lib/timezone.d.ts.map +1 -0
- package/dist-lib/lib/timezone.js +68 -0
- package/package.json +6 -21
- package/dist-lib/components/engine/CapaciteitsmaatregelenPage.d.ts +0 -2
- package/dist-lib/components/engine/CapaciteitsmaatregelenPage.d.ts.map +0 -1
- package/dist-lib/components/engine/CapaciteitsmaatregelenPage.js +0 -40
- package/dist-lib/components/engine/CapaciteitsmonitorPage.d.ts +0 -2
- package/dist-lib/components/engine/CapaciteitsmonitorPage.d.ts.map +0 -1
- package/dist-lib/components/engine/CapaciteitsmonitorPage.js +0 -49
- package/dist-lib/components/engine/FormulesPage.d.ts +0 -2
- package/dist-lib/components/engine/FormulesPage.d.ts.map +0 -1
- package/dist-lib/components/engine/FormulesPage.js +0 -252
- package/dist-lib/components/engine/PlaceholderPage.d.ts +0 -6
- package/dist-lib/components/engine/PlaceholderPage.d.ts.map +0 -1
- package/dist-lib/components/engine/PlaceholderPage.js +0 -6
- package/dist-lib/components/engine/StrategieenPage.d.ts +0 -2
- package/dist-lib/components/engine/StrategieenPage.d.ts.map +0 -1
- package/dist-lib/components/engine/StrategieenPage.js +0 -80
- package/dist-lib/lib/logisticsEngine/capacity.functions.d.ts +0 -64978
- package/dist-lib/lib/logisticsEngine/capacity.functions.d.ts.map +0 -1
- package/dist-lib/lib/logisticsEngine/capacity.functions.js +0 -90
- package/dist-lib/lib/logisticsEngine/config.d.ts +0 -140
- package/dist-lib/lib/logisticsEngine/config.d.ts.map +0 -1
- package/dist-lib/lib/logisticsEngine/config.js +0 -488
- package/dist-lib/lib/logisticsEngine/enginePickTime.d.ts +0 -29
- package/dist-lib/lib/logisticsEngine/enginePickTime.d.ts.map +0 -1
- package/dist-lib/lib/logisticsEngine/enginePickTime.js +0 -136
- package/dist-lib/lib/logisticsEngine/evaluate.functions.d.ts +0 -16278
- package/dist-lib/lib/logisticsEngine/evaluate.functions.d.ts.map +0 -1
- package/dist-lib/lib/logisticsEngine/evaluate.functions.js +0 -104
- package/dist-lib/lib/logisticsEngine/expression.d.ts +0 -21
- package/dist-lib/lib/logisticsEngine/expression.d.ts.map +0 -1
- package/dist-lib/lib/logisticsEngine/expression.js +0 -263
- package/dist-lib/lib/logisticsEngine/formulas.functions.d.ts +0 -32512
- package/dist-lib/lib/logisticsEngine/formulas.functions.d.ts.map +0 -1
- package/dist-lib/lib/logisticsEngine/formulas.functions.js +0 -58
- package/dist-lib/lib/logisticsEngine/safetyLayer.d.ts +0 -83
- package/dist-lib/lib/logisticsEngine/safetyLayer.d.ts.map +0 -1
- package/dist-lib/lib/logisticsEngine/safetyLayer.js +0 -182
- package/dist-lib/lib/logisticsEngine/strategies.functions.d.ts +0 -129961
- package/dist-lib/lib/logisticsEngine/strategies.functions.d.ts.map +0 -1
- package/dist-lib/lib/logisticsEngine/strategies.functions.js +0 -176
- package/dist-lib/lib/logisticsEngine/variables.d.ts +0 -29
- package/dist-lib/lib/logisticsEngine/variables.d.ts.map +0 -1
- package/dist-lib/lib/logisticsEngine/variables.js +0 -144
- package/dist-lib/lib/logisticsEngine/wizard.functions.d.ts +0 -64976
- package/dist-lib/lib/logisticsEngine/wizard.functions.d.ts.map +0 -1
- package/dist-lib/lib/logisticsEngine/wizard.functions.js +0 -175
- package/dist-lib/lib/serverRoutes/logisticsTick.handler.d.ts +0 -3
- package/dist-lib/lib/serverRoutes/logisticsTick.handler.d.ts.map +0 -1
- package/dist-lib/lib/serverRoutes/logisticsTick.handler.js +0 -42
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
export declare const OWNER_MODULE = "afhandeling";
|
|
2
|
+
export declare const SOURCE_MODULE = "afhandeling";
|
|
3
|
+
export type LoadCarrierType = "trolley" | "danish_container" | "dense_container" | "pallet" | "box" | "loose";
|
|
4
|
+
export type EngineTaskStatus = "planned" | "ready" | "in_progress" | "done" | "skipped" | "cancelled" | "failed";
|
|
5
|
+
export type EngineTaskType = "load.compose" | "control.execute" | "print.control_note" | "print.shipping_note" | "transport.dispatch";
|
|
6
|
+
export interface EngineBufferDecision {
|
|
7
|
+
buffer: boolean;
|
|
8
|
+
bufferRef: string | null;
|
|
9
|
+
bufferKey?: string | null;
|
|
10
|
+
matchCriteria?: string[];
|
|
11
|
+
release?: string;
|
|
12
|
+
reason?: string;
|
|
13
|
+
trace?: Array<{
|
|
14
|
+
rule: string;
|
|
15
|
+
result?: boolean;
|
|
16
|
+
value?: unknown;
|
|
17
|
+
message?: string;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
20
|
+
export interface EngineLoadCarrier {
|
|
21
|
+
ref?: string | null;
|
|
22
|
+
index?: number | null;
|
|
23
|
+
type?: LoadCarrierType | null;
|
|
24
|
+
layers?: number | null;
|
|
25
|
+
boxes?: number | null;
|
|
26
|
+
orderRefs?: string[];
|
|
27
|
+
lines?: Array<Record<string, unknown>>;
|
|
28
|
+
[key: string]: unknown;
|
|
29
|
+
}
|
|
30
|
+
export interface EngineLoadComposePayload {
|
|
31
|
+
loadCarriers?: EngineLoadCarrier[];
|
|
32
|
+
fillMode?: "generated" | "manual_scan";
|
|
33
|
+
pickMode?: string | null;
|
|
34
|
+
pickStartMode?: string | null;
|
|
35
|
+
pickMinutes?: number | null;
|
|
36
|
+
staff?: number | null;
|
|
37
|
+
reserveMinutes?: number | null;
|
|
38
|
+
scanner?: "required" | "optional" | "none" | null;
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface EngineTask {
|
|
42
|
+
id: string;
|
|
43
|
+
task_type: string;
|
|
44
|
+
status: string;
|
|
45
|
+
order_ref: string;
|
|
46
|
+
buffer_ref: string | null;
|
|
47
|
+
owner_module: string;
|
|
48
|
+
payload: EngineLoadComposePayload;
|
|
49
|
+
result: Record<string, unknown> | null;
|
|
50
|
+
planned_start: string | null;
|
|
51
|
+
planned_end: string | null;
|
|
52
|
+
due_at: string | null;
|
|
53
|
+
priority: number;
|
|
54
|
+
sequence: number;
|
|
55
|
+
rule_version: number | null;
|
|
56
|
+
shadow: boolean;
|
|
57
|
+
error: string | null;
|
|
58
|
+
claimed_by: string | null;
|
|
59
|
+
claimed_at: string | null;
|
|
60
|
+
started_at: string | null;
|
|
61
|
+
completed_at: string | null;
|
|
62
|
+
created_at: string;
|
|
63
|
+
updated_at: string;
|
|
64
|
+
}
|
|
65
|
+
export interface BufferDecisionInput {
|
|
66
|
+
orderRef: string;
|
|
67
|
+
customerRef?: string | null;
|
|
68
|
+
deliveryLocationRef?: string | null;
|
|
69
|
+
deliveryDate?: string | null;
|
|
70
|
+
checkinAt?: string | null;
|
|
71
|
+
pickupAt?: string | null;
|
|
72
|
+
loadCarrierType?: LoadCarrierType | null;
|
|
73
|
+
isReservation?: boolean;
|
|
74
|
+
strategyId?: string | null;
|
|
75
|
+
}
|
|
76
|
+
/** Vraag het indelingsbesluit op. Nooit zelf indelen zonder dit besluit. */
|
|
77
|
+
export declare function getBufferDecision(input: BufferDecisionInput): Promise<EngineBufferDecision | null>;
|
|
78
|
+
/** Meld een gebeurtenis aan de Engine (bv. order.received / order.changed). */
|
|
79
|
+
export declare function emitEngineEvent(params: {
|
|
80
|
+
eventType: string;
|
|
81
|
+
orderRef: string;
|
|
82
|
+
payload?: Record<string, unknown>;
|
|
83
|
+
shadow?: boolean;
|
|
84
|
+
idempotencyKey?: string;
|
|
85
|
+
}): Promise<boolean>;
|
|
86
|
+
/** Haal de taken op die deze module moet uitvoeren. */
|
|
87
|
+
export declare function listEngineTasks(options?: {
|
|
88
|
+
taskTypes?: string[];
|
|
89
|
+
statuses?: string[];
|
|
90
|
+
limit?: number;
|
|
91
|
+
}): Promise<EngineTask[]>;
|
|
92
|
+
export declare function claimEngineTask(taskId: string, worker?: string): Promise<boolean>;
|
|
93
|
+
/** Rond af op de rule_version van de taak — nooit op een nieuwere versie. */
|
|
94
|
+
export declare function completeEngineTask(task: Pick<EngineTask, "id" | "rule_version">, result?: Record<string, unknown>): Promise<boolean>;
|
|
95
|
+
/** Meld een afwijking terug zodat de Engine kan herplannen. */
|
|
96
|
+
export declare function failEngineTask(taskId: string, reason: string): Promise<boolean>;
|
|
97
|
+
export declare function isScannerRequired(task: EngineTask): boolean;
|
|
98
|
+
export declare function loadCarrierCount(task: EngineTask): number;
|
|
99
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../../src/lib/logisticsEngine/engine.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY,gBAAgB,CAAC;AAC1C,eAAO,MAAM,aAAa,gBAAgB,CAAC;AAE3C,MAAM,MAAM,eAAe,GACvB,SAAS,GACT,kBAAkB,GAClB,iBAAiB,GACjB,QAAQ,GACR,KAAK,GACL,OAAO,CAAC;AAEZ,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,OAAO,GACP,aAAa,GACb,MAAM,GACN,SAAS,GACT,WAAW,GACX,QAAQ,CAAC;AAEb,MAAM,MAAM,cAAc,GACtB,cAAc,GACd,iBAAiB,GACjB,oBAAoB,GACpB,qBAAqB,GACrB,oBAAoB,CAAC;AAEzB,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;I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AAgB,iBAAiB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAE3D;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAEzD"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Koppeling met de Logistics Engine — uitsluitend via de gedeelde Supabase-database.
|
|
3
|
+
*
|
|
4
|
+
* Deze module beslist zelf niets meer over buffering, belading, picken of
|
|
5
|
+
* transport. Alle besluiten komen van de Rule Engine (stap 3 "Order picken").
|
|
6
|
+
*/
|
|
7
|
+
import { supabase } from "../../integrations/supabase/client";
|
|
8
|
+
export const OWNER_MODULE = "afhandeling";
|
|
9
|
+
export const SOURCE_MODULE = "afhandeling";
|
|
10
|
+
/** Vraag het indelingsbesluit op. Nooit zelf indelen zonder dit besluit. */
|
|
11
|
+
export async function getBufferDecision(input) {
|
|
12
|
+
const { data, error } = await supabase.rpc("logistics_buffer_decision", {
|
|
13
|
+
p_order: {
|
|
14
|
+
orderRef: input.orderRef,
|
|
15
|
+
customerRef: input.customerRef ?? null,
|
|
16
|
+
deliveryLocationRef: input.deliveryLocationRef ?? null,
|
|
17
|
+
deliveryDate: input.deliveryDate ?? null,
|
|
18
|
+
checkinAt: input.checkinAt ?? null,
|
|
19
|
+
pickupAt: input.pickupAt ?? null,
|
|
20
|
+
loadCarrierType: input.loadCarrierType ?? null,
|
|
21
|
+
isReservation: input.isReservation ?? false,
|
|
22
|
+
},
|
|
23
|
+
p_strategy_id: input.strategyId ?? undefined,
|
|
24
|
+
});
|
|
25
|
+
if (error) {
|
|
26
|
+
console.error("[engine] buffer decision failed", { message: error.message, orderRef: input.orderRef });
|
|
27
|
+
return null;
|
|
28
|
+
}
|
|
29
|
+
return data ?? null;
|
|
30
|
+
}
|
|
31
|
+
/** Meld een gebeurtenis aan de Engine (bv. order.received / order.changed). */
|
|
32
|
+
export async function emitEngineEvent(params) {
|
|
33
|
+
const { error } = await supabase.rpc("logistics_emit_event", {
|
|
34
|
+
p_source_module: SOURCE_MODULE,
|
|
35
|
+
p_event_type: params.eventType,
|
|
36
|
+
p_order_ref: params.orderRef,
|
|
37
|
+
p_payload: (params.payload ?? {}),
|
|
38
|
+
p_shadow: params.shadow ?? true,
|
|
39
|
+
p_idempotency_key: params.idempotencyKey ?? `${SOURCE_MODULE}:${params.eventType}:${params.orderRef}`,
|
|
40
|
+
});
|
|
41
|
+
if (error) {
|
|
42
|
+
console.error("[engine] emit event failed", { message: error.message, orderRef: params.orderRef });
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
const TASK_COLUMNS = "id, task_type, status, order_ref, buffer_ref, owner_module, payload, result, planned_start, planned_end, due_at, priority, sequence, rule_version, shadow, error, claimed_by, claimed_at, started_at, completed_at, created_at, updated_at";
|
|
48
|
+
/** Haal de taken op die deze module moet uitvoeren. */
|
|
49
|
+
export async function listEngineTasks(options) {
|
|
50
|
+
let query = supabase
|
|
51
|
+
.from("logistics_tasks")
|
|
52
|
+
.select(TASK_COLUMNS)
|
|
53
|
+
.eq("owner_module", OWNER_MODULE)
|
|
54
|
+
.order("planned_start", { ascending: true, nullsFirst: false })
|
|
55
|
+
.order("sequence", { ascending: true })
|
|
56
|
+
.limit(options?.limit ?? 500);
|
|
57
|
+
if (options?.taskTypes?.length)
|
|
58
|
+
query = query.in("task_type", options.taskTypes);
|
|
59
|
+
if (options?.statuses?.length)
|
|
60
|
+
query = query.in("status", options.statuses);
|
|
61
|
+
const { data, error } = await query;
|
|
62
|
+
if (error) {
|
|
63
|
+
console.error("[engine] list tasks failed", { message: error.message });
|
|
64
|
+
return [];
|
|
65
|
+
}
|
|
66
|
+
return (data ?? []);
|
|
67
|
+
}
|
|
68
|
+
export async function claimEngineTask(taskId, worker) {
|
|
69
|
+
const { error } = await supabase.rpc("logistics_claim_task", { p_task_id: taskId, p_worker: worker ?? OWNER_MODULE });
|
|
70
|
+
if (error) {
|
|
71
|
+
console.error("[engine] claim task failed", { message: error.message, taskId });
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
return true;
|
|
75
|
+
}
|
|
76
|
+
/** Rond af op de rule_version van de taak — nooit op een nieuwere versie. */
|
|
77
|
+
export async function completeEngineTask(task, result) {
|
|
78
|
+
const { error } = await supabase.rpc("logistics_complete_task", {
|
|
79
|
+
p_task_id: task.id,
|
|
80
|
+
p_result: { ...(result ?? {}), ruleVersion: task.rule_version },
|
|
81
|
+
});
|
|
82
|
+
if (error) {
|
|
83
|
+
console.error("[engine] complete task failed", { message: error.message, taskId: task.id });
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
88
|
+
/** Meld een afwijking terug zodat de Engine kan herplannen. */
|
|
89
|
+
export async function failEngineTask(taskId, reason) {
|
|
90
|
+
const { error } = await supabase.rpc("logistics_fail_task", { p_task_id: taskId, p_error: reason });
|
|
91
|
+
if (error) {
|
|
92
|
+
console.error("[engine] fail task failed", { message: error.message, taskId });
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
return true;
|
|
96
|
+
}
|
|
97
|
+
export function isScannerRequired(task) {
|
|
98
|
+
return task.payload?.scanner === "required";
|
|
99
|
+
}
|
|
100
|
+
export function loadCarrierCount(task) {
|
|
101
|
+
return task.payload?.loadCarriers?.length ?? 0;
|
|
102
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export interface RescheduleMoment {
|
|
2
|
+
pickupDate: string | null;
|
|
3
|
+
pickupFrom: string | null;
|
|
4
|
+
pickupTo: string | null;
|
|
5
|
+
deliveryDate: string | null;
|
|
6
|
+
}
|
|
7
|
+
export interface ReschedulePreview {
|
|
8
|
+
ok: boolean;
|
|
9
|
+
error?: string;
|
|
10
|
+
orderRef?: string;
|
|
11
|
+
orderId?: string | null;
|
|
12
|
+
bufferId?: string | null;
|
|
13
|
+
planLocked?: boolean;
|
|
14
|
+
current?: RescheduleMoment;
|
|
15
|
+
next?: RescheduleMoment;
|
|
16
|
+
direction?: "earlier" | "later" | "same";
|
|
17
|
+
dayShift?: number;
|
|
18
|
+
timeChanged?: boolean;
|
|
19
|
+
keepDeliveryMoment?: boolean;
|
|
20
|
+
customerNoticeRequired?: boolean;
|
|
21
|
+
affectedTasks?: number;
|
|
22
|
+
}
|
|
23
|
+
export interface RescheduleResult extends ReschedulePreview {
|
|
24
|
+
applied?: boolean;
|
|
25
|
+
rescheduleId?: string | null;
|
|
26
|
+
delayAlertId?: string | null;
|
|
27
|
+
customerNotified?: boolean;
|
|
28
|
+
customerNotifyError?: string | null;
|
|
29
|
+
pickupMoment?: string | null;
|
|
30
|
+
}
|
|
31
|
+
export interface RescheduleInput {
|
|
32
|
+
orderRef: string;
|
|
33
|
+
pickupDate?: string | null;
|
|
34
|
+
pickupFrom?: string | null;
|
|
35
|
+
pickupTo?: string | null;
|
|
36
|
+
}
|
|
37
|
+
export declare function previewReschedule(input: RescheduleInput): Promise<ReschedulePreview>;
|
|
38
|
+
export declare function applyReschedule(input: RescheduleInput & {
|
|
39
|
+
notifyCustomer?: boolean;
|
|
40
|
+
reason?: string;
|
|
41
|
+
userId?: string | null;
|
|
42
|
+
}): Promise<RescheduleResult>;
|
|
43
|
+
export interface RescheduleHistoryRow {
|
|
44
|
+
id: string;
|
|
45
|
+
created_at: string;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
export declare function listRescheduleHistory(orderRef: string): Promise<RescheduleHistoryRow[]>;
|
|
49
|
+
export interface PickMoment {
|
|
50
|
+
taskId: string;
|
|
51
|
+
plannedStart: string | null;
|
|
52
|
+
plannedEnd: string | null;
|
|
53
|
+
}
|
|
54
|
+
/** Het pickmoment zoals de Engine het heeft ingepland (load.compose-taken). */
|
|
55
|
+
export declare function getPickMoments(orderRef: string): Promise<PickMoment[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Verzet de pickdag via de Engine. De RPC bewaart de keuze ook op de order,
|
|
58
|
+
* zodat een volgende Engine-planningsronde de handmatige dag niet overschrijft.
|
|
59
|
+
*/
|
|
60
|
+
export declare function setPickDay(orderRef: string, day: string): Promise<{
|
|
61
|
+
ok: boolean;
|
|
62
|
+
error?: string;
|
|
63
|
+
updated: number;
|
|
64
|
+
}>;
|
|
65
|
+
//# sourceMappingURL=reschedule.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reschedule.d.ts","sourceRoot":"","sources":["../../../src/lib/logisticsEngine/reschedule.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,gBAAgB;IAC/B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,EAAE,EAAE,OAAO,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,gBAAgB,CAAC;IAC3B,IAAI,CAAC,EAAE,gBAAgB,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,GAAG,OAAO,GAAG,MAAM,CAAC;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACzD,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,YAAY,CA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AGG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAezH"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Order verzetten — uitsluitend via de twee RPC's van de Logistics Engine.
|
|
3
|
+
* Deze module rekent zelf niets uit en doet nooit een eigen UPDATE.
|
|
4
|
+
*/
|
|
5
|
+
import { supabase } from "../../integrations/supabase/client";
|
|
6
|
+
export async function previewReschedule(input) {
|
|
7
|
+
const { data, error } = await supabase.rpc("logistics_reschedule_preview", {
|
|
8
|
+
p_order_ref: input.orderRef,
|
|
9
|
+
p_pickup_date: input.pickupDate ?? undefined,
|
|
10
|
+
p_pickup_from: input.pickupFrom ?? undefined,
|
|
11
|
+
p_pickup_to: input.pickupTo ?? undefined,
|
|
12
|
+
});
|
|
13
|
+
if (error) {
|
|
14
|
+
console.error("[reschedule] preview failed", { message: error.message, orderRef: input.orderRef });
|
|
15
|
+
return { ok: false, error: error.message };
|
|
16
|
+
}
|
|
17
|
+
return (data ?? { ok: false, error: "Geen antwoord van de Engine" });
|
|
18
|
+
}
|
|
19
|
+
export async function applyReschedule(input) {
|
|
20
|
+
const { data, error } = await supabase.rpc("logistics_reschedule_order", {
|
|
21
|
+
p_order_ref: input.orderRef,
|
|
22
|
+
p_pickup_date: input.pickupDate ?? undefined,
|
|
23
|
+
p_pickup_from: input.pickupFrom ?? undefined,
|
|
24
|
+
p_pickup_to: input.pickupTo ?? undefined,
|
|
25
|
+
p_notify_customer: input.notifyCustomer ?? false,
|
|
26
|
+
p_reason: input.reason ?? undefined,
|
|
27
|
+
p_source_module: "afhandeling",
|
|
28
|
+
p_user_id: input.userId ?? undefined,
|
|
29
|
+
});
|
|
30
|
+
if (error) {
|
|
31
|
+
console.error("[reschedule] apply failed", { message: error.message, orderRef: input.orderRef });
|
|
32
|
+
return { ok: false, error: error.message };
|
|
33
|
+
}
|
|
34
|
+
return (data ?? { ok: false, error: "Geen antwoord van de Engine" });
|
|
35
|
+
}
|
|
36
|
+
export async function listRescheduleHistory(orderRef) {
|
|
37
|
+
const { data, error } = await supabase
|
|
38
|
+
.from("logistics_reschedules")
|
|
39
|
+
.select("*")
|
|
40
|
+
.eq("order_ref", orderRef)
|
|
41
|
+
.order("created_at", { ascending: false })
|
|
42
|
+
.limit(20);
|
|
43
|
+
if (error) {
|
|
44
|
+
console.error("[reschedule] history failed", { message: error.message, orderRef });
|
|
45
|
+
return [];
|
|
46
|
+
}
|
|
47
|
+
return (data ?? []);
|
|
48
|
+
}
|
|
49
|
+
/** Het pickmoment zoals de Engine het heeft ingepland (load.compose-taken). */
|
|
50
|
+
export async function getPickMoments(orderRef) {
|
|
51
|
+
const { data, error } = await supabase
|
|
52
|
+
.from("logistics_tasks")
|
|
53
|
+
.select("id, planned_start, planned_end")
|
|
54
|
+
.eq("order_ref", orderRef)
|
|
55
|
+
.eq("task_type", "load.compose")
|
|
56
|
+
.order("planned_start", { ascending: true, nullsFirst: false });
|
|
57
|
+
if (error) {
|
|
58
|
+
console.error("[reschedule] pick moments failed", { message: error.message, orderRef });
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
return (data ?? []).map((r) => ({
|
|
62
|
+
taskId: r.id,
|
|
63
|
+
plannedStart: r.planned_start ?? null,
|
|
64
|
+
plannedEnd: r.planned_end ?? null,
|
|
65
|
+
}));
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Verzet de pickdag via de Engine. De RPC bewaart de keuze ook op de order,
|
|
69
|
+
* zodat een volgende Engine-planningsronde de handmatige dag niet overschrijft.
|
|
70
|
+
*/
|
|
71
|
+
export async function setPickDay(orderRef, day) {
|
|
72
|
+
const { data, error } = await supabase.rpc("logistics_set_pick_day", {
|
|
73
|
+
p_order_ref: orderRef,
|
|
74
|
+
p_pick_day: day,
|
|
75
|
+
});
|
|
76
|
+
if (error) {
|
|
77
|
+
console.error("[reschedule] set pick day failed", { message: error.message, orderRef, day });
|
|
78
|
+
return { ok: false, error: error.message, updated: 0 };
|
|
79
|
+
}
|
|
80
|
+
const result = data;
|
|
81
|
+
return {
|
|
82
|
+
ok: result?.ok === true,
|
|
83
|
+
error: result?.error,
|
|
84
|
+
updated: result?.updated ?? 0,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export interface EngineStaffDefaults {
|
|
2
|
+
avgStaff: number | null;
|
|
3
|
+
startTime: string | null;
|
|
4
|
+
endTime: string | null;
|
|
5
|
+
/** Gemiddelde picktijd per kar in minuten (uit de Logistiek Engine). */
|
|
6
|
+
minutesPerCart: number | null;
|
|
7
|
+
}
|
|
8
|
+
export interface DayStaffPlan {
|
|
9
|
+
date: string;
|
|
10
|
+
staffCount: number;
|
|
11
|
+
startTime: string;
|
|
12
|
+
endTime: string;
|
|
13
|
+
isOverride: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare function toDateKey(d: Date): string;
|
|
16
|
+
/** Standaardbezetting zoals ingesteld in de Logistiek Engine. */
|
|
17
|
+
export declare function getEngineStaffDefaults(): Promise<EngineStaffDefaults>;
|
|
18
|
+
/** Dagafwijking (indien aanwezig) op de standaardbezetting. */
|
|
19
|
+
export declare function getDayStaffPlan(date: Date): Promise<DayStaffPlan | null>;
|
|
20
|
+
export declare function setDayStaffPlan(params: {
|
|
21
|
+
date: Date;
|
|
22
|
+
staffCount: number;
|
|
23
|
+
startTime: string;
|
|
24
|
+
endTime: string;
|
|
25
|
+
}): Promise<void>;
|
|
26
|
+
export declare function clearDayStaffPlan(date: Date): Promise<void>;
|
|
27
|
+
/** Beschikbare pickminuten en capaciteit in karren. */
|
|
28
|
+
export declare function computeCapacity(opts: {
|
|
29
|
+
staffCount: number;
|
|
30
|
+
startTime: string;
|
|
31
|
+
endTime: string;
|
|
32
|
+
minutesPerCart: number | null;
|
|
33
|
+
}): {
|
|
34
|
+
workMinutes: number;
|
|
35
|
+
capacityCarts: number | null;
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=staffPlanning.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"staffPlanning.d.ts","sourceRoot":"","sources":["../../../src/lib/logisticsEngine/staffPlanning.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,wEAAwE;IACxE,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,OAAO,CAAC;CACrB;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,GAAG,MAAM,CAIzC;AAOD,iEAAiE;AACjE,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,mBAAmB,CAAC,CA+B3E;AAED,+DAA+D;AAC/D,wBAAsB,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,CAAC,CAgB9E;AAED,wBAAsB,eAAe,CAAC,MAAM,EAAE;IAC5C,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBhB;AAED,wBAAsB,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAMjE;AAED,uDAAuD;AACvD,wBAAgB,eAAe,CAAC,IAAI,EAAE;IACpC,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;CAC/B,GAAG;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAYxD"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { supabase } from "../../integrations/supabase/client";
|
|
2
|
+
import { SOURCE_MODULE } from "./engine";
|
|
3
|
+
export function toDateKey(d) {
|
|
4
|
+
const m = String(d.getMonth() + 1).padStart(2, "0");
|
|
5
|
+
const day = String(d.getDate()).padStart(2, "0");
|
|
6
|
+
return `${d.getFullYear()}-${m}-${day}`;
|
|
7
|
+
}
|
|
8
|
+
function num(v) {
|
|
9
|
+
const n = typeof v === "string" ? Number(v) : typeof v === "number" ? v : NaN;
|
|
10
|
+
return Number.isFinite(n) ? n : null;
|
|
11
|
+
}
|
|
12
|
+
/** Standaardbezetting zoals ingesteld in de Logistiek Engine. */
|
|
13
|
+
export async function getEngineStaffDefaults() {
|
|
14
|
+
const { data, error } = await supabase
|
|
15
|
+
.from("logistics_rule_configs")
|
|
16
|
+
.select("settings, is_active, updated_at")
|
|
17
|
+
.order("is_active", { ascending: false })
|
|
18
|
+
.order("updated_at", { ascending: false })
|
|
19
|
+
.limit(10);
|
|
20
|
+
if (error)
|
|
21
|
+
throw new Error(error.message);
|
|
22
|
+
for (const row of data ?? []) {
|
|
23
|
+
const fields = row.settings?.["pickstations"]?.["fields"] ?? undefined;
|
|
24
|
+
if (!fields)
|
|
25
|
+
continue;
|
|
26
|
+
const avgStaff = num(fields["avg_staff"]);
|
|
27
|
+
if (avgStaff === null)
|
|
28
|
+
continue;
|
|
29
|
+
const pickTimes = Object.entries(fields)
|
|
30
|
+
.filter(([k]) => k.startsWith("pick_time_"))
|
|
31
|
+
.map(([, v]) => num(v))
|
|
32
|
+
.filter((n) => n !== null && n > 0);
|
|
33
|
+
return {
|
|
34
|
+
avgStaff,
|
|
35
|
+
startTime: fields["start_time"] ?? null,
|
|
36
|
+
endTime: fields["end_time"] ?? null,
|
|
37
|
+
minutesPerCart: pickTimes.length
|
|
38
|
+
? pickTimes.reduce((s, n) => s + n, 0) / pickTimes.length
|
|
39
|
+
: null,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return { avgStaff: null, startTime: null, endTime: null, minutesPerCart: null };
|
|
43
|
+
}
|
|
44
|
+
/** Dagafwijking (indien aanwezig) op de standaardbezetting. */
|
|
45
|
+
export async function getDayStaffPlan(date) {
|
|
46
|
+
const key = toDateKey(date);
|
|
47
|
+
const { data, error } = await supabase
|
|
48
|
+
.from("logistics_staff_planning")
|
|
49
|
+
.select("plan_date, staff_count, start_time, end_time")
|
|
50
|
+
.eq("plan_date", key)
|
|
51
|
+
.maybeSingle();
|
|
52
|
+
if (error)
|
|
53
|
+
throw new Error(error.message);
|
|
54
|
+
if (!data)
|
|
55
|
+
return null;
|
|
56
|
+
return {
|
|
57
|
+
date: data.plan_date,
|
|
58
|
+
staffCount: Number(data.staff_count),
|
|
59
|
+
startTime: data.start_time,
|
|
60
|
+
endTime: data.end_time,
|
|
61
|
+
isOverride: true,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
export async function setDayStaffPlan(params) {
|
|
65
|
+
const { data: auth } = await supabase.auth.getUser();
|
|
66
|
+
const userId = auth.user?.id;
|
|
67
|
+
if (!userId)
|
|
68
|
+
throw new Error("Niet ingelogd");
|
|
69
|
+
const { error } = await supabase.from("logistics_staff_planning").upsert({
|
|
70
|
+
user_id: userId,
|
|
71
|
+
plan_date: toDateKey(params.date),
|
|
72
|
+
staff_count: params.staffCount,
|
|
73
|
+
start_time: params.startTime,
|
|
74
|
+
end_time: params.endTime,
|
|
75
|
+
source_module: SOURCE_MODULE,
|
|
76
|
+
}, { onConflict: "user_id,plan_date" });
|
|
77
|
+
if (error)
|
|
78
|
+
throw new Error(error.message);
|
|
79
|
+
}
|
|
80
|
+
export async function clearDayStaffPlan(date) {
|
|
81
|
+
const { error } = await supabase
|
|
82
|
+
.from("logistics_staff_planning")
|
|
83
|
+
.delete()
|
|
84
|
+
.eq("plan_date", toDateKey(date));
|
|
85
|
+
if (error)
|
|
86
|
+
throw new Error(error.message);
|
|
87
|
+
}
|
|
88
|
+
/** Beschikbare pickminuten en capaciteit in karren. */
|
|
89
|
+
export function computeCapacity(opts) {
|
|
90
|
+
const toMin = (t) => {
|
|
91
|
+
const [h, m] = t.split(":");
|
|
92
|
+
return Number(h) * 60 + Number(m ?? 0);
|
|
93
|
+
};
|
|
94
|
+
const span = Math.max(0, toMin(opts.endTime) - toMin(opts.startTime));
|
|
95
|
+
const workMinutes = span * Math.max(0, opts.staffCount);
|
|
96
|
+
const capacityCarts = opts.minutesPerCart && opts.minutesPerCart > 0
|
|
97
|
+
? Math.floor(workMinutes / opts.minutesPerCart)
|
|
98
|
+
: null;
|
|
99
|
+
return { workMinutes, capacityCarts };
|
|
100
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server functions met `requireSupabaseAuth` gooien een ruwe `Response` (401)
|
|
3
|
+
* wanneer er geen geldige sessie is. Zo'n Response is geen Error: hij belandt
|
|
4
|
+
* ongewijzigd bij de error-boundary en levert "Error: [object Response]" met
|
|
5
|
+
* een leeg scherm op. Deze helpers zetten hem altijd om naar een echte Error.
|
|
6
|
+
*/
|
|
7
|
+
export declare function toServerFnError(e: unknown): Promise<Error>;
|
|
8
|
+
/** Roept een server function aan en geeft bij elke fout de fallback terug. */
|
|
9
|
+
export declare function safeServerCall<T>(call: () => Promise<T>, fallback: T, context?: string): Promise<T>;
|
|
10
|
+
//# sourceMappingURL=serverFnError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serverFnError.d.ts","sourceRoot":"","sources":["../../src/lib/serverFnError.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAUhE;AAED,8EAA8E;AAC9E,wBAAsB,cAAc,CAAC,CAAC,EACpC,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,QAAQ,EAAE,CAAC,EACX,OAAO,CAAC,EAAE,MAAM,GACf,OAAO,CAAC,CAAC,CAAC,CAQZ"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server functions met `requireSupabaseAuth` gooien een ruwe `Response` (401)
|
|
3
|
+
* wanneer er geen geldige sessie is. Zo'n Response is geen Error: hij belandt
|
|
4
|
+
* ongewijzigd bij de error-boundary en levert "Error: [object Response]" met
|
|
5
|
+
* een leeg scherm op. Deze helpers zetten hem altijd om naar een echte Error.
|
|
6
|
+
*/
|
|
7
|
+
export async function toServerFnError(e) {
|
|
8
|
+
if (e instanceof Response) {
|
|
9
|
+
const text = await e
|
|
10
|
+
.clone()
|
|
11
|
+
.text()
|
|
12
|
+
.catch(() => "");
|
|
13
|
+
return new Error(`${e.status}: ${text.slice(0, 200) || e.statusText || "Serverfout"}`);
|
|
14
|
+
}
|
|
15
|
+
if (e instanceof Error)
|
|
16
|
+
return e;
|
|
17
|
+
return new Error(String(e));
|
|
18
|
+
}
|
|
19
|
+
/** Roept een server function aan en geeft bij elke fout de fallback terug. */
|
|
20
|
+
export async function safeServerCall(call, fallback, context) {
|
|
21
|
+
try {
|
|
22
|
+
return await call();
|
|
23
|
+
}
|
|
24
|
+
catch (e) {
|
|
25
|
+
const err = await toServerFnError(e);
|
|
26
|
+
console.error("[serverFn] call failed", { context: context ?? "onbekend", message: err.message });
|
|
27
|
+
return fallback;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -2,5 +2,4 @@ export { handlePickstationOrders } from "./pickstationOrders.handler";
|
|
|
2
2
|
export { handlePickstationPrint } from "./pickstationPrint.handler";
|
|
3
3
|
export { handlePickstationStatus } from "./pickstationStatus.handler";
|
|
4
4
|
export { handleDispatchCarrierSignups } from "./dispatchCarrierSignups.handler";
|
|
5
|
-
export { handleLogisticsTick } from "./logisticsTick.handler";
|
|
6
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/serverRoutes/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/serverRoutes/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EAAE,4BAA4B,EAAE,MAAM,kCAAkC,CAAC"}
|
|
@@ -5,4 +5,3 @@ export { handlePickstationOrders } from "./pickstationOrders.handler";
|
|
|
5
5
|
export { handlePickstationPrint } from "./pickstationPrint.handler";
|
|
6
6
|
export { handlePickstationStatus } from "./pickstationStatus.handler";
|
|
7
7
|
export { handleDispatchCarrierSignups } from "./dispatchCarrierSignups.handler";
|
|
8
|
-
export { handleLogisticsTick } from "./logisticsTick.handler";
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Alle datum-/tijdlogica in deze module rekent met de tijdzone van Amsterdam,
|
|
3
|
+
* ongeacht de tijdzone van het apparaat van de gebruiker of de server.
|
|
4
|
+
*/
|
|
5
|
+
export declare const APP_TIME_ZONE = "Europe/Amsterdam";
|
|
6
|
+
export interface AmsterdamParts {
|
|
7
|
+
year: number;
|
|
8
|
+
month: number;
|
|
9
|
+
day: number;
|
|
10
|
+
hour: number;
|
|
11
|
+
minute: number;
|
|
12
|
+
second: number;
|
|
13
|
+
}
|
|
14
|
+
/** Splits een datum op in kalenderonderdelen zoals Amsterdam ze ziet. */
|
|
15
|
+
export declare function amsterdamParts(input: Date | string | number): AmsterdamParts | null;
|
|
16
|
+
/** YYYY-MM-DD in Amsterdamse tijd. */
|
|
17
|
+
export declare function amsterdamDay(input: Date | string | number): string;
|
|
18
|
+
/** HH:MM in Amsterdamse tijd. */
|
|
19
|
+
export declare function amsterdamTime(input: Date | string | number): string;
|
|
20
|
+
/**
|
|
21
|
+
* Bouw een echte tijdstempel uit een Amsterdamse kalenderdag + kloktijd.
|
|
22
|
+
* Houdt rekening met zomer-/wintertijd.
|
|
23
|
+
*/
|
|
24
|
+
export declare function amsterdamToInstant(day: string, hour?: number, minute?: number): Date;
|
|
25
|
+
/** Datum weergeven in Amsterdamse tijd. */
|
|
26
|
+
export declare function formatAmsterdam(input: Date | string | number, options?: Intl.DateTimeFormatOptions): string;
|
|
27
|
+
//# sourceMappingURL=timezone.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/lib/timezone.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,aAAa,qBAAqB,CAAC;AAahD,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,cAAc,GAAG,IAAI,CAcnF;AAID,sCAAsC;AACtC,wBAAgB,YAAY,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAGlE;AAED,iCAAiC;AACjC,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAGnE;AAUD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,SAAI,EAAE,MAAM,SAAI,GAAG,IAAI,CAO1E;AAED,2CAA2C;AAC3C,wBAAgB,eAAe,CAC7B,KAAK,EAAE,IAAI,GAAG,MAAM,GAAG,MAAM,EAC7B,OAAO,GAAE,IAAI,CAAC,qBAAiE,GAC9E,MAAM,CAIR"}
|