Skip to content

Commit 2b7c1da

Browse files
authored
Merge pull request #142 from CIRFMF/release/1.1.31
release/1.1.31
2 parents 53d159c + 2ade10c commit 2b7c1da

19 files changed

Lines changed: 526 additions & 170 deletions

changelog.md

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
# Changelog
22

3-
## [1.1.30]
3+
## [1.1.31]
44

5-
### Added
5+
- Dodano wyświetlenie wszystkich elementow pozycji faktury w korekcie zbiorczej.
6+
- Zmodyfikowano widoczność pola P_15, zawsze wizualizowana.
67

7-
- Dodano `configureFonts()`. Metoda rejestrująca własną czcionkę.
8+
---
89

9-
### Updated
10+
## [1.1.30]
1011

12+
- Dodano `configureFonts()`. Metoda rejestrująca własną czcionkę.
1113
- Ujednolicono separator dzisiętny dla stawki podatku OSS.
1214
- Poprawiono opis dotyczący pola UU_IDZ.
1315
- Ujednolicono nazewnictwo kolumn dla oznaczenia procedury.
@@ -20,13 +22,10 @@
2022

2123
## [1.1.25]
2224

23-
### Added
24-
2525
- Dodano datę nadania numeru KSEF.
26-
27-
### Updated
28-
2926
- Ujednolicono separator dziesiętny dla kwoty podatku akcyzowego.
3027
- usunięto nadmiarową pustą stronę na końcu wizualizacji faktury.
3128
- Ujednolicono separator dziesiętny w tabeli zamówienie w kolumnie ilość.
3229
- Dodano kod waluty w podsumowaniu zamówienia, kwoty zapłaty (zaliczki).
30+
31+
---

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@akmf/ksef-fe-invoice-converter",
3-
"version": "1.1.30",
3+
"version": "1.1.31",
44
"scripts": {
55
"dev": "vite --mode public --config vite.config.ts",
66
"build": "vite build --mode production",

src/lib-public/generators/FA1/Rabat.spec.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,23 @@ describe(generateRabat.name, () => {
8383

8484
expect(PDFFunctions.getContentTable).toHaveBeenCalledWith(
8585
expect.arrayContaining([
86-
expect.objectContaining({ name: 'NrWierszaFa', title: 'Lp.' }),
87-
expect.objectContaining({ name: 'P_7', title: 'Nazwa towaru lub usługi' }),
88-
expect.objectContaining({ name: 'P_8B', title: 'Ilość' }),
89-
expect.objectContaining({ name: 'P_8A', title: 'Miara' }),
86+
expect.objectContaining({
87+
name: 'NrWierszaFa',
88+
title: 'Lp.',
89+
format: FormatTyp.Default,
90+
width: 'auto',
91+
}),
92+
expect.objectContaining({
93+
name: 'P_7',
94+
title: 'Nazwa towaru lub usługi',
95+
format: FormatTyp.Default,
96+
width: '*',
97+
}),
98+
expect.objectContaining({ name: 'P_8B', title: 'Ilość', format: FormatTyp.Default, width: 'auto' }),
99+
expect.objectContaining({ name: 'P_8A', title: 'Miara', format: FormatTyp.Default, width: 'auto' }),
90100
]),
91101
[],
92-
'*'
102+
'auto'
93103
);
94104
});
95105

src/lib-public/generators/FA1/Rabat.ts

Lines changed: 95 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,89 @@ import i18n from 'i18next';
1717
export function generateRabat(invoice: Fa): Content[] {
1818
const faRows: Record<string, FP>[] = getTable(invoice!.FaWiersze?.FaWiersz);
1919
const result: Content[] = [];
20-
const definedHeader: HeaderDefine[] = [
20+
const definedHeaderLp: HeaderDefine[] = [
2121
{ name: 'NrWierszaFa', title: i18n.t('invoice.discount.lp'), format: FormatTyp.Default, width: 'auto' },
22-
{ name: 'P_7', title: i18n.t('invoice.discount.productName'), format: FormatTyp.Default },
23-
{ name: 'P_8B', title: i18n.t('invoice.discount.quantity'), format: FormatTyp.Default },
24-
{ name: 'P_8A', title: i18n.t('invoice.discount.unit'), format: FormatTyp.Default },
2522
];
26-
const tabRabat: TableWithFields = getContentTable<(typeof faRows)[0]>(definedHeader, faRows, '*');
23+
24+
const definedHeader1: HeaderDefine[] = [
25+
{ name: 'P_7', title: i18n.t('invoice.discount.productName'), format: FormatTyp.Default, width: '*' },
26+
{
27+
name: 'P_9A',
28+
title: i18n.t('invoice.discount.netUnitPrice'),
29+
format: FormatTyp.Currency,
30+
width: 'auto',
31+
},
32+
{
33+
name: 'P_9B',
34+
title: i18n.t('invoice.discount.grossUnitPrice'),
35+
format: FormatTyp.Currency,
36+
width: 'auto',
37+
},
38+
{ name: 'P_8B', title: i18n.t('invoice.discount.quantity'), format: FormatTyp.Default, width: 'auto' },
39+
{ name: 'P_8A', title: i18n.t('invoice.discount.unit'), format: FormatTyp.Default, width: 'auto' },
40+
{ name: 'P_10', title: i18n.t('invoice.discount.discount'), format: FormatTyp.Currency, width: 'auto' },
41+
{ name: 'P_12', title: i18n.t('invoice.discount.taxRate'), format: FormatTyp.Default, width: 'auto' },
42+
{
43+
name: 'P_12_XII',
44+
title: i18n.t('invoice.discount.ossTaxRate'),
45+
format: FormatTyp.Percentage,
46+
width: 'auto',
47+
},
48+
{
49+
name: 'P_12_Zal_15',
50+
title: i18n.t('invoice.discount.productMarker'),
51+
format: FormatTyp.Default,
52+
width: 'auto',
53+
},
54+
{
55+
name: 'P_11',
56+
title: i18n.t('invoice.discount.netSalesValue'),
57+
format: FormatTyp.Currency,
58+
width: 'auto',
59+
},
60+
{
61+
name: 'P_11A',
62+
title: i18n.t('invoice.discount.grossSalesValue'),
63+
format: FormatTyp.Currency,
64+
width: 'auto',
65+
},
66+
{
67+
name: 'KursWaluty',
68+
title: i18n.t('invoice.discount.currencyRate'),
69+
format: FormatTyp.Currency6,
70+
width: 'auto',
71+
},
72+
];
73+
74+
const definedHeader2: HeaderDefine[] = [
75+
{ name: 'GTIN', title: i18n.t('invoice.discount.gtin'), format: FormatTyp.Default, width: 'auto' },
76+
{ name: 'PKWiU', title: i18n.t('invoice.discount.pkwiu'), format: FormatTyp.Default, width: 'auto' },
77+
{ name: 'CN', title: i18n.t('invoice.discount.cn'), format: FormatTyp.Default, width: 'auto' },
78+
{ name: 'PKOB', title: i18n.t('invoice.discount.pkob'), format: FormatTyp.Default, width: 'auto' },
79+
{
80+
name: 'KwotaAkcyzy',
81+
title: i18n.t('invoice.discount.exciseTaxAmount'),
82+
format: FormatTyp.Currency,
83+
width: 'auto',
84+
},
85+
{ name: 'GTU', title: i18n.t('invoice.discount.gtu'), format: FormatTyp.Default, width: 'auto' },
86+
{ name: 'Procedura', title: i18n.t('invoice.discount.procedure'), format: FormatTyp.Default, width: '*' },
87+
{ name: 'P_6A', title: i18n.t('invoice.discount.getOrMakeDate'), format: FormatTyp.Date, width: 'auto' },
88+
{ name: 'Indeks', title: i18n.t('invoice.discount.index'), format: FormatTyp.Default, width: 'auto' },
89+
{
90+
name: 'UU_ID',
91+
title: i18n.t('invoice.discount.uuid'),
92+
format: FormatTyp.Default,
93+
width: 'auto',
94+
},
95+
];
96+
97+
let tabRabat: TableWithFields = getContentTable<(typeof faRows)[0]>(
98+
[...definedHeaderLp, ...definedHeader1, ...definedHeader2],
99+
faRows,
100+
'auto'
101+
);
102+
27103
const isNrWierszaFa: boolean = tabRabat.fieldsWithValue.includes('NrWierszaFa');
28104

29105
result.push(
@@ -39,8 +115,21 @@ export function generateRabat(invoice: Fa): Content[] {
39115
''
40116
)
41117
);
42-
if (tabRabat.fieldsWithValue.length > 0 && tabRabat.content) {
118+
119+
if (tabRabat.fieldsWithValue.length < 1) {
120+
result.push([]);
121+
} else if (tabRabat.fieldsWithValue.length <= 8 && tabRabat.content) {
43122
result.push(tabRabat.content);
123+
} else {
124+
tabRabat = getContentTable<(typeof faRows)[0]>([...definedHeaderLp, ...definedHeader1], faRows, '*');
125+
if (tabRabat.content) {
126+
result.push(tabRabat.content);
127+
}
128+
tabRabat = getContentTable<(typeof faRows)[0]>([...definedHeaderLp, ...definedHeader2], faRows, '*');
129+
if (tabRabat.content && tabRabat.fieldsWithValue.length > 1) {
130+
result.push('\n');
131+
result.push(tabRabat.content);
132+
}
44133
}
45134

46135
return createSection(result, true);

src/lib-public/generators/FA1/Wiersze.spec.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ vi.mock('../../../shared/PDF-functions', () => ({
1313
getContentTable: vi.fn(),
1414
getTable: vi.fn(),
1515
getValue: vi.fn(),
16+
hasValue: vi.fn((v) => v?._text || v),
1617
getTStawkaPodatku: vi.fn(),
1718
getDifferentColumnsValue: vi.fn(),
1819
}));
@@ -78,7 +79,7 @@ describe(generateWiersze.name, () => {
7879
content: null,
7980
fieldsWithValue: [],
8081
});
81-
vi.mocked(PDFFunctions.getValue).mockReturnValue('0');
82+
vi.mocked(PDFFunctions.getValue).mockReturnValue(undefined);
8283
vi.mocked(PDFFunctions.getDifferentColumnsValue).mockReturnValue([]);
8384

8485
const result = generateWiersze(mockFaVat);
@@ -383,4 +384,4 @@ describe(generateWiersze.name, () => {
383384
});
384385
});
385386
});
386-
});
387+
});

src/lib-public/generators/FA1/Wiersze.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
getTable,
1010
getTStawkaPodatku,
1111
getValue,
12+
hasValue,
1213
} from '../../../shared/PDF-functions';
1314
import { HeaderDefine } from '../../../shared/types/pdf-types';
1415
import { Procedura, TRodzajFaktury } from '../../../shared/consts/FA.const';
@@ -36,7 +37,6 @@ export function generateWiersze(faVat: Fa): Content {
3637
{ name: 'NrWierszaFa', title: i18n.t('invoice.rows.lp'), format: FormatTyp.Default, width: 'auto' },
3738
];
3839
const definedHeader1: HeaderDefine[] = [
39-
4040
{ name: 'P_7', title: i18n.t('invoice.rows.productName'), format: FormatTyp.Default, width: '*' },
4141
{ name: 'P_9A', title: i18n.t('invoice.rows.netUnitPrice'), format: FormatTyp.Currency, width: 'auto' },
4242
{ name: 'P_9B', title: i18n.t('invoice.rows.grossUnitPrice'), format: FormatTyp.Currency, width: 'auto' },
@@ -100,7 +100,7 @@ export function generateWiersze(faVat: Fa): Content {
100100
{ name: 'GTU', title: i18n.t('invoice.rows.gtu'), format: FormatTyp.Default, width: 'auto' },
101101
{
102102
name: 'Procedura',
103-
title: i18n.t('invoice.rows.procedureMarkings'),
103+
title: i18n.t('invoice.rows.procedure'),
104104
format: FormatTyp.Default,
105105
width: '*',
106106
},
@@ -195,8 +195,13 @@ export function generateWiersze(faVat: Fa): Content {
195195
table.push(content.content);
196196
}
197197
}
198-
if (table.length < 1) {
199-
return [];
198+
if (table.length > 0) {
199+
return createSection([...createHeader(i18n.t('invoice.rows.header')), ceny, ...table, ...opis], true);
200200
}
201-
return createSection([...createHeader(i18n.t('invoice.rows.header')), ceny, ...table, ...opis], true);
201+
202+
if (hasValue(p_15)) {
203+
return createSection([opis], true);
204+
}
205+
206+
return [];
202207
}

src/lib-public/generators/FA2/Rabat.spec.ts

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,23 @@ describe(generateRabat.name, () => {
8383

8484
expect(PDFFunctions.getContentTable).toHaveBeenCalledWith(
8585
expect.arrayContaining([
86-
expect.objectContaining({ name: 'NrWierszaFa', title: 'Lp.' }),
87-
expect.objectContaining({ name: 'P_7', title: 'Nazwa towaru lub usługi' }),
88-
expect.objectContaining({ name: 'P_8B', title: 'Ilość' }),
89-
expect.objectContaining({ name: 'P_8A', title: 'Miara' }),
86+
expect.objectContaining({
87+
name: 'NrWierszaFa',
88+
title: 'Lp.',
89+
format: FormatTyp.Default,
90+
width: 'auto',
91+
}),
92+
expect.objectContaining({
93+
name: 'P_7',
94+
title: 'Nazwa towaru lub usługi',
95+
format: FormatTyp.Default,
96+
width: '*',
97+
}),
98+
expect.objectContaining({ name: 'P_8B', title: 'Ilość', format: FormatTyp.Default, width: 'auto' }),
99+
expect.objectContaining({ name: 'P_8A', title: 'Miara', format: FormatTyp.Default, width: 'auto' }),
90100
]),
91101
[],
92-
'*'
102+
'auto'
93103
);
94104
});
95105

0 commit comments

Comments
 (0)