@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
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { createServerFn } from "@tanstack/react-start";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
7
|
+
import { CART_PLANNER_VERSION } from "./cart-planner";
|
|
7
8
|
// ─── Klanten ────────────────────────────────────────────────────────────────
|
|
8
9
|
// Bron 1: lokale `customers` (incl. eerder geïmporteerde Twinfield-klanten).
|
|
9
10
|
// Bron 2: `twinfield_customers_cache` — klanten die alleen in Twinfield staan.
|
|
@@ -1059,11 +1060,31 @@ export const planAndSaveAutoCarts = createServerFn({ method: "POST" })
|
|
|
1059
1060
|
cartNumber = existingMax[0].cart_number + 1;
|
|
1060
1061
|
const autoCarts = [];
|
|
1061
1062
|
const remainders = [];
|
|
1063
|
+
const blockedLines = [];
|
|
1062
1064
|
for (const it of items ?? []) {
|
|
1063
1065
|
const prod = it.products ?? {};
|
|
1064
|
-
|
|
1065
|
-
const
|
|
1066
|
-
|
|
1066
|
+
// Onbekend blijft onbekend: geen terugval op 1 (1x1x1 = 1 plant per kar).
|
|
1067
|
+
const pos = (v) => {
|
|
1068
|
+
if (v === null || v === undefined)
|
|
1069
|
+
return null;
|
|
1070
|
+
const n = Math.round(Number(v));
|
|
1071
|
+
return Number.isFinite(n) && n > 0 ? n : null;
|
|
1072
|
+
};
|
|
1073
|
+
const ppc = pos(prod.plants_per_crate);
|
|
1074
|
+
const cpl = pos(prod.crates_per_layer);
|
|
1075
|
+
const lpc = pos(prod.layers_per_cart);
|
|
1076
|
+
if (ppc === null || cpl === null || lpc === null) {
|
|
1077
|
+
blockedLines.push({
|
|
1078
|
+
order_item_id: it.id,
|
|
1079
|
+
product_name: it.product_name,
|
|
1080
|
+
missing: [
|
|
1081
|
+
ppc === null ? "plants_per_crate" : null,
|
|
1082
|
+
cpl === null ? "crates_per_layer" : null,
|
|
1083
|
+
lpc === null ? "layers_per_cart" : null,
|
|
1084
|
+
].filter((m) => m !== null),
|
|
1085
|
+
});
|
|
1086
|
+
continue;
|
|
1087
|
+
}
|
|
1067
1088
|
const cratesPerCart = cpl * lpc;
|
|
1068
1089
|
const totalPlants = Math.max(0, Number(it.quantity ?? 0));
|
|
1069
1090
|
const totalCrates = Math.ceil(totalPlants / ppc);
|
|
@@ -1076,6 +1097,9 @@ export const planAndSaveAutoCarts = createServerFn({ method: "POST" })
|
|
|
1076
1097
|
cart_number: cartNumber,
|
|
1077
1098
|
is_auto: true,
|
|
1078
1099
|
is_complete: true,
|
|
1100
|
+
// Expliciet zetten: nooit op de kolom-default leunen.
|
|
1101
|
+
source: "auto",
|
|
1102
|
+
algorithm_version: CART_PLANNER_VERSION,
|
|
1079
1103
|
}).select("id").single();
|
|
1080
1104
|
if (cErr)
|
|
1081
1105
|
throw new Error(cErr.message);
|
|
@@ -1135,7 +1159,24 @@ export const planAndSaveAutoCarts = createServerFn({ method: "POST" })
|
|
|
1135
1159
|
const adjustedRemainders = remainders
|
|
1136
1160
|
.map((r) => ({ ...r, crates_remaining: Math.max(0, r.crates_remaining - (assignedByItem[r.order_item_id] ?? 0)) }))
|
|
1137
1161
|
.filter((r) => r.crates_remaining > 0);
|
|
1138
|
-
|
|
1162
|
+
if (blockedLines.length > 0) {
|
|
1163
|
+
const { error: blockErr } = await supabaseAdmin.rpc("logistics_plan_block", {
|
|
1164
|
+
p_order_ids: [data.orderId],
|
|
1165
|
+
p_reason: "belading_onbekend",
|
|
1166
|
+
p_details: { source: "floriday-verkoop-module/planAndSaveAutoCarts", items: blockedLines },
|
|
1167
|
+
});
|
|
1168
|
+
if (blockErr) {
|
|
1169
|
+
console.warn("[karindeling] blokkade niet vastgelegd:", blockErr.message, blockedLines);
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
return {
|
|
1173
|
+
ok: true,
|
|
1174
|
+
autoCarts,
|
|
1175
|
+
remainders: adjustedRemainders,
|
|
1176
|
+
existingManualCarts,
|
|
1177
|
+
nextCartNumber: cartNumber,
|
|
1178
|
+
blockedLines,
|
|
1179
|
+
};
|
|
1139
1180
|
});
|
|
1140
1181
|
const ManualCartItemSchema = z.object({
|
|
1141
1182
|
order_item_id: z.string().uuid().nullable(),
|
|
@@ -1169,6 +1210,9 @@ export const saveManualCarts = createServerFn({ method: "POST" })
|
|
|
1169
1210
|
is_auto: false,
|
|
1170
1211
|
is_complete: !!cart.is_complete,
|
|
1171
1212
|
notes: cart.notes ?? null,
|
|
1213
|
+
// Expliciet zetten: nooit op de kolom-default leunen.
|
|
1214
|
+
source: "manual",
|
|
1215
|
+
algorithm_version: CART_PLANNER_VERSION,
|
|
1172
1216
|
}).select("id").single();
|
|
1173
1217
|
if (cErr)
|
|
1174
1218
|
throw new Error(cErr.message);
|