@flowselections/floriday-verkoop-module 1.0.161 → 1.0.163
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/types.d.ts +756 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/backfill-flag.d.ts +2 -0
- package/dist-lib/lib/backfill-flag.d.ts.map +1 -0
- package/dist-lib/lib/backfill-flag.js +18 -0
- package/dist-lib/lib/cart-replan.functions.d.ts +7 -12
- package/dist-lib/lib/cart-replan.functions.d.ts.map +1 -1
- package/dist-lib/lib/cart-replan.functions.js +6 -12
- package/dist-lib/lib/cart-replan.server.d.ts +5 -45
- package/dist-lib/lib/cart-replan.server.d.ts.map +1 -1
- package/dist-lib/lib/cart-replan.server.js +13 -364
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +3 -7
- package/dist-lib/lib/floriday-backfill.d.ts.map +1 -1
- package/dist-lib/lib/floriday-backfill.js +5 -4
- package/dist-lib/lib/floriday-external-fulfillment.server.d.ts.map +1 -1
- package/dist-lib/lib/floriday-external-fulfillment.server.js +0 -3
- package/dist-lib/lib/floriday-mirror.server.d.ts.map +1 -1
- package/dist-lib/lib/floriday-mirror.server.js +15 -25
- package/dist-lib/lib/floriday-order-level.d.ts +15 -0
- package/dist-lib/lib/floriday-order-level.d.ts.map +1 -1
- package/dist-lib/lib/floriday-order-level.js +23 -0
- package/dist-lib/lib/invoice-timing.d.ts.map +1 -1
- package/dist-lib/lib/invoice-timing.js +2 -2
- package/dist-lib/lib/logistics-engine.functions.d.ts +1 -1
- package/dist-lib/lib/order-cancel.server.d.ts.map +1 -1
- package/dist-lib/lib/order-cancel.server.js +2 -4
- package/dist-lib/lib/order-status.d.ts.map +1 -1
- package/dist-lib/lib/order-status.js +11 -3
- package/package.json +1 -1
- package/schema/verkoop.sql +765 -17
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"floriday-mirror.server.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-mirror.server.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"floriday-mirror.server.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-mirror.server.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAwB,KAAK,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAwJ9E,MAAM,WAAW,YAAY;IAC3B,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,mEAAmE;IACnE,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,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;AA66CD,eAAO,MAAM,oBAAoB,MAAgB,CAAC;AAElD,wBAAsB,4BAA4B,CAAC,KAAK,SAAgB,EAAE,KAAK,GAAE,MAAM,GAAG,IAAW,yBAEpG;AAED;;;GAGG;AACH,wBAAsB,yBAAyB,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,QAAQ,GAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,GAAG,IAAW,yBAI/G"}
|
|
@@ -12,10 +12,11 @@ import { fillOnlyEmpty, snapshotFromFloridayOrder } from "./packing-snapshot.js"
|
|
|
12
12
|
// - De minuutronde (sync-salesorders) roept `mirrorFloridayOrdersFromCron`
|
|
13
13
|
// aan; het spiegelen draait onder een eigen slot, zodat twee aanroepen
|
|
14
14
|
// nooit tegelijk dezelfde orders verwerken.
|
|
15
|
-
import { deriveOrderLevel } from "./floriday-order-level.js";
|
|
15
|
+
import { cancelledInsertFields, deriveOrderLevel } from "./floriday-order-level.js";
|
|
16
16
|
import { productNameForStorage } from "./product-name.js";
|
|
17
17
|
import { resolveBufferForOrderInternal } from "./order-buffers.server.js";
|
|
18
18
|
import { backfillInsertFields } from "./floriday-backfill.js";
|
|
19
|
+
import { FLORIDAY_CANCEL_REASON } from "./order-cancel.server.js";
|
|
19
20
|
const LOOKBACK_DAYS = 14;
|
|
20
21
|
const DEFAULT_BATCH = 200;
|
|
21
22
|
/** Onbekend blijft onbekend: geen stilzwijgende 1. Zelfde helper als de planner. */
|
|
@@ -672,6 +673,7 @@ async function mirrorUnlocked(limit, since, onlyIds = null, backfill = null) {
|
|
|
672
673
|
status: l.d?.status ?? null,
|
|
673
674
|
orgId: l.orgId || "",
|
|
674
675
|
deleted: Boolean(l.isDeleted),
|
|
676
|
+
latestDeliveryAt: l.d?.delivery?.latestDeliveryDateTime ?? null,
|
|
675
677
|
});
|
|
676
678
|
const lineInfoFromCache = (c) => {
|
|
677
679
|
const d = c?.data ?? {};
|
|
@@ -683,6 +685,7 @@ async function mirrorUnlocked(limit, since, onlyIds = null, backfill = null) {
|
|
|
683
685
|
status: d?.status ?? c?.status ?? null,
|
|
684
686
|
orgId: buyerOrgIdOf(c),
|
|
685
687
|
deleted: Boolean(c?.is_deleted),
|
|
688
|
+
latestDeliveryAt: del ? String(del) : null,
|
|
686
689
|
};
|
|
687
690
|
};
|
|
688
691
|
const lineInfoByFoId = new Map();
|
|
@@ -738,6 +741,8 @@ async function mirrorUnlocked(limit, since, onlyIds = null, backfill = null) {
|
|
|
738
741
|
floriday_received_at: ffPrimary?.receivedAt ?? null,
|
|
739
742
|
floriday_packing: primaryLine.packing,
|
|
740
743
|
floriday_lines: floridayLines,
|
|
744
|
+
// Uiterste levertijd (Floriday delivery.latestDeliveryDateTime); gelezen door de Engine.
|
|
745
|
+
...(groupLvl.latestDeliveryAt ? { floriday_latest_delivery_at: groupLvl.latestDeliveryAt } : {}),
|
|
741
746
|
};
|
|
742
747
|
try {
|
|
743
748
|
// Bestaande order kiezen. Volgorde: de order die al aan deze
|
|
@@ -982,6 +987,8 @@ async function mirrorUnlocked(limit, since, onlyIds = null, backfill = null) {
|
|
|
982
987
|
}
|
|
983
988
|
const lvl = deriveOrderLevel(lineInfos.length ? lineInfos : [lineInfoByFoId.get(primary.foId)]);
|
|
984
989
|
mergedCf.floriday_status = lvl.floridayStatusSummary;
|
|
990
|
+
if (lvl.latestDeliveryAt)
|
|
991
|
+
mergedCf.floriday_latest_delivery_at = lvl.latestDeliveryAt;
|
|
985
992
|
if (lvl.mixedDeliveryDates)
|
|
986
993
|
mergedCf.floriday_mixed_delivery_dates = true;
|
|
987
994
|
else
|
|
@@ -1103,6 +1110,8 @@ async function mirrorUnlocked(limit, since, onlyIds = null, backfill = null) {
|
|
|
1103
1110
|
// Inhalen: markering in dezelfde INSERT, vóór de orderregels.
|
|
1104
1111
|
const bfInfo = backfill?.get(primary.foId) ?? null;
|
|
1105
1112
|
const bf = bfInfo ? backfillInsertFields(bfInfo, memberIds, new Date().toISOString()) : null;
|
|
1113
|
+
// Al geannuleerd in Floriday: status en cancelled_at in dezelfde INSERT.
|
|
1114
|
+
const cx = cancelledInsertFields(groupLvl.status, Boolean(bf), new Date().toISOString(), FLORIDAY_CANCEL_REASON);
|
|
1106
1115
|
const { data: ins, error: iErr } = await supabaseAdmin.from("orders")
|
|
1107
1116
|
.insert({
|
|
1108
1117
|
order_number: orderNumber,
|
|
@@ -1111,6 +1120,7 @@ async function mirrorUnlocked(limit, since, onlyIds = null, backfill = null) {
|
|
|
1111
1120
|
order_date: groupLvl.orderDate ?? primary.orderDateIso,
|
|
1112
1121
|
delivery_date: groupLvl.deliveryDate,
|
|
1113
1122
|
status: bf ? bf.status : groupLvl.status,
|
|
1123
|
+
...(cx ? cx.columns : {}),
|
|
1114
1124
|
total: String(totalPrice),
|
|
1115
1125
|
custom_fields: {
|
|
1116
1126
|
...custom_fields,
|
|
@@ -1118,6 +1128,7 @@ async function mirrorUnlocked(limit, since, onlyIds = null, backfill = null) {
|
|
|
1118
1128
|
...(groupLvl.mixedDeliveryDates ? { floriday_mixed_delivery_dates: true } : {}),
|
|
1119
1129
|
floriday_groups: { [primary.foId]: memberIds },
|
|
1120
1130
|
...(bf ? bf.customFields : {}),
|
|
1131
|
+
...(cx ? cx.customFields : {}),
|
|
1121
1132
|
},
|
|
1122
1133
|
order_source: "floriday",
|
|
1123
1134
|
floriday_sales_order_id: primary.foId,
|
|
@@ -1370,7 +1381,7 @@ async function mirrorUnlocked(limit, since, onlyIds = null, backfill = null) {
|
|
|
1370
1381
|
}
|
|
1371
1382
|
// Geen eigen beladings-/ladingdragercontrole: alleen de Logistiek Engine
|
|
1372
1383
|
// beslist of een belading kan (koppelprompt 22).
|
|
1373
|
-
// Buffer resolven en
|
|
1384
|
+
// Buffer resolven en aanmelden bij de Engine. Alleen orders die buiten
|
|
1374
1385
|
// ons ERP om in Floriday zijn afgehandeld hoeven niet meer gepland te
|
|
1375
1386
|
// worden.
|
|
1376
1387
|
const externallyHandled = anyFulfilled && !ffPrimary?.createdByErp;
|
|
@@ -1419,8 +1430,6 @@ async function mirrorUnlocked(limit, since, onlyIds = null, backfill = null) {
|
|
|
1419
1430
|
if (fErr)
|
|
1420
1431
|
console.warn(`[floriday-mirror] foutteller bijwerken faalde voor ${row.id}: ${fErr.message}`);
|
|
1421
1432
|
}
|
|
1422
|
-
// Batch enqueue voor karherplanning. processed_at resetten, anders blijft een
|
|
1423
|
-
// eerder verwerkte order voor altijd overgeslagen door de cron.
|
|
1424
1433
|
// Annuleringen uit Floriday afhandelen (koppelprompt 1.0.77).
|
|
1425
1434
|
// Afgehandeld in Floriday (buiten het ERP om) — na de ronde, per order.
|
|
1426
1435
|
for (const oid of Array.from(handledOrderIds)) {
|
|
@@ -1448,27 +1457,8 @@ async function mirrorUnlocked(limit, since, onlyIds = null, backfill = null) {
|
|
|
1448
1457
|
errors.push(`${cid}: annulering uit Floriday faalde: ${err.message}`.slice(0, 200));
|
|
1449
1458
|
}
|
|
1450
1459
|
}
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
order_id: oid,
|
|
1454
|
-
requested_at: new Date().toISOString(),
|
|
1455
|
-
processed_at: null,
|
|
1456
|
-
attempts: 0,
|
|
1457
|
-
last_error: null,
|
|
1458
|
-
}));
|
|
1459
|
-
await supabaseAdmin.from("cart_replan_queue").upsert(queueRows, {
|
|
1460
|
-
onConflict: "order_id",
|
|
1461
|
-
});
|
|
1462
|
-
}
|
|
1463
|
-
// Ingehaalde orders: de trigger enqueue_cart_replan zet ze bij het aanmaken
|
|
1464
|
-
// in de herindelwachtrij; weghalen, net als bij volledig afgehandeld.
|
|
1465
|
-
if (backfillOrderIds.size > 0) {
|
|
1466
|
-
const { error: bfqErr } = await supabaseAdmin.from("cart_replan_queue")
|
|
1467
|
-
.delete()
|
|
1468
|
-
.in("order_id", Array.from(backfillOrderIds));
|
|
1469
|
-
if (bfqErr)
|
|
1470
|
-
errors.push(`herindelwachtrij ingehaalde orders opschonen faalde: ${bfqErr.message}`.slice(0, 200));
|
|
1471
|
-
}
|
|
1460
|
+
// Geen cart_replan_queue meer (golf 1): die wachtrij werd door niets verwerkt;
|
|
1461
|
+
// de Engine plant via haar eigen planwachtrij (stap 2 hieronder).
|
|
1472
1462
|
// Stap 2: orders die in deze ronde echt zijn aangemaakt of gewijzigd
|
|
1473
1463
|
// expliciet aanmelden bij de planwachtrij van de logistiek-engine. Mislukt
|
|
1474
1464
|
// dat, dan verschijnt het als duidelijke fout in het syncresultaat.
|
|
@@ -10,6 +10,8 @@ export interface FloridayLineInfo {
|
|
|
10
10
|
orgId: string;
|
|
11
11
|
/** Bestelling is in de gedeelde cache verwijderd. */
|
|
12
12
|
deleted?: boolean;
|
|
13
|
+
/** Floriday delivery.latestDeliveryDateTime (ruw), of null. */
|
|
14
|
+
latestDeliveryAt?: string | null;
|
|
13
15
|
}
|
|
14
16
|
export interface OrderLevel {
|
|
15
17
|
orderDate: string | null;
|
|
@@ -20,7 +22,20 @@ export interface OrderLevel {
|
|
|
20
22
|
floridayStatusSummary: string | null;
|
|
21
23
|
mixedDeliveryDates: boolean;
|
|
22
24
|
multiBuyer: boolean;
|
|
25
|
+
/** Vroegste uiterste levertijd (ISO met tijdzone) over de actieve bestellingen. */
|
|
26
|
+
latestDeliveryAt: string | null;
|
|
23
27
|
}
|
|
24
28
|
export declare function isCancelledLine(l: FloridayLineInfo): boolean;
|
|
25
29
|
export declare function deriveOrderLevel(lines: FloridayLineInfo[]): OrderLevel;
|
|
30
|
+
/** Vroegste geldige tijdstip als ISO met tijdzone (UTC, "Z"); ongeldig/leeg telt niet. */
|
|
31
|
+
export declare function earliestIso(vals: (string | null | undefined)[]): string | null;
|
|
32
|
+
/**
|
|
33
|
+
* Extra velden voor de INSERT van een nieuwe Floriday-order die al geannuleerd
|
|
34
|
+
* binnenkomt: status en cancelled_at altijd samen, net als bij handmatig
|
|
35
|
+
* annuleren. Nooit voor backfill; bestaande orders vallen hier niet onder.
|
|
36
|
+
*/
|
|
37
|
+
export declare function cancelledInsertFields(status: string, isBackfill: boolean, nowIso: string, reason: string): {
|
|
38
|
+
columns: Record<string, unknown>;
|
|
39
|
+
customFields: Record<string, unknown>;
|
|
40
|
+
} | null;
|
|
26
41
|
//# sourceMappingURL=floriday-order-level.d.ts.map
|
|
@@ -1 +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,qDAAq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C,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAAG,MAAM,GAAG,IAAI,CAM9E;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,OAAO,EACnB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,GACb;IAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAAE,GAAG,IAAI,CAMpF"}
|
|
@@ -20,6 +20,7 @@ export function deriveOrderLevel(lines) {
|
|
|
20
20
|
const deliveryDate = minStr(basis.map((l) => l.deliveryDate));
|
|
21
21
|
const activeDates = new Set(active.map((l) => l.deliveryDate).filter(Boolean));
|
|
22
22
|
const statuses = Array.from(new Set(lines.map((l) => (l.deleted ? "DELETED" : l.status)).filter((s) => Boolean(s)))).sort();
|
|
23
|
+
const latestDeliveryAt = earliestIso(basis.map((l) => l.latestDeliveryAt ?? null));
|
|
23
24
|
const orgs = new Set(lines.map((l) => l.orgId).filter(Boolean));
|
|
24
25
|
return {
|
|
25
26
|
orderDate,
|
|
@@ -28,5 +29,27 @@ export function deriveOrderLevel(lines) {
|
|
|
28
29
|
floridayStatusSummary: statuses.length ? statuses.join(",") : null,
|
|
29
30
|
mixedDeliveryDates: activeDates.size > 1,
|
|
30
31
|
multiBuyer: orgs.size > 1,
|
|
32
|
+
latestDeliveryAt,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** Vroegste geldige tijdstip als ISO met tijdzone (UTC, "Z"); ongeldig/leeg telt niet. */
|
|
36
|
+
export function earliestIso(vals) {
|
|
37
|
+
const ms = vals
|
|
38
|
+
.map((v) => (v ? Date.parse(String(v)) : NaN))
|
|
39
|
+
.filter((n) => Number.isFinite(n))
|
|
40
|
+
.sort((a, b) => a - b);
|
|
41
|
+
return ms.length ? new Date(ms[0]).toISOString() : null;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Extra velden voor de INSERT van een nieuwe Floriday-order die al geannuleerd
|
|
45
|
+
* binnenkomt: status en cancelled_at altijd samen, net als bij handmatig
|
|
46
|
+
* annuleren. Nooit voor backfill; bestaande orders vallen hier niet onder.
|
|
47
|
+
*/
|
|
48
|
+
export function cancelledInsertFields(status, isBackfill, nowIso, reason) {
|
|
49
|
+
if (isBackfill || status !== "geannuleerd")
|
|
50
|
+
return null;
|
|
51
|
+
return {
|
|
52
|
+
columns: { cancelled_at: nowIso, cancel_reason: reason, invoice_due_at: null, buffer_id: null },
|
|
53
|
+
customFields: { floriday_cancelled_at: nowIso, floriday_cancel_notice: reason },
|
|
31
54
|
};
|
|
32
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoice-timing.d.ts","sourceRoot":"","sources":["../../src/lib/invoice-timing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"invoice-timing.d.ts","sourceRoot":"","sources":["../../src/lib/invoice-timing.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,aAAa,GACrB,eAAe,GACf,WAAW,GACX,QAAQ,GACR,SAAS,GACT,mBAAmB,GACnB,aAAa,GACb,eAAe,CAAC;AAEpB,eAAO,MAAM,eAAe,EAAE;IAAE,EAAE,EAAE,aAAa,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAQ/E,CAAC;AAEF,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,aAAa,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,aAAa,CAAC;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,sBAAsB,EAAE,OAAO,CAAC;IAChC,eAAe,EAAE,MAAM,CAAC;IAC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AC;IAC1B,oBAAoB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,0CAA0C;IAC1C,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAOzD;AAoDD,2FAA2F;AAC3F,wBAAgB,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAS7D;AAqCD;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,kBAAkB,EACzB,QAAQ,EAAE,qBAAqB,GAC9B,MAAM,GAAG,IAAI,CAef;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,qBAAqB,EAAE,SAAS,UAAQ,GAAG,MAAM,CAWhG;AAED;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,EAAE;IAAE,aAAa,CAAC,EAAE,OAAO,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAC/D,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACnC,MAAM,GAAG,IAAI,CAMf"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Pure rekenlogica voor het instelbare factuurmoment.
|
|
2
2
|
// Formule: factuurmoment = ijkpunt + X dagen (op tijdstip T).
|
|
3
3
|
// Zelfafhalers kunnen een eigen ijkpunt/offset hebben.
|
|
4
|
+
import { isBackfillMarked } from "./backfill-flag.js";
|
|
4
5
|
export const INVOICE_ANCHORS = [
|
|
5
6
|
{ id: "order_created", label: "Order binnengekomen", hint: "Moment waarop de order is aangemaakt" },
|
|
6
7
|
{ id: "confirmed", label: "Order bevestigd", hint: "Zodra de order is bevestigd/ingepland" },
|
|
@@ -190,8 +191,7 @@ export function describeInvoiceTiming(settings, forPickup = false) {
|
|
|
190
191
|
* factureren (YYYY-MM-DD, Nederlandse dag). Zonder startdatum geldt alleen de backfill-regel.
|
|
191
192
|
*/
|
|
192
193
|
export function invoiceReleaseExcluded(row, startDate) {
|
|
193
|
-
|
|
194
|
-
if (cf && typeof cf === "object" && "backfill" in cf)
|
|
194
|
+
if (isBackfillMarked(row.custom_fields))
|
|
195
195
|
return "ingehaalde of herstelde order";
|
|
196
196
|
const d = String(row.delivery_date ?? "").slice(0, 10);
|
|
197
197
|
const start = String(startDate ?? "").slice(0, 10);
|
|
@@ -5,7 +5,7 @@ export declare const sendOrderEventToEngine: import("@tanstack/start-client-core
|
|
|
5
5
|
claims: import("@supabase/auth-js").User;
|
|
6
6
|
}, undefined, undefined, undefined>], (input: unknown) => {
|
|
7
7
|
orderId: string;
|
|
8
|
-
type: "order.
|
|
8
|
+
type: "order.received" | "order.changed";
|
|
9
9
|
}, Promise<{
|
|
10
10
|
ok: false;
|
|
11
11
|
error: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-cancel.server.d.ts","sourceRoot":"","sources":["../../src/lib/order-cancel.server.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,EAAE,EAAE,GAAG,EACP,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,GAAG,WAAW,CAAC,CASxC;AAED,oFAAoF;AACpF,wBAAsB,wBAAwB,CAAC,KAAK,EAAE;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,yFAAyF;IACzF,MAAM,EAAE,GAAG,CAAC;IACZ,gGAAgG;IAChG,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,gBAAgB,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"order-cancel.server.d.ts","sourceRoot":"","sources":["../../src/lib/order-cancel.server.ts"],"names":[],"mappings":"AASA,eAAO,MAAM,gBAAgB,gBAAgB,CAAC;AAE9C;;;;;GAKG;AACH,wBAAsB,yBAAyB,CAC7C,EAAE,EAAE,GAAG,EACP,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,GAAG,WAAW,CAAC,CASxC;AAED,oFAAoF;AACpF,wBAAsB,wBAAwB,CAAC,KAAK,EAAE;IACpD,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,yFAAyF;IACzF,MAAM,EAAE,GAAG,CAAC;IACZ,gGAAgG;IAChG,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACxB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,gBAAgB,EAAE,OAAO,CAAC;IAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,QAAQ,EAAE,eAAe,GAAG,WAAW,GAAG,IAAI,CAAA;CAAE,CAAC,CA2D/H;AAED,eAAO,MAAM,sBAAsB,wCAAwC,CAAC;AAC5E,eAAO,MAAM,8BAA8B,6DACiB,CAAC;AAE7D;;;;;GAKG;AACH,wBAAsB,0BAA0B,CAC9C,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,WAAW,GAAG,gBAAgB,GAAG,cAAc,GAAG,mBAAmB,CAAC,CA8EhF"}
|
|
@@ -4,7 +4,7 @@ import { stockError } from "./stock-errors.js";
|
|
|
4
4
|
// Annuleren = order bewaren, maar uit de afhandeling halen:
|
|
5
5
|
// - eerst voorraad terugdraaien via Voorraad (voorraad_order_terugdraaien),
|
|
6
6
|
// - status op `geannuleerd` met tijdstip en reden,
|
|
7
|
-
// - los uit de buffer
|
|
7
|
+
// - los uit de buffer en de karplanning,
|
|
8
8
|
// - `invoice_due_at` leegmaken zodat automatische facturatie hem niet oppakt.
|
|
9
9
|
export const CANCELLED_STATUS = "geannuleerd";
|
|
10
10
|
/**
|
|
@@ -47,9 +47,8 @@ export async function cancelLocalOrderInternal(input) {
|
|
|
47
47
|
const reason = (input.reason ?? "").trim();
|
|
48
48
|
// Eerst de voorraad via Voorraad; mislukt dat, dan wordt er niets geannuleerd.
|
|
49
49
|
const voorraad = await voorraadOrderTerugdraaien(input.sbUser, input.orderId, reason ? `Bestelling geannuleerd — ${reason}` : "Bestelling geannuleerd");
|
|
50
|
-
// Uit de planning halen: karren
|
|
50
|
+
// Uit de planning halen: karren opruimen (cart_replan_queue wordt sinds golf 1 niet meer gevuld).
|
|
51
51
|
await supabaseAdmin.from("order_carts").delete().eq("order_id", input.orderId);
|
|
52
|
-
await supabaseAdmin.from("cart_replan_queue").delete().eq("order_id", input.orderId);
|
|
53
52
|
const { error: uErr } = await supabaseAdmin.from("orders")
|
|
54
53
|
.update({
|
|
55
54
|
status: CANCELLED_STATUS,
|
|
@@ -140,7 +139,6 @@ export async function handleFloridayCancellation(orderId) {
|
|
|
140
139
|
}
|
|
141
140
|
// Geen gebruiker bij een annulering uit Floriday (minuutronde): beheerclient.
|
|
142
141
|
await voorraadOrderTerugdraaien(supabaseAdmin, orderId, `Bestelling geannuleerd — ${FLORIDAY_CANCEL_REASON}`);
|
|
143
|
-
await supabaseAdmin.from("cart_replan_queue").delete().eq("order_id", orderId);
|
|
144
142
|
const { error: uErr } = await supabaseAdmin.from("orders")
|
|
145
143
|
.update({
|
|
146
144
|
status: CANCELLED_STATUS,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"order-status.d.ts","sourceRoot":"","sources":["../../src/lib/order-status.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"order-status.d.ts","sourceRoot":"","sources":["../../src/lib/order-status.ts"],"names":[],"mappings":"AAMA,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;AAEpF,eAAO,MAAM,YAAY,EAAE;IAAE,EAAE,EAAE,UAAU,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAMzE,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,CAAC;AAErD,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,SAAS,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CAIhG;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,CAAC,EAAE,SAAS,GAAG,MAAM,CAI3E;AAED,qDAAqD;AACrD,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAa9D;AAiCD,MAAM,WAAW,eAAe;IAC9B,qEAAqE;IACrE,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iDAAiD;IACjD,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,8CAA8C;IAC9C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,kDAAkD;IAClD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,+EAA+E;IAC/E,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,eAAe,GAAG,UAAU,CAUpE;AAID,mFAAmF;AACnF,wBAAgB,WAAW,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,UAAU,CAM5D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Centrale vertaallaag: opgeslagen orderstatussen -> de vijf labels die de
|
|
2
2
|
// kwekerij in de UI ziet. De databasewaarden blijven ongewijzigd, zodat de
|
|
3
3
|
// Logistiek Engine, de afhandelings- en facturatiemodule blijven werken.
|
|
4
|
+
import { isBackfillMarked } from "./backfill-flag.js";
|
|
4
5
|
export const ORDER_STAGES = [
|
|
5
6
|
{ id: "incoming", label: "Inkomende orders", hint: "Nieuw binnengekomen en nog te verwerken" },
|
|
6
7
|
{ id: "topick", label: "Te picken", hint: "Bevestigd/ingepland, maar nog niet gepickt" },
|
|
@@ -11,8 +12,7 @@ export const ORDER_STAGES = [
|
|
|
11
12
|
export function orderStageNote(input) {
|
|
12
13
|
if (input.deletedAt)
|
|
13
14
|
return "deleted";
|
|
14
|
-
|
|
15
|
-
if (cf && typeof cf === "object" && "backfill" in cf)
|
|
15
|
+
if (isBackfillMarked(input.customFields))
|
|
16
16
|
return "handled";
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
@@ -38,7 +38,8 @@ export function orderStageBadgeClass(stage) {
|
|
|
38
38
|
return "bg-muted text-muted-foreground";
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
|
-
|
|
41
|
+
// Afgestemd op de statuslijst van de Logistiek Engine (logistics_status_fase); golf1.check.ts bewaakt dat.
|
|
42
|
+
const CANCELLED = new Set(["cancelled", "canceled", "geannuleerd", "rejected", "afgewezen", "vervallen"]);
|
|
42
43
|
const SHIPPED = new Set([
|
|
43
44
|
"shipped",
|
|
44
45
|
"verzonden",
|
|
@@ -47,7 +48,14 @@ const SHIPPED = new Set([
|
|
|
47
48
|
"aangemeld",
|
|
48
49
|
"dispatched",
|
|
49
50
|
"in_transit",
|
|
51
|
+
"afgehandeld",
|
|
52
|
+
"afgemeld",
|
|
53
|
+
"afgerond",
|
|
50
54
|
"gereed voor facturatie",
|
|
55
|
+
"gefactureerd",
|
|
56
|
+
"invoiced",
|
|
57
|
+
"afgehandeld floriday",
|
|
58
|
+
"afgehandeld via floriday",
|
|
51
59
|
]);
|
|
52
60
|
const PICKED = new Set(["picked", "gepickt", "controlled", "gecontroleerd", "verzend klaar", "ready"]);
|
|
53
61
|
const TOPICK = new Set([
|