@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
|
@@ -146,6 +146,81 @@ export const setPriceGroupMembers = createServerFn({ method: "POST" })
|
|
|
146
146
|
}
|
|
147
147
|
return { ok: true, count: data.customerKeys.length };
|
|
148
148
|
});
|
|
149
|
+
// ---------------------------------------------------------------------------
|
|
150
|
+
// Prijsgroep per klant (vanuit het klantdetail)
|
|
151
|
+
// ---------------------------------------------------------------------------
|
|
152
|
+
export const getPriceGroupsForCustomer = createServerFn({ method: "GET" })
|
|
153
|
+
.middleware([requireSupabaseAuth])
|
|
154
|
+
.inputValidator((input) => z.object({ customerKey: z.string().min(1) }).parse(input))
|
|
155
|
+
.handler(async ({ data, context }) => {
|
|
156
|
+
const { data: members, error } = await context.supabase
|
|
157
|
+
.from("customer_price_group_members")
|
|
158
|
+
.select("price_group_id")
|
|
159
|
+
.eq("customer_key", data.customerKey);
|
|
160
|
+
if (error)
|
|
161
|
+
throw new Error(error.message);
|
|
162
|
+
const ids = (members ?? []).map((m) => m.price_group_id);
|
|
163
|
+
if (ids.length === 0)
|
|
164
|
+
return { priceGroupIds: [], groups: [] };
|
|
165
|
+
const { data: groups, error: gErr } = await context.supabase
|
|
166
|
+
.from("customer_price_groups")
|
|
167
|
+
.select("id, name")
|
|
168
|
+
.in("id", ids);
|
|
169
|
+
if (gErr)
|
|
170
|
+
throw new Error(gErr.message);
|
|
171
|
+
return {
|
|
172
|
+
priceGroupIds: ids,
|
|
173
|
+
groups: (groups ?? []).map((g) => ({ id: g.id, name: g.name })),
|
|
174
|
+
};
|
|
175
|
+
});
|
|
176
|
+
/** Zoek de gegroepeerde klantsleutel (group_key) bij een lokale klant-id. */
|
|
177
|
+
export const resolveCustomerKeyForLocalCustomer = createServerFn({ method: "GET" })
|
|
178
|
+
.middleware([requireSupabaseAuth])
|
|
179
|
+
.inputValidator((input) => z.object({ customerId: z.string().min(1) }).parse(input))
|
|
180
|
+
.handler(async ({ data, context }) => {
|
|
181
|
+
const { data: rows, error } = await context.supabase
|
|
182
|
+
.from("external_customers_grouped")
|
|
183
|
+
.select("group_key, sources");
|
|
184
|
+
if (error)
|
|
185
|
+
throw new Error(error.message);
|
|
186
|
+
for (const row of (rows ?? [])) {
|
|
187
|
+
const sources = Array.isArray(row.sources) ? row.sources : [];
|
|
188
|
+
for (const s of sources) {
|
|
189
|
+
if (s?.provider === "local" && String(s?.external_id ?? "") === data.customerId) {
|
|
190
|
+
return { customerKey: String(row.group_key) };
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return { customerKey: null };
|
|
195
|
+
});
|
|
196
|
+
export const setPriceGroupForCustomer = createServerFn({ method: "POST" })
|
|
197
|
+
.middleware([requireSupabaseAuth])
|
|
198
|
+
.inputValidator((input) => z
|
|
199
|
+
.object({
|
|
200
|
+
customerKey: z.string().min(1),
|
|
201
|
+
priceGroupId: z.string().uuid().nullable(),
|
|
202
|
+
})
|
|
203
|
+
.parse(input))
|
|
204
|
+
.handler(async ({ data, context }) => {
|
|
205
|
+
const { error: delErr } = await context.supabase
|
|
206
|
+
.from("customer_price_group_members")
|
|
207
|
+
.delete()
|
|
208
|
+
.eq("customer_key", data.customerKey);
|
|
209
|
+
if (delErr)
|
|
210
|
+
throw new Error(delErr.message);
|
|
211
|
+
if (data.priceGroupId) {
|
|
212
|
+
const { error: insErr } = await context.supabase
|
|
213
|
+
.from("customer_price_group_members")
|
|
214
|
+
.insert({
|
|
215
|
+
price_group_id: data.priceGroupId,
|
|
216
|
+
customer_key: data.customerKey,
|
|
217
|
+
owner_id: context.userId,
|
|
218
|
+
});
|
|
219
|
+
if (insErr)
|
|
220
|
+
throw new Error(insErr.message);
|
|
221
|
+
}
|
|
222
|
+
return { ok: true };
|
|
223
|
+
});
|
|
149
224
|
function mapUnit(salesUnit) {
|
|
150
225
|
switch ((salesUnit ?? "").toUpperCase()) {
|
|
151
226
|
case "PACKAGE":
|
|
@@ -314,3 +389,73 @@ export const importFloridayPriceGroups = createServerFn({ method: "POST" })
|
|
|
314
389
|
unmatchedOrganizations: Array.from(unmatched),
|
|
315
390
|
};
|
|
316
391
|
});
|
|
392
|
+
export const listPriceGroupItemPrices = createServerFn({ method: "POST" })
|
|
393
|
+
.middleware([requireSupabaseAuth])
|
|
394
|
+
.inputValidator((input) => z.object({ priceGroupId: z.string().uuid() }).parse(input))
|
|
395
|
+
.handler(async ({ data, context }) => {
|
|
396
|
+
const { data: rows, error } = await context.supabase
|
|
397
|
+
.from("trade_item_prices")
|
|
398
|
+
.select("trade_item_key, price_per_piece, currency")
|
|
399
|
+
.eq("price_group_id", data.priceGroupId);
|
|
400
|
+
if (error)
|
|
401
|
+
throw new Error(error.message);
|
|
402
|
+
return {
|
|
403
|
+
prices: (rows ?? []).map((r) => ({
|
|
404
|
+
trade_item_key: String(r.trade_item_key),
|
|
405
|
+
price_per_piece: Number(r.price_per_piece),
|
|
406
|
+
currency: r.currency ?? "EUR",
|
|
407
|
+
})),
|
|
408
|
+
};
|
|
409
|
+
});
|
|
410
|
+
export const setPriceGroupItemPrice = createServerFn({ method: "POST" })
|
|
411
|
+
.middleware([requireSupabaseAuth])
|
|
412
|
+
.inputValidator((input) => z
|
|
413
|
+
.object({
|
|
414
|
+
priceGroupId: z.string().uuid(),
|
|
415
|
+
tradeItemKey: z.string().min(1),
|
|
416
|
+
price: z.number().nonnegative().nullable(),
|
|
417
|
+
currency: z.string().trim().min(3).max(3).default("EUR"),
|
|
418
|
+
})
|
|
419
|
+
.parse(input))
|
|
420
|
+
.handler(async ({ data, context }) => {
|
|
421
|
+
if (data.price == null) {
|
|
422
|
+
const { error } = await context.supabase
|
|
423
|
+
.from("trade_item_prices")
|
|
424
|
+
.delete()
|
|
425
|
+
.eq("price_group_id", data.priceGroupId)
|
|
426
|
+
.eq("trade_item_key", data.tradeItemKey);
|
|
427
|
+
if (error)
|
|
428
|
+
throw new Error(error.message);
|
|
429
|
+
return { ok: true, removed: true };
|
|
430
|
+
}
|
|
431
|
+
const { data: existing } = await context.supabase
|
|
432
|
+
.from("trade_item_prices")
|
|
433
|
+
.select("id")
|
|
434
|
+
.eq("price_group_id", data.priceGroupId)
|
|
435
|
+
.eq("trade_item_key", data.tradeItemKey)
|
|
436
|
+
.maybeSingle();
|
|
437
|
+
if (existing?.id) {
|
|
438
|
+
const { error } = await context.supabase
|
|
439
|
+
.from("trade_item_prices")
|
|
440
|
+
.update({
|
|
441
|
+
price_per_piece: data.price,
|
|
442
|
+
currency: data.currency,
|
|
443
|
+
updated_at: new Date().toISOString(),
|
|
444
|
+
})
|
|
445
|
+
.eq("id", existing.id);
|
|
446
|
+
if (error)
|
|
447
|
+
throw new Error(error.message);
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
const { error } = await context.supabase.from("trade_item_prices").insert({
|
|
451
|
+
user_id: context.userId,
|
|
452
|
+
price_group_id: data.priceGroupId,
|
|
453
|
+
trade_item_key: data.tradeItemKey,
|
|
454
|
+
price_per_piece: data.price,
|
|
455
|
+
currency: data.currency,
|
|
456
|
+
});
|
|
457
|
+
if (error)
|
|
458
|
+
throw new Error(error.message);
|
|
459
|
+
}
|
|
460
|
+
return { ok: true, removed: false };
|
|
461
|
+
});
|