@flowselections/floriday-voorraad 1.0.14 → 1.0.16
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/voorraad/ArtikelWizard.d.ts.map +1 -1
- package/dist-lib/components/voorraad/ArtikelWizard.js +48 -7
- package/dist-lib/components/voorraad/ExcelExportButton.d.ts +2 -1
- package/dist-lib/components/voorraad/ExcelExportButton.d.ts.map +1 -1
- package/dist-lib/components/voorraad/ExcelExportButton.js +24 -5
- package/dist-lib/components/voorraad/ProductLinkCard.d.ts +13 -0
- package/dist-lib/components/voorraad/ProductLinkCard.d.ts.map +1 -0
- package/dist-lib/components/voorraad/ProductLinkCard.js +159 -0
- package/dist-lib/components/voorraad/StockBulkButtons.d.ts.map +1 -1
- package/dist-lib/components/voorraad/StockBulkButtons.js +88 -7
- package/dist-lib/hooks/useTradeItemSpec.d.ts.map +1 -1
- package/dist-lib/hooks/useTradeItemSpec.js +4 -1
- package/dist-lib/hooks/useVoorraadData.d.ts +5 -4
- package/dist-lib/hooks/useVoorraadData.d.ts.map +1 -1
- package/dist-lib/hooks/useVoorraadData.js +40 -6
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +1 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +743 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +743 -0
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +743 -0
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +763 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/ensure-article-codes.d.ts +8 -0
- package/dist-lib/lib/ensure-article-codes.d.ts.map +1 -0
- package/dist-lib/lib/ensure-article-codes.js +78 -0
- package/dist-lib/lib/floricode-required-features.functions.d.ts +743 -0
- package/dist-lib/lib/floricode-required-features.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-client.d.ts +6 -0
- package/dist-lib/lib/floriday-client.d.ts.map +1 -1
- package/dist-lib/lib/floriday-gateway.functions.d.ts +2972 -0
- package/dist-lib/lib/floriday-gateway.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-payload.d.ts +19 -5
- package/dist-lib/lib/floriday-payload.d.ts.map +1 -1
- package/dist-lib/lib/floriday-payload.js +106 -33
- package/dist-lib/lib/floriday-warehouse.functions.d.ts +32228 -0
- package/dist-lib/lib/floriday-warehouse.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-warehouse.functions.js +98 -0
- package/dist-lib/lib/floriday-writes.functions.d.ts +1616 -130
- package/dist-lib/lib/floriday-writes.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-writes.functions.js +34 -6
- package/package.json +7 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TradeItem } from "./floriday-client";
|
|
2
|
+
/**
|
|
3
|
+
* Zorgt dat elk item in de lijst een niet-lege, unieke `articleNumber` heeft.
|
|
4
|
+
* Genereert er automatisch één als het ontbreekt, slaat die op in de juiste
|
|
5
|
+
* brontabel en retourneert een nieuwe lijst met bijgewerkte items.
|
|
6
|
+
*/
|
|
7
|
+
export declare function ensureArticleCodes(items: TradeItem[]): Promise<TradeItem[]>;
|
|
8
|
+
//# sourceMappingURL=ensure-article-codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ensure-article-codes.d.ts","sourceRoot":"","sources":["../../src/lib/ensure-article-codes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAqBnD;;;;GAIG;AACH,wBAAsB,kBAAkB,CACtC,KAAK,EAAE,SAAS,EAAE,GACjB,OAAO,CAAC,SAAS,EAAE,CAAC,CAkDtB"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { supabase } from "../integrations/supabase/client";
|
|
2
|
+
/** 6-hex-char suffix, e.g. `ART-9F3A2C`. */
|
|
3
|
+
function generateCode(existing) {
|
|
4
|
+
for (let i = 0; i < 50; i++) {
|
|
5
|
+
const rand = Math.floor(Math.random() * 0xffffff)
|
|
6
|
+
.toString(16)
|
|
7
|
+
.toUpperCase()
|
|
8
|
+
.padStart(6, "0");
|
|
9
|
+
const code = `ART-${rand}`;
|
|
10
|
+
if (!existing.has(code)) {
|
|
11
|
+
existing.add(code);
|
|
12
|
+
return code;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// Fallback with timestamp (extremely unlikely collision).
|
|
16
|
+
const code = `ART-${Date.now().toString(16).toUpperCase()}`;
|
|
17
|
+
existing.add(code);
|
|
18
|
+
return code;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Zorgt dat elk item in de lijst een niet-lege, unieke `articleNumber` heeft.
|
|
22
|
+
* Genereert er automatisch één als het ontbreekt, slaat die op in de juiste
|
|
23
|
+
* brontabel en retourneert een nieuwe lijst met bijgewerkte items.
|
|
24
|
+
*/
|
|
25
|
+
export async function ensureArticleCodes(items) {
|
|
26
|
+
const existing = new Set();
|
|
27
|
+
for (const it of items) {
|
|
28
|
+
const code = (it.articleNumber ?? "").trim();
|
|
29
|
+
if (code)
|
|
30
|
+
existing.add(code);
|
|
31
|
+
}
|
|
32
|
+
const result = [];
|
|
33
|
+
for (const it of items) {
|
|
34
|
+
const current = (it.articleNumber ?? "").trim();
|
|
35
|
+
if (current) {
|
|
36
|
+
result.push({ ...it, articleNumber: current });
|
|
37
|
+
continue;
|
|
38
|
+
}
|
|
39
|
+
const newCode = generateCode(existing);
|
|
40
|
+
// Persisteer per bron.
|
|
41
|
+
try {
|
|
42
|
+
if (it.source === "erp" && it.productId) {
|
|
43
|
+
await supabase
|
|
44
|
+
.from("products")
|
|
45
|
+
.update({ barcode: newCode })
|
|
46
|
+
.eq("id", it.productId);
|
|
47
|
+
}
|
|
48
|
+
else if (it.localId) {
|
|
49
|
+
// Draft: patch data.articleCode in-place.
|
|
50
|
+
const row = it.raw;
|
|
51
|
+
const nextData = { ...(row?.data ?? {}), articleCode: newCode };
|
|
52
|
+
await supabase
|
|
53
|
+
.from("trade_item_drafts")
|
|
54
|
+
.update({ data: nextData, updated_at: new Date().toISOString() })
|
|
55
|
+
.eq("id", it.localId);
|
|
56
|
+
}
|
|
57
|
+
else if (it.published && it.id) {
|
|
58
|
+
// Published cache: mirror lokaal zodat volgende exports consistent zijn.
|
|
59
|
+
const row = it.raw;
|
|
60
|
+
const nextData = {
|
|
61
|
+
...(row ?? {}),
|
|
62
|
+
supplierArticleCode: newCode,
|
|
63
|
+
};
|
|
64
|
+
await supabase
|
|
65
|
+
.from("floriday_trade_items_cache")
|
|
66
|
+
.update({ data: nextData })
|
|
67
|
+
.eq("floriday_id", it.id);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch (e) {
|
|
71
|
+
// Log maar blijf doorgaan; de gegenereerde code komt sowieso in de export.
|
|
72
|
+
// eslint-disable-next-line no-console
|
|
73
|
+
console.warn("ensureArticleCodes: persist failed", it.id, e);
|
|
74
|
+
}
|
|
75
|
+
result.push({ ...it, articleNumber: newCode });
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|