@flowselections/floriday-klanten-module 1.0.34 → 1.0.35
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/assets/floriday-logo.png.asset.json +11 -0
- package/dist-lib/components/klanten/CustomerAssortmentTab.d.ts +5 -0
- package/dist-lib/components/klanten/CustomerAssortmentTab.d.ts.map +1 -0
- package/dist-lib/components/klanten/CustomerAssortmentTab.js +74 -0
- package/dist-lib/components/klanten/FloridayPriceImportDialog.d.ts +5 -0
- package/dist-lib/components/klanten/FloridayPriceImportDialog.d.ts.map +1 -0
- package/dist-lib/components/klanten/FloridayPriceImportDialog.js +55 -0
- package/dist-lib/components/klanten/GroupedKlantDetail.d.ts.map +1 -1
- package/dist-lib/components/klanten/GroupedKlantDetail.js +4 -3
- package/dist-lib/components/klanten/KlantDetail.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantDetail.js +10 -2
- package/dist-lib/components/klanten/KlantenOverzicht.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantenOverzicht.js +24 -3
- package/dist-lib/components/klanten/pricegroups/CustomerPriceGroupSelect.d.ts +4 -0
- package/dist-lib/components/klanten/pricegroups/CustomerPriceGroupSelect.d.ts.map +1 -0
- package/dist-lib/components/klanten/pricegroups/CustomerPriceGroupSelect.js +47 -0
- package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.d.ts.map +1 -1
- package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.js +2 -1
- package/dist-lib/components/klanten/pricegroups/PriceGroupItemPrices.d.ts +5 -0
- package/dist-lib/components/klanten/pricegroups/PriceGroupItemPrices.d.ts.map +1 -0
- package/dist-lib/components/klanten/pricegroups/PriceGroupItemPrices.js +83 -0
- package/dist-lib/index.d.ts +8 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +8 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +595 -0
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +595 -0
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.server.d.ts +595 -0
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +597 -0
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/lib/accounting/twinfield/mapping.js +13 -13
- package/dist-lib/lib/accounting/twinfield/worker.functions.d.ts +1785 -0
- package/dist-lib/lib/accounting/twinfield/worker.functions.d.ts.map +1 -1
- package/dist-lib/lib/accounting.functions.d.ts +1785 -0
- package/dist-lib/lib/accounting.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-analytics.functions.d.ts +595 -0
- package/dist-lib/lib/customer-analytics.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-assortment.functions.d.ts +26666 -0
- package/dist-lib/lib/customer-assortment.functions.d.ts.map +1 -0
- package/dist-lib/lib/customer-assortment.functions.js +280 -0
- package/dist-lib/lib/customer-notes.functions.d.ts +1190 -0
- package/dist-lib/lib/customer-notes.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-revenue.functions.d.ts +595 -0
- package/dist-lib/lib/customer-revenue.functions.d.ts.map +1 -1
- package/dist-lib/lib/customers.functions.d.ts +5355 -0
- package/dist-lib/lib/customers.functions.d.ts.map +1 -1
- package/dist-lib/lib/delivery-locations.functions.d.ts +2975 -0
- package/dist-lib/lib/delivery-locations.functions.d.ts.map +1 -1
- package/dist-lib/lib/errors.d.ts +12 -0
- package/dist-lib/lib/errors.d.ts.map +1 -1
- package/dist-lib/lib/errors.js +24 -0
- package/dist-lib/lib/external-customers.functions.d.ts +2380 -0
- package/dist-lib/lib/external-customers.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-assortment.functions.d.ts +595 -0
- package/dist-lib/lib/floriday-assortment.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-catalog-prices.d.ts +33 -0
- package/dist-lib/lib/floriday-catalog-prices.d.ts.map +1 -0
- package/dist-lib/lib/floriday-catalog-prices.js +98 -0
- package/dist-lib/lib/floriday-discounts.functions.d.ts +1190 -0
- package/dist-lib/lib/floriday-discounts.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-price-import.functions.d.ts +53265 -0
- package/dist-lib/lib/floriday-price-import.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-price-import.functions.js +219 -0
- package/dist-lib/lib/floriday-trade-items.functions.d.ts +595 -0
- package/dist-lib/lib/floriday-trade-items.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday.server.d.ts +55 -0
- package/dist-lib/lib/floriday.server.d.ts.map +1 -0
- package/dist-lib/lib/floriday.server.js +765 -0
- package/dist-lib/lib/local-discounts.functions.d.ts +4165 -0
- package/dist-lib/lib/local-discounts.functions.d.ts.map +1 -1
- package/dist-lib/lib/logistics-events.functions.d.ts +595 -0
- package/dist-lib/lib/logistics-events.functions.d.ts.map +1 -1
- package/dist-lib/lib/logistics-strategy.functions.d.ts +2380 -0
- package/dist-lib/lib/logistics-strategy.functions.d.ts.map +1 -1
- package/dist-lib/lib/overdue-invoices.functions.d.ts +595 -0
- package/dist-lib/lib/overdue-invoices.functions.d.ts.map +1 -1
- package/dist-lib/lib/price-groups-local.functions.d.ts +137905 -27
- package/dist-lib/lib/price-groups-local.functions.d.ts.map +1 -1
- package/dist-lib/lib/price-groups-local.functions.js +145 -0
- package/dist-lib/lib/price-groups.functions.d.ts +601 -1
- package/dist-lib/lib/price-groups.functions.d.ts.map +1 -1
- package/dist-lib/lib/twinfield-adopt.functions.d.ts +1190 -0
- package/dist-lib/lib/twinfield-adopt.functions.d.ts.map +1 -1
- package/dist-lib/lib/twinfield-ledger.functions.d.ts +595 -0
- package/dist-lib/lib/twinfield-ledger.functions.d.ts.map +1 -1
- package/dist-lib/lib/twinfield-ledger.server.js +21 -21
- package/package.json +1 -1
- package/public/flowselections-assets/Klanten/twinfield-logo.svg +217 -217
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Leeslogica voor Floriday-catalogusprijzen.
|
|
3
|
+
*
|
|
4
|
+
* Bron: public.floriday_catalog_prices_cache — gevuld door de Floriday-
|
|
5
|
+
* authenticatiemodule (supply lines). Deze module is read-only: nooit zelf
|
|
6
|
+
* vullen of muteren.
|
|
7
|
+
*
|
|
8
|
+
* Keuzeregel per artikel: klantgroepprijs > weekprijs > basisprijs.
|
|
9
|
+
* Weekprijzen matchen op ISO jaar/week of op valid_from/valid_to rondom de
|
|
10
|
+
* leverdatum.
|
|
11
|
+
*/
|
|
12
|
+
export type CatalogPrice = {
|
|
13
|
+
trade_item_id: string;
|
|
14
|
+
supplier_article_code: string | null;
|
|
15
|
+
price: number;
|
|
16
|
+
currency: string;
|
|
17
|
+
price_type: "base" | "week" | "customer_group";
|
|
18
|
+
price_group_name: string | null;
|
|
19
|
+
sales_unit: string | null;
|
|
20
|
+
year: number | null;
|
|
21
|
+
week: number | null;
|
|
22
|
+
label: string;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Haalt de geldende catalogusprijs per trade_item_id op.
|
|
26
|
+
* `priceGroupNames`: namen van de Floriday-prijsgroep(en) van deze klant —
|
|
27
|
+
* alleen klantgroepprijzen met een passende naam tellen mee.
|
|
28
|
+
*/
|
|
29
|
+
export declare function loadFloridayCatalogPrices(sb: any, opts?: {
|
|
30
|
+
priceGroupNames?: (string | null | undefined)[];
|
|
31
|
+
deliveryDate?: Date;
|
|
32
|
+
}): Promise<Map<string, CatalogPrice>>;
|
|
33
|
+
//# sourceMappingURL=floriday-catalog-prices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"floriday-catalog-prices.d.ts","sourceRoot":"","sources":["../../src/lib/floriday-catalog-prices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,MAAM,MAAM,YAAY,GAAG;IACzB,aAAa,EAAE,MAAM,CAAC;IACtB,qBAAqB,EAAE,MAAM,GAAG,IAAI,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,gBAAgB,CAAC;IAC/C,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AA2BF;;;;GAIG;AACH,wBAAsB,yBAAyB,CAC7C,EAAE,EAAE,GAAG,EACP,IAAI,GAAE;IAAE,eAAe,CAAC,EAAE,CAAC,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,CAAC;IAAC,YAAY,CAAC,EAAE,IAAI,CAAA;CAAO,GAClF,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAiEpC"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Leeslogica voor Floriday-catalogusprijzen.
|
|
3
|
+
*
|
|
4
|
+
* Bron: public.floriday_catalog_prices_cache — gevuld door de Floriday-
|
|
5
|
+
* authenticatiemodule (supply lines). Deze module is read-only: nooit zelf
|
|
6
|
+
* vullen of muteren.
|
|
7
|
+
*
|
|
8
|
+
* Keuzeregel per artikel: klantgroepprijs > weekprijs > basisprijs.
|
|
9
|
+
* Weekprijzen matchen op ISO jaar/week of op valid_from/valid_to rondom de
|
|
10
|
+
* leverdatum.
|
|
11
|
+
*/
|
|
12
|
+
function isoYearWeek(d) {
|
|
13
|
+
const t = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()));
|
|
14
|
+
const day = t.getUTCDay() || 7;
|
|
15
|
+
t.setUTCDate(t.getUTCDate() + 4 - day);
|
|
16
|
+
const start = new Date(Date.UTC(t.getUTCFullYear(), 0, 1));
|
|
17
|
+
const week = Math.ceil(((t.getTime() - start.getTime()) / 86400000 + 1) / 7);
|
|
18
|
+
return { year: t.getUTCFullYear(), week };
|
|
19
|
+
}
|
|
20
|
+
const RANK = { base: 1, week: 2, customer_group: 3 };
|
|
21
|
+
function labelFor(row) {
|
|
22
|
+
if (row.price_type === "customer_group") {
|
|
23
|
+
return row.price_group_name
|
|
24
|
+
? `Floriday prijsgroep ${row.price_group_name}`
|
|
25
|
+
: "Floriday klantgroepprijs";
|
|
26
|
+
}
|
|
27
|
+
if (row.price_type === "week") {
|
|
28
|
+
return row.year && row.week
|
|
29
|
+
? `Floriday weekprijs ${row.year}-W${String(row.week).padStart(2, "0")}`
|
|
30
|
+
: "Floriday weekprijs";
|
|
31
|
+
}
|
|
32
|
+
return "Floriday catalogusprijs";
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Haalt de geldende catalogusprijs per trade_item_id op.
|
|
36
|
+
* `priceGroupNames`: namen van de Floriday-prijsgroep(en) van deze klant —
|
|
37
|
+
* alleen klantgroepprijzen met een passende naam tellen mee.
|
|
38
|
+
*/
|
|
39
|
+
export async function loadFloridayCatalogPrices(sb, opts = {}) {
|
|
40
|
+
const groupNames = new Set((opts.priceGroupNames ?? [])
|
|
41
|
+
.filter((n) => typeof n === "string" && n.trim().length > 0)
|
|
42
|
+
.map((n) => n.trim().toLowerCase()));
|
|
43
|
+
const ref = opts.deliveryDate ?? new Date();
|
|
44
|
+
const { year, week } = isoYearWeek(ref);
|
|
45
|
+
const refTime = ref.getTime();
|
|
46
|
+
const out = new Map();
|
|
47
|
+
const rank = new Map();
|
|
48
|
+
const pageSize = 1000;
|
|
49
|
+
for (let from = 0;; from += pageSize) {
|
|
50
|
+
const { data, error } = await sb
|
|
51
|
+
.from("floriday_catalog_prices_cache")
|
|
52
|
+
.select("trade_item_id, supplier_article_code, price, currency, price_type, price_group_name, sales_unit, year, week, valid_from, valid_to")
|
|
53
|
+
.eq("is_deleted", false)
|
|
54
|
+
.range(from, from + pageSize - 1);
|
|
55
|
+
if (error)
|
|
56
|
+
throw new Error(error.message);
|
|
57
|
+
const rows = data ?? [];
|
|
58
|
+
for (const row of rows) {
|
|
59
|
+
const id = row?.trade_item_id ? String(row.trade_item_id) : null;
|
|
60
|
+
const price = row?.price != null ? Number(row.price) : null;
|
|
61
|
+
if (!id || price == null || !Number.isFinite(price))
|
|
62
|
+
continue;
|
|
63
|
+
const type = (row.price_type ?? "base");
|
|
64
|
+
if (type === "customer_group") {
|
|
65
|
+
const name = (row.price_group_name ?? "").trim().toLowerCase();
|
|
66
|
+
if (!name || !groupNames.has(name))
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (type === "week") {
|
|
70
|
+
const matchesWeek = row.year === year && row.week === week;
|
|
71
|
+
const fromT = row.valid_from ? Date.parse(row.valid_from) : null;
|
|
72
|
+
const toT = row.valid_to ? Date.parse(row.valid_to) : null;
|
|
73
|
+
const matchesRange = (fromT == null || fromT <= refTime) && (toT == null || toT >= refTime);
|
|
74
|
+
if (!matchesWeek && !(fromT != null || toT != null ? matchesRange : false))
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
const r = RANK[type] ?? 0;
|
|
78
|
+
if ((rank.get(id) ?? 0) >= r)
|
|
79
|
+
continue;
|
|
80
|
+
rank.set(id, r);
|
|
81
|
+
out.set(id, {
|
|
82
|
+
trade_item_id: id,
|
|
83
|
+
supplier_article_code: row.supplier_article_code ?? null,
|
|
84
|
+
price,
|
|
85
|
+
currency: row.currency ?? "EUR",
|
|
86
|
+
price_type: type,
|
|
87
|
+
price_group_name: row.price_group_name ?? null,
|
|
88
|
+
sales_unit: row.sales_unit ?? null,
|
|
89
|
+
year: row.year ?? null,
|
|
90
|
+
week: row.week ?? null,
|
|
91
|
+
label: labelFor(row),
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
if (rows.length < pageSize)
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
return out;
|
|
98
|
+
}
|