@flowselections/floriday-afhandeling-module 1.0.48 → 1.0.50
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/AutoProcessStatus.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/AutoProcessStatus.js +4 -1
- package/dist-lib/components/afhandeling/ControlePage.js +1 -1
- package/dist-lib/components/afhandeling/DagDetailDialog.d.ts.map +1 -1
- package/dist-lib/components/afhandeling/DagDetailDialog.js +12 -6
- package/dist-lib/components/afhandeling/NuVersturenButton.d.ts +5 -0
- package/dist-lib/components/afhandeling/NuVersturenButton.d.ts.map +1 -0
- package/dist-lib/components/afhandeling/NuVersturenButton.js +50 -0
- package/dist-lib/components/afhandeling/ScanControleView.js +1 -1
- package/dist-lib/components/afhandeling/VervoerdersPage.js +1 -1
- package/dist-lib/components/afhandeling/VerzetOrderDialog.js +1 -1
- package/dist-lib/components/afhandeling/WerkplekWaarschuwing.d.ts +9 -9
- package/dist-lib/components/afhandeling/WerkplekWaarschuwing.js +28 -28
- package/dist-lib/components/ui/responsive-dialog.js +1 -1
- package/dist-lib/hooks/usePickMode.d.ts +1 -1
- package/dist-lib/integrations/supabase/client.server.js +1 -1
- package/dist-lib/integrations/supabase/moduleClient.d.ts +4 -31315
- package/dist-lib/integrations/supabase/moduleClient.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +3518 -66
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/afhandelingSettings.functions.d.ts.map +1 -1
- package/dist-lib/lib/afhandelingSettings.functions.js +2 -1
- package/dist-lib/lib/authGateway.server.d.ts +2 -0
- package/dist-lib/lib/authGateway.server.d.ts.map +1 -1
- package/dist-lib/lib/authGateway.server.js +2 -2
- package/dist-lib/lib/cartAssignments.functions.d.ts +20 -3
- package/dist-lib/lib/cartAssignments.functions.d.ts.map +1 -1
- package/dist-lib/lib/cartAssignments.functions.js +48 -37
- package/dist-lib/lib/deliveryNotePrint.d.ts +33 -33
- package/dist-lib/lib/deliveryNotePrint.js +219 -219
- package/dist-lib/lib/floridayAutoProcess.d.ts +1 -1
- package/dist-lib/lib/floridayAutoProcess.d.ts.map +1 -1
- package/dist-lib/lib/floridayFulfillmentSend.server.d.ts +31 -0
- package/dist-lib/lib/floridayFulfillmentSend.server.d.ts.map +1 -0
- package/dist-lib/lib/floridayFulfillmentSend.server.js +75 -0
- package/dist-lib/lib/floridayLoading.functions.d.ts +91 -0
- package/dist-lib/lib/floridayLoading.functions.d.ts.map +1 -0
- package/dist-lib/lib/floridayLoading.functions.js +311 -0
- package/dist-lib/lib/logisticsEngine/capacity.js +1 -1
- package/dist-lib/lib/logisticsEngine/staffPlanning.js +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"afhandelingSettings.functions.d.ts","sourceRoot":"","sources":["../../src/lib/afhandelingSettings.functions.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC,uBAAuB,EAAE,MAAM,CAAC;IAChC,2BAA2B,EAAE,MAAM,CAAC;IACpC,uBAAuB,EAAE,OAAO,CAAC;IACjC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,iEAAiE;IACjE,yBAAyB,EAAE,MAAM,CAAC;IAClC,iGAAiG;IACjG,iBAAiB,EAAE,OAAO,CAAC;IAC3B,8EAA8E;IAC9E,qBAAqB,EAAE,OAAO,CAAC;CAChC;
|
|
1
|
+
{"version":3,"file":"afhandelingSettings.functions.d.ts","sourceRoot":"","sources":["../../src/lib/afhandelingSettings.functions.ts"],"names":[],"mappings":"AAIA;;;;;;;GAOG;AACH,MAAM,WAAW,mBAAmB;IAClC,uBAAuB,EAAE,MAAM,CAAC;IAChC,2BAA2B,EAAE,MAAM,CAAC;IACpC,uBAAuB,EAAE,OAAO,CAAC;IACjC,sBAAsB,EAAE,MAAM,CAAC;IAC/B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,qBAAqB,EAAE,MAAM,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,8DAA8D;IAC9D,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,iEAAiE;IACjE,yBAAyB,EAAE,MAAM,CAAC;IAClC,iGAAiG;IACjG,iBAAiB,EAAE,OAAO,CAAC;IAC3B,8EAA8E;IAC9E,qBAAqB,EAAE,OAAO,CAAC;CAChC;AAgCD,eAAO,MAAM,sBAAsB;;;;8EAmC/B,CAAC;AAEL,eAAO,MAAM,yBAAyB;;;;6CAEb;IACrB,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,2BAA2B,CAAC,EAAE,MAAM,CAAC;IACrC,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,yBAAyB,CAAC,EAAE,MAAM,CAAC;IACnC,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,qBAAqB,CAAC,EAAE,OAAO,CAAC;CACjC;;;;;;;;;;;;gCAqGC,CAAC"}
|
|
@@ -10,7 +10,8 @@ const DEFAULTS = {
|
|
|
10
10
|
signupMailPurpose: "afhandeling_carrier_signup",
|
|
11
11
|
pickWeekdays: [1, 2, 3, 4, 5],
|
|
12
12
|
extraPickDaysWithStickers: 0,
|
|
13
|
-
|
|
13
|
+
// Een geaccepteerde Floriday-opdracht is niet terug te draaien: standaard uit.
|
|
14
|
+
autoProcessPaused: true,
|
|
14
15
|
autoPrintDeliveryNote: false,
|
|
15
16
|
};
|
|
16
17
|
const SELECT_COLS = "pick_days_before_transport, transport_register_days_before, pick_distribution_enabled, max_workdays_earlier_pick, signup_mail_enabled, signup_mail_lead_minutes, signup_mail_purpose, pick_weekdays, extra_pick_days_with_stickers, auto_process_paused, auto_print_delivery_note";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export declare function getFloridayEnvironment(): Promise<string>;
|
|
1
2
|
/** Batch-variant — geeft per sales-order-id een set delivery-order-ids terug. */
|
|
2
3
|
export declare function resolveDeliveryOrdersBatch(salesOrderIds: string[]): Promise<Map<string, string[]>>;
|
|
4
|
+
export declare function signBody(secret: string, timestamp: string, body: string): Promise<string>;
|
|
3
5
|
/**
|
|
4
6
|
* Haalt de Floriday-afleverbrief PDF op voor een sales-order via de
|
|
5
7
|
* Authenticatie-module gateway. Retourneert null wanneer:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authGateway.server.d.ts","sourceRoot":"","sources":["../../src/lib/authGateway.server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"authGateway.server.d.ts","sourceRoot":"","sources":["../../src/lib/authGateway.server.ts"],"names":[],"mappings":"AA6BA,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,MAAM,CAAC,CAqB9D;AA2BD,iFAAiF;AACjF,wBAAsB,0BAA0B,CAC9C,aAAa,EAAE,MAAM,EAAE,GACtB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CA6BhC;AAED,wBAAsB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAgB/F;AA4BD;;;;;;;;GAQG;AACH,wBAAsB,oBAAoB,CACxC,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAAC,CAyElD"}
|
|
@@ -23,7 +23,7 @@ function getSupabase() {
|
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
25
|
let cachedEnvironment = null;
|
|
26
|
-
async function getFloridayEnvironment() {
|
|
26
|
+
export async function getFloridayEnvironment() {
|
|
27
27
|
if (cachedEnvironment)
|
|
28
28
|
return cachedEnvironment;
|
|
29
29
|
try {
|
|
@@ -96,7 +96,7 @@ export async function resolveDeliveryOrdersBatch(salesOrderIds) {
|
|
|
96
96
|
}
|
|
97
97
|
return out;
|
|
98
98
|
}
|
|
99
|
-
async function signBody(secret, timestamp, body) {
|
|
99
|
+
export async function signBody(secret, timestamp, body) {
|
|
100
100
|
const key = await globalThis.crypto.subtle.importKey("raw", new TextEncoder().encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
101
101
|
const sig = await globalThis.crypto.subtle.sign("HMAC", key, new TextEncoder().encode(`${timestamp}.${body}`));
|
|
102
102
|
return Array.from(new Uint8Array(sig))
|
|
@@ -82,10 +82,26 @@ export interface DayCartContent {
|
|
|
82
82
|
maxLayers: number | null;
|
|
83
83
|
occupancy: number | null;
|
|
84
84
|
layerUtilization: number | null;
|
|
85
|
-
crates: number;
|
|
86
|
-
|
|
85
|
+
crates: number | null;
|
|
86
|
+
/** Planten worden niet door de Engine-dekking geleverd; null = onbekend. */
|
|
87
|
+
plants: number | null;
|
|
88
|
+
/** Gedeelde bufferkar: alleen de regels van déze order tellen mee. */
|
|
89
|
+
shared: boolean;
|
|
90
|
+
}
|
|
91
|
+
export type CoverageState = "ingedeeld" | "deels" | "geen_indeling" | "geen_regels";
|
|
92
|
+
export type CoveragePickStatus = "geen_pickrij" | "open" | "bezig" | "gepickt";
|
|
93
|
+
export interface DayOrderCoverage {
|
|
94
|
+
orderRef: string;
|
|
95
|
+
state: CoverageState | null;
|
|
96
|
+
label: string | null;
|
|
97
|
+
pickStatus: CoveragePickStatus | null;
|
|
98
|
+
pickedAt: string | null;
|
|
87
99
|
}
|
|
88
|
-
/**
|
|
100
|
+
/**
|
|
101
|
+
* Karindeling per order via de Engine-leesfunctie `logistics_order_plan_coverage`.
|
|
102
|
+
* Ook karren op een gedeelde bufferkar tellen mee; per kar alleen de regels van deze order.
|
|
103
|
+
* Deze module leest order_carts / order_cart_items niet zelf.
|
|
104
|
+
*/
|
|
89
105
|
export declare const getDayCartContents: import("@tanstack/start-client-core").RequiredFetcher<readonly [import("@tanstack/start-client-core").FunctionMiddlewareAfterServer<{}, unknown, undefined, {
|
|
90
106
|
supabase: import("../integrations/supabase/auth-middleware").AuthedSupabaseClient;
|
|
91
107
|
userId: string;
|
|
@@ -96,5 +112,6 @@ export declare const getDayCartContents: import("@tanstack/start-client-core").R
|
|
|
96
112
|
orderRefs: string[];
|
|
97
113
|
}, Promise<{
|
|
98
114
|
carts: DayCartContent[];
|
|
115
|
+
orders: DayOrderCoverage[];
|
|
99
116
|
}>>;
|
|
100
117
|
//# sourceMappingURL=cartAssignments.functions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cartAssignments.functions.d.ts","sourceRoot":"","sources":["../../src/lib/cartAssignments.functions.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,UAAU,GAAG,WAAW,GAAG,gBAAgB,GAAG,QAAQ,CAAC;AACnE,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,QAAQ,CAAC;AAEhD,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,WAAW,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;CACtB;AAUD,eAAO,MAAM,iBAAiB;;;;;eAEuB,YAA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AgB,EAAE;GA0D/F,CAAC"}
|
|
@@ -128,7 +128,13 @@ export const getOrderLines = createServerFn({ method: "GET" })
|
|
|
128
128
|
}
|
|
129
129
|
return { lines };
|
|
130
130
|
});
|
|
131
|
-
|
|
131
|
+
const num = (v) => (v == null || v === "" || !Number.isFinite(Number(v)) ? null : Number(v));
|
|
132
|
+
const arr = (v) => (Array.isArray(v) ? v : []);
|
|
133
|
+
/**
|
|
134
|
+
* Karindeling per order via de Engine-leesfunctie `logistics_order_plan_coverage`.
|
|
135
|
+
* Ook karren op een gedeelde bufferkar tellen mee; per kar alleen de regels van deze order.
|
|
136
|
+
* Deze module leest order_carts / order_cart_items niet zelf.
|
|
137
|
+
*/
|
|
132
138
|
export const getDayCartContents = createServerFn({ method: "POST" })
|
|
133
139
|
.middleware([requireSupabaseAuth])
|
|
134
140
|
.inputValidator((d) => ({
|
|
@@ -138,7 +144,7 @@ export const getDayCartContents = createServerFn({ method: "POST" })
|
|
|
138
144
|
const supabase = context.supabase;
|
|
139
145
|
const refs = data.orderRefs;
|
|
140
146
|
if (refs.length === 0)
|
|
141
|
-
return { carts: [] };
|
|
147
|
+
return { carts: [], orders: [] };
|
|
142
148
|
const uuidRe = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
143
149
|
const orderRefById = new Map();
|
|
144
150
|
const chunk = (a, n) => Array.from({ length: Math.ceil(a.length / n) }, (_, i) => a.slice(i * n, i * n + n));
|
|
@@ -157,43 +163,48 @@ export const getDayCartContents = createServerFn({ method: "POST" })
|
|
|
157
163
|
orderRefById.set(r.id, ref);
|
|
158
164
|
}
|
|
159
165
|
}
|
|
160
|
-
const orderIds = [...orderRefById.keys()];
|
|
161
|
-
// layerUtilizationPct komt uit de Engine (logistics_cart_slip_plan); null = onbekend.
|
|
162
|
-
const utilByCart = new Map();
|
|
163
|
-
for (const part of chunk(orderIds, 6)) {
|
|
164
|
-
await Promise.all(part.map(async (oid) => {
|
|
165
|
-
const { data: plan, error } = await supabase.rpc("logistics_cart_slip_plan", { p_order_id: oid });
|
|
166
|
-
if (error || !plan)
|
|
167
|
-
return;
|
|
168
|
-
for (const c of (plan.carts ?? [])) {
|
|
169
|
-
const v = c.layerUtilizationPct;
|
|
170
|
-
if (c.cartId)
|
|
171
|
-
utilByCart.set(String(c.cartId), v != null ? Number(v) : null);
|
|
172
|
-
}
|
|
173
|
-
}));
|
|
174
|
-
}
|
|
175
166
|
const carts = [];
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
.
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
plants: items.reduce((s, i) => s + Number(i.crates ?? 0) * Number(i.plants_per_crate ?? 0), 0),
|
|
167
|
+
const orders = [];
|
|
168
|
+
for (const part of chunk([...orderRefById.keys()], 6)) {
|
|
169
|
+
await Promise.all(part.map(async (oid) => {
|
|
170
|
+
const orderRef = orderRefById.get(oid);
|
|
171
|
+
const [cov, slip] = await Promise.all([
|
|
172
|
+
supabase.rpc("logistics_order_plan_coverage", { p_order_id: oid }),
|
|
173
|
+
supabase.rpc("logistics_cart_slip_plan", { p_order_id: oid }),
|
|
174
|
+
]);
|
|
175
|
+
if (cov.error)
|
|
176
|
+
throw new Error(cov.error.message);
|
|
177
|
+
const c = (cov.data ?? {});
|
|
178
|
+
orders.push({
|
|
179
|
+
orderRef,
|
|
180
|
+
state: c.state ?? null,
|
|
181
|
+
label: typeof c.label === "string" ? c.label : null,
|
|
182
|
+
pickStatus: c.pickStatus ?? null,
|
|
183
|
+
pickedAt: typeof c.pickedAt === "string" ? c.pickedAt : null,
|
|
194
184
|
});
|
|
195
|
-
|
|
185
|
+
// Lagen/bezetting alleen als de Engine ze in het karbriefplan levert; anders onbekend.
|
|
186
|
+
const slipByCart = new Map();
|
|
187
|
+
if (!slip.error)
|
|
188
|
+
for (const s of arr(slip.data?.carts))
|
|
189
|
+
if (s?.cartId)
|
|
190
|
+
slipByCart.set(String(s.cartId), s);
|
|
191
|
+
arr(c.carts).forEach((k, idx) => {
|
|
192
|
+
const s = slipByCart.get(String(k?.cartId ?? "")) ?? {};
|
|
193
|
+
const lines = arr(k?.lines);
|
|
194
|
+
carts.push({
|
|
195
|
+
orderRef,
|
|
196
|
+
cartNumber: num(k?.cartNumber) ?? idx + 1,
|
|
197
|
+
layersUsed: num(s.layersUsed ?? s.totalLayersUsed),
|
|
198
|
+
maxLayers: num(s.maxLayers),
|
|
199
|
+
occupancy: num(s.occupancyPct) != null ? Math.round(num(s.occupancyPct)) : null,
|
|
200
|
+
layerUtilization: num(s.layerUtilizationPct),
|
|
201
|
+
crates: lines.length ? lines.reduce((t, l) => t + (num(l?.crates) ?? 0), 0) : null,
|
|
202
|
+
plants: null,
|
|
203
|
+
shared: k?.shared === true,
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
}));
|
|
196
207
|
}
|
|
197
208
|
carts.sort((a, b) => a.orderRef.localeCompare(b.orderRef) || a.cartNumber - b.cartNumber);
|
|
198
|
-
return { carts };
|
|
209
|
+
return { carts, orders };
|
|
199
210
|
});
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
export interface DeliveryNoteItem {
|
|
2
|
-
id: string;
|
|
3
|
-
salesOrderId?: string | null;
|
|
4
|
-
deliveryOrderId?: string | null;
|
|
5
|
-
fulfillmentOrderId?: string | null;
|
|
6
|
-
}
|
|
7
|
-
/** Haalt de signed URL van een enkele afleverbrief op. */
|
|
8
|
-
export declare function fetchDeliveryNoteUrl(salesOrderId: string): Promise<string>;
|
|
9
|
-
/** Print een PDF vanaf een (signed) URL via de printwachtrij. */
|
|
10
|
-
export declare function printPdfFromUrl(url: string, opties: {
|
|
11
|
-
documentnaam: string;
|
|
12
|
-
isHerprint?: boolean;
|
|
13
|
-
}): Promise<void>;
|
|
14
|
-
/** Haal en print één afleverbrief. */
|
|
15
|
-
export declare function printDeliveryNote(salesOrderId: string, opties?: {
|
|
16
|
-
documentnaam?: string;
|
|
17
|
-
isHerprint?: boolean;
|
|
18
|
-
}): Promise<void>;
|
|
19
|
-
export interface BulkPrintResult {
|
|
20
|
-
total: number;
|
|
21
|
-
success: number;
|
|
22
|
-
failed: Array<{
|
|
23
|
-
id: string;
|
|
24
|
-
error: string;
|
|
25
|
-
}>;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Print meerdere afleverbrieven als samengevoegde PDF's van maximaal 25 stuks.
|
|
29
|
-
* Te grote opdrachten worden automatisch verder opgeknipt.
|
|
30
|
-
*/
|
|
31
|
-
export declare function printDeliveryNotesMerged(items: DeliveryNoteItem[], opties?: {
|
|
32
|
-
isHerprint?: boolean;
|
|
33
|
-
}): Promise<BulkPrintResult>;
|
|
1
|
+
export interface DeliveryNoteItem {
|
|
2
|
+
id: string;
|
|
3
|
+
salesOrderId?: string | null;
|
|
4
|
+
deliveryOrderId?: string | null;
|
|
5
|
+
fulfillmentOrderId?: string | null;
|
|
6
|
+
}
|
|
7
|
+
/** Haalt de signed URL van een enkele afleverbrief op. */
|
|
8
|
+
export declare function fetchDeliveryNoteUrl(salesOrderId: string): Promise<string>;
|
|
9
|
+
/** Print een PDF vanaf een (signed) URL via de printwachtrij. */
|
|
10
|
+
export declare function printPdfFromUrl(url: string, opties: {
|
|
11
|
+
documentnaam: string;
|
|
12
|
+
isHerprint?: boolean;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
/** Haal en print één afleverbrief. */
|
|
15
|
+
export declare function printDeliveryNote(salesOrderId: string, opties?: {
|
|
16
|
+
documentnaam?: string;
|
|
17
|
+
isHerprint?: boolean;
|
|
18
|
+
}): Promise<void>;
|
|
19
|
+
export interface BulkPrintResult {
|
|
20
|
+
total: number;
|
|
21
|
+
success: number;
|
|
22
|
+
failed: Array<{
|
|
23
|
+
id: string;
|
|
24
|
+
error: string;
|
|
25
|
+
}>;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Print meerdere afleverbrieven als samengevoegde PDF's van maximaal 25 stuks.
|
|
29
|
+
* Te grote opdrachten worden automatisch verder opgeknipt.
|
|
30
|
+
*/
|
|
31
|
+
export declare function printDeliveryNotesMerged(items: DeliveryNoteItem[], opties?: {
|
|
32
|
+
isHerprint?: boolean;
|
|
33
|
+
}): Promise<BulkPrintResult>;
|
|
34
34
|
//# sourceMappingURL=deliveryNotePrint.d.ts.map
|