@flowselections/floriday-verkoop-module 1.0.136 → 1.0.137
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 +1249 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.d.ts.map +1 -1
- package/dist-lib/lib/create-order.functions.js +18 -3
- package/dist-lib/lib/module-version.d.ts +1 -1
- package/dist-lib/lib/module-version.js +1 -1
- package/dist-lib/lib/stock-product-link.check.js +10 -2
- package/dist-lib/lib/stock-product-link.d.ts +2 -0
- package/dist-lib/lib/stock-product-link.d.ts.map +1 -1
- package/dist-lib/lib/stock-product-link.js +8 -7
- package/dist-lib/lib/stock-product-link.server.d.ts +2 -0
- package/dist-lib/lib/stock-product-link.server.d.ts.map +1 -1
- package/dist-lib/lib/stock-product-link.server.js +33 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,2BAA2B;;;;;;GA+CpC,CAAC;AAIL,eAAO,MAAM,2BAA2B;;;;0CAElB,OAAO;;;;GAoDzB,CAAC;AAWL,eAAO,MAAM,0BAA0B;;;;;;YA+D7B,MAAM;iBACD,MAAM;sBACD,MAAM,GAAG,IAAI;cACrB,MAAM;oBACA,MAAM,GAAG,IAAI;0BACP,MAAM,GAAG,IAAI;0BACb,MAAM,GAAG,IAAI;yBACd,MAAM,GAAG,IAAI;wBACd,MAAM;wBACN,MAAM;yBACL,MAAM;kBACb,OAAO;gBACT,UAAU,GAAG,OAAO,GAAG,OAAO,GAAG,SAAS;;
|
|
1
|
+
{"version":3,"file":"create-order.functions.d.ts","sourceRoot":"","sources":["../../src/lib/create-order.functions.ts"],"names":[],"mappings":"AAeA,eAAO,MAAM,2BAA2B;;;;;;GA+CpC,CAAC;AAIL,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BACS,MAAM,GAAG,IAAI;qBACT,MAAM;;cAErB,MAAM,GAAG,IAAI;;;;;;;GASpC,CAAC;AAIL,eAAO,MAAM,gBAAgB;;;;8CAEH,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyR7B,CAAC;AAKL,eAAO,MAAM,kBAAkB;;;;8CAEL,OAAO;;;;;;;;WAUM,MAAM;YAAU,MAAM,GAAG,IAAI;WAmBhE,CAAC;AAOL,eAAO,MAAM,2BAA2B;;;;8CAEd,OAAO;;;;gBAIgC,MAAM,EAAE;GAoCrE,CAAC"}
|
|
@@ -136,7 +136,7 @@ export const listProductsForCreateOrder = createServerFn({ method: "GET" })
|
|
|
136
136
|
.range(0, 9999),
|
|
137
137
|
context.supabase
|
|
138
138
|
.from("products")
|
|
139
|
-
.select("id, product, unit, sale_price, plants_per_crate, crates_per_layer, layers_per_cart, quantity, custom_fields, trade_item_key")
|
|
139
|
+
.select("id, product, unit, sale_price, plants_per_crate, crates_per_layer, layers_per_cart, quantity, custom_fields, trade_item_key, floriday_trade_item_id")
|
|
140
140
|
.range(0, 4999),
|
|
141
141
|
]);
|
|
142
142
|
// Supabase geeft standaard max. 1000 rijen terug. Voor productgroepen kan de
|
|
@@ -225,6 +225,14 @@ export const listProductsForCreateOrder = createServerFn({ method: "GET" })
|
|
|
225
225
|
// of het bare Floriday-id.
|
|
226
226
|
const mirrorProductIdsByDraft = new Map();
|
|
227
227
|
const mirrorProductIdsByFloriday = new Map();
|
|
228
|
+
// Canoniek eigen artikel per Floriday-id (geen spiegel): daar staat de echte voorraad.
|
|
229
|
+
const ownByFloriday = new Map();
|
|
230
|
+
for (const p of Array.isArray(productsRes.data) ? productsRes.data : []) {
|
|
231
|
+
const src = String((p.custom_fields ?? {}).source ?? "");
|
|
232
|
+
const ti = p.floriday_trade_item_id;
|
|
233
|
+
if (ti && !/^sales-module-.*-mirror$/.test(src))
|
|
234
|
+
ownByFloriday.set(String(ti), p.id);
|
|
235
|
+
}
|
|
228
236
|
for (const p of Array.isArray(productsRes.data) ? productsRes.data : []) {
|
|
229
237
|
const cf = (p.custom_fields ?? {});
|
|
230
238
|
const pid = p.id;
|
|
@@ -250,7 +258,9 @@ export const listProductsForCreateOrder = createServerFn({ method: "GET" })
|
|
|
250
258
|
const id = r.floriday_id;
|
|
251
259
|
const articleCode = d.supplierArticleCode ?? null;
|
|
252
260
|
const mirrorKeys = (mirrorProductIdsByFloriday.get(id) ?? []).map((pid) => `product:${pid}`);
|
|
253
|
-
const
|
|
261
|
+
const own = ownByFloriday.get(id);
|
|
262
|
+
// Eigen artikel bestaat → alleen de canonieke voorraadregel, nooit de spiegel.
|
|
263
|
+
const sAgg = own ? stockOfAliases([`product:${own}`, id]) : stockOfAliases([id, ...mirrorKeys]);
|
|
254
264
|
const physical = sAgg.physical;
|
|
255
265
|
const reserved = sAgg.reserved;
|
|
256
266
|
const available = Math.max(0, physical - reserved);
|
|
@@ -817,7 +827,12 @@ export const createManualOrder = createServerFn({ method: "POST" })
|
|
|
817
827
|
const { loadStockLinks } = await import("./stock-product-link.server.js");
|
|
818
828
|
const { fillLineFromStock } = await import("./stock-product-link.js");
|
|
819
829
|
const links = await loadStockLinks(supabaseAdmin, data.lines.map((l) => l.product_id));
|
|
820
|
-
|
|
830
|
+
// 1.0.136: bestaat er al een voorraadartikel (eerst floriday_trade_item_id,
|
|
831
|
+
// dan products.id), dan krijgt de regel dat artikel en maken we géén spiegel.
|
|
832
|
+
data.lines = data.lines.map((l) => {
|
|
833
|
+
const link = links.get(l.product_id);
|
|
834
|
+
return { ...fillLineFromStock(l, link), product_id: link?.stockProductId ?? l.product_id };
|
|
835
|
+
});
|
|
821
836
|
}
|
|
822
837
|
const productIds = Array.from(new Set(data.lines.map((l) => l.product_id)));
|
|
823
838
|
const [existingProductsRes, draftsRes, floridayRes, groupsRes] = await Promise.all([
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const MODULE_VERSION = "1.0.
|
|
1
|
+
export declare const MODULE_VERSION = "1.0.137";
|
|
2
2
|
//# sourceMappingURL=module-version.d.ts.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// Draai: bun src/lib/stock-product-link.check.ts
|
|
2
|
-
import { fallbackPrice, fillLineFromStock, linkStockProducts } from "./stock-product-link.js";
|
|
2
|
+
import { canonicalProductId, fallbackPrice, fillLineFromStock, linkStockProducts } from "./stock-product-link.js";
|
|
3
3
|
let failed = 0;
|
|
4
4
|
function check(name, got, want) {
|
|
5
5
|
const g = JSON.stringify(got), w = JSON.stringify(want);
|
|
@@ -17,7 +17,7 @@ const packs = [{ product_id: STOCK, is_primary: true, sort_order: 0, vbn_package
|
|
|
17
17
|
const link = linkStockProducts([TI], products, packs).get(TI);
|
|
18
18
|
check("trade-item-id → voorraadartikel via floriday_trade_item_id", link?.stockProductId, STOCK);
|
|
19
19
|
check("primaire belading", link?.primary, { vbn_package_code: "18", load_carrier_type: "DANISH_TROLLEY", plants_per_crate: 12, crates_per_layer: 5, layers_per_cart: 8 });
|
|
20
|
-
check("
|
|
20
|
+
check("eigen artikel via eigen id", linkStockProducts([STOCK], products, packs).get(STOCK)?.stockProductId, STOCK);
|
|
21
21
|
const line = fillLineFromStock({ vbn_package_code: null, load_carrier_type: null, packing_source: null }, link);
|
|
22
22
|
check("lege regel krijgt belading", [line.vbn_package_code, line.load_carrier_type, line.plants_per_crate, line.packing_source], ["18", "DANISH_TROLLEY", 12, "product_primary"]);
|
|
23
23
|
const chosen = fillLineFromStock({ vbn_package_code: "575", load_carrier_type: "AUCTION_TROLLEY", plants_per_crate: 6, packing_source: "chosen" }, link);
|
|
@@ -25,6 +25,14 @@ check("gekozen belading blijft", [chosen.vbn_package_code, chosen.load_carrier_t
|
|
|
25
25
|
check("handmatig zonder prijsgroep → artikelprijs", fallbackPrice("manual", null, link), { price: 1.25, source: "artikel" });
|
|
26
26
|
check("prijsgroep gaat voor", fallbackPrice("manual", 2, link), { price: 2, source: "prijsgroep" });
|
|
27
27
|
check("Floriday-order nooit artikelprijs", fallbackPrice("floriday", null, link), null);
|
|
28
|
+
const OWN2 = "aaaa0000-0000-0000-0000-000000000000";
|
|
29
|
+
const both = [
|
|
30
|
+
{ id: TI, sale_price: null, floriday_trade_item_id: null, is_mirror: false },
|
|
31
|
+
{ id: OWN2, sale_price: 1.4, floriday_trade_item_id: TI, is_mirror: false },
|
|
32
|
+
];
|
|
33
|
+
check("floriday_trade_item_id gaat vóór products.id", linkStockProducts([TI], both, []).get(TI)?.stockProductId, OWN2);
|
|
34
|
+
check("bestaand eigen artikel → geen spiegel, regel krijgt eigen artikel", canonicalProductId(TI, linkStockProducts([TI], both, []).get(TI)), OWN2);
|
|
35
|
+
check("niets gevonden → gekozen id (spiegel)", canonicalProductId("x", linkStockProducts(["x"], both, []).get("x")), "x");
|
|
28
36
|
if (failed) {
|
|
29
37
|
console.error(`${failed} fout(en)`);
|
|
30
38
|
process.exit(1);
|
|
@@ -42,4 +42,6 @@ export declare function fallbackPrice(orderKind: "manual" | "floriday", groupPri
|
|
|
42
42
|
price: number;
|
|
43
43
|
source: string;
|
|
44
44
|
} | null;
|
|
45
|
+
/** Gekozen id → canoniek product-id; bestaat er geen artikel, dan het gekozen id (spiegel volgt). */
|
|
46
|
+
export declare function canonicalProductId(id: string, link: StockLink | undefined): string;
|
|
45
47
|
//# sourceMappingURL=stock-product-link.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stock-product-link.d.ts","sourceRoot":"","sources":["../../src/lib/stock-product-link.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"stock-product-link.d.ts","sourceRoot":"","sources":["../../src/lib/stock-product-link.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,UAAU,GAAG;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACnC,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,SAAS,EAAE,OAAO,CAAC;CACpB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C;IAAC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAE,MAAM,CAAC;IAC/E,cAAc,CAAC,EAAE,iBAAiB,GAAG,UAAU,GAAG,QAAQ,GAAG,IAAI,CAAC;CACnE,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,CAAC,CAa1C;AAED,gFAAgF;AAChF,wBAAgB,aAAa,CAAC,SAAS,EAAE,QAAQ,GAAG,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,IAAI,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAIhK;AAED,qGAAqG;AACrG,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAElF"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Koppeling orderregel → voorraadartikel (client-safe, pure logica).
|
|
2
2
|
// Contract gelijk aan Engine 1.0.215 (logistics_ladingdrager_voor_regel):
|
|
3
|
-
// 1) products.
|
|
4
|
-
// 2) anders products.
|
|
3
|
+
// 1) eigen artikel: products.floriday_trade_item_id = gekozen id (geen spiegel)
|
|
4
|
+
// 2) anders products.id = gekozen id
|
|
5
|
+
// Volgorde gelijk aan Voorraad (voorraad_canoniek_artikel), sinds 1.0.136.
|
|
5
6
|
// Een spiegelrij (custom_fields.source = 'sales-module-*-mirror') zonder
|
|
6
7
|
// primaire verpakking telt niet als voorraadartikel bij stap 1.
|
|
7
8
|
// Verpakkingen hangen aan products.id (product_packings.product_id).
|
|
@@ -38,16 +39,12 @@ export function linkStockProducts(ids, products, packings) {
|
|
|
38
39
|
const mk = (p) => ({ stockProductId: p.id, salePrice: pos(p.sale_price), primary: primaryPacking(packsBy.get(p.id) ?? []) });
|
|
39
40
|
const out = new Map();
|
|
40
41
|
for (const id of ids) {
|
|
41
|
-
const direct = byId.get(id);
|
|
42
|
-
if (direct && !(direct.is_mirror && !(packsBy.get(direct.id)?.length))) {
|
|
43
|
-
out.set(id, mk(direct));
|
|
44
|
-
continue;
|
|
45
|
-
}
|
|
46
42
|
const viaTi = byTradeItem.get(id);
|
|
47
43
|
if (viaTi) {
|
|
48
44
|
out.set(id, mk(viaTi));
|
|
49
45
|
continue;
|
|
50
46
|
}
|
|
47
|
+
const direct = byId.get(id);
|
|
51
48
|
if (direct)
|
|
52
49
|
out.set(id, mk(direct));
|
|
53
50
|
}
|
|
@@ -77,3 +74,7 @@ export function fallbackPrice(orderKind, groupPrice, link) {
|
|
|
77
74
|
return null;
|
|
78
75
|
return link?.salePrice ? { price: link.salePrice, source: "artikel" } : null;
|
|
79
76
|
}
|
|
77
|
+
/** Gekozen id → canoniek product-id; bestaat er geen artikel, dan het gekozen id (spiegel volgt). */
|
|
78
|
+
export function canonicalProductId(id, link) {
|
|
79
|
+
return link?.stockProductId ?? id;
|
|
80
|
+
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { type StockLink } from "./stock-product-link.js";
|
|
2
|
+
export type CanonicalSource = "voorraad_canoniek_artikel" | "terugval";
|
|
3
|
+
export declare let lastCanonicalSource: CanonicalSource;
|
|
2
4
|
export declare function loadStockLinks(sb: any, ids: string[]): Promise<Map<string, StockLink>>;
|
|
3
5
|
//# sourceMappingURL=stock-product-link.server.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stock-product-link.server.d.ts","sourceRoot":"","sources":["../../src/lib/stock-product-link.server.ts"],"names":[],"mappings":"AACA,OAAO,EAAuD,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE3G,wBAAsB,cAAc,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"stock-product-link.server.d.ts","sourceRoot":"","sources":["../../src/lib/stock-product-link.server.ts"],"names":[],"mappings":"AACA,OAAO,EAAuD,KAAK,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAE3G,MAAM,MAAM,eAAe,GAAG,2BAA2B,GAAG,UAAU,CAAC;AACvE,eAAO,IAAI,mBAAmB,EAAE,eAA4B,CAAC;AAc7D,wBAAsB,cAAc,CAAC,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAkC5F"}
|
|
@@ -1,9 +1,42 @@
|
|
|
1
1
|
// Leest products + product_packings en koppelt via stock-product-link.ts.
|
|
2
2
|
import { linkStockProducts } from "./stock-product-link.js";
|
|
3
|
+
export let lastCanonicalSource = "terugval";
|
|
4
|
+
/** Probeert eerst de functie van Voorraad; ontbreekt die of faalt hij → null (terugval). */
|
|
5
|
+
async function viaVoorraad(sb, ids) {
|
|
6
|
+
const out = new Map();
|
|
7
|
+
for (const id of ids) {
|
|
8
|
+
const { data, error } = await sb.rpc("voorraad_canoniek_artikel", { p_id: id });
|
|
9
|
+
if (error)
|
|
10
|
+
return null;
|
|
11
|
+
const v = typeof data === "string" ? data : (data?.product_id ?? data?.id ?? (Array.isArray(data) ? data[0]?.product_id ?? data[0]?.id : null));
|
|
12
|
+
if (v)
|
|
13
|
+
out.set(id, String(v));
|
|
14
|
+
}
|
|
15
|
+
return out;
|
|
16
|
+
}
|
|
3
17
|
export async function loadStockLinks(sb, ids) {
|
|
4
18
|
const uniq = Array.from(new Set(ids.filter(Boolean)));
|
|
5
19
|
if (!uniq.length)
|
|
6
20
|
return new Map();
|
|
21
|
+
const canon = await viaVoorraad(sb, uniq);
|
|
22
|
+
lastCanonicalSource = canon ? "voorraad_canoniek_artikel" : "terugval";
|
|
23
|
+
if (canon && canon.size) {
|
|
24
|
+
const targets = Array.from(new Set(canon.values()));
|
|
25
|
+
const { data: rows } = await sb.from("products").select("id, sale_price, floriday_trade_item_id, custom_fields").in("id", targets);
|
|
26
|
+
const { data: packs } = await sb
|
|
27
|
+
.from("product_packings")
|
|
28
|
+
.select("product_id, is_primary, sort_order, vbn_package_code, load_carrier, pieces_per_package, packages_per_layer, layers_per_load_carrier")
|
|
29
|
+
.in("product_id", targets);
|
|
30
|
+
const prods = (rows ?? []).map((r) => ({ id: r.id, sale_price: r.sale_price, floriday_trade_item_id: null, is_mirror: false }));
|
|
31
|
+
const out = new Map();
|
|
32
|
+
const one = linkStockProducts(targets, prods, (packs ?? []));
|
|
33
|
+
for (const [id, t] of canon) {
|
|
34
|
+
const l = one.get(t);
|
|
35
|
+
if (l)
|
|
36
|
+
out.set(id, l);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
}
|
|
7
40
|
const [a, b] = await Promise.all([
|
|
8
41
|
sb.from("products").select("id, sale_price, floriday_trade_item_id, custom_fields").in("id", uniq),
|
|
9
42
|
sb.from("products").select("id, sale_price, floriday_trade_item_id, custom_fields").in("floriday_trade_item_id", uniq),
|