@flowselections/floriday-voorraad 1.0.105 → 1.0.108
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 +3 -2
- package/dist-lib/components/voorraad/FloridayLoadCarriers.d.ts +9 -0
- package/dist-lib/components/voorraad/FloridayLoadCarriers.d.ts.map +1 -0
- package/dist-lib/components/voorraad/FloridayLoadCarriers.js +60 -0
- package/dist-lib/components/voorraad/FustenPage.d.ts.map +1 -1
- package/dist-lib/components/voorraad/FustenPage.js +14 -6
- package/dist-lib/components/voorraad/NieuwArtikelPage.d.ts.map +1 -1
- package/dist-lib/components/voorraad/NieuwArtikelPage.js +7 -6
- package/dist-lib/components/voorraad/StockBulkButtons.d.ts.map +1 -1
- package/dist-lib/components/voorraad/StockBulkButtons.js +3 -6
- package/dist-lib/components/voorraad/StockSyncStatus.d.ts.map +1 -1
- package/dist-lib/components/voorraad/StockSyncStatus.js +10 -2
- package/dist-lib/components/voorraad/VoorraadStockCard.d.ts.map +1 -1
- package/dist-lib/components/voorraad/VoorraadStockCard.js +6 -4
- package/dist-lib/components/voorraad/VoorraadTable.d.ts.map +1 -1
- package/dist-lib/components/voorraad/VoorraadTable.js +6 -1
- package/dist-lib/hooks/useFloridayWriteMode.d.ts +7 -0
- package/dist-lib/hooks/useFloridayWriteMode.d.ts.map +1 -0
- package/dist-lib/hooks/useFloridayWriteMode.js +21 -0
- package/dist-lib/hooks/useStockSyncHealth.d.ts +9 -0
- package/dist-lib/hooks/useStockSyncHealth.d.ts.map +1 -1
- package/dist-lib/hooks/useStockSyncHealth.js +23 -0
- package/dist-lib/hooks/useTradeItemStock.d.ts.map +1 -1
- package/dist-lib/hooks/useTradeItemStock.js +19 -9
- package/dist-lib/integrations/supabase/types.d.ts +1495 -179
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/__tests__/floriday-write-mode.test.d.ts +2 -0
- package/dist-lib/lib/__tests__/floriday-write-mode.test.d.ts.map +1 -0
- package/dist-lib/lib/__tests__/floriday-write-mode.test.js +40 -0
- package/dist-lib/lib/floriday-write-mode.d.ts +21 -0
- package/dist-lib/lib/floriday-write-mode.d.ts.map +1 -0
- package/dist-lib/lib/floriday-write-mode.js +40 -0
- package/dist-lib/lib/fusten.d.ts +20 -0
- package/dist-lib/lib/fusten.d.ts.map +1 -1
- package/dist-lib/lib/fusten.js +48 -41
- package/dist-lib/lib/stock-scope.d.ts +3 -1
- package/dist-lib/lib/stock-scope.d.ts.map +1 -1
- package/dist-lib/lib/stock-scope.js +3 -1
- package/package.json +1 -1
- package/sql/AGENTS.md +2 -8
- package/sql/floriday-voorraad-schema.sql +190 -68
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floriday-write-mode.test.d.ts","sourceRoot":"","sources":["../../../src/lib/__tests__/floriday-write-mode.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { gateBlockedText, waitCauseText, WRITE_MODE_UNREADABLE_TEXT } from "../floriday-write-mode.js";
|
|
3
|
+
import { resolveFustDimensions } from "../fusten.js";
|
|
4
|
+
import { loadCarriersFromCache } from "../../components/voorraad/FloridayLoadCarriers.js";
|
|
5
|
+
describe("oorzaak bij wachtende regels", () => {
|
|
6
|
+
it("toont reason als read_only aan staat", () => {
|
|
7
|
+
expect(waitCauseText({ read_only: true, reason: "Alleen lezen staat aan" })).toBe("Alleen lezen staat aan");
|
|
8
|
+
});
|
|
9
|
+
it("toont niets als schrijven aan staat", () => {
|
|
10
|
+
expect(waitCauseText({ read_only: false, reason: null })).toBeNull();
|
|
11
|
+
});
|
|
12
|
+
it("meldt onbekend als lezen mislukt", () => {
|
|
13
|
+
expect(waitCauseText(null)).toBe(WRITE_MODE_UNREADABLE_TEXT);
|
|
14
|
+
});
|
|
15
|
+
it("verpakkingsverschil noemt artikel en verwijst naar Verpakking", () => {
|
|
16
|
+
const t = gateBlockedText({ name: "Roos", code: "R1" });
|
|
17
|
+
expect(t).toContain("Roos (R1)");
|
|
18
|
+
expect(t).toContain("Floriday koppeling → Verpakking");
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
describe("fustmaten zonder standaardwaarden", () => {
|
|
22
|
+
const fc = new Map([["12", { name: "Deksel", lengthMm: 1000, widthMm: 300, heightMm: null }]]);
|
|
23
|
+
it("Floricode gaat voor, lege maat blijft leeg", () => {
|
|
24
|
+
expect(resolveFustDimensions({ vbn_code: 12, length_mm: null, width_mm: null, height_mm: null }, fc))
|
|
25
|
+
.toEqual({ length_mm: 1000, width_mm: 300, height_mm: null, source: "floricode" });
|
|
26
|
+
});
|
|
27
|
+
it("onbekend fust krijgt geen maten", () => {
|
|
28
|
+
expect(resolveFustDimensions({ vbn_code: 99, length_mm: null, width_mm: null, height_mm: null }, fc))
|
|
29
|
+
.toEqual({ length_mm: null, width_mm: null, height_mm: null, source: "onbekend" });
|
|
30
|
+
});
|
|
31
|
+
it("handmatige maat blijft staan", () => {
|
|
32
|
+
expect(resolveFustDimensions({ vbn_code: 99, length_mm: 500, width_mm: null, height_mm: null }, fc).source).toBe("handmatig");
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
describe("ladingdrager uit de Floriday-gegevens", () => {
|
|
36
|
+
it("leest loadCarrier per verpakking, leeg blijft leeg", () => {
|
|
37
|
+
expect(loadCarriersFromCache({ packingConfigurations: [{ loadCarrier: "DANISH_TROLLEY", primary: true }, {}] }))
|
|
38
|
+
.toEqual([{ loadCarrier: "DANISH_TROLLEY", primary: true }, { loadCarrier: null, primary: false }]);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export interface FloridayWriteMode {
|
|
2
|
+
read_only: boolean;
|
|
3
|
+
reason: string | null;
|
|
4
|
+
}
|
|
5
|
+
export declare const WRITE_MODE_UNREADABLE_TEXT = "Oorzaak onbekend (Floriday-status niet leesbaar)";
|
|
6
|
+
export declare const GATE_HINT_TEXT = "Floriday koppeling \u2192 Verpakking";
|
|
7
|
+
export declare function fetchFloridayWriteMode(): Promise<FloridayWriteMode>;
|
|
8
|
+
/**
|
|
9
|
+
* Oorzaaktekst naast een wachtmelding.
|
|
10
|
+
* - mode === undefined: nog aan het laden → niets tonen.
|
|
11
|
+
* - mode === null: lezen mislukt → expliciet "onbekend".
|
|
12
|
+
* - read_only: het veld reason (of "onbekend" als het leeg is).
|
|
13
|
+
* - schrijven staat aan: geen extra oorzaak.
|
|
14
|
+
*/
|
|
15
|
+
export declare function waitCauseText(mode: FloridayWriteMode | null | undefined): string | null;
|
|
16
|
+
/** Tekst voor een regel die door het verpakkingsverschil is tegengehouden. */
|
|
17
|
+
export declare function gateBlockedText(article: {
|
|
18
|
+
name?: string | null;
|
|
19
|
+
code?: string | null;
|
|
20
|
+
}): string;
|
|
21
|
+
//# sourceMappingURL=floriday-write-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floriday-write-mode.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-write-mode.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,OAAO,CAAC;IACnB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,eAAO,MAAM,0BAA0B,qDAAqD,CAAC;AAC7F,eAAO,MAAM,cAAc,yCAAoC,CAAC;AAEhE,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,iBAAiB,CAAC,CAQzE;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,iBAAiB,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,GAAG,IAAI,CAKvF;AAED,8EAA8E;AAC9E,wBAAgB,eAAe,CAAC,OAAO,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,GAAG,MAAM,CAI/F"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Schrijfstand van de Floriday-koppeling, gelezen via `floriday_write_mode()`
|
|
3
|
+
* (eigenaar: Floriday-authenticatie). Alleen lezen: dit verandert niets aan
|
|
4
|
+
* de wachtrij of aan statussen.
|
|
5
|
+
*/
|
|
6
|
+
import { supabase } from "../integrations/supabase/client.js";
|
|
7
|
+
export const WRITE_MODE_UNREADABLE_TEXT = "Oorzaak onbekend (Floriday-status niet leesbaar)";
|
|
8
|
+
export const GATE_HINT_TEXT = "Floriday koppeling → Verpakking";
|
|
9
|
+
export async function fetchFloridayWriteMode() {
|
|
10
|
+
const { data, error } = await supabase.rpc("floriday_write_mode");
|
|
11
|
+
if (error)
|
|
12
|
+
throw new Error(error.message);
|
|
13
|
+
const d = (data ?? {});
|
|
14
|
+
return {
|
|
15
|
+
read_only: d.read_only === true,
|
|
16
|
+
reason: typeof d.reason === "string" && d.reason.trim() ? d.reason : null,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Oorzaaktekst naast een wachtmelding.
|
|
21
|
+
* - mode === undefined: nog aan het laden → niets tonen.
|
|
22
|
+
* - mode === null: lezen mislukt → expliciet "onbekend".
|
|
23
|
+
* - read_only: het veld reason (of "onbekend" als het leeg is).
|
|
24
|
+
* - schrijven staat aan: geen extra oorzaak.
|
|
25
|
+
*/
|
|
26
|
+
export function waitCauseText(mode) {
|
|
27
|
+
if (mode === undefined)
|
|
28
|
+
return null;
|
|
29
|
+
if (mode === null)
|
|
30
|
+
return WRITE_MODE_UNREADABLE_TEXT;
|
|
31
|
+
if (!mode.read_only)
|
|
32
|
+
return null;
|
|
33
|
+
return mode.reason ?? WRITE_MODE_UNREADABLE_TEXT;
|
|
34
|
+
}
|
|
35
|
+
/** Tekst voor een regel die door het verpakkingsverschil is tegengehouden. */
|
|
36
|
+
export function gateBlockedText(article) {
|
|
37
|
+
const name = (article.name ?? "").trim() || "Onbekend artikel";
|
|
38
|
+
const code = (article.code ?? "").trim();
|
|
39
|
+
return `${name}${code ? ` (${code})` : ""}: verpakking wijkt af van Floriday – zie ${GATE_HINT_TEXT}`;
|
|
40
|
+
}
|
package/dist-lib/lib/fusten.d.ts
CHANGED
|
@@ -45,6 +45,25 @@ export declare function formatFustDimensions(f: {
|
|
|
45
45
|
}): string | null;
|
|
46
46
|
/** Stabiele sleutel per fusttype: VBN-code of custom package. */
|
|
47
47
|
export declare function fustKeyOf(p: Partial<PackingConfigurationInput>): string | null;
|
|
48
|
+
interface VbnCatalogEntry {
|
|
49
|
+
name: string;
|
|
50
|
+
lengthMm: number | null;
|
|
51
|
+
widthMm: number | null;
|
|
52
|
+
heightMm: number | null;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Namen én afmetingen van VBN-fusten uit `floricode_packaging_types()`
|
|
56
|
+
* (eigenaar Floriday-authenticatie). Lege maten blijven null.
|
|
57
|
+
*/
|
|
58
|
+
export declare function fetchFloricodeFustMap(): Promise<Map<string, VbnCatalogEntry>>;
|
|
59
|
+
export type FustDimensionSource = "floricode" | "handmatig" | "onbekend";
|
|
60
|
+
/** Floricode eerst, dan handmatig ingevoerd, anders leeg. Nooit standaardwaarden. */
|
|
61
|
+
export declare function resolveFustDimensions(fust: Pick<FustType, "vbn_code" | "length_mm" | "width_mm" | "height_mm">, floricode: Map<string, VbnCatalogEntry> | null): {
|
|
62
|
+
length_mm: number | null;
|
|
63
|
+
width_mm: number | null;
|
|
64
|
+
height_mm: number | null;
|
|
65
|
+
source: FustDimensionSource;
|
|
66
|
+
};
|
|
48
67
|
/** Verzamel elk uniek fusttype dat in een belading wordt gebruikt. */
|
|
49
68
|
export declare function collectFustUsage(connectionId: string | null): Promise<FustUsage[]>;
|
|
50
69
|
/**
|
|
@@ -85,4 +104,5 @@ export declare function registerSaleFustUsage(params: {
|
|
|
85
104
|
note?: string;
|
|
86
105
|
reason?: string;
|
|
87
106
|
}): Promise<void>;
|
|
107
|
+
export {};
|
|
88
108
|
//# sourceMappingURL=fusten.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fusten.d.ts","sourceRoot":"","sources":["../../src/lib/fusten.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fusten.d.ts","sourceRoot":"","sources":["../../src/lib/fusten.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,oBAAoB,CAAC;AAEpE,MAAM,WAAW,QAAQ;IACvB,EAAE,EAAE,MAAM,CAAC;IACX,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,MAAM,EAAE,OAAO,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACxB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC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AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAAC,MAAM,EAAE;IAClD,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,GAAG,OAAO,CAAC,IAAI,CAAC,CA4ChB"}
|
package/dist-lib/lib/fusten.js
CHANGED
|
@@ -10,7 +10,6 @@
|
|
|
10
10
|
* - automatische afschrijving bij verkoop op basis van de belading.
|
|
11
11
|
*/
|
|
12
12
|
import { supabase } from "../integrations/supabase/client.js";
|
|
13
|
-
import { listFloricode } from "./floricode-client.js";
|
|
14
13
|
/** Afmetingen als "L × B × H mm", of null wanneer onbekend. */
|
|
15
14
|
export function formatFustDimensions(f) {
|
|
16
15
|
const parts = [f.length_mm, f.width_mm, f.height_mm];
|
|
@@ -87,46 +86,58 @@ async function loadAllPackings(connectionId) {
|
|
|
87
86
|
}
|
|
88
87
|
return out;
|
|
89
88
|
}
|
|
90
|
-
/**
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
/**
|
|
90
|
+
* Namen én afmetingen van VBN-fusten uit `floricode_packaging_types()`
|
|
91
|
+
* (eigenaar Floriday-authenticatie). Lege maten blijven null.
|
|
92
|
+
*/
|
|
93
|
+
export async function fetchFloricodeFustMap() {
|
|
94
|
+
const map = new Map();
|
|
95
|
+
const { data, error } = await supabase.rpc("floricode_packaging_types");
|
|
96
|
+
if (error)
|
|
97
|
+
throw new Error(error.message);
|
|
98
|
+
for (const r of (data ?? [])) {
|
|
99
|
+
const code = String(r.code ?? "").trim();
|
|
100
|
+
if (!code)
|
|
95
101
|
continue;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
102
|
+
map.set(code, {
|
|
103
|
+
name: String(r.name ?? "").trim() || code,
|
|
104
|
+
lengthMm: positiveOrNull(r.length_mm),
|
|
105
|
+
widthMm: positiveOrNull(r.width_mm),
|
|
106
|
+
heightMm: positiveOrNull(r.height_mm),
|
|
107
|
+
});
|
|
99
108
|
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
109
|
+
return map;
|
|
110
|
+
}
|
|
111
|
+
function positiveOrNull(v) {
|
|
112
|
+
if (v === null || v === undefined || v === "")
|
|
113
|
+
return null;
|
|
114
|
+
const n = Number(v);
|
|
115
|
+
return Number.isFinite(n) && n > 0 ? Math.round(n) : null;
|
|
116
|
+
}
|
|
117
|
+
/** Floricode eerst, dan handmatig ingevoerd, anders leeg. Nooit standaardwaarden. */
|
|
118
|
+
export function resolveFustDimensions(fust, floricode) {
|
|
119
|
+
const fc = fust.vbn_code != null ? floricode?.get(String(fust.vbn_code)) : undefined;
|
|
120
|
+
if (fc && (fc.lengthMm != null || fc.widthMm != null || fc.heightMm != null)) {
|
|
121
|
+
return {
|
|
122
|
+
length_mm: fc.lengthMm ?? fust.length_mm ?? null,
|
|
123
|
+
width_mm: fc.widthMm ?? fust.width_mm ?? null,
|
|
124
|
+
height_mm: fc.heightMm ?? fust.height_mm ?? null,
|
|
125
|
+
source: "floricode",
|
|
126
|
+
};
|
|
107
127
|
}
|
|
108
|
-
|
|
128
|
+
if (fust.length_mm != null || fust.width_mm != null || fust.height_mm != null) {
|
|
129
|
+
return { length_mm: fust.length_mm, width_mm: fust.width_mm, height_mm: fust.height_mm, source: "handmatig" };
|
|
130
|
+
}
|
|
131
|
+
return { length_mm: null, width_mm: null, height_mm: null, source: "onbekend" };
|
|
109
132
|
}
|
|
110
|
-
/** Namen én afmetingen van VBN-fusten uit de Floricode-catalogus. */
|
|
111
133
|
async function loadVbnCatalog() {
|
|
112
|
-
const map = new Map();
|
|
113
134
|
try {
|
|
114
|
-
|
|
115
|
-
for (const r of rows) {
|
|
116
|
-
const code = String(r.data?.code ?? r.data?.id ?? r.record_id);
|
|
117
|
-
const data = r.data ?? {};
|
|
118
|
-
map.set(code, {
|
|
119
|
-
name: String(data.name ?? data.description ?? code),
|
|
120
|
-
lengthMm: dimOf(data, ["length", "lengte"]),
|
|
121
|
-
widthMm: dimOf(data, ["width", "breedte"]),
|
|
122
|
-
heightMm: dimOf(data, ["height", "hoogte"]),
|
|
123
|
-
});
|
|
124
|
-
}
|
|
135
|
+
return await fetchFloricodeFustMap();
|
|
125
136
|
}
|
|
126
137
|
catch {
|
|
127
|
-
//
|
|
138
|
+
// Floricode niet leesbaar — we vallen terug op de code als naam.
|
|
139
|
+
return new Map();
|
|
128
140
|
}
|
|
129
|
-
return map;
|
|
130
141
|
}
|
|
131
142
|
/** Verzamel elk uniek fusttype dat in een belading wordt gebruikt. */
|
|
132
143
|
export async function collectFustUsage(connectionId) {
|
|
@@ -215,19 +226,15 @@ export async function syncFustTypes(connectionId) {
|
|
|
215
226
|
custom_package_id: u.customPackageId,
|
|
216
227
|
in_use: true,
|
|
217
228
|
used_by_count: u.usedByCount,
|
|
218
|
-
length_mm:
|
|
219
|
-
width_mm:
|
|
220
|
-
height_mm:
|
|
229
|
+
length_mm: null,
|
|
230
|
+
width_mm: null,
|
|
231
|
+
height_mm: null,
|
|
221
232
|
});
|
|
222
233
|
continue;
|
|
223
234
|
}
|
|
235
|
+
// Maten worden niet meer gekopieerd: Floricode is de bron en wordt bij het
|
|
236
|
+
// tonen gelezen; opgeslagen maten zijn alleen handmatige aanvullingen.
|
|
224
237
|
const dimPatch = {};
|
|
225
|
-
if (cur.length_mm == null && u.lengthMm != null)
|
|
226
|
-
dimPatch.length_mm = u.lengthMm;
|
|
227
|
-
if (cur.width_mm == null && u.widthMm != null)
|
|
228
|
-
dimPatch.width_mm = u.widthMm;
|
|
229
|
-
if (cur.height_mm == null && u.heightMm != null)
|
|
230
|
-
dimPatch.height_mm = u.heightMm;
|
|
231
238
|
if (cur.name !== u.name ||
|
|
232
239
|
!cur.in_use ||
|
|
233
240
|
cur.used_by_count !== u.usedByCount ||
|
|
@@ -8,8 +8,10 @@ export declare function connectionStatusOf(input: {
|
|
|
8
8
|
error: string | null;
|
|
9
9
|
connectionId: string | null;
|
|
10
10
|
}): ConnectionStatus;
|
|
11
|
-
/**
|
|
11
|
+
/** Oude uitleg (1.0.102); blijft beschikbaar voor andere modules die hem importeren. */
|
|
12
12
|
export declare const STOCK_WRITE_NEEDS_CONNECTION = "Voorraad opslaan kan pas met een Floriday-koppeling; dit komt in een volgende versie.";
|
|
13
|
+
/** Uitleg bij voorraad zonder Floriday-koppeling (1.0.107). */
|
|
14
|
+
export declare const LOCAL_STOCK_TEXT = "Geen Floriday-koppeling: dit wordt eigen voorraad en gaat niet naar Floriday.";
|
|
13
15
|
export declare function noConnectionText(environment: string | null): string;
|
|
14
16
|
export interface ScopedStockRow {
|
|
15
17
|
connection_id: string | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stock-scope.d.ts","sourceRoot":"","sources":["../../src/lib/stock-scope.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,GAAG,gBAAgB,GAAG,MAAM,CAAC;AAE9E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,GAAG,gBAAgB,CAInB;AAED,
|
|
1
|
+
{"version":3,"file":"stock-scope.d.ts","sourceRoot":"","sources":["../../src/lib/stock-scope.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG,QAAQ,GAAG,gBAAgB,GAAG,MAAM,CAAC;AAE9E,wBAAgB,kBAAkB,CAAC,KAAK,EAAE;IACxC,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,GAAG,gBAAgB,CAInB;AAED,wFAAwF;AACxF,eAAO,MAAM,4BAA4B,0FACgD,CAAC;AAE1F,+DAA+D;AAC/D,eAAO,MAAM,gBAAgB,kFACoD,CAAC;AAElF,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,CAKnE;AAED,MAAM,WAAW,cAAc;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,cAAc,EAC1D,IAAI,EAAE,CAAC,EAAE,EACT,kBAAkB,EAAE,MAAM,GAAG,IAAI,GAChC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAShB"}
|
|
@@ -9,8 +9,10 @@ export function connectionStatusOf(input) {
|
|
|
9
9
|
return "fout";
|
|
10
10
|
return input.connectionId ? "actief" : "geen_koppeling";
|
|
11
11
|
}
|
|
12
|
-
/**
|
|
12
|
+
/** Oude uitleg (1.0.102); blijft beschikbaar voor andere modules die hem importeren. */
|
|
13
13
|
export const STOCK_WRITE_NEEDS_CONNECTION = "Voorraad opslaan kan pas met een Floriday-koppeling; dit komt in een volgende versie.";
|
|
14
|
+
/** Uitleg bij voorraad zonder Floriday-koppeling (1.0.107). */
|
|
15
|
+
export const LOCAL_STOCK_TEXT = "Geen Floriday-koppeling: dit wordt eigen voorraad en gaat niet naar Floriday.";
|
|
14
16
|
export function noConnectionText(environment) {
|
|
15
17
|
const env = environment === "live" ? "live" : environment === "staging" ? "test" : null;
|
|
16
18
|
return env
|
package/package.json
CHANGED
package/sql/AGENTS.md
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
- `floriday-voorraad-schema.sql` is generated from the database by `scripts/generate-voorraad-schema.py` (via `voorraad_schema_ddl`, service role only); regenerate after every migration and never hand-edit, because a new Shell gets its schema only from this file.
|
|
2
|
-
- Voorraad owns `floriday_continuous_stock_queue_status_check`; the schema recreates it with all statuses, because other modules once recreated it without ours.
|
|
3
|
-
- Schema-update order 20 (`flowselections.schema.order`); the generator keeps only own objects and wraps statements that touch other modules' tables in a to_regclass guard with a NOTICE, because Floriday-auth (30) and the Engine (60) run after Voorraad.
|
|
4
1
|
|
|
5
|
-
-
|
|
6
|
-
-
|
|
7
|
-
- ZERO_BATCH ignores sources IMPORT/IMPORT_UNDO and stores article code/name; the log keeps everything (deliberate bulk actions are no incidents).
|
|
8
|
-
- Queue cleanup: only `floriday_cleanup_stock_queue_v2` (nightly, retention in `inventory_recompute_limits`, batched, logged) and it keeps the newest skipped/failed row per article, because labels and requeue-on-price read it.
|
|
9
|
-
- The schema file never grants to anon or PUBLIC unless an own migration grants anon explicitly; PUBLIC execute becomes explicit authenticated + service_role, because a database's default privileges are not our migrations' intent.
|
|
2
|
+
- Voorraad never creates or replaces functions owned by other modules (Engine `logistics_*`, Floriday-auth, Verkoop; list in `FOREIGN_FUNCS` of `scripts/generate-voorraad-schema.py`); the schema file contains own objects only, because the schema sync would overwrite another module's version.
|
|
3
|
+
- Data corrections only via `voorraad_correctie_<nr>(p_uitvoeren default false)` functions: server-only, match on id, insert/update only (never DELETE), hash-check Floriday cache + queue, log every run in `voorraad_correcties`; `voorraad_correctie_status()` tells other modules whether it ran, because loose SQL per Shell is not repeatable.
|