makeapps-transformer 1.0.0
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/.vscode/settings.json +3 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +4 -0
- package/dist/lib-public/FA3-generator.js +50 -0
- package/dist/lib-public/enums/invoice.enums.js +9 -0
- package/dist/lib-public/generate-invoice.js +21 -0
- package/dist/lib-public/generators/FA2/Adnotacje.js +174 -0
- package/dist/lib-public/generators/FA2/Adres.js +23 -0
- package/dist/lib-public/generators/FA2/DodatkoweInformacje.js +69 -0
- package/dist/lib-public/generators/FA2/Platnosc.js +91 -0
- package/dist/lib-public/generators/FA2/Podmiot1.js +32 -0
- package/dist/lib-public/generators/FA2/Podmiot1Podmiot1K.js +63 -0
- package/dist/lib-public/generators/FA2/Podmiot2.js +28 -0
- package/dist/lib-public/generators/FA2/Podmiot2Podmiot2k.js +62 -0
- package/dist/lib-public/generators/FA2/Podmiot3.js +37 -0
- package/dist/lib-public/generators/FA2/Podmiot3Podmiot2k.js +57 -0
- package/dist/lib-public/generators/FA2/PodmiotAdres.js +14 -0
- package/dist/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.js +10 -0
- package/dist/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.js +34 -0
- package/dist/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.js +44 -0
- package/dist/lib-public/generators/FA2/PodmiotDaneKontaktowe.js +13 -0
- package/dist/lib-public/generators/FA2/PodmiotUpowazniony.js +29 -0
- package/dist/lib-public/generators/FA2/PodmiotUpowaznionyDaneKontaktowe.js +28 -0
- package/dist/lib-public/generators/FA2/Podmioty.js +92 -0
- package/dist/lib-public/generators/FA2/PodsumowanieStawekPodatkuVat.js +260 -0
- package/dist/lib-public/generators/FA2/Przewoznik.js +17 -0
- package/dist/lib-public/generators/FA2/Rabat.js +57 -0
- package/dist/lib-public/generators/FA2/RachunekBankowy.js +54 -0
- package/dist/lib-public/generators/FA2/Szczegoly.js +138 -0
- package/dist/lib-public/generators/FA2/Transport.js +78 -0
- package/dist/lib-public/generators/FA2/WarunkiTransakcji.js +68 -0
- package/dist/lib-public/generators/FA2/Wiersze.js +140 -0
- package/dist/lib-public/generators/FA2/Zamowienie.js +148 -0
- package/dist/lib-public/generators/FA3/Adnotacje.js +185 -0
- package/dist/lib-public/generators/FA3/Adres.js +23 -0
- package/dist/lib-public/generators/FA3/DodatkoweInformacje.js +69 -0
- package/dist/lib-public/generators/FA3/Platnosc.js +105 -0
- package/dist/lib-public/generators/FA3/Podmiot1.js +32 -0
- package/dist/lib-public/generators/FA3/Podmiot1Podmiot1K.js +67 -0
- package/dist/lib-public/generators/FA3/Podmiot2.js +34 -0
- package/dist/lib-public/generators/FA3/Podmiot2Podmiot2k.js +49 -0
- package/dist/lib-public/generators/FA3/Podmiot3.js +37 -0
- package/dist/lib-public/generators/FA3/Podmiot3Podmiot2k.js +57 -0
- package/dist/lib-public/generators/FA3/PodmiotAdres.js +14 -0
- package/dist/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.js +10 -0
- package/dist/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.js +34 -0
- package/dist/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.js +44 -0
- package/dist/lib-public/generators/FA3/PodmiotDaneKontaktowe.js +13 -0
- package/dist/lib-public/generators/FA3/PodmiotUpowazniony.js +29 -0
- package/dist/lib-public/generators/FA3/PodmiotUpowaznionyDaneKontaktowe.js +28 -0
- package/dist/lib-public/generators/FA3/Podmioty.js +92 -0
- package/dist/lib-public/generators/FA3/PodsumowanieStawekPodatkuVat.js +264 -0
- package/dist/lib-public/generators/FA3/Przewoznik.js +17 -0
- package/dist/lib-public/generators/FA3/Rabat.js +57 -0
- package/dist/lib-public/generators/FA3/RachunekBankowy.js +58 -0
- package/dist/lib-public/generators/FA3/Szczegoly.js +138 -0
- package/dist/lib-public/generators/FA3/Transport.js +78 -0
- package/dist/lib-public/generators/FA3/WarunkiTransakcji.js +68 -0
- package/dist/lib-public/generators/FA3/Wiersze.js +140 -0
- package/dist/lib-public/generators/FA3/Zamowienie.js +148 -0
- package/dist/lib-public/generators/common/DaneFaKorygowanej.js +74 -0
- package/dist/lib-public/generators/common/Naglowek.js +100 -0
- package/dist/lib-public/generators/common/Rozliczenie.js +120 -0
- package/dist/lib-public/generators/common/Stopka.js +113 -0
- package/dist/lib-public/generators/common/Wiersze.js +28 -0
- package/dist/lib-public/generators/common/Zalaczniki.js +182 -0
- package/dist/lib-public/index.js +5 -0
- package/dist/lib-public/types/common.types.js +2 -0
- package/dist/lib-public/types/fa1-additional-types.js +2 -0
- package/dist/lib-public/types/fa1.types.js +2 -0
- package/dist/lib-public/types/fa2-additional-types.js +2 -0
- package/dist/lib-public/types/fa2.types.js +2 -0
- package/dist/lib-public/types/fa2Podmiot3DaneIdentyfikacyjne.types.js +2 -0
- package/dist/lib-public/types/fa3.types.js +2 -0
- package/dist/lib-public/types/fa3Podmiot3DaneIdentyfikacyjne.types.js +2 -0
- package/dist/lib-public/types/tax-summary.types.js +2 -0
- package/dist/lib-public/types/upo-v4_2.types.js +2 -0
- package/dist/shared/PDF-functions.js +429 -0
- package/dist/shared/XML-parser.js +21 -0
- package/dist/shared/consts/const.js +390 -0
- package/dist/shared/enums/common.enum.js +48 -0
- package/dist/shared/enums/invoice.enums.js +13 -0
- package/dist/shared/generators/common/functions.js +95 -0
- package/dist/shared/types/additional-data.types.js +2 -0
- package/dist/shared/types/pdf-types.js +2 -0
- package/dist/shared/types/universal.types.js +2 -0
- package/package.json +21 -0
- package/src/index.d.ts +7 -0
- package/src/index.ts +2 -0
- package/src/lib-public/FA3-generator.ts +56 -0
- package/src/lib-public/enums/invoice.enums.ts +5 -0
- package/src/lib-public/generate-invoice.ts +32 -0
- package/src/lib-public/generators/FA2/Adnotacje.ts +206 -0
- package/src/lib-public/generators/FA2/Adres.ts +20 -0
- package/src/lib-public/generators/FA2/DodatkoweInformacje.ts +97 -0
- package/src/lib-public/generators/FA2/Platnosc.ts +131 -0
- package/src/lib-public/generators/FA2/Podmiot1.ts +40 -0
- package/src/lib-public/generators/FA2/Podmiot1Podmiot1K.ts +73 -0
- package/src/lib-public/generators/FA2/Podmiot2.ts +42 -0
- package/src/lib-public/generators/FA2/Podmiot2Podmiot2k.ts +74 -0
- package/src/lib-public/generators/FA2/Podmiot3.ts +50 -0
- package/src/lib-public/generators/FA2/Podmiot3Podmiot2k.ts +77 -0
- package/src/lib-public/generators/FA2/PodmiotAdres.ts +19 -0
- package/src/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.ts +10 -0
- package/src/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.ts +37 -0
- package/src/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.ts +44 -0
- package/src/lib-public/generators/FA2/PodmiotDaneKontaktowe.ts +12 -0
- package/src/lib-public/generators/FA2/PodmiotUpowazniony.ts +31 -0
- package/src/lib-public/generators/FA2/PodmiotUpowaznionyDaneKontaktowe.ts +34 -0
- package/src/lib-public/generators/FA2/Podmioty.ts +96 -0
- package/src/lib-public/generators/FA2/PodsumowanieStawekPodatkuVat.ts +294 -0
- package/src/lib-public/generators/FA2/Przewoznik.ts +21 -0
- package/src/lib-public/generators/FA2/Rabat.ts +47 -0
- package/src/lib-public/generators/FA2/RachunekBankowy.ts +60 -0
- package/src/lib-public/generators/FA2/Szczegoly.ts +187 -0
- package/src/lib-public/generators/FA2/Transport.ts +108 -0
- package/src/lib-public/generators/FA2/WarunkiTransakcji.ts +105 -0
- package/src/lib-public/generators/FA2/Wiersze.ts +126 -0
- package/src/lib-public/generators/FA2/Zamowienie.ts +144 -0
- package/src/lib-public/generators/FA3/Adnotacje.ts +249 -0
- package/src/lib-public/generators/FA3/Adres.ts +20 -0
- package/src/lib-public/generators/FA3/DodatkoweInformacje.ts +92 -0
- package/src/lib-public/generators/FA3/Platnosc.ts +144 -0
- package/src/lib-public/generators/FA3/Podmiot1.ts +40 -0
- package/src/lib-public/generators/FA3/Podmiot1Podmiot1K.ts +78 -0
- package/src/lib-public/generators/FA3/Podmiot2.ts +55 -0
- package/src/lib-public/generators/FA3/Podmiot2Podmiot2k.ts +59 -0
- package/src/lib-public/generators/FA3/Podmiot3.ts +50 -0
- package/src/lib-public/generators/FA3/Podmiot3Podmiot2k.ts +78 -0
- package/src/lib-public/generators/FA3/PodmiotAdres.ts +19 -0
- package/src/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.ts +10 -0
- package/src/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.ts +37 -0
- package/src/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.ts +44 -0
- package/src/lib-public/generators/FA3/PodmiotDaneKontaktowe.ts +12 -0
- package/src/lib-public/generators/FA3/PodmiotUpowazniony.ts +31 -0
- package/src/lib-public/generators/FA3/PodmiotUpowaznionyDaneKontaktowe.ts +34 -0
- package/src/lib-public/generators/FA3/Podmioty.ts +96 -0
- package/src/lib-public/generators/FA3/PodsumowanieStawekPodatkuVat.ts +298 -0
- package/src/lib-public/generators/FA3/Przewoznik.ts +24 -0
- package/src/lib-public/generators/FA3/Rabat.ts +45 -0
- package/src/lib-public/generators/FA3/RachunekBankowy.ts +60 -0
- package/src/lib-public/generators/FA3/Szczegoly.ts +184 -0
- package/src/lib-public/generators/FA3/Transport.ts +108 -0
- package/src/lib-public/generators/FA3/WarunkiTransakcji.ts +100 -0
- package/src/lib-public/generators/FA3/Wiersze.ts +126 -0
- package/src/lib-public/generators/FA3/Zamowienie.ts +143 -0
- package/src/lib-public/generators/common/DaneFaKorygowanej.ts +91 -0
- package/src/lib-public/generators/common/Naglowek.ts +84 -0
- package/src/lib-public/generators/common/Rozliczenie.ts +119 -0
- package/src/lib-public/generators/common/Stopka.ts +161 -0
- package/src/lib-public/generators/common/Wiersze.ts +32 -0
- package/src/lib-public/generators/common/Zalaczniki.ts +232 -0
- package/src/lib-public/index.ts +3 -0
- package/src/lib-public/types/common.types.ts +29 -0
- package/src/lib-public/types/fa1-additional-types.ts +26 -0
- package/src/lib-public/types/fa1.types.ts +299 -0
- package/src/lib-public/types/fa2-additional-types.ts +30 -0
- package/src/lib-public/types/fa2.types.ts +307 -0
- package/src/lib-public/types/fa2Podmiot3DaneIdentyfikacyjne.types.ts +12 -0
- package/src/lib-public/types/fa3.types.ts +384 -0
- package/src/lib-public/types/fa3Podmiot3DaneIdentyfikacyjne.types.ts +12 -0
- package/src/lib-public/types/tax-summary.types.ts +8 -0
- package/src/lib-public/types/upo-v4_2.types.ts +68 -0
- package/src/shared/PDF-functions.ts +466 -0
- package/src/shared/XML-parser.ts +42 -0
- package/src/shared/consts/const.ts +406 -0
- package/src/shared/enums/common.enum.ts +45 -0
- package/src/shared/enums/invoice.enums.ts +9 -0
- package/src/shared/generators/common/functions.ts +101 -0
- package/src/shared/types/additional-data.types.ts +15 -0
- package/src/shared/types/pdf-types.ts +58 -0
- package/src/shared/types/universal.types.ts +16 -0
- package/transformer.code-workspace +45 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
import { Content, ContentTable, TableCell } from 'pdfmake/interfaces';
|
|
2
|
+
import {
|
|
3
|
+
createHeader,
|
|
4
|
+
createLabelText,
|
|
5
|
+
formatText,
|
|
6
|
+
getTable,
|
|
7
|
+
hasValue,
|
|
8
|
+
verticalSpacing,
|
|
9
|
+
} from '../../../shared/PDF-functions';
|
|
10
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
11
|
+
import { Adnotacje, NoweSrodkiTransportu } from '../../types/fa3.types';
|
|
12
|
+
|
|
13
|
+
export function generateAdnotacje(adnotacje?: Adnotacje): Content[] {
|
|
14
|
+
const result: Content[] = [];
|
|
15
|
+
const firstColumn: Content[] = [];
|
|
16
|
+
const secondColumn: Content[] = [];
|
|
17
|
+
|
|
18
|
+
if (adnotacje) {
|
|
19
|
+
const zwolnienie = adnotacje.Zwolnienie;
|
|
20
|
+
|
|
21
|
+
if (zwolnienie?.P_19?._text === '1') {
|
|
22
|
+
addToColumn(
|
|
23
|
+
firstColumn,
|
|
24
|
+
secondColumn,
|
|
25
|
+
{
|
|
26
|
+
text: 'Dostawa towarów lub świadczenie usług zwolnionych od podatku na podstawie art. 43 ust. 1, art. 113 ust. 1 i 9 albo przepisów wydanych na podstawie art. 82 ust. 3 lub na podstawie innych przepisów',
|
|
27
|
+
},
|
|
28
|
+
true
|
|
29
|
+
);
|
|
30
|
+
if (zwolnienie.P_19A?._text) {
|
|
31
|
+
addToColumn(
|
|
32
|
+
firstColumn,
|
|
33
|
+
secondColumn,
|
|
34
|
+
createLabelText(
|
|
35
|
+
'Podstawa zwolnienia od podatku: ',
|
|
36
|
+
'Przepis ustawy albo aktu wydanego na podstawie ustawy, na podstawie którego podatnik stosuje zwolnienie od podatku'
|
|
37
|
+
),
|
|
38
|
+
true
|
|
39
|
+
);
|
|
40
|
+
addToColumn(
|
|
41
|
+
firstColumn,
|
|
42
|
+
secondColumn,
|
|
43
|
+
createLabelText('Przepis ustawy albo aktu wydanego na podstawie ustawy: ', zwolnienie.P_19A._text),
|
|
44
|
+
true
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
if (zwolnienie.P_19B?._text) {
|
|
48
|
+
addToColumn(
|
|
49
|
+
firstColumn,
|
|
50
|
+
secondColumn,
|
|
51
|
+
createLabelText(
|
|
52
|
+
'Podstawa zwolnienia od podatku: ',
|
|
53
|
+
'Przepis dyrektywy 2006/112/WE, który zwalnia od podatku taką dostawę towarów lub takie świadczenie usług'
|
|
54
|
+
),
|
|
55
|
+
true
|
|
56
|
+
);
|
|
57
|
+
addToColumn(
|
|
58
|
+
firstColumn,
|
|
59
|
+
secondColumn,
|
|
60
|
+
createLabelText('Przepis dyrektywy: ', zwolnienie.P_19B._text),
|
|
61
|
+
true
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (zwolnienie.P_19C?._text) {
|
|
65
|
+
addToColumn(
|
|
66
|
+
firstColumn,
|
|
67
|
+
secondColumn,
|
|
68
|
+
createLabelText(
|
|
69
|
+
'Podstawa zwolnienia od podatku: ',
|
|
70
|
+
'Inna podstawa prawna wskazującą na to, że dostawa towarów lub świadczenie usług korzysta ze zwolnienia'
|
|
71
|
+
),
|
|
72
|
+
true
|
|
73
|
+
);
|
|
74
|
+
addToColumn(
|
|
75
|
+
firstColumn,
|
|
76
|
+
secondColumn,
|
|
77
|
+
createLabelText('Inna podstawa prawna: ', zwolnienie.P_19C._text),
|
|
78
|
+
true
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (
|
|
84
|
+
adnotacje.NoweSrodkiTransportu?.P_42_5?._text === '1' ||
|
|
85
|
+
adnotacje.NoweSrodkiTransportu?.P_42_5?._text === '2'
|
|
86
|
+
) {
|
|
87
|
+
let obowiazekVAT: Content[] = [];
|
|
88
|
+
let value = ' ';
|
|
89
|
+
|
|
90
|
+
if (adnotacje.NoweSrodkiTransportu.P_42_5?._text === '1') {
|
|
91
|
+
value = 'Istnieje obowiązek wystawienia dokumentu VAT-22';
|
|
92
|
+
} else if (adnotacje.NoweSrodkiTransportu.P_42_5?._text === '2') {
|
|
93
|
+
value = 'Nie istnieje obowiązek wystawienia dokumentu VAT-22';
|
|
94
|
+
}
|
|
95
|
+
obowiazekVAT = [
|
|
96
|
+
...createLabelText('Wewnątrzwspólnotowe dostawy nowych środków transportu: ', value ?? ''),
|
|
97
|
+
];
|
|
98
|
+
if (obowiazekVAT) {
|
|
99
|
+
addToColumn(firstColumn, secondColumn, obowiazekVAT, true);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
if (adnotacje.P_18A?._text === '1') {
|
|
104
|
+
addToColumn(firstColumn, secondColumn, { text: 'Mechanizm podzielonej płatności' });
|
|
105
|
+
}
|
|
106
|
+
if (adnotacje.P_16?._text === '1') {
|
|
107
|
+
addToColumn(firstColumn, secondColumn, { text: 'Metoda kasowa' });
|
|
108
|
+
}
|
|
109
|
+
if (adnotacje.P_18?._text === '1') {
|
|
110
|
+
addToColumn(firstColumn, secondColumn, { text: 'Odwrotne obciążenie' });
|
|
111
|
+
}
|
|
112
|
+
if (adnotacje.P_23?._text === '1') {
|
|
113
|
+
addToColumn(firstColumn, secondColumn, { text: 'Procedura trójstronna uproszczona' });
|
|
114
|
+
}
|
|
115
|
+
if (adnotacje.PMarzy?.P_PMarzy?._text === '1') {
|
|
116
|
+
let valueMarzy = '';
|
|
117
|
+
|
|
118
|
+
if (adnotacje.PMarzy.P_PMarzy_3_1?._text === '1') {
|
|
119
|
+
valueMarzy = 'towary używane';
|
|
120
|
+
} else if (adnotacje.PMarzy.P_PMarzy_3_2?._text === '1') {
|
|
121
|
+
valueMarzy = 'dzieła sztuki';
|
|
122
|
+
} else if (adnotacje.PMarzy.P_PMarzy_2?._text === '1') {
|
|
123
|
+
valueMarzy = 'biura podróży';
|
|
124
|
+
} else if (adnotacje.PMarzy.P_PMarzy_3_3?._text === '1') {
|
|
125
|
+
valueMarzy = 'przedmioty kolekcjonerskie i antyki';
|
|
126
|
+
}
|
|
127
|
+
addToColumn(firstColumn, secondColumn, createLabelText('Procedura marży: ', valueMarzy));
|
|
128
|
+
}
|
|
129
|
+
if (adnotacje.P_17?._text === '1') {
|
|
130
|
+
addToColumn(firstColumn, secondColumn, { text: 'Samofakturowanie' });
|
|
131
|
+
}
|
|
132
|
+
if (firstColumn.length || secondColumn.length) {
|
|
133
|
+
result.push({ columns: [firstColumn, secondColumn], columnGap: 20 });
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (result.length) {
|
|
137
|
+
result.unshift(verticalSpacing(1));
|
|
138
|
+
result.unshift(createHeader('Adnotacje'));
|
|
139
|
+
result.unshift(verticalSpacing(1));
|
|
140
|
+
result.push(verticalSpacing(1));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (
|
|
144
|
+
adnotacje.NoweSrodkiTransportu?.P_42_5?._text === '1' ||
|
|
145
|
+
adnotacje.NoweSrodkiTransportu?.P_42_5?._text === '2'
|
|
146
|
+
) {
|
|
147
|
+
result.push(generateDostawy(adnotacje.NoweSrodkiTransportu));
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return result;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function generateDostawy(noweSrodkiTransportu: NoweSrodkiTransportu): Content[] {
|
|
154
|
+
const nowySrodekTransportu = getTable(noweSrodkiTransportu.NowySrodekTransportu);
|
|
155
|
+
let tableBody: TableCell[] = [];
|
|
156
|
+
const table: ContentTable = {
|
|
157
|
+
table: {
|
|
158
|
+
headerRows: 1,
|
|
159
|
+
widths: [100, '*'],
|
|
160
|
+
body: [] as TableCell[][],
|
|
161
|
+
},
|
|
162
|
+
layout: {
|
|
163
|
+
hLineWidth: () => 1,
|
|
164
|
+
hLineColor: () => '#BABABA',
|
|
165
|
+
vLineWidth: () => 1,
|
|
166
|
+
vLineColor: () => '#BABABA',
|
|
167
|
+
},
|
|
168
|
+
marginTop: 4,
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
if (nowySrodekTransportu?.length) {
|
|
172
|
+
const definedHeader: Content[] = [
|
|
173
|
+
{ text: 'Data dopuszczenia do użytku', style: FormatTyp.GrayBoldTitle },
|
|
174
|
+
{ text: 'Opis', style: FormatTyp.GrayBoldTitle },
|
|
175
|
+
];
|
|
176
|
+
|
|
177
|
+
tableBody = nowySrodekTransportu.map((item) => {
|
|
178
|
+
const value: string[] = [];
|
|
179
|
+
const anyP22B =
|
|
180
|
+
hasValue(item.P_22B) ||
|
|
181
|
+
hasValue(item.P_22BT) ||
|
|
182
|
+
hasValue(item.P_22B1) ||
|
|
183
|
+
hasValue(item.P_22B2) ||
|
|
184
|
+
hasValue(item.P_22B3) ||
|
|
185
|
+
hasValue(item.P_22B4);
|
|
186
|
+
const anyP22C = hasValue(item.P_22C) || hasValue(item.P_22C1);
|
|
187
|
+
const anyP22D = hasValue(item.P_22D) || hasValue(item.P_22D1);
|
|
188
|
+
const anyP22N =
|
|
189
|
+
hasValue(item.P_22B1) || hasValue(item.P_22B2) || hasValue(item.P_22B3) || hasValue(item.P_22B4);
|
|
190
|
+
|
|
191
|
+
if (item.P_NrWierszaNST?._text) {
|
|
192
|
+
value.push(item.P_NrWierszaNST._text);
|
|
193
|
+
}
|
|
194
|
+
if (anyP22B) {
|
|
195
|
+
value.push('Dostawa dotyczy pojazdów lądowych, o których mowa w art. 2 pkt 10 lit. a ustawy');
|
|
196
|
+
} else if (anyP22C) {
|
|
197
|
+
value.push('Dostawa dotyczy jednostek pływających, o których mowa w art. 2 pkt 10 lit. b ustawy');
|
|
198
|
+
} else if (anyP22D) {
|
|
199
|
+
value.push('Dostawa dotyczy statków powietrznych, o których mowa w art. 2 pkt 10 lit. c ustawy');
|
|
200
|
+
}
|
|
201
|
+
if (item.DetailsString?._text) {
|
|
202
|
+
value.push(item.DetailsString._text);
|
|
203
|
+
}
|
|
204
|
+
if (anyP22B || anyP22C || anyP22D) {
|
|
205
|
+
value.push(item.P_22B?._text ?? item.P_22C?._text ?? item.P_22D?._text ?? '');
|
|
206
|
+
}
|
|
207
|
+
if (item.P_22C1?._text) {
|
|
208
|
+
value.push(`Numer kadłuba nowego środka transportu: ${item.P_22C1._text}`);
|
|
209
|
+
}
|
|
210
|
+
if (item.P_22D1?._text) {
|
|
211
|
+
value.push(`Numer fabryczny nowego środka transportu: ${item.P_22D1._text}`);
|
|
212
|
+
}
|
|
213
|
+
if (anyP22N) {
|
|
214
|
+
if (item.P_22B1?._text) {
|
|
215
|
+
value.push(`Numer VIN: ${item.P_22B1._text}`);
|
|
216
|
+
}
|
|
217
|
+
if (item.P_22B2?._text) {
|
|
218
|
+
value.push(`Numer nadwozia: ${item.P_22B2._text}`);
|
|
219
|
+
}
|
|
220
|
+
if (item.P_22B3?._text) {
|
|
221
|
+
value.push(`Numer podwozia: ${item.P_22B3._text}`);
|
|
222
|
+
}
|
|
223
|
+
if (item.P_22B4?._text) {
|
|
224
|
+
value.push(`Numer ramy: ${item.P_22B4._text}`);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
if (item.P_22BT?._text) {
|
|
228
|
+
value.push(item.P_22BT._text);
|
|
229
|
+
}
|
|
230
|
+
return [formatText(item.P_22A?._text), { text: value.join('\n') }];
|
|
231
|
+
});
|
|
232
|
+
table.table.body = [[...definedHeader], ...tableBody] as TableCell[][];
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return tableBody.length ? [table, verticalSpacing(1)] : [];
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function addToColumn(
|
|
239
|
+
firstColumn: Content[],
|
|
240
|
+
secondColumn: Content[],
|
|
241
|
+
content: Content,
|
|
242
|
+
isFirstColumn?: boolean
|
|
243
|
+
): void {
|
|
244
|
+
if (firstColumn.length > secondColumn.length && isFirstColumn) {
|
|
245
|
+
secondColumn.push(content);
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
firstColumn.push(content);
|
|
249
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import { createLabelText, formatText, getKraj } from '../../../shared/PDF-functions';
|
|
3
|
+
import { Adres } from '../../types/fa3.types';
|
|
4
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
5
|
+
|
|
6
|
+
export function generateAdres(adres: Adres): Content[] {
|
|
7
|
+
const result: Content[] = [];
|
|
8
|
+
|
|
9
|
+
if (adres?.AdresL1) {
|
|
10
|
+
result.push(formatText(adres.AdresL1._text, FormatTyp.Value));
|
|
11
|
+
}
|
|
12
|
+
if (adres?.AdresL2) {
|
|
13
|
+
result.push(formatText(adres.AdresL2._text, FormatTyp.Value));
|
|
14
|
+
}
|
|
15
|
+
if (adres?.KodKraju) {
|
|
16
|
+
result.push(formatText(getKraj(adres.KodKraju._text ?? ''), FormatTyp.Value));
|
|
17
|
+
}
|
|
18
|
+
result.push(...createLabelText('GLN: ', adres.GLN));
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import {
|
|
3
|
+
createHeader,
|
|
4
|
+
createSection,
|
|
5
|
+
createSubHeader,
|
|
6
|
+
formatText,
|
|
7
|
+
getContentTable,
|
|
8
|
+
getTable,
|
|
9
|
+
getValue,
|
|
10
|
+
} from '../../../shared/PDF-functions';
|
|
11
|
+
import { HeaderDefine } from '../../../shared/types/pdf-types';
|
|
12
|
+
import { DodatkowyOpi, Fa } from '../../types/fa3.types';
|
|
13
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
14
|
+
|
|
15
|
+
export function generateDodatkoweInformacje(faVat: Fa): Content[] {
|
|
16
|
+
const tpLabel1: Content[] = [];
|
|
17
|
+
const tpLabel2: Content[] = [];
|
|
18
|
+
|
|
19
|
+
if (getValue(faVat.TP) === '1') {
|
|
20
|
+
tpLabel1.push(
|
|
21
|
+
formatText('- Istniejące powiązania między nabywcą a dokonującym dostawy towarów lub usługodawcą')
|
|
22
|
+
);
|
|
23
|
+
tpLabel2.push(formatText('- Faktura, o której mowa w art. 109 ust. 3d ustawy'));
|
|
24
|
+
}
|
|
25
|
+
const zwrotAkcyzyLabel: Content[] = [];
|
|
26
|
+
|
|
27
|
+
if (getValue(faVat.ZwrotAkcyzy) === '1') {
|
|
28
|
+
zwrotAkcyzyLabel.push(
|
|
29
|
+
formatText(
|
|
30
|
+
'- Informacja dodatkowa związana ze zwrotem podatku akcyzowego zawartego w cenie oleju napędowego'
|
|
31
|
+
)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const labels = [tpLabel1, tpLabel2, zwrotAkcyzyLabel].filter((el) => el.length > 0);
|
|
36
|
+
const table: Content[] = [
|
|
37
|
+
...createHeader('Dodatkowe informacje'),
|
|
38
|
+
...labels,
|
|
39
|
+
...generateDodatkowyOpis(faVat.DodatkowyOpis),
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
return table.length > 1 ? createSection(table, true) : [];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function generateDodatkowyOpis(fakturaZaliczkowaData: DodatkowyOpi[] | undefined): Content[] {
|
|
46
|
+
if (!fakturaZaliczkowaData) {
|
|
47
|
+
return [];
|
|
48
|
+
}
|
|
49
|
+
const fakturaZaliczkowa = getTable(fakturaZaliczkowaData)?.map((item, index) => ({
|
|
50
|
+
...item,
|
|
51
|
+
lp: { _text: index + 1 },
|
|
52
|
+
}));
|
|
53
|
+
const table: Content[] = createSubHeader('Dodatkowy opis');
|
|
54
|
+
|
|
55
|
+
const fakturaZaliczkowaHeader: HeaderDefine[] = [
|
|
56
|
+
{
|
|
57
|
+
name: 'lp',
|
|
58
|
+
title: 'Lp.',
|
|
59
|
+
format: FormatTyp.Default,
|
|
60
|
+
width: 'auto',
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'NrWiersza',
|
|
64
|
+
title: 'Numer wiersza',
|
|
65
|
+
format: FormatTyp.Default,
|
|
66
|
+
width: 'auto',
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: 'Klucz',
|
|
70
|
+
title: 'Rodzaj informacji',
|
|
71
|
+
format: FormatTyp.Default,
|
|
72
|
+
width: 'auto',
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: 'Wartosc',
|
|
76
|
+
title: 'Treść informacji',
|
|
77
|
+
format: FormatTyp.Default,
|
|
78
|
+
width: '*',
|
|
79
|
+
},
|
|
80
|
+
];
|
|
81
|
+
const tableFakturaZaliczkowa = getContentTable<(typeof fakturaZaliczkowa)[0]>(
|
|
82
|
+
fakturaZaliczkowaHeader,
|
|
83
|
+
fakturaZaliczkowa,
|
|
84
|
+
'*',
|
|
85
|
+
[0, 0, 0, 0]
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
if (tableFakturaZaliczkowa.content) {
|
|
89
|
+
table.push(tableFakturaZaliczkowa.content);
|
|
90
|
+
}
|
|
91
|
+
return table;
|
|
92
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { Content, ContentText } from 'pdfmake/interfaces';
|
|
2
|
+
import {
|
|
3
|
+
createHeader,
|
|
4
|
+
createLabelText,
|
|
5
|
+
formatText,
|
|
6
|
+
generateLine,
|
|
7
|
+
generateTwoColumns,
|
|
8
|
+
getContentTable,
|
|
9
|
+
getTable,
|
|
10
|
+
getValue,
|
|
11
|
+
hasValue,
|
|
12
|
+
} from '../../../shared/PDF-functions';
|
|
13
|
+
import { HeaderDefine } from '../../../shared/types/pdf-types';
|
|
14
|
+
import { Platnosc } from '../../types/fa3.types';
|
|
15
|
+
import { getFormaPlatnosciString } from '../../../shared/generators/common/functions';
|
|
16
|
+
import { generujRachunekBankowy } from './RachunekBankowy';
|
|
17
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
18
|
+
|
|
19
|
+
export function generatePlatnosc(platnosc: Platnosc | undefined): Content {
|
|
20
|
+
if (!platnosc) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
const terminPlatnosci = getTable(platnosc.TerminPlatnosci);
|
|
24
|
+
|
|
25
|
+
const zaplataCzesciowaHeader: HeaderDefine[] = [
|
|
26
|
+
{
|
|
27
|
+
name: 'Termin',
|
|
28
|
+
title: 'Termin płatności',
|
|
29
|
+
format: FormatTyp.Default,
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
|
|
33
|
+
if (terminPlatnosci.some((termin) => termin.TerminOpis)) {
|
|
34
|
+
zaplataCzesciowaHeader.push({ name: 'TerminOpis', title: 'Opis płatności', format: FormatTyp.Default });
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const zaplataCzesciowaNaglowek: HeaderDefine[] = [
|
|
38
|
+
{
|
|
39
|
+
name: 'DataZaplatyCzesciowej',
|
|
40
|
+
title: 'Data zapłaty częściowej',
|
|
41
|
+
format: FormatTyp.Default,
|
|
42
|
+
},
|
|
43
|
+
{ name: 'KwotaZaplatyCzesciowej', title: 'Kwota zapłaty częściowej', format: FormatTyp.Currency },
|
|
44
|
+
{ name: 'FormaPlatnosci', title: 'Forma płatności', format: FormatTyp.FormOfPayment },
|
|
45
|
+
];
|
|
46
|
+
|
|
47
|
+
const table: Content[] = [generateLine(), ...createHeader('Płatność')];
|
|
48
|
+
|
|
49
|
+
// TODO: Add to FA2 and FA1? (KSEF20-15289)
|
|
50
|
+
if (getValue(platnosc.Zaplacono) === '1') {
|
|
51
|
+
table.push(createLabelText('Informacja o płatności: ', 'Zapłacono'));
|
|
52
|
+
table.push(createLabelText('Data zapłaty: ', platnosc.DataZaplaty));
|
|
53
|
+
} else if (
|
|
54
|
+
getValue(platnosc.ZnacznikZaplatyCzesciowej) === '1' ||
|
|
55
|
+
getValue(platnosc.ZnacznikZaplatyCzesciowej) === '2'
|
|
56
|
+
) {
|
|
57
|
+
table.push(createLabelText('Informacja o płatności: ', 'Zapłata częściowa'));
|
|
58
|
+
table.push(
|
|
59
|
+
createLabelText(
|
|
60
|
+
'Informacja o płatności (kontynuacja): ',
|
|
61
|
+
getValue(platnosc.ZnacznikZaplatyCzesciowej) === '1'
|
|
62
|
+
? 'Zapłacono w części'
|
|
63
|
+
: 'Zapłacono całość w częściach'
|
|
64
|
+
)
|
|
65
|
+
);
|
|
66
|
+
} else {
|
|
67
|
+
table.push(createLabelText('Informacja o płatności: ', 'Brak zapłaty'));
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
if (hasValue(platnosc.FormaPlatnosci)) {
|
|
71
|
+
table.push(createLabelText('Forma płatności: ', getFormaPlatnosciString(platnosc.FormaPlatnosci)));
|
|
72
|
+
} else {
|
|
73
|
+
if (platnosc.OpisPlatnosci?._text) {
|
|
74
|
+
table.push(createLabelText('Forma płatności: ', 'Płatność inna'));
|
|
75
|
+
table.push(createLabelText('Opis płatności innej: ', platnosc.OpisPlatnosci));
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const zaplataCzesciowa = getTable(platnosc.ZaplataCzesciowa);
|
|
80
|
+
const tableZaplataCzesciowa = getContentTable<(typeof zaplataCzesciowa)[0]>(
|
|
81
|
+
zaplataCzesciowaNaglowek,
|
|
82
|
+
zaplataCzesciowa,
|
|
83
|
+
'*'
|
|
84
|
+
);
|
|
85
|
+
const terminPatnosciContent = terminPlatnosci.map((platnosc) => {
|
|
86
|
+
if (!terminPlatnosci.some((termin) => termin.TerminOpis)) {
|
|
87
|
+
return platnosc;
|
|
88
|
+
} else {
|
|
89
|
+
return {
|
|
90
|
+
...platnosc,
|
|
91
|
+
TerminOpis: {
|
|
92
|
+
_text: `${platnosc.TerminOpis?.Ilosc?._text ?? ''} ${platnosc.TerminOpis?.Jednostka?._text ?? ''} ${platnosc.TerminOpis?.ZdarzeniePoczatkowe?._text ?? ''}`,
|
|
93
|
+
} as any,
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const tableTerminPlatnosci = getContentTable<(typeof terminPlatnosci)[0]>(
|
|
99
|
+
zaplataCzesciowaHeader,
|
|
100
|
+
terminPatnosciContent,
|
|
101
|
+
'*'
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
if (zaplataCzesciowa.length > 0 && terminPlatnosci.length > 0) {
|
|
105
|
+
table.push(
|
|
106
|
+
generateTwoColumns(
|
|
107
|
+
tableZaplataCzesciowa.content ?? [],
|
|
108
|
+
tableTerminPlatnosci.content ?? [],
|
|
109
|
+
[0, 4, 0, 0]
|
|
110
|
+
)
|
|
111
|
+
);
|
|
112
|
+
} else if (terminPlatnosci.length > 0) {
|
|
113
|
+
if (tableTerminPlatnosci.content) {
|
|
114
|
+
table.push(generateTwoColumns([], tableTerminPlatnosci.content));
|
|
115
|
+
}
|
|
116
|
+
} else if (zaplataCzesciowa.length > 0 && tableZaplataCzesciowa.content) {
|
|
117
|
+
table.push(tableZaplataCzesciowa.content);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
if (platnosc.LinkDoPlatnosci) {
|
|
121
|
+
table.push(formatText('Link do płatności bezgotówkowej: ', FormatTyp.Label));
|
|
122
|
+
table.push({
|
|
123
|
+
text: formatText(platnosc.LinkDoPlatnosci._text, FormatTyp.Link),
|
|
124
|
+
link: formatText(platnosc.LinkDoPlatnosci._text, FormatTyp.Link),
|
|
125
|
+
} as ContentText);
|
|
126
|
+
}
|
|
127
|
+
if (platnosc.IPKSeF?._text) {
|
|
128
|
+
createLabelText('Identyfikator płatności Krajowego Systemu e-Faktur: ', platnosc.IPKSeF);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
table.push(
|
|
132
|
+
generateTwoColumns(
|
|
133
|
+
generujRachunekBankowy(getTable(platnosc.RachunekBankowy), 'Numer rachunku bankowego'),
|
|
134
|
+
generujRachunekBankowy(getTable(platnosc.RachunekBankowyFaktora), 'Numer rachunku bankowego faktora')
|
|
135
|
+
)
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
if (platnosc.Skonto) {
|
|
139
|
+
table.push(createHeader('Skonto', [0, 0]));
|
|
140
|
+
table.push(createLabelText('Warunki skonta: ', platnosc.Skonto.WarunkiSkonta));
|
|
141
|
+
table.push(createLabelText('Wysokość skonta: ', platnosc.Skonto.WysokoscSkonta));
|
|
142
|
+
}
|
|
143
|
+
return table;
|
|
144
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import { createHeader, createLabelText, formatText } from '../../../shared/PDF-functions';
|
|
3
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
4
|
+
import { Podmiot1 } from '../../types/fa3.types';
|
|
5
|
+
import { generateAdres } from './Adres';
|
|
6
|
+
import { generateDaneIdentyfikacyjneTPodmiot1Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot1Dto';
|
|
7
|
+
import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
|
|
8
|
+
|
|
9
|
+
export function generatePodmiot1(podmiot1: Podmiot1): Content[] {
|
|
10
|
+
const result: Content[] = createHeader('Sprzedawca');
|
|
11
|
+
|
|
12
|
+
result.push(
|
|
13
|
+
createLabelText('NrEORI: ', podmiot1.NrEORI),
|
|
14
|
+
createLabelText('Prefiks VAT: ', podmiot1.PrefiksPodatnika)
|
|
15
|
+
);
|
|
16
|
+
if (podmiot1.DaneIdentyfikacyjne) {
|
|
17
|
+
result.push(...generateDaneIdentyfikacyjneTPodmiot1Dto(podmiot1.DaneIdentyfikacyjne));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
if (podmiot1.Adres) {
|
|
21
|
+
result.push(formatText('Adres', [FormatTyp.Label, FormatTyp.LabelMargin]), generateAdres(podmiot1.Adres));
|
|
22
|
+
}
|
|
23
|
+
if (podmiot1.AdresKoresp) {
|
|
24
|
+
result.push(
|
|
25
|
+
formatText('Adres do korespondencji', [FormatTyp.Label, FormatTyp.LabelMargin]),
|
|
26
|
+
...generateAdres(podmiot1.AdresKoresp)
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
if (podmiot1.DaneKontaktowe) {
|
|
30
|
+
result.push(
|
|
31
|
+
formatText('Dane kontaktowe', [FormatTyp.Label, FormatTyp.LabelMargin]),
|
|
32
|
+
...generateDaneKontaktowe(podmiot1.DaneKontaktowe)
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
result.push(createLabelText('Status podatnika: ', podmiot1.StatusInfoPodatnika));
|
|
36
|
+
} else if (podmiot1.StatusInfoPodatnika) {
|
|
37
|
+
result.push(createLabelText('Status podatnika: ', podmiot1.StatusInfoPodatnika));
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import {
|
|
3
|
+
createHeader,
|
|
4
|
+
createLabelText,
|
|
5
|
+
formatText,
|
|
6
|
+
getTable,
|
|
7
|
+
verticalSpacing,
|
|
8
|
+
} from '../../../shared/PDF-functions';
|
|
9
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
10
|
+
import { Podmiot1, Podmiot1K } from '../../types/fa2.types';
|
|
11
|
+
import { generateDaneIdentyfikacyjneTPodmiot1Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot1Dto';
|
|
12
|
+
import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
|
|
13
|
+
import { generateAdres } from './Adres';
|
|
14
|
+
|
|
15
|
+
export function generatePodmiot1Podmiot1K(podmiot1: Podmiot1, podmiot1K: Podmiot1K): Content[] {
|
|
16
|
+
const result: Content[] = createHeader('Sprzedawca');
|
|
17
|
+
let firstColumn: Content[] = [];
|
|
18
|
+
let secondColumn: Content[] = [];
|
|
19
|
+
|
|
20
|
+
firstColumn.push(createHeader('Dane identyfikacyjne'), createLabelText('Numer EORI: ', podmiot1.NrEORI));
|
|
21
|
+
if (podmiot1.DaneIdentyfikacyjne) {
|
|
22
|
+
firstColumn.push(...generateDaneIdentyfikacyjneTPodmiot1Dto(podmiot1.DaneIdentyfikacyjne));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (podmiot1.DaneKontaktowe) {
|
|
26
|
+
const daneKontaktowe = generateDaneKontaktowe(getTable(podmiot1.DaneKontaktowe));
|
|
27
|
+
|
|
28
|
+
if (daneKontaktowe.length) {
|
|
29
|
+
firstColumn.push(createHeader('Dane kontaktowe'));
|
|
30
|
+
firstColumn.push(daneKontaktowe);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (podmiot1.StatusInfoPodatnika) {
|
|
34
|
+
firstColumn.push(createLabelText('Status podatnika: ', podmiot1.StatusInfoPodatnika));
|
|
35
|
+
}
|
|
36
|
+
if (firstColumn.length) {
|
|
37
|
+
result.push({
|
|
38
|
+
columns: [firstColumn, []],
|
|
39
|
+
columnGap: 20,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
firstColumn = generateCorrectedContent(podmiot1K);
|
|
43
|
+
secondColumn = generateCorrectedContent(podmiot1);
|
|
44
|
+
|
|
45
|
+
if (podmiot1.AdresKoresp) {
|
|
46
|
+
secondColumn.push(
|
|
47
|
+
formatText('Adres do korespondencji', [FormatTyp.Label, FormatTyp.LabelMargin]),
|
|
48
|
+
generateAdres(podmiot1.AdresKoresp)
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
if (firstColumn.length || secondColumn.length) {
|
|
52
|
+
result.push({
|
|
53
|
+
columns: [firstColumn, secondColumn],
|
|
54
|
+
columnGap: 20,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (result.length) {
|
|
58
|
+
result.push(verticalSpacing(1));
|
|
59
|
+
}
|
|
60
|
+
return result;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function generateCorrectedContent(podmiot: Podmiot1 | Podmiot1K): Content[] {
|
|
64
|
+
const result: Content[] = [];
|
|
65
|
+
|
|
66
|
+
result.push(createHeader('Treść korygowana'));
|
|
67
|
+
|
|
68
|
+
if (podmiot.PrefiksPodatnika?._text) {
|
|
69
|
+
result.push(createLabelText('Prefiks VAT: ', podmiot.PrefiksPodatnika));
|
|
70
|
+
}
|
|
71
|
+
if (podmiot.DaneIdentyfikacyjne) {
|
|
72
|
+
result.push(...generateDaneIdentyfikacyjneTPodmiot1Dto(podmiot.DaneIdentyfikacyjne));
|
|
73
|
+
}
|
|
74
|
+
if (podmiot.Adres) {
|
|
75
|
+
result.push(formatText('Adres', [FormatTyp.Label, FormatTyp.LabelMargin]), generateAdres(podmiot.Adres));
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import { createHeader, createLabelText, formatText, getTable } from '../../../shared/PDF-functions';
|
|
3
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
4
|
+
import { Podmiot2 } from '../../types/fa3.types';
|
|
5
|
+
import { generateAdres } from './Adres';
|
|
6
|
+
import { generateDaneIdentyfikacyjneTPodmiot2Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot2Dto';
|
|
7
|
+
import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
|
|
8
|
+
import { DaneIdentyfikacyjneTPodmiot2Dto } from '../../types/fa2-additional-types';
|
|
9
|
+
|
|
10
|
+
export function generatePodmiot2(podmiot2: Podmiot2): Content[] {
|
|
11
|
+
const result: Content[] = createHeader('Nabywca');
|
|
12
|
+
|
|
13
|
+
result.push(
|
|
14
|
+
createLabelText('Identyfikator nabywcy: ', podmiot2.IDNabywcy),
|
|
15
|
+
createLabelText('NrEORI: ', podmiot2.NrEORI)
|
|
16
|
+
);
|
|
17
|
+
if (podmiot2.DaneIdentyfikacyjne) {
|
|
18
|
+
result.push(
|
|
19
|
+
...generateDaneIdentyfikacyjneTPodmiot2Dto(
|
|
20
|
+
podmiot2.DaneIdentyfikacyjne as DaneIdentyfikacyjneTPodmiot2Dto
|
|
21
|
+
)
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (podmiot2.Adres) {
|
|
26
|
+
result.push(formatText('Adres', [FormatTyp.Label, FormatTyp.LabelMargin]), generateAdres(podmiot2.Adres));
|
|
27
|
+
}
|
|
28
|
+
if (podmiot2.AdresKoresp) {
|
|
29
|
+
result.push(
|
|
30
|
+
formatText('Adres do korespondencji', [FormatTyp.Label, FormatTyp.LabelMargin]),
|
|
31
|
+
...generateAdres(podmiot2.AdresKoresp)
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
if (podmiot2.DaneKontaktowe || podmiot2.NrKlienta) {
|
|
35
|
+
result.push(
|
|
36
|
+
formatText('Dane kontaktowe', [FormatTyp.Label, FormatTyp.LabelMargin]),
|
|
37
|
+
...generateDaneKontaktowe(podmiot2.DaneKontaktowe ?? []),
|
|
38
|
+
createLabelText('Numer klienta: ', podmiot2.NrKlienta)
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
const daneKontaktowe = getTable(podmiot2.DaneKontaktowe);
|
|
42
|
+
|
|
43
|
+
if (daneKontaktowe.length) {
|
|
44
|
+
createLabelText(
|
|
45
|
+
'Faktura dotyczy jednostki podrzędnej JST: ',
|
|
46
|
+
daneKontaktowe[0].JST?._text === '1' ? 'TAK' : 'NIE'
|
|
47
|
+
);
|
|
48
|
+
createLabelText(
|
|
49
|
+
'Faktura dotyczy członka grupy GV: ',
|
|
50
|
+
daneKontaktowe[0].GV?._text === '1' ? 'TAK' : 'NIE'
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
}
|