includio-cms 0.36.5 → 0.36.7
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/API.md +1 -1
- package/CHANGELOG.md +11 -0
- package/DOCS.md +1 -1
- package/dist/admin/components/fields/blocks-field.svelte +8 -8
- package/dist/admin/components/fields/relation-field.svelte +1 -1
- package/dist/paraglide/messages/_index.d.ts +36 -3
- package/dist/paraglide/messages/_index.js +71 -3
- package/dist/paraglide/messages/en.d.ts +5 -0
- package/dist/paraglide/messages/en.js +14 -0
- package/dist/paraglide/messages/pl.d.ts +5 -0
- package/dist/paraglide/messages/pl.js +14 -0
- package/dist/shop/adapters/fakturownia/payload.d.ts +2 -0
- package/dist/shop/adapters/fakturownia/payload.js +1 -0
- package/dist/shop/server/invoices.d.ts +16 -2
- package/dist/shop/server/invoices.js +86 -9
- package/dist/shop/types.d.ts +5 -0
- package/dist/updates/0.36.7/index.d.ts +2 -0
- package/dist/updates/0.36.7/index.js +13 -0
- package/dist/updates/index.js +3 -1
- package/package.json +1 -1
- package/dist/paraglide/messages/hello_world.d.ts +0 -5
- package/dist/paraglide/messages/hello_world.js +0 -33
- package/dist/paraglide/messages/login_hello.d.ts +0 -16
- package/dist/paraglide/messages/login_hello.js +0 -34
- package/dist/paraglide/messages/login_please_login.d.ts +0 -16
- package/dist/paraglide/messages/login_please_login.js +0 -34
package/API.md
CHANGED
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to includio-cms are documented here.
|
|
4
4
|
Generated from `src/lib/updates/` — do not edit manually.
|
|
5
5
|
|
|
6
|
+
## 0.36.7 — 2026-06-24
|
|
7
|
+
|
|
8
|
+
Faktura uwzględnia rabat z kuponu i koszt wysyłki. Pozycje są wystawiane w cenach po rabacie (finalna kwota = kwota zapłacona), a użyty kod rabatowy trafia do uwag faktury. Wcześniej faktura zawierała pełne ceny katalogowe i pomijała rabat.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- Rabat z kuponu na fakturze: ceny pozycji obniżone proporcjonalnie do udziału brutto (reszta zaokrąglenia do ostatniej pozycji), suma = `order.totalGross`. Kod rabatowy dopisywany do uwag faktury (Fakturownia: pole `description`), zlokalizowany PL/EN wg języka zamówienia.
|
|
12
|
+
- Koszt wysyłki dodawany jako pozycja „Wysyłka" gdy > 0 (VAT rekonstruowany z net/gross, fallback 23%).
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
- Faktury z kuponem nie pomijają już rabatu — wartość faktury zgadza się z kwotą zapłaconą przez klienta.
|
|
16
|
+
|
|
6
17
|
## 0.36.5 — 2026-06-11
|
|
7
18
|
|
|
8
19
|
Zależności tiptap przypięte do exact `3.26.1` (wcześniej `^3.17.1`). Rozjazd zakresów powodował, że konsument mógł rozwiązać rdzeń `@tiptap/core` na inną wersję niż rozszerzenia (np. core 3.22.3 vs extension-highlight 3.26.1), co wywalało produkcyjny build („getStyleProperty is not exported by @tiptap/core"). Bez potrzeby override po stronie projektu.
|
package/DOCS.md
CHANGED
|
@@ -276,8 +276,8 @@
|
|
|
276
276
|
let blockPickerOpen = $state(false);
|
|
277
277
|
</script>
|
|
278
278
|
|
|
279
|
-
<div class="flex items-center justify-between gap-4">
|
|
280
|
-
<div class="flex items-center gap-2">
|
|
279
|
+
<div class="flex flex-wrap items-center justify-between gap-x-4 gap-y-2">
|
|
280
|
+
<div class="flex min-w-0 items-center gap-2">
|
|
281
281
|
<RequiredLabel required={field.minItems !== undefined && field.minItems > 0} class="text-lg"
|
|
282
282
|
>{getLocalizedLabel(field.label, interfaceLanguage.current)}</RequiredLabel
|
|
283
283
|
>
|
|
@@ -353,10 +353,10 @@
|
|
|
353
353
|
{#if objectField}
|
|
354
354
|
<Accordion.Item value={index.toString()} class="overflow-hidden rounded-md border-0" data-depth={depth + 1}>
|
|
355
355
|
<Accordion.Trigger
|
|
356
|
-
class="items-center rounded-md border bg-card/60 px-4 text-base font-normal data-[state=open]:rounded-b-none"
|
|
356
|
+
class="min-w-0 items-center rounded-md border bg-card/60 px-4 text-base font-normal data-[state=open]:rounded-b-none"
|
|
357
357
|
>
|
|
358
|
-
<div class="flex grow items-center justify-between gap-4">
|
|
359
|
-
<div class="flex items-center gap-4">
|
|
358
|
+
<div class="flex min-w-0 grow items-center justify-between gap-4">
|
|
359
|
+
<div class="flex min-w-0 items-center gap-4">
|
|
360
360
|
{#if !isFixedLength || fixedCount > 1}
|
|
361
361
|
<!-- svelte-ignore a11y_no_static_element_interactions a11y_click_events_have_key_events -->
|
|
362
362
|
<div
|
|
@@ -371,12 +371,12 @@
|
|
|
371
371
|
<GripVertical class="h-4 w-4" />
|
|
372
372
|
</div>
|
|
373
373
|
{/if}
|
|
374
|
-
<span>{index < 10 ? '0' : ''}{index + 1}</span>
|
|
375
|
-
<Badge variant="outline"
|
|
374
|
+
<span class="shrink-0">{index < 10 ? '0' : ''}{index + 1}</span>
|
|
375
|
+
<Badge variant="outline" class="shrink-0"
|
|
376
376
|
>{getLocalizedLabel(objectField.label, interfaceLanguage.current) ||
|
|
377
377
|
objectField.slug}</Badge
|
|
378
378
|
>
|
|
379
|
-
<span>{getAccordionLabel($value[index])}</span>
|
|
379
|
+
<span class="truncate">{getAccordionLabel($value[index])}</span>
|
|
380
380
|
</div>
|
|
381
381
|
|
|
382
382
|
{#if !(isFixedLength && fixedCount <= 1)}
|
|
@@ -355,7 +355,7 @@
|
|
|
355
355
|
<ChevronDown class="h-3.5 w-3.5" />
|
|
356
356
|
</button>
|
|
357
357
|
{/if}
|
|
358
|
-
<span class="flex-1 truncate">{item.label}</span>
|
|
358
|
+
<span class="min-w-0 flex-1 truncate">{item.label}</span>
|
|
359
359
|
<button
|
|
360
360
|
type="button"
|
|
361
361
|
class="shrink-0 text-muted-foreground hover:text-destructive"
|
|
@@ -1,3 +1,36 @@
|
|
|
1
|
-
export
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
export function hello_world(inputs: {
|
|
2
|
+
name: NonNullable<unknown>;
|
|
3
|
+
}, options?: {
|
|
4
|
+
locale?: "en" | "pl";
|
|
5
|
+
}): string;
|
|
6
|
+
/**
|
|
7
|
+
* This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
|
|
8
|
+
*
|
|
9
|
+
* - Changing this function will be over-written by the next build.
|
|
10
|
+
*
|
|
11
|
+
* - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
|
|
12
|
+
* use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
|
|
13
|
+
*
|
|
14
|
+
* @param {{}} inputs
|
|
15
|
+
* @param {{ locale?: "en" | "pl" }} options
|
|
16
|
+
* @returns {string}
|
|
17
|
+
*/
|
|
18
|
+
declare function login_hello(inputs?: {}, options?: {
|
|
19
|
+
locale?: "en" | "pl";
|
|
20
|
+
}): string;
|
|
21
|
+
/**
|
|
22
|
+
* This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
|
|
23
|
+
*
|
|
24
|
+
* - Changing this function will be over-written by the next build.
|
|
25
|
+
*
|
|
26
|
+
* - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
|
|
27
|
+
* use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
|
|
28
|
+
*
|
|
29
|
+
* @param {{}} inputs
|
|
30
|
+
* @param {{ locale?: "en" | "pl" }} options
|
|
31
|
+
* @returns {string}
|
|
32
|
+
*/
|
|
33
|
+
declare function login_please_login(inputs?: {}, options?: {
|
|
34
|
+
locale?: "en" | "pl";
|
|
35
|
+
}): string;
|
|
36
|
+
export { login_hello as login.hello, login_please_login as login.please_login };
|
|
@@ -1,4 +1,72 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer } from "../runtime.js"
|
|
3
|
+
import * as en from "./en.js"
|
|
4
|
+
import * as pl from "./pl.js"
|
|
5
|
+
/**
|
|
6
|
+
* This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
|
|
7
|
+
*
|
|
8
|
+
* - Changing this function will be over-written by the next build.
|
|
9
|
+
*
|
|
10
|
+
* - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
|
|
11
|
+
* use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
|
|
12
|
+
*
|
|
13
|
+
* @param {{ name: NonNullable<unknown> }} inputs
|
|
14
|
+
* @param {{ locale?: "en" | "pl" }} options
|
|
15
|
+
* @returns {string}
|
|
16
|
+
*/
|
|
17
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
18
|
+
export const hello_world = (inputs, options = {}) => {
|
|
19
|
+
if (experimentalMiddlewareLocaleSplitting && isServer === false) {
|
|
20
|
+
return /** @type {any} */ (globalThis).__paraglide_ssr.hello_world(inputs)
|
|
21
|
+
}
|
|
22
|
+
const locale = options.locale ?? getLocale()
|
|
23
|
+
trackMessageCall("hello_world", locale)
|
|
24
|
+
if (locale === "en") return en.hello_world(inputs)
|
|
25
|
+
return pl.hello_world(inputs)
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
|
|
29
|
+
*
|
|
30
|
+
* - Changing this function will be over-written by the next build.
|
|
31
|
+
*
|
|
32
|
+
* - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
|
|
33
|
+
* use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
|
|
34
|
+
*
|
|
35
|
+
* @param {{}} inputs
|
|
36
|
+
* @param {{ locale?: "en" | "pl" }} options
|
|
37
|
+
* @returns {string}
|
|
38
|
+
*/
|
|
39
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
40
|
+
const login_hello = (inputs = {}, options = {}) => {
|
|
41
|
+
if (experimentalMiddlewareLocaleSplitting && isServer === false) {
|
|
42
|
+
return /** @type {any} */ (globalThis).__paraglide_ssr.login_hello(inputs)
|
|
43
|
+
}
|
|
44
|
+
const locale = options.locale ?? getLocale()
|
|
45
|
+
trackMessageCall("login_hello", locale)
|
|
46
|
+
if (locale === "en") return en.login_hello(inputs)
|
|
47
|
+
return pl.login_hello(inputs)
|
|
48
|
+
};
|
|
49
|
+
export { login_hello as "login.hello" }
|
|
50
|
+
/**
|
|
51
|
+
* This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
|
|
52
|
+
*
|
|
53
|
+
* - Changing this function will be over-written by the next build.
|
|
54
|
+
*
|
|
55
|
+
* - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
|
|
56
|
+
* use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
|
|
57
|
+
*
|
|
58
|
+
* @param {{}} inputs
|
|
59
|
+
* @param {{ locale?: "en" | "pl" }} options
|
|
60
|
+
* @returns {string}
|
|
61
|
+
*/
|
|
62
|
+
/* @__NO_SIDE_EFFECTS__ */
|
|
63
|
+
const login_please_login = (inputs = {}, options = {}) => {
|
|
64
|
+
if (experimentalMiddlewareLocaleSplitting && isServer === false) {
|
|
65
|
+
return /** @type {any} */ (globalThis).__paraglide_ssr.login_please_login(inputs)
|
|
66
|
+
}
|
|
67
|
+
const locale = options.locale ?? getLocale()
|
|
68
|
+
trackMessageCall("login_please_login", locale)
|
|
69
|
+
if (locale === "en") return en.login_please_login(inputs)
|
|
70
|
+
return pl.login_please_login(inputs)
|
|
71
|
+
};
|
|
72
|
+
export { login_please_login as "login.please_login" }
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const hello_world = /** @type {(inputs: { name: NonNullable<unknown> }) => string} */ (i) => {
|
|
5
|
+
return `Hello, ${i.name} from en!`
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const login_hello = /** @type {(inputs: {}) => string} */ () => {
|
|
9
|
+
return `Welcome back`
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const login_please_login = /** @type {(inputs: {}) => string} */ () => {
|
|
13
|
+
return `Login to your account`
|
|
14
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
export const hello_world = /** @type {(inputs: { name: NonNullable<unknown> }) => string} */ (i) => {
|
|
5
|
+
return `Hello, ${i.name} from pl!`
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
export const login_hello = /** @type {(inputs: {}) => string} */ () => {
|
|
9
|
+
return `Witaj ponownie`
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const login_please_login = /** @type {(inputs: {}) => string} */ () => {
|
|
13
|
+
return `Zaloguj się na swoje konto`
|
|
14
|
+
};
|
|
@@ -25,6 +25,8 @@ export interface FakturowniaInvoiceBody {
|
|
|
25
25
|
buyer_city?: string;
|
|
26
26
|
buyer_post_code?: string;
|
|
27
27
|
buyer_country?: string;
|
|
28
|
+
/** Printed remarks ("Uwagi") — e.g. the applied coupon code. */
|
|
29
|
+
description?: string;
|
|
28
30
|
positions: FakturowniaPosition[];
|
|
29
31
|
}
|
|
30
32
|
/**
|
|
@@ -39,6 +39,7 @@ export function buildFakturowniaInvoice(payload, opts = {}) {
|
|
|
39
39
|
? { buyer_post_code: pick(buyer.address, 'postCode', 'zip', 'postalCode') }
|
|
40
40
|
: {}),
|
|
41
41
|
...(pick(buyer.address, 'country') ? { buyer_country: pick(buyer.address, 'country') } : {}),
|
|
42
|
+
...(payload.note ? { description: payload.note } : {}),
|
|
42
43
|
positions: payload.items.map((item) => ({
|
|
43
44
|
name: item.name,
|
|
44
45
|
quantity: item.quantity,
|
|
@@ -44,8 +44,22 @@ export declare function decideInvoiceAction(order: InvoiceOrderState, existing:
|
|
|
44
44
|
} | null, policy: InvoiceIssuePolicy, opts?: {
|
|
45
45
|
force?: boolean;
|
|
46
46
|
}): InvoiceAction;
|
|
47
|
-
/**
|
|
48
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Map order + items onto the provider-agnostic {@link InvoicePayload}. Pure.
|
|
49
|
+
* `opts.discount` lowers the item prices to the post-discount amounts and adds a
|
|
50
|
+
* remark (`note`) with the coupon code; `opts.shipping` appends a "Wysyłka" line
|
|
51
|
+
* when charged (>0). Together the line totals equal `order.totalGross`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildInvoicePayload(order: InvoiceOrderData, items: InvoiceItemData[], paidAt: string, opts?: {
|
|
54
|
+
discount?: {
|
|
55
|
+
code: string;
|
|
56
|
+
amount: number;
|
|
57
|
+
};
|
|
58
|
+
shipping?: {
|
|
59
|
+
net: number;
|
|
60
|
+
gross: number;
|
|
61
|
+
};
|
|
62
|
+
}): InvoicePayload;
|
|
49
63
|
export declare function getInvoiceByOrderId(orderId: string): Promise<InvoiceRow | null>;
|
|
50
64
|
/**
|
|
51
65
|
* Issue an invoice for an order if it qualifies. Fire-and-forget, fail-open —
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { eq } from 'drizzle-orm';
|
|
2
2
|
import { shopInvoicesTable, shopOrderItemsTable, shopOrdersTable } from '../../db-postgres/schema/shop/index.js';
|
|
3
3
|
import { getShopDb, requireShopConfig } from './db.js';
|
|
4
|
+
import { getOrderCoupon } from './coupons.js';
|
|
4
5
|
const FULLY_PAID_STATES = new Set(['paid', 'preparing', 'sent', 'done']);
|
|
5
6
|
export class InvoiceError extends Error {
|
|
6
7
|
code;
|
|
@@ -59,8 +60,82 @@ function lineName(name) {
|
|
|
59
60
|
return `${product} — ${variant}`;
|
|
60
61
|
return product || variant || Object.values(name)[0] || '';
|
|
61
62
|
}
|
|
62
|
-
/**
|
|
63
|
-
|
|
63
|
+
/**
|
|
64
|
+
* Build the shipping invoice line, or `null` when shipping is free. VAT is
|
|
65
|
+
* reconstructed from the actually-charged net/gross (falls back to 23% when the
|
|
66
|
+
* net is zero but a gross was charged). Pure.
|
|
67
|
+
*/
|
|
68
|
+
function buildShippingLine(shipping) {
|
|
69
|
+
if (shipping.gross <= 0)
|
|
70
|
+
return null;
|
|
71
|
+
const vatRate = shipping.net > 0 ? Math.round(((shipping.gross - shipping.net) / shipping.net) * 100) : 23;
|
|
72
|
+
return { name: 'Wysyłka', quantity: 1, unitPriceGross: shipping.gross, vatRate };
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Reduce item line prices by a gross coupon discount, so the invoice shows the
|
|
76
|
+
* actually-charged (post-discount) prices — the final total equals the amount
|
|
77
|
+
* paid (`order.totalGross`). The gross discount is distributed across lines
|
|
78
|
+
* proportionally to each line's gross share; the last line absorbs the rounding
|
|
79
|
+
* remainder so the reduced line totals sum to `subtotal − discountAmount`
|
|
80
|
+
* exactly. The per-unit price may carry fractional grosze; the provider
|
|
81
|
+
* recomputes it from the line total (Fakturownia: `total_price_gross ÷ quantity`).
|
|
82
|
+
* Pure.
|
|
83
|
+
*/
|
|
84
|
+
function applyDiscountToLines(lines, discountAmount) {
|
|
85
|
+
if (discountAmount <= 0 || lines.length === 0)
|
|
86
|
+
return lines;
|
|
87
|
+
const lineGross = (l) => l.unitPriceGross * l.quantity;
|
|
88
|
+
const subtotal = lines.reduce((s, l) => s + lineGross(l), 0);
|
|
89
|
+
if (subtotal <= 0)
|
|
90
|
+
return lines;
|
|
91
|
+
let allocated = 0;
|
|
92
|
+
return lines.map((line, idx) => {
|
|
93
|
+
const gross = lineGross(line);
|
|
94
|
+
const isLast = idx === lines.length - 1;
|
|
95
|
+
const lineDiscount = isLast
|
|
96
|
+
? discountAmount - allocated
|
|
97
|
+
: Math.round((discountAmount * gross) / subtotal);
|
|
98
|
+
allocated += lineDiscount;
|
|
99
|
+
return { ...line, unitPriceGross: (gross - lineDiscount) / line.quantity };
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
/** Format minor units (grosze) as a localized currency string. Pure. */
|
|
103
|
+
function formatMoney(grosze, currency, language) {
|
|
104
|
+
return new Intl.NumberFormat(language === 'en' ? 'en-GB' : 'pl-PL', {
|
|
105
|
+
style: 'currency',
|
|
106
|
+
currency,
|
|
107
|
+
minimumFractionDigits: 2
|
|
108
|
+
}).format(grosze / 100);
|
|
109
|
+
}
|
|
110
|
+
/** Build the printed invoice remark describing the applied coupon. Pure. */
|
|
111
|
+
function discountNote(discount, currency, language) {
|
|
112
|
+
const amount = formatMoney(discount.amount, currency, language);
|
|
113
|
+
return language === 'en'
|
|
114
|
+
? `Discount code ${discount.code} applied (-${amount}).`
|
|
115
|
+
: `Zastosowano kod rabatowy ${discount.code} (rabat -${amount}).`;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Map order + items onto the provider-agnostic {@link InvoicePayload}. Pure.
|
|
119
|
+
* `opts.discount` lowers the item prices to the post-discount amounts and adds a
|
|
120
|
+
* remark (`note`) with the coupon code; `opts.shipping` appends a "Wysyłka" line
|
|
121
|
+
* when charged (>0). Together the line totals equal `order.totalGross`.
|
|
122
|
+
*/
|
|
123
|
+
export function buildInvoicePayload(order, items, paidAt, opts = {}) {
|
|
124
|
+
let lines = items.map((item) => ({
|
|
125
|
+
name: lineName(item.nameSnapshot),
|
|
126
|
+
quantity: item.qty,
|
|
127
|
+
unitPriceGross: item.priceGrossSnapshot,
|
|
128
|
+
vatRate: item.vatRate
|
|
129
|
+
}));
|
|
130
|
+
const hasDiscount = Boolean(opts.discount && opts.discount.amount > 0);
|
|
131
|
+
if (opts.discount && hasDiscount) {
|
|
132
|
+
lines = applyDiscountToLines(lines, opts.discount.amount);
|
|
133
|
+
}
|
|
134
|
+
if (opts.shipping) {
|
|
135
|
+
const shippingLine = buildShippingLine(opts.shipping);
|
|
136
|
+
if (shippingLine)
|
|
137
|
+
lines.push(shippingLine);
|
|
138
|
+
}
|
|
64
139
|
return {
|
|
65
140
|
orderNumber: order.number,
|
|
66
141
|
currency: order.currency,
|
|
@@ -72,12 +147,10 @@ export function buildInvoicePayload(order, items, paidAt) {
|
|
|
72
147
|
companyName: order.customerCompanyName,
|
|
73
148
|
address: order.billingAddress ?? order.shippingAddress ?? null
|
|
74
149
|
},
|
|
75
|
-
items:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
vatRate: item.vatRate
|
|
80
|
-
}))
|
|
150
|
+
items: lines,
|
|
151
|
+
...(opts.discount && hasDiscount
|
|
152
|
+
? { note: discountNote(opts.discount, order.currency, order.language) }
|
|
153
|
+
: {})
|
|
81
154
|
};
|
|
82
155
|
}
|
|
83
156
|
export async function getInvoiceByOrderId(orderId) {
|
|
@@ -144,7 +217,11 @@ async function runCreate(order, existing, adapter) {
|
|
|
144
217
|
.from(shopOrderItemsTable)
|
|
145
218
|
.where(eq(shopOrderItemsTable.orderId, order.id));
|
|
146
219
|
const paidAt = order.partialPayment?.paidAt ?? now.toISOString();
|
|
147
|
-
const
|
|
220
|
+
const coupon = await getOrderCoupon(order.id);
|
|
221
|
+
const payload = buildInvoicePayload(toOrderData(order), toItemData(items), paidAt, {
|
|
222
|
+
discount: coupon ? { code: coupon.code, amount: coupon.discountAmount } : undefined,
|
|
223
|
+
shipping: { net: order.shippingNet, gross: order.shippingGross }
|
|
224
|
+
});
|
|
148
225
|
try {
|
|
149
226
|
const result = await adapter.createInvoice(payload, { language: order.language });
|
|
150
227
|
let status = 'issued';
|
package/dist/shop/types.d.ts
CHANGED
|
@@ -359,6 +359,11 @@ export interface InvoicePayload {
|
|
|
359
359
|
items: InvoiceLineItem[];
|
|
360
360
|
/** ISO timestamp the payment was confirmed — used as issue / paid date. */
|
|
361
361
|
paidAt: string;
|
|
362
|
+
/**
|
|
363
|
+
* Free-text remark printed on the invoice (e.g. the applied coupon code).
|
|
364
|
+
* Adapters map it onto their notes field (Fakturownia: `description`).
|
|
365
|
+
*/
|
|
366
|
+
note?: string;
|
|
362
367
|
}
|
|
363
368
|
/** @public */
|
|
364
369
|
export interface InvoiceCreateResult {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const update = {
|
|
2
|
+
version: '0.36.7',
|
|
3
|
+
date: '2026-06-24',
|
|
4
|
+
description: 'Faktura uwzględnia rabat z kuponu i koszt wysyłki. Pozycje są wystawiane w cenach po rabacie (finalna kwota = kwota zapłacona), a użyty kod rabatowy trafia do uwag faktury. Wcześniej faktura zawierała pełne ceny katalogowe i pomijała rabat.',
|
|
5
|
+
features: [
|
|
6
|
+
'Rabat z kuponu na fakturze: ceny pozycji obniżone proporcjonalnie do udziału brutto (reszta zaokrąglenia do ostatniej pozycji), suma = `order.totalGross`. Kod rabatowy dopisywany do uwag faktury (Fakturownia: pole `description`), zlokalizowany PL/EN wg języka zamówienia.',
|
|
7
|
+
'Koszt wysyłki dodawany jako pozycja „Wysyłka" gdy > 0 (VAT rekonstruowany z net/gross, fallback 23%).'
|
|
8
|
+
],
|
|
9
|
+
fixes: [
|
|
10
|
+
'Faktury z kuponem nie pomijają już rabatu — wartość faktury zgadza się z kwotą zapłaconą przez klienta.'
|
|
11
|
+
],
|
|
12
|
+
breakingChanges: []
|
|
13
|
+
};
|
package/dist/updates/index.js
CHANGED
|
@@ -72,6 +72,7 @@ import { update as update0362 } from './0.36.2/index.js';
|
|
|
72
72
|
import { update as update0363 } from './0.36.3/index.js';
|
|
73
73
|
import { update as update0364 } from './0.36.4/index.js';
|
|
74
74
|
import { update as update0365 } from './0.36.5/index.js';
|
|
75
|
+
import { update as update0367 } from './0.36.7/index.js';
|
|
75
76
|
export const updates = [
|
|
76
77
|
update0065,
|
|
77
78
|
update0066,
|
|
@@ -146,7 +147,8 @@ export const updates = [
|
|
|
146
147
|
update0362,
|
|
147
148
|
update0363,
|
|
148
149
|
update0364,
|
|
149
|
-
update0365
|
|
150
|
+
update0365,
|
|
151
|
+
update0367
|
|
150
152
|
];
|
|
151
153
|
export const getUpdatesFrom = (fromVersion) => {
|
|
152
154
|
const fromParts = fromVersion.split('.').map(Number);
|
package/package.json
CHANGED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer } from '../runtime.js';
|
|
3
|
-
|
|
4
|
-
const en_hello_world = /** @type {(inputs: { name: NonNullable<unknown> }) => string} */ (i) => {
|
|
5
|
-
return `Hello, ${i.name} from en!`
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const pl_hello_world = /** @type {(inputs: { name: NonNullable<unknown> }) => string} */ (i) => {
|
|
9
|
-
return `Hello, ${i.name} from pl!`
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
|
|
14
|
-
*
|
|
15
|
-
* - Changing this function will be over-written by the next build.
|
|
16
|
-
*
|
|
17
|
-
* - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
|
|
18
|
-
* use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
|
|
19
|
-
*
|
|
20
|
-
* @param {{ name: NonNullable<unknown> }} inputs
|
|
21
|
-
* @param {{ locale?: "en" | "pl" }} options
|
|
22
|
-
* @returns {string}
|
|
23
|
-
*/
|
|
24
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
25
|
-
export const hello_world = (inputs, options = {}) => {
|
|
26
|
-
if (experimentalMiddlewareLocaleSplitting && isServer === false) {
|
|
27
|
-
return /** @type {any} */ (globalThis).__paraglide_ssr.hello_world(inputs)
|
|
28
|
-
}
|
|
29
|
-
const locale = options.locale ?? getLocale()
|
|
30
|
-
trackMessageCall("hello_world", locale)
|
|
31
|
-
if (locale === "en") return en_hello_world(inputs)
|
|
32
|
-
return pl_hello_world(inputs)
|
|
33
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { login_hello as login.hello };
|
|
2
|
-
/**
|
|
3
|
-
* This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
|
|
4
|
-
*
|
|
5
|
-
* - Changing this function will be over-written by the next build.
|
|
6
|
-
*
|
|
7
|
-
* - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
|
|
8
|
-
* use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
|
|
9
|
-
*
|
|
10
|
-
* @param {{}} inputs
|
|
11
|
-
* @param {{ locale?: "en" | "pl" }} options
|
|
12
|
-
* @returns {string}
|
|
13
|
-
*/
|
|
14
|
-
declare function login_hello(inputs?: {}, options?: {
|
|
15
|
-
locale?: "en" | "pl";
|
|
16
|
-
}): string;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer } from '../runtime.js';
|
|
3
|
-
|
|
4
|
-
const en_login_hello = /** @type {(inputs: {}) => string} */ () => {
|
|
5
|
-
return `Welcome back`
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const pl_login_hello = /** @type {(inputs: {}) => string} */ () => {
|
|
9
|
-
return `Witaj ponownie`
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
|
|
14
|
-
*
|
|
15
|
-
* - Changing this function will be over-written by the next build.
|
|
16
|
-
*
|
|
17
|
-
* - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
|
|
18
|
-
* use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
|
|
19
|
-
*
|
|
20
|
-
* @param {{}} inputs
|
|
21
|
-
* @param {{ locale?: "en" | "pl" }} options
|
|
22
|
-
* @returns {string}
|
|
23
|
-
*/
|
|
24
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
25
|
-
const login_hello = (inputs = {}, options = {}) => {
|
|
26
|
-
if (experimentalMiddlewareLocaleSplitting && isServer === false) {
|
|
27
|
-
return /** @type {any} */ (globalThis).__paraglide_ssr.login_hello(inputs)
|
|
28
|
-
}
|
|
29
|
-
const locale = options.locale ?? getLocale()
|
|
30
|
-
trackMessageCall("login_hello", locale)
|
|
31
|
-
if (locale === "en") return en_login_hello(inputs)
|
|
32
|
-
return pl_login_hello(inputs)
|
|
33
|
-
};
|
|
34
|
-
export { login_hello as "login.hello" }
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export { login_please_login as login.please_login };
|
|
2
|
-
/**
|
|
3
|
-
* This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
|
|
4
|
-
*
|
|
5
|
-
* - Changing this function will be over-written by the next build.
|
|
6
|
-
*
|
|
7
|
-
* - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
|
|
8
|
-
* use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
|
|
9
|
-
*
|
|
10
|
-
* @param {{}} inputs
|
|
11
|
-
* @param {{ locale?: "en" | "pl" }} options
|
|
12
|
-
* @returns {string}
|
|
13
|
-
*/
|
|
14
|
-
declare function login_please_login(inputs?: {}, options?: {
|
|
15
|
-
locale?: "en" | "pl";
|
|
16
|
-
}): string;
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
import { getLocale, trackMessageCall, experimentalMiddlewareLocaleSplitting, isServer } from '../runtime.js';
|
|
3
|
-
|
|
4
|
-
const en_login_please_login = /** @type {(inputs: {}) => string} */ () => {
|
|
5
|
-
return `Login to your account`
|
|
6
|
-
};
|
|
7
|
-
|
|
8
|
-
const pl_login_please_login = /** @type {(inputs: {}) => string} */ () => {
|
|
9
|
-
return `Zaloguj się na swoje konto`
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* This function has been compiled by [Paraglide JS](https://inlang.com/m/gerre34r).
|
|
14
|
-
*
|
|
15
|
-
* - Changing this function will be over-written by the next build.
|
|
16
|
-
*
|
|
17
|
-
* - If you want to change the translations, you can either edit the source files e.g. `en.json`, or
|
|
18
|
-
* use another inlang app like [Fink](https://inlang.com/m/tdozzpar) or the [VSCode extension Sherlock](https://inlang.com/m/r7kp499g).
|
|
19
|
-
*
|
|
20
|
-
* @param {{}} inputs
|
|
21
|
-
* @param {{ locale?: "en" | "pl" }} options
|
|
22
|
-
* @returns {string}
|
|
23
|
-
*/
|
|
24
|
-
/* @__NO_SIDE_EFFECTS__ */
|
|
25
|
-
const login_please_login = (inputs = {}, options = {}) => {
|
|
26
|
-
if (experimentalMiddlewareLocaleSplitting && isServer === false) {
|
|
27
|
-
return /** @type {any} */ (globalThis).__paraglide_ssr.login_please_login(inputs)
|
|
28
|
-
}
|
|
29
|
-
const locale = options.locale ?? getLocale()
|
|
30
|
-
trackMessageCall("login_please_login", locale)
|
|
31
|
-
if (locale === "en") return en_login_please_login(inputs)
|
|
32
|
-
return pl_login_please_login(inputs)
|
|
33
|
-
};
|
|
34
|
-
export { login_please_login as "login.please_login" }
|