@flowselections/floriday-verkoop-module 1.0.49 → 1.0.51
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/integrations/supabase/auth-middleware.d.ts +288 -1
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +288 -1
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +288 -1
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +294 -1
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/cart-lock.functions.d.ts +288 -1
- package/dist-lib/lib/cart-lock.functions.d.ts.map +1 -1
- package/dist-lib/lib/cart-planner.d.ts +15 -4
- package/dist-lib/lib/cart-planner.d.ts.map +1 -1
- package/dist-lib/lib/cart-planner.js +44 -12
- package/dist-lib/lib/cart-planning-settings.functions.d.ts +3600 -443
- package/dist-lib/lib/cart-planning-settings.functions.d.ts.map +1 -1
- package/dist-lib/lib/cart-replan.functions.d.ts +876 -3
- package/dist-lib/lib/cart-replan.functions.d.ts.map +1 -1
- package/dist-lib/lib/cart-replan.functions.js +49 -3
- package/dist-lib/lib/create-order.functions.d.ts +5657 -773
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +48 -4
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts +864 -3
- package/dist-lib/lib/floriday-auto-fulfillment.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-logistic-labels.functions.d.ts +288 -1
- package/dist-lib/lib/floriday-logistic-labels.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.functions.d.ts +288 -1
- package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.functions.js +28 -1
- package/dist-lib/lib/floriday-public.functions.d.ts +2232 -223
- package/dist-lib/lib/floriday-public.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-writes.functions.d.ts +1548 -113
- package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
- package/dist-lib/lib/invoice-timing.functions.d.ts +1260 -112
- package/dist-lib/lib/invoice-timing.functions.d.ts.map +1 -1
- package/dist-lib/lib/load-carriers.functions.d.ts +288 -1
- package/dist-lib/lib/load-carriers.functions.d.ts.map +1 -1
- package/dist-lib/lib/logistics-engine.functions.d.ts +1548 -113
- package/dist-lib/lib/logistics-engine.functions.d.ts.map +1 -1
- package/dist-lib/lib/logistics-stock.functions.d.ts +576 -2
- package/dist-lib/lib/logistics-stock.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-addresses.functions.d.ts +288 -1
- package/dist-lib/lib/order-addresses.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-buffers.functions.d.ts +864 -3
- package/dist-lib/lib/order-buffers.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-carrier.functions.d.ts +576 -2
- package/dist-lib/lib/order-carrier.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-pickup.functions.d.ts +576 -2
- package/dist-lib/lib/order-pickup.functions.d.ts.map +1 -1
- package/dist-lib/lib/order-shipments.functions.d.ts +1260 -112
- package/dist-lib/lib/order-shipments.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.functions.d.ts +288 -1
- package/dist-lib/lib/salesorders-list.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +61 -3
- package/dist-lib/lib/salesorders.functions.d.ts +1548 -113
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/stock-consumption-alerts.functions.d.ts +576 -2
- package/dist-lib/lib/stock-consumption-alerts.functions.d.ts.map +1 -1
- package/dist-lib/lib/tradeitems.functions.d.ts +288 -1
- package/dist-lib/lib/tradeitems.functions.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -40,6 +40,7 @@ export async function replanScopeInternal(scope) {
|
|
|
40
40
|
replacedManualCount: 0,
|
|
41
41
|
usedFloridayPacking: false,
|
|
42
42
|
warnings: ["plan_locked"],
|
|
43
|
+
blockedItems: [],
|
|
43
44
|
skipped: "locked",
|
|
44
45
|
};
|
|
45
46
|
}
|
|
@@ -50,6 +51,18 @@ export async function replanScopeInternal(scope) {
|
|
|
50
51
|
.in("order_id", orderIds.length > 0 ? orderIds : ["00000000-0000-0000-0000-000000000000"]);
|
|
51
52
|
if (itErr)
|
|
52
53
|
throw new Error(itErr.message);
|
|
54
|
+
// Onbekend blijft onbekend: geen ?? 1. De planner blokkeert regels
|
|
55
|
+
// zonder (volledige) belading in plaats van 1×1×1 te plannen.
|
|
56
|
+
const pick = (a, b) => {
|
|
57
|
+
for (const v of [a, b]) {
|
|
58
|
+
if (v === null || v === undefined)
|
|
59
|
+
continue;
|
|
60
|
+
const n = Number(v);
|
|
61
|
+
if (Number.isFinite(n) && n > 0)
|
|
62
|
+
return Math.round(n);
|
|
63
|
+
}
|
|
64
|
+
return null;
|
|
65
|
+
};
|
|
53
66
|
const inputs = (items ?? []).map((it) => {
|
|
54
67
|
const prod = it.products ?? {};
|
|
55
68
|
return {
|
|
@@ -57,9 +70,9 @@ export async function replanScopeInternal(scope) {
|
|
|
57
70
|
product_id: it.product_id,
|
|
58
71
|
product_name: it.product_name,
|
|
59
72
|
plants: Math.max(0, Number(it.quantity ?? 0)),
|
|
60
|
-
plants_per_crate:
|
|
61
|
-
crates_per_layer:
|
|
62
|
-
layers_per_cart:
|
|
73
|
+
plants_per_crate: pick(it.plants_per_crate, prod.plants_per_crate),
|
|
74
|
+
crates_per_layer: pick(it.crates_per_layer, prod.crates_per_layer),
|
|
75
|
+
layers_per_cart: pick(it.layers_per_cart, prod.layers_per_cart),
|
|
63
76
|
};
|
|
64
77
|
});
|
|
65
78
|
// Item → order-map voor het toewijzen van cart.order_id bij homogene karren.
|
|
@@ -79,6 +92,7 @@ export async function replanScopeInternal(scope) {
|
|
|
79
92
|
let usedFloridayPacking = false;
|
|
80
93
|
let plannedCarts = [];
|
|
81
94
|
const warnings = [];
|
|
95
|
+
let blockedItems = [];
|
|
82
96
|
const solo = orderRows.length === 1 ? orderRows[0] : null;
|
|
83
97
|
const soloCustom = solo?.custom_fields ?? {};
|
|
84
98
|
const floridayPacking = soloCustom?.floriday_packing ?? null;
|
|
@@ -123,6 +137,36 @@ export async function replanScopeInternal(scope) {
|
|
|
123
137
|
});
|
|
124
138
|
plannedCarts = result.carts;
|
|
125
139
|
warnings.push(...result.warnings);
|
|
140
|
+
// Regels zonder (volledige) belading: NOOIT karren maken. Meld de
|
|
141
|
+
// blokkade aan de logistiek-engine zodat die zichtbaar wordt in
|
|
142
|
+
// logistics_plan_queue / logistics_events / logistics_decisions.
|
|
143
|
+
if (result.blocked.length > 0) {
|
|
144
|
+
const blockedOrderIds = [
|
|
145
|
+
...new Set(result.blocked
|
|
146
|
+
.map((b) => itemToOrder.get(b.order_item_id))
|
|
147
|
+
.filter((v) => !!v)),
|
|
148
|
+
];
|
|
149
|
+
blockedItems = result.blocked.map((b) => ({
|
|
150
|
+
order_item_id: b.order_item_id,
|
|
151
|
+
order_id: itemToOrder.get(b.order_item_id) ?? null,
|
|
152
|
+
product_name: b.product_name,
|
|
153
|
+
reason: b.reason,
|
|
154
|
+
missing: b.missing,
|
|
155
|
+
}));
|
|
156
|
+
if (blockedOrderIds.length > 0) {
|
|
157
|
+
const { error: blockErr } = await supabaseAdmin.rpc("logistics_plan_block", {
|
|
158
|
+
p_order_ids: blockedOrderIds,
|
|
159
|
+
p_reason: "belading_onbekend",
|
|
160
|
+
p_details: { source: "floriday-verkoop-module/cart-replan", items: blockedItems },
|
|
161
|
+
});
|
|
162
|
+
if (blockErr) {
|
|
163
|
+
warnings.push(`Blokkade kon niet worden vastgelegd in de engine (${blockErr.message}); regels overgeslagen.`);
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
warnings.push(`Blokkade gemeld aan engine voor ${blockedOrderIds.length} order(s).`);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
126
170
|
}
|
|
127
171
|
let cartsCreated = 0;
|
|
128
172
|
for (const cart of plannedCarts) {
|
|
@@ -180,6 +224,7 @@ export async function replanScopeInternal(scope) {
|
|
|
180
224
|
replacedManualCount,
|
|
181
225
|
usedFloridayPacking,
|
|
182
226
|
warnings,
|
|
227
|
+
blockedItems,
|
|
183
228
|
};
|
|
184
229
|
}
|
|
185
230
|
async function replanOrderInternal(orderId) {
|
|
@@ -193,6 +238,7 @@ async function replanOrderInternal(orderId) {
|
|
|
193
238
|
replacedManualCount: res.replacedManualCount,
|
|
194
239
|
usedFloridayPacking: res.usedFloridayPacking,
|
|
195
240
|
warnings: res.warnings,
|
|
241
|
+
blockedItems: res.blockedItems,
|
|
196
242
|
skipped: res.skipped,
|
|
197
243
|
};
|
|
198
244
|
}
|