@flowselections/floriday-klanten-module 1.0.15 → 1.0.17
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/BackLink.d.ts +12 -0
- package/dist-lib/components/klanten/BackLink.d.ts.map +1 -0
- package/dist-lib/components/klanten/BackLink.js +12 -0
- package/dist-lib/components/klanten/FloridayAssortmentTab.d.ts +4 -0
- package/dist-lib/components/klanten/FloridayAssortmentTab.d.ts.map +1 -0
- package/dist-lib/components/klanten/FloridayAssortmentTab.js +80 -0
- package/dist-lib/components/klanten/FloridayDeeplinkButton.d.ts +8 -0
- package/dist-lib/components/klanten/FloridayDeeplinkButton.d.ts.map +1 -0
- package/dist-lib/components/klanten/FloridayDeeplinkButton.js +9 -0
- package/dist-lib/components/klanten/GroupedKlantDetail.d.ts.map +1 -1
- package/dist-lib/components/klanten/GroupedKlantDetail.js +19 -5
- package/dist-lib/components/klanten/ImportKlanten.d.ts.map +1 -1
- package/dist-lib/components/klanten/ImportKlanten.js +3 -2
- package/dist-lib/components/klanten/KlantDetail.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantDetail.js +9 -3
- package/dist-lib/components/klanten/KlantenOverzicht.d.ts.map +1 -1
- package/dist-lib/components/klanten/KlantenOverzicht.js +9 -6
- package/dist-lib/components/klanten/NetwerkPagina.d.ts.map +1 -1
- package/dist-lib/components/klanten/NetwerkPagina.js +21 -18
- package/dist-lib/components/klanten/NieuweKlant.d.ts.map +1 -1
- package/dist-lib/components/klanten/NieuweKlant.js +23 -8
- package/dist-lib/components/klanten/PriceGroupBadges.d.ts +7 -0
- package/dist-lib/components/klanten/PriceGroupBadges.d.ts.map +1 -0
- package/dist-lib/components/klanten/PriceGroupBadges.js +13 -0
- package/dist-lib/components/klanten/SyncStatusChip.d.ts +4 -0
- package/dist-lib/components/klanten/SyncStatusChip.d.ts.map +1 -0
- package/dist-lib/components/klanten/SyncStatusChip.js +49 -0
- package/dist-lib/components/klanten/pricegroups/CustomerPickerDialog.d.ts +8 -0
- package/dist-lib/components/klanten/pricegroups/CustomerPickerDialog.d.ts.map +1 -0
- package/dist-lib/components/klanten/pricegroups/CustomerPickerDialog.js +75 -0
- package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.d.ts +4 -0
- package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.d.ts.map +1 -0
- package/dist-lib/components/klanten/pricegroups/PriceGroupFormPage.js +269 -0
- package/dist-lib/components/klanten/pricegroups/PriceGroupsPage.d.ts +2 -0
- package/dist-lib/components/klanten/pricegroups/PriceGroupsPage.d.ts.map +1 -0
- package/dist-lib/components/klanten/pricegroups/PriceGroupsPage.js +133 -0
- package/dist-lib/components/klanten/pricegroups/ProductPickerDialog.d.ts +8 -0
- package/dist-lib/components/klanten/pricegroups/ProductPickerDialog.d.ts.map +1 -0
- package/dist-lib/components/klanten/pricegroups/ProductPickerDialog.js +18 -0
- package/dist-lib/index.d.ts +1 -0
- package/dist-lib/index.d.ts.map +1 -1
- package/dist-lib/index.js +6 -1
- package/dist-lib/integrations/supabase/auth-middleware.d.ts +1684 -93
- package/dist-lib/integrations/supabase/auth-middleware.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.d.ts +1684 -93
- package/dist-lib/integrations/supabase/client.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/client.js +4 -3
- package/dist-lib/integrations/supabase/client.server.d.ts +1684 -93
- package/dist-lib/integrations/supabase/client.server.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.d.ts +1712 -72
- package/dist-lib/integrations/supabase/types.d.ts.map +1 -1
- package/dist-lib/integrations/supabase/types.js +3 -9
- package/dist-lib/lib/accounting/twinfield/client.server.d.ts +21 -0
- package/dist-lib/lib/accounting/twinfield/client.server.d.ts.map +1 -0
- package/dist-lib/lib/accounting/twinfield/client.server.js +171 -0
- package/dist-lib/lib/accounting/twinfield/mapping.d.ts +46 -0
- package/dist-lib/lib/accounting/twinfield/mapping.d.ts.map +1 -0
- package/dist-lib/lib/accounting/twinfield/mapping.js +121 -0
- package/dist-lib/lib/accounting/twinfield/worker.functions.d.ts +38814 -0
- package/dist-lib/lib/accounting/twinfield/worker.functions.d.ts.map +1 -0
- package/dist-lib/lib/accounting/twinfield/worker.functions.js +48 -0
- package/dist-lib/lib/accounting/twinfield/worker.server.d.ts +12 -0
- package/dist-lib/lib/accounting/twinfield/worker.server.d.ts.map +1 -0
- package/dist-lib/lib/accounting/twinfield/worker.server.js +124 -0
- package/dist-lib/lib/accounting.functions.d.ts +4806 -33
- package/dist-lib/lib/accounting.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-analytics.functions.d.ts +1684 -93
- package/dist-lib/lib/customer-analytics.functions.d.ts.map +1 -1
- package/dist-lib/lib/customer-schemas.d.ts +2 -0
- package/dist-lib/lib/customer-schemas.d.ts.map +1 -1
- package/dist-lib/lib/customer-schemas.js +1 -0
- package/dist-lib/lib/customers.functions.d.ts +25793 -163
- package/dist-lib/lib/customers.functions.d.ts.map +1 -1
- package/dist-lib/lib/customers.functions.js +92 -4
- package/dist-lib/lib/delivery-locations.functions.d.ts +6408 -44
- package/dist-lib/lib/delivery-locations.functions.d.ts.map +1 -1
- package/dist-lib/lib/external-customers.functions.d.ts +6408 -44
- package/dist-lib/lib/external-customers.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-assortment.functions.d.ts +12959 -0
- package/dist-lib/lib/floriday-assortment.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-assortment.functions.js +213 -0
- package/dist-lib/lib/floriday-discounts.functions.d.ts +3398 -216
- package/dist-lib/lib/floriday-discounts.functions.d.ts.map +1 -1
- package/dist-lib/lib/floriday-trade-items.functions.d.ts +12943 -0
- package/dist-lib/lib/floriday-trade-items.functions.d.ts.map +1 -0
- package/dist-lib/lib/floriday-trade-items.functions.js +107 -0
- package/dist-lib/lib/local-discounts.functions.d.ts +11216 -79
- package/dist-lib/lib/local-discounts.functions.d.ts.map +1 -1
- package/dist-lib/lib/overdue-invoices.functions.d.ts +1684 -93
- package/dist-lib/lib/overdue-invoices.functions.d.ts.map +1 -1
- package/dist-lib/lib/price-groups-local.functions.d.ts +90665 -0
- package/dist-lib/lib/price-groups-local.functions.d.ts.map +1 -0
- package/dist-lib/lib/price-groups-local.functions.js +148 -0
- package/dist-lib/lib/price-groups.functions.d.ts +12952 -0
- package/dist-lib/lib/price-groups.functions.d.ts.map +1 -0
- package/dist-lib/lib/price-groups.functions.js +115 -0
- package/dist-lib/lib/pricing.d.ts +24 -0
- package/dist-lib/lib/pricing.d.ts.map +1 -0
- package/dist-lib/lib/pricing.js +60 -0
- package/package.json +8 -4
- package/public/flowselections-assets/Klanten/floriday-logo.png +0 -0
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { createServerFn } from "@tanstack/react-start";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { requireSupabaseAuth } from "../integrations/supabase/auth-middleware";
|
|
4
|
+
const priceGroupInputSchema = z.object({
|
|
5
|
+
name: z.string().trim().min(1, "Naam is verplicht").max(120),
|
|
6
|
+
currency: z.string().trim().min(3).max(3).default("EUR"),
|
|
7
|
+
pricing_mode: z.enum(["manual", "calculated"]).default("manual"),
|
|
8
|
+
group_type: z.enum(["general", "customer_specific"]).default("customer_specific"),
|
|
9
|
+
price_scope: z.enum(["incl_delivery", "excl_delivery"]).default("incl_delivery"),
|
|
10
|
+
include_stickers: z.boolean().default(false),
|
|
11
|
+
unit: z.string().trim().min(1).default("per_fust"),
|
|
12
|
+
calc_type: z.enum(["discount", "surcharge"]).nullable().optional(),
|
|
13
|
+
calc_value_type: z.enum(["fixed", "percentage"]).nullable().optional(),
|
|
14
|
+
calc_value: z.number().nullable().optional(),
|
|
15
|
+
handling_fee: z.number().nullable().optional(),
|
|
16
|
+
distribute_over: z.enum(["ladingdrager", "laag", "fust"]).nullable().optional(),
|
|
17
|
+
rounding: z.enum(["none", "up", "down", "nearest"]).default("none"),
|
|
18
|
+
rounding_step: z.number().positive().optional(),
|
|
19
|
+
is_active: z.boolean().default(true),
|
|
20
|
+
});
|
|
21
|
+
export const listCustomerPriceGroups = createServerFn({ method: "GET" })
|
|
22
|
+
.middleware([requireSupabaseAuth])
|
|
23
|
+
.handler(async ({ context }) => {
|
|
24
|
+
const { data: groups, error } = await context.supabase
|
|
25
|
+
.from("customer_price_groups")
|
|
26
|
+
.select("*")
|
|
27
|
+
.order("sort_order", { ascending: true })
|
|
28
|
+
.order("created_at", { ascending: true });
|
|
29
|
+
if (error)
|
|
30
|
+
throw new Error(error.message);
|
|
31
|
+
const { data: members } = await context.supabase
|
|
32
|
+
.from("customer_price_group_members")
|
|
33
|
+
.select("price_group_id");
|
|
34
|
+
const counts = new Map();
|
|
35
|
+
for (const m of members ?? []) {
|
|
36
|
+
const id = m.price_group_id;
|
|
37
|
+
counts.set(id, (counts.get(id) ?? 0) + 1);
|
|
38
|
+
}
|
|
39
|
+
return (groups ?? []).map((g) => ({
|
|
40
|
+
...g,
|
|
41
|
+
calc_value: g.calc_value != null ? Number(g.calc_value) : null,
|
|
42
|
+
handling_fee: g.handling_fee != null ? Number(g.handling_fee) : null,
|
|
43
|
+
member_count: counts.get(g.id) ?? 0,
|
|
44
|
+
}));
|
|
45
|
+
});
|
|
46
|
+
export const getCustomerPriceGroup = createServerFn({ method: "GET" })
|
|
47
|
+
.middleware([requireSupabaseAuth])
|
|
48
|
+
.inputValidator((input) => z.object({ id: z.string().uuid() }).parse(input))
|
|
49
|
+
.handler(async ({ data, context }) => {
|
|
50
|
+
const { data: group, error } = await context.supabase
|
|
51
|
+
.from("customer_price_groups")
|
|
52
|
+
.select("*")
|
|
53
|
+
.eq("id", data.id)
|
|
54
|
+
.single();
|
|
55
|
+
if (error)
|
|
56
|
+
throw new Error(error.message);
|
|
57
|
+
const { data: members } = await context.supabase
|
|
58
|
+
.from("customer_price_group_members")
|
|
59
|
+
.select("customer_key")
|
|
60
|
+
.eq("price_group_id", data.id);
|
|
61
|
+
return {
|
|
62
|
+
group: {
|
|
63
|
+
...group,
|
|
64
|
+
calc_value: group.calc_value != null ? Number(group.calc_value) : null,
|
|
65
|
+
handling_fee: group.handling_fee != null ? Number(group.handling_fee) : null,
|
|
66
|
+
},
|
|
67
|
+
customerKeys: (members ?? []).map((m) => m.customer_key),
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
export const createCustomerPriceGroup = createServerFn({ method: "POST" })
|
|
71
|
+
.middleware([requireSupabaseAuth])
|
|
72
|
+
.inputValidator((input) => priceGroupInputSchema.parse(input))
|
|
73
|
+
.handler(async ({ data, context }) => {
|
|
74
|
+
const { data: maxRow } = await context.supabase
|
|
75
|
+
.from("customer_price_groups")
|
|
76
|
+
.select("sort_order")
|
|
77
|
+
.order("sort_order", { ascending: false })
|
|
78
|
+
.limit(1)
|
|
79
|
+
.maybeSingle();
|
|
80
|
+
const nextOrder = (maxRow?.sort_order ?? 0) + 1;
|
|
81
|
+
const { data: row, error } = await context.supabase
|
|
82
|
+
.from("customer_price_groups")
|
|
83
|
+
.insert({ ...data, owner_id: context.userId, sort_order: nextOrder })
|
|
84
|
+
.select("*")
|
|
85
|
+
.single();
|
|
86
|
+
if (error)
|
|
87
|
+
throw new Error(error.message);
|
|
88
|
+
return row;
|
|
89
|
+
});
|
|
90
|
+
export const updateCustomerPriceGroup = createServerFn({ method: "POST" })
|
|
91
|
+
.middleware([requireSupabaseAuth])
|
|
92
|
+
.inputValidator((input) => z.object({ id: z.string().uuid(), input: priceGroupInputSchema }).parse(input))
|
|
93
|
+
.handler(async ({ data, context }) => {
|
|
94
|
+
const { data: row, error } = await context.supabase
|
|
95
|
+
.from("customer_price_groups")
|
|
96
|
+
.update(data.input)
|
|
97
|
+
.eq("id", data.id)
|
|
98
|
+
.select("*")
|
|
99
|
+
.single();
|
|
100
|
+
if (error)
|
|
101
|
+
throw new Error(error.message);
|
|
102
|
+
return row;
|
|
103
|
+
});
|
|
104
|
+
export const deleteCustomerPriceGroup = createServerFn({ method: "POST" })
|
|
105
|
+
.middleware([requireSupabaseAuth])
|
|
106
|
+
.inputValidator((input) => z.object({ id: z.string().uuid() }).parse(input))
|
|
107
|
+
.handler(async ({ data, context }) => {
|
|
108
|
+
const { error } = await context.supabase
|
|
109
|
+
.from("customer_price_groups")
|
|
110
|
+
.delete()
|
|
111
|
+
.eq("id", data.id);
|
|
112
|
+
if (error)
|
|
113
|
+
throw new Error(error.message);
|
|
114
|
+
return { ok: true };
|
|
115
|
+
});
|
|
116
|
+
export const reorderCustomerPriceGroups = createServerFn({ method: "POST" })
|
|
117
|
+
.middleware([requireSupabaseAuth])
|
|
118
|
+
.inputValidator((input) => z.object({ ids: z.array(z.string().uuid()).min(1) }).parse(input))
|
|
119
|
+
.handler(async ({ data, context }) => {
|
|
120
|
+
const { error } = await context.supabase.rpc("reorder_customer_price_groups", { _ids: data.ids });
|
|
121
|
+
if (error)
|
|
122
|
+
throw new Error(error.message);
|
|
123
|
+
return { ok: true };
|
|
124
|
+
});
|
|
125
|
+
export const setPriceGroupMembers = createServerFn({ method: "POST" })
|
|
126
|
+
.middleware([requireSupabaseAuth])
|
|
127
|
+
.inputValidator((input) => z.object({ id: z.string().uuid(), customerKeys: z.array(z.string().min(1)) }).parse(input))
|
|
128
|
+
.handler(async ({ data, context }) => {
|
|
129
|
+
const { error: delErr } = await context.supabase
|
|
130
|
+
.from("customer_price_group_members")
|
|
131
|
+
.delete()
|
|
132
|
+
.eq("price_group_id", data.id);
|
|
133
|
+
if (delErr)
|
|
134
|
+
throw new Error(delErr.message);
|
|
135
|
+
if (data.customerKeys.length > 0) {
|
|
136
|
+
const rows = Array.from(new Set(data.customerKeys)).map((k) => ({
|
|
137
|
+
price_group_id: data.id,
|
|
138
|
+
customer_key: k,
|
|
139
|
+
owner_id: context.userId,
|
|
140
|
+
}));
|
|
141
|
+
const { error: insErr } = await context.supabase
|
|
142
|
+
.from("customer_price_group_members")
|
|
143
|
+
.insert(rows);
|
|
144
|
+
if (insErr)
|
|
145
|
+
throw new Error(insErr.message);
|
|
146
|
+
}
|
|
147
|
+
return { ok: true, count: data.customerKeys.length };
|
|
148
|
+
});
|