@flowselections/floriday-verkoop-module 1.0.70 → 1.0.74
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/verkoop/SalesOrderDetailView.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrderDetailView.js +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.d.ts.map +1 -1
- package/dist-lib/components/verkoop/SalesOrdersTable.js +5 -1
- package/dist-lib/integrations/supabase/types.d.ts +1930 -38
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.functions.d.ts +5 -0
- package/dist-lib/lib/floriday-mirror.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.functions.js +133 -22
- package/dist-lib/lib/floriday-order-level.d.ts +26 -0
- package/dist-lib/lib/floriday-order-level.d.ts.map +1 -0
- package/dist-lib/lib/floriday-order-level.js +32 -0
- package/dist-lib/lib/floriday-unlinked-products.d.ts +9 -0
- package/dist-lib/lib/floriday-unlinked-products.d.ts.map +1 -0
- package/dist-lib/lib/floriday-unlinked-products.js +27 -0
- package/dist-lib/lib/salesorders-list.server.d.ts.map +1 -1
- package/dist-lib/lib/salesorders-list.server.js +6 -1
- package/dist-lib/lib/salesorders-mapping.d.ts +7 -0
- package/dist-lib/lib/salesorders-mapping.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.d.ts.map +1 -1
- package/dist-lib/lib/salesorders.functions.js +4 -1
- package/package.json +2 -2
|
@@ -7,6 +7,11 @@ interface MirrorResult {
|
|
|
7
7
|
unchanged?: number;
|
|
8
8
|
failed: number;
|
|
9
9
|
enqueued?: number;
|
|
10
|
+
/** Per gewijzigde order welke velden echt veranderden. */
|
|
11
|
+
changes?: {
|
|
12
|
+
order_id: string;
|
|
13
|
+
fields: string[];
|
|
14
|
+
}[];
|
|
10
15
|
errors: string[];
|
|
11
16
|
skipped_reason?: string;
|
|
12
17
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floriday-mirror.functions.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-mirror.functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"floriday-mirror.functions.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-mirror.functions.ts"],"names":[],"mappings":"AA8IA,UAAU,YAAY;IACpB,EAAE,EAAE,OAAO,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0DAA0D;IAC1D,OAAO,CAAC,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,EAAE,CAAA;KAAE,EAAE,CAAC;IACnD,MAAM,EAAE,MAAM,EAAE,CAAC;IACjB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AA42CD,wBAAsB,4BAA4B,CAAC,KAAK,SAAgB,yBAEvE;AAED,eAAO,MAAM,oBAAoB;;;;8CAEP,OAAO;;yBAG0C,CAAC"}
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
// nooit tegelijk dezelfde orders verwerken.
|
|
11
11
|
import { createServerFn } from "@tanstack/react-start";
|
|
12
12
|
import { z } from "zod";
|
|
13
|
+
import { deriveOrderLevel } from "./floriday-order-level";
|
|
13
14
|
import { productNameForStorage } from "./product-name";
|
|
14
15
|
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
15
16
|
import { resolveBufferForOrderInternal } from "./order-buffers.functions";
|
|
@@ -688,9 +689,43 @@ async function mirrorUnlocked(limit) {
|
|
|
688
689
|
};
|
|
689
690
|
// Terugkerend falen per Floriday-bestelling, om zichtbaar te markeren.
|
|
690
691
|
const failuresByFoId = new Map();
|
|
692
|
+
// Ordervelden-invoer per Floriday-bestelling (uit deze ronde of de cache).
|
|
693
|
+
const lineInfoOf = (l) => ({
|
|
694
|
+
foId: l.foId,
|
|
695
|
+
orderDate: l.orderDateIso || null,
|
|
696
|
+
deliveryDate: l.deliveryIso ? l.deliveryIso.slice(0, 10) : null,
|
|
697
|
+
status: l.d?.status ?? null,
|
|
698
|
+
orgId: l.orgId || "",
|
|
699
|
+
deleted: Boolean(l.isDeleted),
|
|
700
|
+
});
|
|
701
|
+
const lineInfoFromCache = (c) => {
|
|
702
|
+
const d = c?.data ?? {};
|
|
703
|
+
const del = d?.delivery?.latestDeliveryDateTime ?? "";
|
|
704
|
+
return {
|
|
705
|
+
foId: String(c.floriday_id),
|
|
706
|
+
orderDate: d?.orderDateTime ?? d?.creationDateTime ?? null,
|
|
707
|
+
deliveryDate: del ? String(del).slice(0, 10) : null,
|
|
708
|
+
status: d?.status ?? c?.status ?? null,
|
|
709
|
+
orgId: buyerOrgIdOf(c),
|
|
710
|
+
deleted: Boolean(c?.is_deleted),
|
|
711
|
+
};
|
|
712
|
+
};
|
|
713
|
+
const lineInfoByFoId = new Map();
|
|
714
|
+
for (const l of allLines)
|
|
715
|
+
lineInfoByFoId.set(l.foId, lineInfoOf(l));
|
|
716
|
+
// Orders die in deze ronde al door een andere bestelling zijn geschreven.
|
|
717
|
+
const handledOrderIds = new Set();
|
|
718
|
+
// Welke velden per order echt veranderden (voor melding en syncresultaat).
|
|
719
|
+
const changedFieldsByOrder = new Map();
|
|
720
|
+
const noteChange = (orderId, field) => {
|
|
721
|
+
const s = changedFieldsByOrder.get(orderId) ?? new Set();
|
|
722
|
+
s.add(field);
|
|
723
|
+
changedFieldsByOrder.set(orderId, s);
|
|
724
|
+
};
|
|
691
725
|
for (const { group, key: groupKey } of keyedGroups) {
|
|
692
726
|
const primary = group[0];
|
|
693
727
|
const memberIds = group.map((l) => l.foId);
|
|
728
|
+
const groupLvl = deriveOrderLevel(group.map(lineInfoOf));
|
|
694
729
|
const anyFulfilled = group.some((l) => l.fullyFulfilled);
|
|
695
730
|
const ffPrimary = primary.ff;
|
|
696
731
|
const totalPrice = group.reduce((s, l) => s + (Number(l.totalPrice) || 0), 0);
|
|
@@ -768,9 +803,13 @@ async function mirrorUnlocked(limit) {
|
|
|
768
803
|
}
|
|
769
804
|
// Hangt het doel aan een andere bestelsleutel, dan is het een order die
|
|
770
805
|
// de Engine heeft samengesteld: we vullen hem aan, nooit overschrijven.
|
|
806
|
+
// Ook als een andere bestelling deze order in dezelfde ronde al heeft
|
|
807
|
+
// geschreven: dan alleen aanvullen, de identiteit niet overschrijven.
|
|
771
808
|
const viaMerge = Boolean(target &&
|
|
772
|
-
String(target.floriday_sales_order_id ?? "") !== primary.foId &&
|
|
773
|
-
|
|
809
|
+
((String(target.floriday_sales_order_id ?? "") !== primary.foId &&
|
|
810
|
+
String(target.floriday_order_group_key ?? "") !== groupKey) ||
|
|
811
|
+
(handledOrderIds.has(String(target.id)) &&
|
|
812
|
+
String(target.floriday_order_group_key ?? "") !== groupKey)));
|
|
774
813
|
// Vergrendelde/verzonden order: een nieuwe insert zou elke ronde opnieuw
|
|
775
814
|
// stukslaan op orders_floriday_sales_order_id_uidx. Dat herkennen we
|
|
776
815
|
// expliciet: de order wordt zichtbaar gemarkeerd voor handmatige
|
|
@@ -861,15 +900,8 @@ async function mirrorUnlocked(limit) {
|
|
|
861
900
|
let orderId;
|
|
862
901
|
let staleCandidateKeys = [];
|
|
863
902
|
if (target) {
|
|
864
|
-
// Tweerichtingssynchronisatie: de
|
|
865
|
-
//
|
|
866
|
-
// vorige spiegelronde.
|
|
867
|
-
const prevFloridayStatus = (target?.custom_fields ?? {})?.floriday_status ?? null;
|
|
868
|
-
const floridayStatusChanged = String(primary.d?.status ?? "") !== String(prevFloridayStatus ?? "");
|
|
869
|
-
const localStatus = String(target?.status ?? "");
|
|
870
|
-
const statusPatch = floridayStatusChanged && primary.status !== localStatus
|
|
871
|
-
? { status: primary.status, status_sync_token: globalThis.crypto.randomUUID() }
|
|
872
|
-
: {};
|
|
903
|
+
// Tweerichtingssynchronisatie: de status wordt verderop bepaald uit
|
|
904
|
+
// alle bestellingen op de order samen (deriveOrderLevel).
|
|
873
905
|
// Custom fields: lijsten van alle Floriday-bestellingen in deze order
|
|
874
906
|
// samenvoegen, nooit overschrijven — de order kan door de Engine uit
|
|
875
907
|
// meerdere bestellingen zijn samengesteld.
|
|
@@ -915,6 +947,54 @@ async function mirrorUnlocked(limit) {
|
|
|
915
947
|
delete mergedCf.manual_review_source;
|
|
916
948
|
}
|
|
917
949
|
}
|
|
950
|
+
// Vaste regels voor de ordervelden, over ALLE bestellingen op deze
|
|
951
|
+
// order samen (zie floriday-order-level.ts). Zo krijgt elke bestelling
|
|
952
|
+
// in de ronde dezelfde uitkomst en schrijven ze elkaar niet over.
|
|
953
|
+
const lineInfos = [];
|
|
954
|
+
const missing = [];
|
|
955
|
+
for (const id of mergedCf.floriday_sales_order_ids) {
|
|
956
|
+
const info = lineInfoByFoId.get(id);
|
|
957
|
+
if (info)
|
|
958
|
+
lineInfos.push(info);
|
|
959
|
+
else
|
|
960
|
+
missing.push(id);
|
|
961
|
+
}
|
|
962
|
+
if (missing.length > 0) {
|
|
963
|
+
const { data: mRows, error: mErr } = await supabaseAdmin
|
|
964
|
+
.from("floriday_salesorders_cache")
|
|
965
|
+
.select("floriday_id, data, status, is_deleted, buyer_organization_id")
|
|
966
|
+
.in("floriday_id", missing);
|
|
967
|
+
if (mErr)
|
|
968
|
+
throw new Error(`cache lezen voor ordervelden: ${mErr.message}`);
|
|
969
|
+
for (const c of (mRows ?? [])) {
|
|
970
|
+
const info = lineInfoFromCache(c);
|
|
971
|
+
lineInfoByFoId.set(info.foId, info);
|
|
972
|
+
lineInfos.push(info);
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
const lvl = deriveOrderLevel(lineInfos.length ? lineInfos : [lineInfoByFoId.get(primary.foId)]);
|
|
976
|
+
mergedCf.floriday_status = lvl.floridayStatusSummary;
|
|
977
|
+
if (lvl.mixedDeliveryDates)
|
|
978
|
+
mergedCf.floriday_mixed_delivery_dates = true;
|
|
979
|
+
else
|
|
980
|
+
delete mergedCf.floriday_mixed_delivery_dates;
|
|
981
|
+
if (lvl.multiBuyer) {
|
|
982
|
+
mergedCf.needs_manual_review = true;
|
|
983
|
+
mergedCf.manual_review_source = "multi_buyer";
|
|
984
|
+
mergedCf.manual_review_reason = "Bestellingen van verschillende kopers op één order";
|
|
985
|
+
}
|
|
986
|
+
else if (mergedCf.manual_review_source === "multi_buyer") {
|
|
987
|
+
delete mergedCf.needs_manual_review;
|
|
988
|
+
delete mergedCf.manual_review_reason;
|
|
989
|
+
delete mergedCf.manual_review_source;
|
|
990
|
+
}
|
|
991
|
+
// Status alleen overnemen als de Floriday-kant echt veranderde.
|
|
992
|
+
const prevFloridayStatus = prevCf.floriday_status ?? null;
|
|
993
|
+
const floridayStatusChanged = String(lvl.floridayStatusSummary ?? "") !== String(prevFloridayStatus ?? "");
|
|
994
|
+
const localStatus = String(target?.status ?? "");
|
|
995
|
+
const statusPatch = floridayStatusChanged && lvl.status !== localStatus
|
|
996
|
+
? { status: lvl.status, status_sync_token: globalThis.crypto.randomUUID() }
|
|
997
|
+
: {};
|
|
918
998
|
// Alleen regels die eerder bij déze bestelling hoorden mogen als
|
|
919
999
|
// verouderd worden gewist; regels van andere (door de Engine
|
|
920
1000
|
// samengevoegde) bestellingen blijven altijd staan.
|
|
@@ -934,10 +1014,15 @@ async function mirrorUnlocked(limit) {
|
|
|
934
1014
|
}
|
|
935
1015
|
: {
|
|
936
1016
|
order_number: orderNumber,
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
1017
|
+
// Verschillende kopers op één order: nooit gokken welke klant.
|
|
1018
|
+
...(lvl.multiBuyer
|
|
1019
|
+
? {}
|
|
1020
|
+
: {
|
|
1021
|
+
customer_id: primary.custId ?? target?.customer_id ?? null,
|
|
1022
|
+
customer_name: primary.customerName,
|
|
1023
|
+
}),
|
|
1024
|
+
delivery_date: lvl.deliveryDate,
|
|
1025
|
+
order_date: lvl.orderDate ?? primary.orderDateIso,
|
|
941
1026
|
...statusPatch,
|
|
942
1027
|
// Bevat de order ook andere bestellingen, dan rekent de Engine
|
|
943
1028
|
// het totaal; alleen dit deel meetellen zou het verkeerd maken.
|
|
@@ -974,6 +1059,7 @@ async function mirrorUnlocked(limit) {
|
|
|
974
1059
|
return String(prev ?? "") !== String(next ?? "");
|
|
975
1060
|
});
|
|
976
1061
|
orderId = target.id;
|
|
1062
|
+
handledOrderIds.add(orderId);
|
|
977
1063
|
if (changedKeys.length > 0) {
|
|
978
1064
|
const { error: uErr } = await supabaseAdmin.from("orders")
|
|
979
1065
|
.update(patch)
|
|
@@ -982,6 +1068,10 @@ async function mirrorUnlocked(limit) {
|
|
|
982
1068
|
throw new Error(uErr.message);
|
|
983
1069
|
updated++;
|
|
984
1070
|
changedOrderIds.push(orderId);
|
|
1071
|
+
for (const k of changedKeys)
|
|
1072
|
+
noteChange(orderId, k);
|
|
1073
|
+
// Volgende bestelling in dezelfde ronde ziet de net geschreven waarden.
|
|
1074
|
+
Object.assign(target, patch);
|
|
985
1075
|
}
|
|
986
1076
|
else {
|
|
987
1077
|
unchanged++;
|
|
@@ -993,11 +1083,16 @@ async function mirrorUnlocked(limit) {
|
|
|
993
1083
|
order_number: orderNumber,
|
|
994
1084
|
customer_name: primary.customerName,
|
|
995
1085
|
customer_id: primary.custId,
|
|
996
|
-
order_date: primary.orderDateIso,
|
|
997
|
-
delivery_date:
|
|
998
|
-
status:
|
|
1086
|
+
order_date: groupLvl.orderDate ?? primary.orderDateIso,
|
|
1087
|
+
delivery_date: groupLvl.deliveryDate,
|
|
1088
|
+
status: groupLvl.status,
|
|
999
1089
|
total: String(totalPrice),
|
|
1000
|
-
custom_fields: {
|
|
1090
|
+
custom_fields: {
|
|
1091
|
+
...custom_fields,
|
|
1092
|
+
floriday_status: groupLvl.floridayStatusSummary,
|
|
1093
|
+
...(groupLvl.mixedDeliveryDates ? { floriday_mixed_delivery_dates: true } : {}),
|
|
1094
|
+
floriday_groups: { [primary.foId]: memberIds },
|
|
1095
|
+
},
|
|
1001
1096
|
order_source: "floriday",
|
|
1002
1097
|
floriday_sales_order_id: primary.foId,
|
|
1003
1098
|
floriday_order_group_key: groupKey,
|
|
@@ -1010,6 +1105,8 @@ async function mirrorUnlocked(limit) {
|
|
|
1010
1105
|
orderId = ins.id;
|
|
1011
1106
|
inserted++;
|
|
1012
1107
|
changedOrderIds.push(orderId);
|
|
1108
|
+
noteChange(orderId, "nieuw");
|
|
1109
|
+
handledOrderIds.add(orderId);
|
|
1013
1110
|
}
|
|
1014
1111
|
// Handmatig vastgezette belading beschermen. Een orderregel met
|
|
1015
1112
|
// packing_locked_at is bewust door een medewerker gecorrigeerd en mag
|
|
@@ -1042,7 +1139,11 @@ async function mirrorUnlocked(limit) {
|
|
|
1042
1139
|
return {
|
|
1043
1140
|
order_id: orderId,
|
|
1044
1141
|
source_line_key: l.foId,
|
|
1045
|
-
|
|
1142
|
+
// Geen product via het trade-item-id gevonden? Dan een al ingevuld
|
|
1143
|
+
// product op de regel laten staan, nooit overschrijven met "geen
|
|
1144
|
+
// product" (anders schrijft elke ronde opnieuw en plant de Engine
|
|
1145
|
+
// telkens opnieuw in).
|
|
1146
|
+
product_id: l.productId ?? existingLineByKey.get(l.foId)?.product_id ?? null,
|
|
1046
1147
|
product_name: l.productName,
|
|
1047
1148
|
quantity: Math.max(0, l.numberOfPieces),
|
|
1048
1149
|
unit: "stuks",
|
|
@@ -1080,8 +1181,12 @@ async function mirrorUnlocked(limit) {
|
|
|
1080
1181
|
pos(prev.layers_per_cart) !== pos(r.layers_per_cart));
|
|
1081
1182
|
};
|
|
1082
1183
|
const writeRows = lineRows.filter(lineChanged);
|
|
1083
|
-
if (writeRows.length > 0)
|
|
1184
|
+
if (writeRows.length > 0) {
|
|
1084
1185
|
changedOrderIds.push(orderId);
|
|
1186
|
+
noteChange(orderId, writeRows.some((r) => !existingLineByKey.has(String(r.source_line_key)))
|
|
1187
|
+
? "orderregels (nieuw)"
|
|
1188
|
+
: "orderregels");
|
|
1189
|
+
}
|
|
1085
1190
|
// Twee vormen: vrije regels inclusief belading, vastgezette regels
|
|
1086
1191
|
// zónder de beladingskolommen (die worden dan niet meegeschreven).
|
|
1087
1192
|
const freeRows = writeRows
|
|
@@ -1264,9 +1369,12 @@ async function mirrorUnlocked(limit) {
|
|
|
1264
1369
|
let enqueued = 0;
|
|
1265
1370
|
const toEnqueue = Array.from(new Set(changedOrderIds)).filter((id) => affectedOrderIds.includes(id));
|
|
1266
1371
|
for (const oid of toEnqueue) {
|
|
1372
|
+
const fields = Array.from(changedFieldsByOrder.get(oid) ?? []).sort();
|
|
1267
1373
|
const { error: enqErr } = await supabaseAdmin.rpc("logistics_plan_enqueue", {
|
|
1268
1374
|
p_order_id: oid,
|
|
1269
|
-
p_reason:
|
|
1375
|
+
p_reason: fields.length
|
|
1376
|
+
? `nieuwe of gewijzigde Floriday-order: ${fields.join(", ")}`.slice(0, 300)
|
|
1377
|
+
: "nieuwe of gewijzigde Floriday-order",
|
|
1270
1378
|
});
|
|
1271
1379
|
if (enqErr) {
|
|
1272
1380
|
errors.push(`${oid}: aanmelden voor karindeling faalde: ${enqErr.message.slice(0, 150)}`);
|
|
@@ -1296,6 +1404,9 @@ async function mirrorUnlocked(limit) {
|
|
|
1296
1404
|
skipped,
|
|
1297
1405
|
failed,
|
|
1298
1406
|
enqueued,
|
|
1407
|
+
changes: Array.from(changedFieldsByOrder.entries())
|
|
1408
|
+
.slice(0, 50)
|
|
1409
|
+
.map(([order_id, f]) => ({ order_id, fields: Array.from(f).sort() })),
|
|
1299
1410
|
errors: errors.slice(0, 20),
|
|
1300
1411
|
};
|
|
1301
1412
|
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface FloridayLineInfo {
|
|
2
|
+
foId: string;
|
|
3
|
+
/** ISO-tijdstip van bestellen, of null als onbekend. */
|
|
4
|
+
orderDate: string | null;
|
|
5
|
+
/** Leverdatum (YYYY-MM-DD), of null als onbekend. */
|
|
6
|
+
deliveryDate: string | null;
|
|
7
|
+
/** Ruwe Floriday-status, of null als onbekend. */
|
|
8
|
+
status: string | null;
|
|
9
|
+
/** Koper-organisatienummer, of "" als onbekend. */
|
|
10
|
+
orgId: string;
|
|
11
|
+
/** Bestelling is in de gedeelde cache verwijderd. */
|
|
12
|
+
deleted?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export interface OrderLevel {
|
|
15
|
+
orderDate: string | null;
|
|
16
|
+
deliveryDate: string | null;
|
|
17
|
+
/** "Nog te picken" zolang minstens één bestelling actief is. */
|
|
18
|
+
status: "Nog te picken" | "geannuleerd";
|
|
19
|
+
/** Samengevatte Floriday-status: gesorteerde unieke statussen. */
|
|
20
|
+
floridayStatusSummary: string | null;
|
|
21
|
+
mixedDeliveryDates: boolean;
|
|
22
|
+
multiBuyer: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare function isCancelledLine(l: FloridayLineInfo): boolean;
|
|
25
|
+
export declare function deriveOrderLevel(lines: FloridayLineInfo[]): OrderLevel;
|
|
26
|
+
//# sourceMappingURL=floriday-order-level.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floriday-order-level.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-order-level.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,qDAAqD;IACrD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,kDAAkD;IAClD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,qDAAqD;IACrD,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,gEAAgE;IAChE,MAAM,EAAE,eAAe,GAAG,aAAa,CAAC;IACxC,kEAAkE;IAClE,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;CACrB;AAID,wBAAgB,eAAe,CAAC,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAE5D;AAOD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,GAAG,UAAU,CAqBtE"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Vaste regels voor de ordervelden van een order die uit meerdere
|
|
2
|
+
// Floriday-bestellingen bestaat. Puur (geen IO), zodat elke bestelling in een
|
|
3
|
+
// ronde exact dezelfde uitkomst krijgt en er geen heen-en-weer schrijven meer
|
|
4
|
+
// ontstaat tussen bestellingen op dezelfde order.
|
|
5
|
+
const CANCELLED = new Set(["cancelled", "canceled", "rejected", "expired", "unfulfillable", "deleted"]);
|
|
6
|
+
export function isCancelledLine(l) {
|
|
7
|
+
return Boolean(l.deleted) || CANCELLED.has(String(l.status ?? "").toLowerCase());
|
|
8
|
+
}
|
|
9
|
+
const minStr = (vals) => {
|
|
10
|
+
const v = vals.filter((x) => Boolean(x)).sort();
|
|
11
|
+
return v[0] ?? null;
|
|
12
|
+
};
|
|
13
|
+
export function deriveOrderLevel(lines) {
|
|
14
|
+
const active = lines.filter((l) => !isCancelledLine(l));
|
|
15
|
+
const basis = active.length > 0 ? active : lines;
|
|
16
|
+
const orderDate = lines
|
|
17
|
+
.map((l) => l.orderDate)
|
|
18
|
+
.filter((x) => Boolean(x))
|
|
19
|
+
.sort((a, b) => (Date.parse(a) || 0) - (Date.parse(b) || 0))[0] ?? null;
|
|
20
|
+
const deliveryDate = minStr(basis.map((l) => l.deliveryDate));
|
|
21
|
+
const activeDates = new Set(active.map((l) => l.deliveryDate).filter(Boolean));
|
|
22
|
+
const statuses = Array.from(new Set(lines.map((l) => (l.deleted ? "DELETED" : l.status)).filter((s) => Boolean(s)))).sort();
|
|
23
|
+
const orgs = new Set(lines.map((l) => l.orgId).filter(Boolean));
|
|
24
|
+
return {
|
|
25
|
+
orderDate,
|
|
26
|
+
deliveryDate,
|
|
27
|
+
status: active.length > 0 ? "Nog te picken" : "geannuleerd",
|
|
28
|
+
floridayStatusSummary: statuses.length ? statuses.join(",") : null,
|
|
29
|
+
mixedDeliveryDates: activeDates.size > 1,
|
|
30
|
+
multiBuyer: orgs.size > 1,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export type UnlinkedFloridayProduct = {
|
|
2
|
+
name: string;
|
|
3
|
+
tradeItemId: string | null;
|
|
4
|
+
};
|
|
5
|
+
export declare function unlinkedFloridayProducts(row: {
|
|
6
|
+
custom_fields?: any;
|
|
7
|
+
order_items?: any[] | null;
|
|
8
|
+
}): UnlinkedFloridayProduct[];
|
|
9
|
+
//# sourceMappingURL=floriday-unlinked-products.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floriday-unlinked-products.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-unlinked-products.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,uBAAuB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC;AAEnF,wBAAgB,wBAAwB,CAAC,GAAG,EAAE;IAC5C,aAAa,CAAC,EAAE,GAAG,CAAC;IACpB,WAAW,CAAC,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;CAC5B,GAAG,uBAAuB,EAAE,CAkB5B"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Floriday-regels zonder gekoppeld product (alleen-lezen, voor weergave).
|
|
2
|
+
// De synchronisatie koppelt uitsluitend op trade-item-id; lukt dat niet, dan
|
|
3
|
+
// blijft product_id leeg. Deze helper maakt dat zichtbaar — er wordt niets
|
|
4
|
+
// geschreven en de regel wordt niet apart gezet.
|
|
5
|
+
import { resolveProductName } from "./product-name";
|
|
6
|
+
export function unlinkedFloridayProducts(row) {
|
|
7
|
+
const cf = (row?.custom_fields ?? {});
|
|
8
|
+
if (cf.source !== "floriday")
|
|
9
|
+
return [];
|
|
10
|
+
const tradeBySo = new Map();
|
|
11
|
+
for (const l of Array.isArray(cf.floriday_lines) ? cf.floriday_lines : []) {
|
|
12
|
+
if (l?.sales_order_id && l?.trade_item_id)
|
|
13
|
+
tradeBySo.set(String(l.sales_order_id), String(l.trade_item_id));
|
|
14
|
+
}
|
|
15
|
+
const out = [];
|
|
16
|
+
for (const it of Array.isArray(row?.order_items) ? row.order_items : []) {
|
|
17
|
+
if (!it || it.quarantined_at || it.product_id)
|
|
18
|
+
continue;
|
|
19
|
+
const key = it.source_line_key ? String(it.source_line_key) : "";
|
|
20
|
+
out.push({
|
|
21
|
+
name: resolveProductName(it.product_name) ?? "Onbekend artikel",
|
|
22
|
+
tradeItemId: (key && tradeBySo.get(key)) ||
|
|
23
|
+
(tradeBySo.size <= 1 ? (cf.floriday_trade_item_id ?? null) : null),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
return out;
|
|
27
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"salesorders-list.server.d.ts","sourceRoot":"","sources":["../../src/lib/salesorders-list.server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"salesorders-list.server.d.ts","sourceRoot":"","sources":["../../src/lib/salesorders-list.server.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAE5D,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,iBAAiB,EAEvB,MAAM,uBAAuB,CAAC;AAO/B,OAAO,EAAkC,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAKjF,4EAA4E;AAC5E,MAAM,MAAM,SAAS,GAAG,KAAK,GAAG,UAAU,GAAG,SAAS,CAAC;AAEvD,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,SAAS,GAAG,UAAU,CAAC;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,+DAA+D;IAC/D,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,yEAAyE;IACzE,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,aAAa,EAAE,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACxC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC;IAChC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;CACpB;AA8ID,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,cAAc,EACxB,MAAM,EAAE,UAAU,EAClB,kBAAkB,GAAE,cAAyB,GAC5C,OAAO,CAAC,UAAU,CAAC,CAgiCrB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unlinkedFloridayProducts } from "./floriday-unlinked-products";
|
|
1
2
|
import { productNameForStorage, resolveProductName } from "./product-name";
|
|
2
3
|
import { centralOrderNumber, computeTotals, mapJsonbToSalesOrderDTO, packingConfigFromFloridayPacking, } from "./salesorders-mapping";
|
|
3
4
|
import { cratePackageName, loadCarrierName, mergeTypeNames } from "./load-carrier-labels";
|
|
@@ -190,7 +191,7 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
190
191
|
}
|
|
191
192
|
}
|
|
192
193
|
// 3) Lokale orders binnen hetzelfde venster.
|
|
193
|
-
const localOrderSelect = "id, order_number, customer_name, customer_id, order_date, delivery_date, status, status_origin, status_changed_at, total, custom_fields, order_source, created_at, is_reservation, plan_locked_at, buffer_id, floriday_sales_order_id, floriday_order_group_key, order_items(id, product_id, product_name, quantity, unit, unit_price, quarantined_at, products(plants_per_crate, crates_per_layer, layers_per_cart, floriday_trade_item_id, custom_fields))";
|
|
194
|
+
const localOrderSelect = "id, order_number, customer_name, customer_id, order_date, delivery_date, status, status_origin, status_changed_at, total, custom_fields, order_source, created_at, is_reservation, plan_locked_at, buffer_id, floriday_sales_order_id, floriday_order_group_key, order_items(id, product_id, product_name, source_line_key, quantity, unit, unit_price, quarantined_at, products(plants_per_crate, crates_per_layer, layers_per_cart, floriday_trade_item_id, custom_fields))";
|
|
194
195
|
let localOrderRows = [];
|
|
195
196
|
if (params.localOrderId) {
|
|
196
197
|
const primaryRes = await supabase
|
|
@@ -519,6 +520,8 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
519
520
|
at: reviewCf.floriday_change_detected_at ?? null,
|
|
520
521
|
}
|
|
521
522
|
: null;
|
|
523
|
+
dto.mixedDeliveryDates = Boolean(reviewCf?.floriday_mixed_delivery_dates);
|
|
524
|
+
dto.unlinkedProducts = localRow ? unlinkedFloridayProducts(localRow) : [];
|
|
522
525
|
dto.incomplete = [
|
|
523
526
|
...(dto.customer.name && dto.customer.name !== "Onbekende klant" ? [] : ["geen klant gekoppeld"]),
|
|
524
527
|
...(dto.deliveryAt ? [] : ["geen leverdatum"]),
|
|
@@ -661,6 +664,8 @@ export async function buildSalesOrdersList(supabase, params, connectionSupabase
|
|
|
661
664
|
: undefined;
|
|
662
665
|
localOrders.push({
|
|
663
666
|
id: `local:${r.id}`,
|
|
667
|
+
mixedDeliveryDates: Boolean(r.custom_fields?.floriday_mixed_delivery_dates),
|
|
668
|
+
unlinkedProducts: unlinkedFloridayProducts(r),
|
|
664
669
|
orderNumber: centralOrderNumber(r.order_number),
|
|
665
670
|
productName: firstProduct
|
|
666
671
|
? lineItems.length > 1
|
|
@@ -58,6 +58,13 @@ export interface SalesOrderDTO {
|
|
|
58
58
|
reason: string;
|
|
59
59
|
at: string | null;
|
|
60
60
|
} | null;
|
|
61
|
+
/** De Floriday-bestellingen op deze order hebben verschillende leverdatums. */
|
|
62
|
+
mixedDeliveryDates?: boolean;
|
|
63
|
+
/** Floriday-regels zonder gekoppeld product (naam + trade-item-id). */
|
|
64
|
+
unlinkedProducts?: {
|
|
65
|
+
name: string;
|
|
66
|
+
tradeItemId: string | null;
|
|
67
|
+
}[];
|
|
61
68
|
/** Pickdag zoals bepaald door de Logistiek Engine (ligt nooit in het verleden). */
|
|
62
69
|
pickDate?: string | null;
|
|
63
70
|
/** Engine: order is te laat aangemeld en doorgeschoven. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"salesorders-mapping.d.ts","sourceRoot":"","sources":["../../src/lib/salesorders-mapping.ts"],"names":[],"mappings":"AAEA,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAElE,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE;QAAE,UAAU,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;IACnE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EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC;CACnE;AAGD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,CAWnF;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,GAAG,EAAE,IAAI,CAAA;CAAE,CAIlF;AAYD,wBAAgB,YAAY,CAC1B,MAAM,EAAE,aAAa,EAAE,EACvB,CAAC,EAAE,iBAAiB,GACnB,aAAa,EAAE,CAuDjB;AAED,wBAAgB,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAyCtF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"salesorders.functions.d.ts","sourceRoot":"","sources":["../../src/lib/salesorders.functions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"salesorders.functions.d.ts","sourceRoot":"","sources":["../../src/lib/salesorders.functions.ts"],"names":[],"mappings":"AAMA,OAAO,EAIL,KAAK,aAAa,EAEnB,MAAM,uBAAuB,CAAC;AAqD/B,wBAAsB,0BAA0B;QAlB1C,OAAO;cACD,OAAO;cACP,MAAM;GAkBjB;AAGD,eAAO,MAAM,kBAAkB;;;;;QAvBzB,OAAO;cACD,OAAO;cACP,MAAM;GAuB+B,CAAC;AA6BlD,eAAO,MAAM,gBAAgB;;;;6CAEJ,OAAO;;;;;;;;;;;;;GAmC5B,CAAC;AAGL,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDnC,CAAC;AASL,MAAM,MAAM,sBAAsB,GAAG;IACnC,KAAK,EAAE,aAAa,GAAG,IAAI,CAAC;IAC5B,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,SAAS,GAAG,MAAM,CAAC;IAChC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,cAAc,EAAE,aAAa,EAAE,CAAC;CACjC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;;0CAEV,OAAO;;mCAsXzB,CAAC;AAQL,eAAO,MAAM,uBAAuB;;;;0CAEd,OAAO;;;;;GAQzB,CAAC;AAOL,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,SAAS,GAAG,MAAM,GAAG,IAAI,CAAC;IACvC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC;IACf,mBAAmB,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,qEAAqE;IACrE,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B,CAAC;AAIF,eAAO,MAAM,qBAAqB;;;;6EA4E9B,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unlinkedFloridayProducts } from "./floriday-unlinked-products";
|
|
1
2
|
// Sales orders sync (Floriday sequence-pattern) + write actions.
|
|
2
3
|
// Alle Floriday HTTP-calls lopen via floriday-gateway.server.
|
|
3
4
|
import { createServerFn } from "@tanstack/react-start";
|
|
@@ -307,7 +308,7 @@ export const getSalesOrderDetail = createServerFn({ method: "POST" })
|
|
|
307
308
|
try {
|
|
308
309
|
const ownRes = await supabase
|
|
309
310
|
.from("orders")
|
|
310
|
-
.select("id, buffer_id, status, is_reservation, custom_fields")
|
|
311
|
+
.select("id, buffer_id, status, is_reservation, custom_fields, order_items(product_id, product_name, source_line_key, quarantined_at)")
|
|
311
312
|
.eq("floriday_sales_order_id", data.id)
|
|
312
313
|
.maybeSingle();
|
|
313
314
|
const ownRow = ownRes.data ?? null;
|
|
@@ -326,6 +327,8 @@ export const getSalesOrderDetail = createServerFn({ method: "POST" })
|
|
|
326
327
|
});
|
|
327
328
|
dto.floridayFulfilled = Boolean((ownRow?.custom_fields ?? {})?.floriday_fulfilled);
|
|
328
329
|
const reviewCf = (ownRow?.custom_fields ?? {});
|
|
330
|
+
dto.mixedDeliveryDates = Boolean(reviewCf?.floriday_mixed_delivery_dates);
|
|
331
|
+
dto.unlinkedProducts = ownRow ? unlinkedFloridayProducts(ownRow) : [];
|
|
329
332
|
dto.needsManualReview = reviewCf?.needs_manual_review
|
|
330
333
|
? {
|
|
331
334
|
reason: String(reviewCf.manual_review_reason ?? "") ||
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowselections/floriday-verkoop-module",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.74",
|
|
4
4
|
"private": false,
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"type": "module",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
"@cloudflare/vite-plugin": "^1.25.5",
|
|
53
53
|
"@eslint/js": "^9.32.0",
|
|
54
54
|
"@flowselections/core": "1.0.29",
|
|
55
|
-
"@lovable.dev/vite-tanstack-config": "2.
|
|
55
|
+
"@lovable.dev/vite-tanstack-config": "2.25.3",
|
|
56
56
|
"@rsbuild/core": "^1.0.0",
|
|
57
57
|
"@tailwindcss/vite": "^4.2.1",
|
|
58
58
|
"@tanstack/react-query": "^5.83.0",
|