@flowselections/pick-schermen-kwekers 1.0.2 → 1.0.3
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/PickPublicPage.d.ts +7 -0
- package/dist-lib/components/PickPublicPage.d.ts.map +1 -0
- package/dist-lib/components/PickPublicPage.js +19 -0
- package/dist-lib/components/PickstationsPage.d.ts.map +1 -1
- package/dist-lib/components/PickstationsPage.js +57 -14
- package/dist-lib/components/pick/LanguageTiles.d.ts +8 -0
- package/dist-lib/components/pick/LanguageTiles.d.ts.map +1 -0
- package/dist-lib/components/pick/LanguageTiles.js +11 -0
- package/dist-lib/components/pick/PickScherm.d.ts +6 -4
- package/dist-lib/components/pick/PickScherm.d.ts.map +1 -1
- package/dist-lib/components/pick/PickScherm.js +145 -61
- package/dist-lib/components/pick/QueueTable.d.ts +4 -1
- package/dist-lib/components/pick/QueueTable.d.ts.map +1 -1
- package/dist-lib/components/pick/QueueTable.js +11 -10
- package/dist-lib/hooks/usePickQueue.d.ts +7 -1
- package/dist-lib/hooks/usePickQueue.d.ts.map +1 -1
- package/dist-lib/hooks/usePickQueue.js +43 -6
- package/dist-lib/index.d.ts +5 -6
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +6 -12
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +8929 -5189
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +8929 -5189
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +8929 -5189
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +9245 -5437
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/layoutApi.d.ts +23 -0
- package/dist-lib/lib/layoutApi.d.ts.map +1 -0
- package/dist-lib/lib/layoutApi.js +94 -0
- package/dist-lib/lib/layoutMaker/documentProfiles.d.ts +50 -0
- package/dist-lib/lib/layoutMaker/documentProfiles.d.ts.map +1 -0
- package/dist-lib/lib/layoutMaker/documentProfiles.js +458 -0
- package/dist-lib/lib/layoutMaker/documentTypes.d.ts +123 -0
- package/dist-lib/lib/layoutMaker/documentTypes.d.ts.map +1 -0
- package/dist-lib/lib/layoutMaker/documentTypes.js +74 -0
- package/dist-lib/lib/layoutMaker/logoLibrary.d.ts +13 -0
- package/dist-lib/lib/layoutMaker/logoLibrary.d.ts.map +1 -0
- package/dist-lib/lib/layoutMaker/logoLibrary.js +54 -0
- package/dist-lib/lib/layoutMaker/pakbonBuilder.d.ts +196 -0
- package/dist-lib/lib/layoutMaker/pakbonBuilder.d.ts.map +1 -0
- package/dist-lib/lib/layoutMaker/pakbonBuilder.js +813 -0
- package/dist-lib/lib/layoutMaker/pakbonHtml.d.ts +48 -0
- package/dist-lib/lib/layoutMaker/pakbonHtml.d.ts.map +1 -0
- package/dist-lib/lib/layoutMaker/pakbonHtml.js +703 -0
- package/dist-lib/lib/layoutRenderer.d.ts +7 -0
- package/dist-lib/lib/layoutRenderer.d.ts.map +1 -0
- package/dist-lib/lib/layoutRenderer.js +233 -0
- package/dist-lib/lib/layoutTypes.d.ts +84 -0
- package/dist-lib/lib/layoutTypes.d.ts.map +1 -0
- package/dist-lib/lib/layoutTypes.js +25 -0
- package/dist-lib/lib/logisticsApi.d.ts +54 -0
- package/dist-lib/lib/logisticsApi.d.ts.map +1 -0
- package/dist-lib/lib/logisticsApi.js +72 -0
- package/dist-lib/lib/logisticsTypes.d.ts +34 -0
- package/dist-lib/lib/logisticsTypes.d.ts.map +1 -0
- package/dist-lib/lib/logisticsTypes.js +36 -0
- package/dist-lib/lib/orderContext.d.ts +50 -0
- package/dist-lib/lib/orderContext.d.ts.map +1 -0
- package/dist-lib/lib/orderContext.js +162 -0
- package/dist-lib/lib/pakbonOrderInput.d.ts +8 -0
- package/dist-lib/lib/pakbonOrderInput.d.ts.map +1 -0
- package/dist-lib/lib/pakbonOrderInput.js +150 -0
- package/dist-lib/lib/pickApi.d.ts +24 -1
- package/dist-lib/lib/pickApi.d.ts.map +1 -1
- package/dist-lib/lib/pickApi.js +46 -5
- package/dist-lib/lib/pickI18n.d.ts +14 -0
- package/dist-lib/lib/pickI18n.d.ts.map +1 -0
- package/dist-lib/lib/pickI18n.js +500 -0
- package/dist-lib/lib/pickPrint.d.ts +18 -0
- package/dist-lib/lib/pickPrint.d.ts.map +1 -0
- package/dist-lib/lib/pickPrint.js +184 -0
- package/dist-lib/lib/pickTypes.d.ts +1 -0
- package/dist-lib/lib/pickTypes.d.ts.map +1 -1
- package/package.json +5 -20
- package/dist-lib/components/PickBeheerPage.d.ts +0 -2
- package/dist-lib/components/PickBeheerPage.d.ts.map +0 -1
- package/dist-lib/components/PickBeheerPage.js +0 -84
- package/dist-lib/components/PickDashboardPage.d.ts +0 -2
- package/dist-lib/components/PickDashboardPage.d.ts.map +0 -1
- package/dist-lib/components/PickDashboardPage.js +0 -54
- package/dist-lib/components/PickKioskPage.d.ts +0 -7
- package/dist-lib/components/PickKioskPage.d.ts.map +0 -1
- package/dist-lib/components/PickKioskPage.js +0 -18
- package/dist-lib/components/PickstationDetailPage.d.ts +0 -6
- package/dist-lib/components/PickstationDetailPage.d.ts.map +0 -1
- package/dist-lib/components/PickstationDetailPage.js +0 -25
- package/dist-lib/components/pick/ConfigCrud.d.ts +0 -27
- package/dist-lib/components/pick/ConfigCrud.d.ts.map +0 -1
- package/dist-lib/components/pick/ConfigCrud.js +0 -64
- package/dist-lib/components/pick/CountryTiles.d.ts +0 -9
- package/dist-lib/components/pick/CountryTiles.d.ts.map +0 -1
- package/dist-lib/components/pick/CountryTiles.js +0 -13
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// Haalt de volledige ordercontext op voor het printen van een pakbon.
|
|
2
|
+
// De wachtrijregel alleen bevat te weinig gegevens: order, klant, afleveradres,
|
|
3
|
+
// orderregels, karren, lagen, producten en fusten komen hier uit de database.
|
|
4
|
+
import { pickDb } from "./pickApi";
|
|
5
|
+
function obj(raw) {
|
|
6
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
7
|
+
}
|
|
8
|
+
function arr(raw) {
|
|
9
|
+
return Array.isArray(raw) ? raw : [];
|
|
10
|
+
}
|
|
11
|
+
function num(raw, fallback = 0) {
|
|
12
|
+
const n = Number(raw);
|
|
13
|
+
return Number.isFinite(n) ? n : fallback;
|
|
14
|
+
}
|
|
15
|
+
function customField(source, keys) {
|
|
16
|
+
const custom = obj(source["custom_fields"]);
|
|
17
|
+
for (const key of keys) {
|
|
18
|
+
const v = source[key] ?? custom[key];
|
|
19
|
+
if (v !== undefined && v !== null && v !== "")
|
|
20
|
+
return String(v);
|
|
21
|
+
}
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
/** Zet een karregel uit de database om in producten voor de pakbon. */
|
|
25
|
+
function toProduct(entry) {
|
|
26
|
+
const item = obj(entry["item"]);
|
|
27
|
+
const product = obj(entry["product"]);
|
|
28
|
+
const orderItem = obj(entry["order_item"]);
|
|
29
|
+
const crates = num(item["crates"]);
|
|
30
|
+
const perCrate = num(item["plants_per_crate"] ?? product["plants_per_crate"] ?? orderItem["plants_per_crate"]);
|
|
31
|
+
const aantal = crates && perCrate ? crates * perCrate : num(orderItem["quantity"], crates);
|
|
32
|
+
return {
|
|
33
|
+
artikelnummer: product["article_number"] ?? product["barcode"] ?? null,
|
|
34
|
+
artikelnaam: item["product_name"] ?? product["product"] ?? orderItem["product_name"] ?? null,
|
|
35
|
+
potmaat: customField(product, ["potmaat", "pot_size"]) ??
|
|
36
|
+
customField(orderItem, ["potmaat", "pot_size"]),
|
|
37
|
+
kleur: customField(product, ["kleur", "color"]) ?? customField(orderItem, ["kleur", "color"]),
|
|
38
|
+
aantal,
|
|
39
|
+
locatie: product["location"] || orderItem["location"] || null,
|
|
40
|
+
fust_aantal: crates,
|
|
41
|
+
fustsoort: customField(product, ["fustsoort", "fust", "unit"]) ?? orderItem["unit"] ?? null,
|
|
42
|
+
planten_per_fust: perCrate || null,
|
|
43
|
+
barcode: product["barcode"] ?? orderItem["barcode"] ?? null,
|
|
44
|
+
opmerking: customField(item, ["notes", "opmerking"]),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** Verdeelt de producten van een kar over lagen op basis van de beladingsgegevens. */
|
|
48
|
+
function toLayers(entries) {
|
|
49
|
+
const layers = [];
|
|
50
|
+
let current = 1;
|
|
51
|
+
let filled = 0;
|
|
52
|
+
for (const entry of entries) {
|
|
53
|
+
const item = obj(entry["item"]);
|
|
54
|
+
const product = toProduct(entry);
|
|
55
|
+
const perLayer = num(item["crates_per_layer"] ?? obj(entry["product"])["crates_per_layer"]);
|
|
56
|
+
const used = perLayer > 0 && product.fust_aantal > 0 ? product.fust_aantal / perLayer : num(item["layer_fraction"], 1);
|
|
57
|
+
let remaining = Math.max(used, 0.0001);
|
|
58
|
+
while (remaining > 0.0001) {
|
|
59
|
+
const space = Math.max(1 - filled, 0.0001);
|
|
60
|
+
const take = Math.min(space, remaining);
|
|
61
|
+
const share = take / Math.max(used, 0.0001);
|
|
62
|
+
const laag = layers.find((l) => l.laagnummer === current) ??
|
|
63
|
+
(layers.push({ laagnummer: current, belading: "", producten: [] }),
|
|
64
|
+
layers[layers.length - 1]);
|
|
65
|
+
laag.producten.push({
|
|
66
|
+
...product,
|
|
67
|
+
aantal: Math.round(product.aantal * share) || product.aantal,
|
|
68
|
+
fust_aantal: Math.round(product.fust_aantal * share) || product.fust_aantal,
|
|
69
|
+
});
|
|
70
|
+
filled += take;
|
|
71
|
+
remaining -= take;
|
|
72
|
+
if (filled >= 0.999) {
|
|
73
|
+
filled = 0;
|
|
74
|
+
current += 1;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
for (const laag of layers) {
|
|
79
|
+
const fusten = laag.producten.reduce((sum, p) => sum + p.fust_aantal, 0);
|
|
80
|
+
laag.belading = fusten ? `${fusten} fust` : `${laag.producten.length} product(en)`;
|
|
81
|
+
}
|
|
82
|
+
return layers;
|
|
83
|
+
}
|
|
84
|
+
/** Bouwt de datacontext voor de pakbon-sectierenderer. */
|
|
85
|
+
export async function fetchPakbonData(args) {
|
|
86
|
+
if (!args.orderId && !args.orderNumber)
|
|
87
|
+
return null;
|
|
88
|
+
const { data, error } = await pickDb.rpc("pick_order_context", {
|
|
89
|
+
_order_id: args.orderId ?? null,
|
|
90
|
+
_order_number: args.orderNumber ?? null,
|
|
91
|
+
});
|
|
92
|
+
if (error)
|
|
93
|
+
throw new Error(error.message);
|
|
94
|
+
const ctx = obj(data);
|
|
95
|
+
const order = obj(ctx["order"]);
|
|
96
|
+
if (!order["id"])
|
|
97
|
+
return null;
|
|
98
|
+
const customer = obj(ctx["customer"]);
|
|
99
|
+
const regels = arr(ctx["items"]).map((r) => obj(r));
|
|
100
|
+
const karren = arr(ctx["carts"]).map((raw) => {
|
|
101
|
+
const wrapper = obj(raw);
|
|
102
|
+
const cart = obj(wrapper["cart"]);
|
|
103
|
+
const entries = arr(wrapper["items"]).map((e) => obj(e));
|
|
104
|
+
const lagen = toLayers(entries);
|
|
105
|
+
return {
|
|
106
|
+
karnummer: cart["cart_number"] ?? "-",
|
|
107
|
+
karsoort: cart["carrier_type"] ?? null,
|
|
108
|
+
lagen,
|
|
109
|
+
producten: entries.map(toProduct),
|
|
110
|
+
aantal_lagen: lagen.length || num(cart["total_layers_used"]),
|
|
111
|
+
};
|
|
112
|
+
});
|
|
113
|
+
const fustMap = {};
|
|
114
|
+
let producten = 0;
|
|
115
|
+
let fusten = 0;
|
|
116
|
+
for (const kar of karren) {
|
|
117
|
+
for (const p of kar.producten) {
|
|
118
|
+
producten += p.aantal;
|
|
119
|
+
fusten += p.fust_aantal;
|
|
120
|
+
const key = p.fustsoort ?? "Fust";
|
|
121
|
+
fustMap[key] = (fustMap[key] ?? 0) + p.fust_aantal;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
if (!karren.length) {
|
|
125
|
+
for (const r of regels)
|
|
126
|
+
producten += num(r["quantity"]);
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
order: {
|
|
130
|
+
...order,
|
|
131
|
+
ordernummer: order["order_number"] ?? null,
|
|
132
|
+
orderdatum: order["order_date"] ?? null,
|
|
133
|
+
leverdatum: order["delivery_date"] ?? null,
|
|
134
|
+
referentie: customField(order, ["referentie", "reference"]),
|
|
135
|
+
klantnaam: order["customer_name"] ?? customer["name"] ?? null,
|
|
136
|
+
orderstatus: order["status"] ?? null,
|
|
137
|
+
},
|
|
138
|
+
klant: {
|
|
139
|
+
...customer,
|
|
140
|
+
naam: customer["name"] ?? order["customer_name"] ?? null,
|
|
141
|
+
klantnummer: customer["customer_number"] ?? null,
|
|
142
|
+
},
|
|
143
|
+
afleveradres: {
|
|
144
|
+
naam: customer["name"] ?? order["customer_name"] ?? null,
|
|
145
|
+
adres: customer["address_line1"] ?? customer["address"] ?? null,
|
|
146
|
+
adres2: customer["address_line2"] ?? null,
|
|
147
|
+
postcode: customer["postal_code"] ?? null,
|
|
148
|
+
plaats: customer["city"] ?? null,
|
|
149
|
+
land: customer["country"] ?? null,
|
|
150
|
+
},
|
|
151
|
+
regels,
|
|
152
|
+
karren,
|
|
153
|
+
fusten: Object.entries(fustMap).map(([fusttype, aantal]) => ({ fusttype, aantal })),
|
|
154
|
+
totalen: {
|
|
155
|
+
karren: karren.length,
|
|
156
|
+
lagen: karren.reduce((s, k) => s + (k.lagen.length || k.aantal_lagen), 0),
|
|
157
|
+
producten,
|
|
158
|
+
fusten,
|
|
159
|
+
gewicht: 0,
|
|
160
|
+
},
|
|
161
|
+
};
|
|
162
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PakbonData } from "./orderContext";
|
|
2
|
+
/**
|
|
3
|
+
* Bouwt de invoer voor `maakPakbonOrder()` uit de opgehaalde ordercontext.
|
|
4
|
+
* Orderregels zonder karren worden als platte productlijst meegegeven; de
|
|
5
|
+
* layout-module plaatst die zelf in één kar/laag.
|
|
6
|
+
*/
|
|
7
|
+
export declare function pakbonOrderInput(data: PakbonData): Record<string, unknown>;
|
|
8
|
+
//# sourceMappingURL=pakbonOrderInput.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pakbonOrderInput.d.ts","sourceRoot":"","sources":["../../src/lib/pakbonOrderInput.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAA4B,MAAM,gBAAgB,CAAC;AAsF3E;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAqE1E"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
function txt(v) {
|
|
2
|
+
return v === null || v === undefined ? "" : String(v);
|
|
3
|
+
}
|
|
4
|
+
/** Productnamen komen soms als vertaal-JSON ({"nl":"..."}) uit de database. */
|
|
5
|
+
function naam(v) {
|
|
6
|
+
const s = txt(v).trim();
|
|
7
|
+
if (!s.startsWith("{"))
|
|
8
|
+
return s;
|
|
9
|
+
try {
|
|
10
|
+
const parsed = JSON.parse(s);
|
|
11
|
+
const keys = ["nl", "en", "de", ...Object.keys(parsed)];
|
|
12
|
+
for (const k of keys) {
|
|
13
|
+
const w = parsed[k];
|
|
14
|
+
if (typeof w === "string" && w.trim())
|
|
15
|
+
return w;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
catch {
|
|
19
|
+
// geen JSON: onbewerkt teruggeven
|
|
20
|
+
}
|
|
21
|
+
return s;
|
|
22
|
+
}
|
|
23
|
+
function obj(raw) {
|
|
24
|
+
return raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
25
|
+
}
|
|
26
|
+
function arr(raw) {
|
|
27
|
+
return Array.isArray(raw) ? raw : [];
|
|
28
|
+
}
|
|
29
|
+
function product(p) {
|
|
30
|
+
return {
|
|
31
|
+
artikelnummer: txt(p.artikelnummer),
|
|
32
|
+
artikelnaam: naam(p.artikelnaam),
|
|
33
|
+
potmaat: txt(p.potmaat),
|
|
34
|
+
kleur: txt(p.kleur),
|
|
35
|
+
aantal: Number(p.aantal) || 0,
|
|
36
|
+
locatie: txt(p.locatie),
|
|
37
|
+
barcode: txt(p.barcode),
|
|
38
|
+
opmerking: txt(p.opmerking),
|
|
39
|
+
fust_aantal: Number(p.fust_aantal) || 0,
|
|
40
|
+
fustsoort: txt(p.fustsoort),
|
|
41
|
+
planten_per_fust: Number(p.planten_per_fust) || 0,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
/** Fusten van een laag, samengevoegd per fustsoort. */
|
|
45
|
+
function fusten(producten) {
|
|
46
|
+
const map = new Map();
|
|
47
|
+
for (const p of arr(producten)) {
|
|
48
|
+
const soort = txt(p.fustsoort) || "Fust";
|
|
49
|
+
map.set(soort, (map.get(soort) ?? 0) + (Number(p.fust_aantal) || 0));
|
|
50
|
+
}
|
|
51
|
+
return [...map.entries()]
|
|
52
|
+
.filter(([, aantal]) => aantal > 0)
|
|
53
|
+
.map(([fusttype, aantal]) => ({ fusttype, aantal }));
|
|
54
|
+
}
|
|
55
|
+
function kar(k, index, transport) {
|
|
56
|
+
const lagen = arr(k.lagen).map((l, j) => ({
|
|
57
|
+
laagnummer: Number(l.laagnummer) || j + 1,
|
|
58
|
+
belading: txt(l.belading),
|
|
59
|
+
potmaat: txt(arr(l.producten)[0]?.potmaat),
|
|
60
|
+
producten: arr(l.producten).map(product),
|
|
61
|
+
fusten: fusten(arr(l.producten)),
|
|
62
|
+
}));
|
|
63
|
+
return {
|
|
64
|
+
karnummer: Number(k.karnummer) || index + 1,
|
|
65
|
+
route: transport["route"] ?? "",
|
|
66
|
+
chauffeur: transport["chauffeur"] ?? "",
|
|
67
|
+
gewicht: "",
|
|
68
|
+
lagen: lagen.length
|
|
69
|
+
? lagen
|
|
70
|
+
: [
|
|
71
|
+
{
|
|
72
|
+
laagnummer: 1,
|
|
73
|
+
belading: "",
|
|
74
|
+
potmaat: "",
|
|
75
|
+
producten: arr(k.producten).map(product),
|
|
76
|
+
fusten: fusten(arr(k.producten)),
|
|
77
|
+
},
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Bouwt de invoer voor `maakPakbonOrder()` uit de opgehaalde ordercontext.
|
|
83
|
+
* Orderregels zonder karren worden als platte productlijst meegegeven; de
|
|
84
|
+
* layout-module plaatst die zelf in één kar/laag.
|
|
85
|
+
*/
|
|
86
|
+
export function pakbonOrderInput(data) {
|
|
87
|
+
const order = obj(data.order);
|
|
88
|
+
const klant = obj(data.klant);
|
|
89
|
+
const aflever = obj(data.afleveradres);
|
|
90
|
+
const transport = {
|
|
91
|
+
transporteur: txt(order["transporteur"] ?? order["carrier"] ?? order["transporter"]),
|
|
92
|
+
route: txt(order["route"] ?? order["route_name"]),
|
|
93
|
+
chauffeur: txt(order["chauffeur"] ?? order["driver"]),
|
|
94
|
+
track: txt(order["track_trace"] ?? order["tracking_code"]),
|
|
95
|
+
};
|
|
96
|
+
const karren = arr(data.karren).map((k, i) => kar(k, i, transport));
|
|
97
|
+
const losseRegels = arr(data.regels).map((r) => ({
|
|
98
|
+
artikelnummer: txt(r["article_number"] ?? r["artikelnummer"]),
|
|
99
|
+
artikelnaam: naam(r["product_name"] ?? r["artikelnaam"] ?? r["product"]),
|
|
100
|
+
potmaat: txt(r["potmaat"] ?? r["pot_size"]),
|
|
101
|
+
aantal: Number(r["quantity"] ?? r["aantal"]) || 0,
|
|
102
|
+
locatie: txt(r["location"] ?? r["locatie"]),
|
|
103
|
+
barcode: txt(r["barcode"]),
|
|
104
|
+
fust_aantal: Number(r["crates"] ?? r["fust_aantal"]) || 0,
|
|
105
|
+
fustsoort: txt(r["unit"] ?? r["fustsoort"]),
|
|
106
|
+
planten_per_fust: Number(r["plants_per_crate"] ?? r["planten_per_fust"]) || 0,
|
|
107
|
+
opmerking: txt(r["notes"] ?? r["opmerking"]),
|
|
108
|
+
}));
|
|
109
|
+
const adres = [aflever["adres"], aflever["adres2"]].filter(Boolean).join(" · ");
|
|
110
|
+
const plaats = [aflever["postcode"], aflever["plaats"]].filter(Boolean).join(" ");
|
|
111
|
+
return {
|
|
112
|
+
order: {
|
|
113
|
+
nummer: txt(order["ordernummer"] ?? order["order_number"]),
|
|
114
|
+
datum: txt(order["orderdatum"] ?? order["order_date"]),
|
|
115
|
+
leverdatum: txt(order["leverdatum"] ?? order["delivery_date"]),
|
|
116
|
+
referentie: txt(order["referentie"] ?? order["reference"]),
|
|
117
|
+
opmerking: txt(order["notes"] ?? order["opmerking"] ?? order["remarks"]),
|
|
118
|
+
},
|
|
119
|
+
bedrijf: {
|
|
120
|
+
naam: txt(order["company_name"] ?? ""),
|
|
121
|
+
adres: "",
|
|
122
|
+
plaats: "",
|
|
123
|
+
telefoon: "",
|
|
124
|
+
email: "",
|
|
125
|
+
kvk: "",
|
|
126
|
+
btw: "",
|
|
127
|
+
},
|
|
128
|
+
klant: {
|
|
129
|
+
naam: txt(klant["naam"] ?? klant["name"]),
|
|
130
|
+
nummer: txt(klant["klantnummer"] ?? klant["customer_number"]),
|
|
131
|
+
contact: txt(klant["contact_name"] ?? klant["contactpersoon"] ?? klant["email"]),
|
|
132
|
+
referentie: txt(order["customer_reference"] ?? order["referentie"]),
|
|
133
|
+
},
|
|
134
|
+
afleveradres: {
|
|
135
|
+
naam: txt(aflever["naam"]),
|
|
136
|
+
adres,
|
|
137
|
+
plaats,
|
|
138
|
+
land: txt(aflever["land"]),
|
|
139
|
+
},
|
|
140
|
+
factuuradres: {
|
|
141
|
+
naam: txt(klant["naam"] ?? klant["name"]),
|
|
142
|
+
adres: txt(klant["invoice_address"] ?? aflever["adres"]),
|
|
143
|
+
plaats: txt(klant["invoice_city"] ?? aflever["plaats"]),
|
|
144
|
+
land: txt(klant["invoice_country"] ?? aflever["land"]),
|
|
145
|
+
},
|
|
146
|
+
transport,
|
|
147
|
+
karren,
|
|
148
|
+
producten: karren.length ? [] : losseRegels,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
@@ -19,6 +19,7 @@ export declare const pickApi: {
|
|
|
19
19
|
stationTypes(): Promise<PickStationType[]>;
|
|
20
20
|
tasks(): Promise<PickTask[]>;
|
|
21
21
|
stations(): Promise<PickStation[]>;
|
|
22
|
+
stationBySlug(slug: string): Promise<PickStation>;
|
|
22
23
|
screens(stationId?: string): Promise<PickScreen[]>;
|
|
23
24
|
screenDocumentTypes(screenId: string): Promise<{
|
|
24
25
|
document_type_id: string;
|
|
@@ -27,7 +28,28 @@ export declare const pickApi: {
|
|
|
27
28
|
}[]>;
|
|
28
29
|
locks(stationId?: string): Promise<PickLock[]>;
|
|
29
30
|
dashboard(): Promise<PickDashboardRow[]>;
|
|
30
|
-
|
|
31
|
+
/** Actuele pickdag volgens de Logistiek Engine (YYYY-MM-DD) of null. */
|
|
32
|
+
currentPickDay(): Promise<string | null>;
|
|
33
|
+
/**
|
|
34
|
+
* Laat de Logistiek Engine de wachtrij bijwerken naar de actuele pickdag.
|
|
35
|
+
* Zonder deze aanroep blijven regels van een vorige dag staan en lijkt de
|
|
36
|
+
* wachtrij leeg zodra de pickdag om middernacht omslaat.
|
|
37
|
+
*/
|
|
38
|
+
syncQueue(): Promise<void>;
|
|
39
|
+
/** Aantallen van de actuele pickdag: nog printen versus geprint. */
|
|
40
|
+
dayCounts(args: {
|
|
41
|
+
stationId?: string;
|
|
42
|
+
screenId?: string;
|
|
43
|
+
pickDay?: string | null;
|
|
44
|
+
}): Promise<{
|
|
45
|
+
total: number;
|
|
46
|
+
printed: number;
|
|
47
|
+
pending: number;
|
|
48
|
+
}>;
|
|
49
|
+
countryCounts(args: {
|
|
50
|
+
stationId?: string;
|
|
51
|
+
screenId?: string;
|
|
52
|
+
}): Promise<Record<string, number>>;
|
|
31
53
|
/** Server-side gefilterde, gepagineerde wachtrij. */
|
|
32
54
|
queue(params: {
|
|
33
55
|
screenId?: string;
|
|
@@ -37,6 +59,7 @@ export declare const pickApi: {
|
|
|
37
59
|
documentTypeId?: string | null;
|
|
38
60
|
urgentOnly?: boolean;
|
|
39
61
|
includeDone?: boolean;
|
|
62
|
+
pickDay?: string | null;
|
|
40
63
|
sortRules?: PickSortRule[];
|
|
41
64
|
page?: number;
|
|
42
65
|
pageSize?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pickApi.d.ts","sourceRoot":"","sources":["../../src/lib/pickApi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,aAAa,EACb,UAAU,EACV,YAAY,EACZ,WAAW,EACX,eAAe,EACf,UAAU,EACV,QAAQ,EACT,MAAM,aAAa,CAAC;AAIrB,QAAA,MAAM,EAAE,EAA0B;IAChC,IAAI,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,GAAG,CAAC;IACzB,GAAG,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC;QAAE,IAAI,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,GAAG,CAAA;KAAE,CAAC,CAAC;IACxF,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,GAAG,CAAC;IAC/B,aAAa,EAAE,CAAC,CAAC,EAAE,GAAG,KAAK,IAAI,CAAC;IAChC,IAAI,EAAE,OAAO,QAAQ,CAAC,IAAI,CAAC;CAC5B,CAAC;AAEF,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,CAAC;AAOxB,eAAO,MAAM,OAAO;;;;;;;;wBAwBQ,MAAM;kCAKI,MAAM;0BACN,MAAM;qBAAe,MAAM;oBAAc,MAAM,GAAG,IAAI;;sBAIlE,MAAM;;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,MAAM;mBACP,MAAM,GAAG,IAAI;oBACZ,MAAM;sBACJ,MAAM;;;YAMhB,MAAM;gBACF,MAAM;oBACF,MAAM;iBACT,MAAM,GAAG,IAAI;uBACP,MAAM,GAAG,IAAI;oBAChB,MAAM,GAAG,IAAI;;kBAIT,MAAM,OAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;kBAMpC,MAAM,MAAM,MAAM;CAIvC,CAAC;AAEF,wBAAgB,YAAY,IAAI,MAAM,CASrC"}
|
package/dist-lib/lib/pickApi.js
CHANGED
|
@@ -30,6 +30,10 @@ export const pickApi = {
|
|
|
30
30
|
async stations() {
|
|
31
31
|
return unwrap(await db.from("pick_stations").select("*").order("sort_order"));
|
|
32
32
|
},
|
|
33
|
+
async stationBySlug(slug) {
|
|
34
|
+
const rows = unwrap(await db.from("pick_stations").select("*").eq("slug", slug).limit(1));
|
|
35
|
+
return rows[0] ?? null;
|
|
36
|
+
},
|
|
33
37
|
async screens(stationId) {
|
|
34
38
|
let q = db.from("pick_station_screens").select("*").order("sort_order");
|
|
35
39
|
if (stationId)
|
|
@@ -51,14 +55,48 @@ export const pickApi = {
|
|
|
51
55
|
throw new Error(error.message);
|
|
52
56
|
return safeArray(data);
|
|
53
57
|
},
|
|
54
|
-
|
|
55
|
-
|
|
58
|
+
/** Actuele pickdag volgens de Logistiek Engine (YYYY-MM-DD) of null. */
|
|
59
|
+
async currentPickDay() {
|
|
60
|
+
const { data, error } = await db.rpc("pick_current_pick_day");
|
|
61
|
+
if (error)
|
|
62
|
+
throw new Error(error.message);
|
|
63
|
+
return typeof data === "string" && data.length >= 10 ? data.slice(0, 10) : null;
|
|
64
|
+
},
|
|
65
|
+
/**
|
|
66
|
+
* Laat de Logistiek Engine de wachtrij bijwerken naar de actuele pickdag.
|
|
67
|
+
* Zonder deze aanroep blijven regels van een vorige dag staan en lijkt de
|
|
68
|
+
* wachtrij leeg zodra de pickdag om middernacht omslaat.
|
|
69
|
+
*/
|
|
70
|
+
async syncQueue() {
|
|
71
|
+
const { error } = await db.rpc("logistics_sync_pick_queue");
|
|
72
|
+
if (error)
|
|
73
|
+
throw new Error(error.message);
|
|
74
|
+
},
|
|
75
|
+
/** Aantallen van de actuele pickdag: nog printen versus geprint. */
|
|
76
|
+
async dayCounts(args) {
|
|
77
|
+
let q = db.from("pick_queue").select("printed_at").is("cancelled_at", null).limit(5000);
|
|
78
|
+
if (args.screenId)
|
|
79
|
+
q = q.eq("screen_id", args.screenId);
|
|
80
|
+
if (args.stationId)
|
|
81
|
+
q = q.eq("station_id", args.stationId);
|
|
82
|
+
if (args.pickDay)
|
|
83
|
+
q = q.eq("payload->>pickDate", args.pickDay);
|
|
84
|
+
const rows = unwrap(await q);
|
|
85
|
+
const printed = rows.filter((r) => r.printed_at).length;
|
|
86
|
+
return { total: rows.length, printed, pending: rows.length - printed };
|
|
87
|
+
},
|
|
88
|
+
async countryCounts(args) {
|
|
89
|
+
let q = db
|
|
56
90
|
.from("pick_queue")
|
|
57
91
|
.select("country_code")
|
|
58
|
-
.eq("screen_id", screenId)
|
|
59
92
|
.is("printed_at", null)
|
|
60
93
|
.is("cancelled_at", null)
|
|
61
|
-
.limit(5000)
|
|
94
|
+
.limit(5000);
|
|
95
|
+
if (args.screenId)
|
|
96
|
+
q = q.eq("screen_id", args.screenId);
|
|
97
|
+
if (args.stationId)
|
|
98
|
+
q = q.eq("station_id", args.stationId);
|
|
99
|
+
const rows = unwrap(await q);
|
|
62
100
|
const counts = {};
|
|
63
101
|
for (const r of rows) {
|
|
64
102
|
const c = r.country_code ?? "??";
|
|
@@ -81,8 +119,11 @@ export const pickApi = {
|
|
|
81
119
|
q = q.eq("document_type_id", params.documentTypeId);
|
|
82
120
|
if (params.urgentOnly)
|
|
83
121
|
q = q.eq("is_urgent", true);
|
|
122
|
+
if (params.pickDay)
|
|
123
|
+
q = q.eq("payload->>pickDate", params.pickDay);
|
|
124
|
+
q = q.is("cancelled_at", null);
|
|
84
125
|
if (!params.includeDone)
|
|
85
|
-
q = q.is("printed_at", null)
|
|
126
|
+
q = q.is("printed_at", null);
|
|
86
127
|
if (params.search) {
|
|
87
128
|
const s = `%${params.search}%`;
|
|
88
129
|
q = q.or([
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface PickLanguage {
|
|
2
|
+
code: string;
|
|
3
|
+
label: string;
|
|
4
|
+
flag: string;
|
|
5
|
+
locale: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const PICK_LANGUAGES: PickLanguage[];
|
|
8
|
+
export type PickTextKey = "chooseLanguage" | "chooseLanguageHint" | "back" | "changeLanguage" | "refresh" | "printNext" | "offline" | "queueCount" | "loadingQueue" | "search" | "page" | "of" | "previous" | "next" | "document" | "order" | "customer" | "deliveryAddress" | "lines" | "carts" | "status" | "priority" | "announced" | "waiting" | "action" | "print" | "inProgress" | "urgent" | "emptyQueue" | "warning" | "sentToPrinter" | "noDocument" | "notAvailable" | "confirmPrintTitle" | "confirmPrintBody" | "confirm" | "cancel" | "statusToPrint" | "statusPrinted";
|
|
9
|
+
export type PickTranslator = ((key: PickTextKey) => string) & {
|
|
10
|
+
lang: string;
|
|
11
|
+
locale: string;
|
|
12
|
+
};
|
|
13
|
+
export declare function getPickTranslator(lang: string): PickTranslator;
|
|
14
|
+
//# sourceMappingURL=pickI18n.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pickI18n.d.ts","sourceRoot":"","sources":["../../src/lib/pickI18n.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,eAAO,MAAM,cAAc,EAAE,YAAY,EAaxC,CAAC;AAEF,MAAM,MAAM,WAAW,GACnB,gBAAgB,GAChB,oBAAoB,GACpB,MAAM,GACN,gBAAgB,GAChB,SAAS,GACT,WAAW,GACX,SAAS,GACT,YAAY,GACZ,cAAc,GACd,QAAQ,GACR,MAAM,GACN,IAAI,GACJ,UAAU,GACV,MAAM,GACN,UAAU,GACV,OAAO,GACP,UAAU,GACV,iBAAiB,GACjB,OAAO,GACP,OAAO,GACP,QAAQ,GACR,UAAU,GACV,WAAW,GACX,SAAS,GACT,QAAQ,GACR,OAAO,GACP,YAAY,GACZ,QAAQ,GACR,YAAY,GACZ,SAAS,GACT,eAAe,GACf,YAAY,GACZ,cAAc,GACd,mBAAmB,GACnB,kBAAkB,GAClB,SAAS,GACT,QAAQ,GACR,eAAe,GACf,eAAe,CAAC;AA6epB,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,GAAG,EAAE,WAAW,KAAK,MAAM,CAAC,GAAG;IAC5D,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAO9D"}
|