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,74 @@
|
|
|
1
|
+
import { Content } 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 { Podmiot2, Podmiot2K } from '../../types/fa3.types';
|
|
12
|
+
import { generateAdres } from './Adres';
|
|
13
|
+
import { generateDaneIdentyfikacyjneTPodmiot1Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot1Dto';
|
|
14
|
+
import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
|
|
15
|
+
|
|
16
|
+
export function generatePodmiot2Podmiot2K(podmiot2: Podmiot2, podmiot2K: Podmiot2K): Content[] {
|
|
17
|
+
const result: Content[] = createHeader('Nabywca');
|
|
18
|
+
let firstColumn: Content[] = [];
|
|
19
|
+
let secondColumn: Content[] = [];
|
|
20
|
+
|
|
21
|
+
firstColumn.push(createHeader('Dane identyfikacyjne'), createLabelText('Numer EORI: ', podmiot2.NrEORI));
|
|
22
|
+
if (podmiot2.DaneIdentyfikacyjne) {
|
|
23
|
+
firstColumn.push(...generateDaneIdentyfikacyjneTPodmiot1Dto(podmiot2.DaneIdentyfikacyjne));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (podmiot2.DaneKontaktowe) {
|
|
27
|
+
firstColumn.push(generateDaneKontaktowe(getTable(podmiot2.DaneKontaktowe)));
|
|
28
|
+
}
|
|
29
|
+
if (podmiot2.NrKlienta) {
|
|
30
|
+
firstColumn.push(createLabelText('Numer klienta: ', podmiot2.NrKlienta));
|
|
31
|
+
}
|
|
32
|
+
if (firstColumn.length) {
|
|
33
|
+
result.push({
|
|
34
|
+
columns: [firstColumn, []],
|
|
35
|
+
columnGap: 20,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
firstColumn = generateCorrectedContent(podmiot2K);
|
|
39
|
+
secondColumn = generateCorrectedContent(podmiot2);
|
|
40
|
+
if (podmiot2.AdresKoresp) {
|
|
41
|
+
secondColumn.push(
|
|
42
|
+
formatText('Adres do korespondencji', [FormatTyp.Label, FormatTyp.LabelMargin]),
|
|
43
|
+
generateAdres(podmiot2.AdresKoresp)
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (firstColumn.length || secondColumn.length) {
|
|
48
|
+
result.push({
|
|
49
|
+
columns: [firstColumn, secondColumn],
|
|
50
|
+
columnGap: 20,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (result.length) {
|
|
54
|
+
result.push(verticalSpacing(1));
|
|
55
|
+
}
|
|
56
|
+
return result;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function generateCorrectedContent(podmiot: Podmiot2 | Podmiot2K): Content[] {
|
|
60
|
+
const result: Content[] = [];
|
|
61
|
+
|
|
62
|
+
result.push(createHeader('Treść korygowana'));
|
|
63
|
+
|
|
64
|
+
if (hasValue(podmiot.IDNabywcy)) {
|
|
65
|
+
result.push(createLabelText('Identyfikator nabywcy: ', podmiot.IDNabywcy));
|
|
66
|
+
}
|
|
67
|
+
if (podmiot.DaneIdentyfikacyjne) {
|
|
68
|
+
result.push(...generateDaneIdentyfikacyjneTPodmiot1Dto(podmiot.DaneIdentyfikacyjne));
|
|
69
|
+
}
|
|
70
|
+
if (podmiot.Adres) {
|
|
71
|
+
result.push(formatText('Adres', [FormatTyp.Label, FormatTyp.LabelMargin]), generateAdres(podmiot.Adres));
|
|
72
|
+
}
|
|
73
|
+
return result;
|
|
74
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import {
|
|
3
|
+
createHeader,
|
|
4
|
+
createLabelText,
|
|
5
|
+
formatText,
|
|
6
|
+
generateLine,
|
|
7
|
+
generateTwoColumns,
|
|
8
|
+
} from '../../../shared/PDF-functions';
|
|
9
|
+
import { Podmiot3 } from '../../types/fa2.types';
|
|
10
|
+
import { generateAdres } from './Adres';
|
|
11
|
+
import { generateDaneIdentyfikacyjneTPodmiot3Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot3Dto';
|
|
12
|
+
import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
|
|
13
|
+
import { getRolaString } from '../../../shared/generators/common/functions';
|
|
14
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
15
|
+
|
|
16
|
+
export function generatePodmiot3(podmiot: Podmiot3, index: number): Content[] {
|
|
17
|
+
const result: Content[] = [];
|
|
18
|
+
|
|
19
|
+
result.push(generateLine());
|
|
20
|
+
const column1: Content[] = [
|
|
21
|
+
...createHeader(`Podmiot inny ${index + 1}`),
|
|
22
|
+
createLabelText('Identyfikator nabywcy: ', podmiot.IDNabywcy),
|
|
23
|
+
createLabelText('NrEORI: ', podmiot.NrEORI),
|
|
24
|
+
...generateDaneIdentyfikacyjneTPodmiot3Dto(podmiot.DaneIdentyfikacyjne),
|
|
25
|
+
createLabelText('Rola: ', getRolaString(podmiot.Rola, 2)),
|
|
26
|
+
createLabelText('Rola inna: ', podmiot.OpisRoli),
|
|
27
|
+
createLabelText('Udział: ', podmiot.Udzial, [FormatTyp.Percentage]),
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
const column2: Content[] = [];
|
|
31
|
+
|
|
32
|
+
if (podmiot.Adres) {
|
|
33
|
+
column2.push(formatText('Adres', [FormatTyp.Label, FormatTyp.LabelMargin]), generateAdres(podmiot.Adres));
|
|
34
|
+
}
|
|
35
|
+
if (podmiot.AdresKoresp) {
|
|
36
|
+
column2.push(
|
|
37
|
+
formatText('Adres do korespondencji', [FormatTyp.Label, FormatTyp.LabelMargin]),
|
|
38
|
+
...generateAdres(podmiot.AdresKoresp)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
if (podmiot.DaneKontaktowe) {
|
|
42
|
+
column2.push(
|
|
43
|
+
formatText('Dane kontaktowe', [FormatTyp.Label, FormatTyp.LabelMargin]),
|
|
44
|
+
...generateDaneKontaktowe(podmiot.DaneKontaktowe),
|
|
45
|
+
createLabelText('Numer klienta: ', podmiot.NrKlienta)
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
result.push(generateTwoColumns(column1, column2));
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import {
|
|
3
|
+
createHeader,
|
|
4
|
+
createLabelText,
|
|
5
|
+
generateTwoColumns,
|
|
6
|
+
getTable,
|
|
7
|
+
hasValue,
|
|
8
|
+
} from '../../../shared/PDF-functions';
|
|
9
|
+
import { Podmiot3Podmiot2KDto } from '../../types/fa2-additional-types';
|
|
10
|
+
import { getRolaString } from '../../../shared/generators/common/functions';
|
|
11
|
+
import { generatePodmiotAdres } from './PodmiotAdres';
|
|
12
|
+
import { generateDaneIdentyfikacyjneTPodmiot2Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot2Dto';
|
|
13
|
+
import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
|
|
14
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
15
|
+
import { Podmiot1DaneKontaktowe, Podmiot2K, Podmiot3 } from '../../types/fa2.types';
|
|
16
|
+
import { Adres } from '../../types/fa1.types';
|
|
17
|
+
|
|
18
|
+
export function generateDaneIdentyfikacyjneTPodmiot3Dto(
|
|
19
|
+
podmiot2KDto: Podmiot3Podmiot2KDto | undefined,
|
|
20
|
+
index: number
|
|
21
|
+
): Content[] {
|
|
22
|
+
if (!podmiot2KDto) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
const podmiot1: Podmiot3 = podmiot2KDto.fakturaPodmiotNDto;
|
|
26
|
+
const podmiot1DaneKontaktowe: Podmiot1DaneKontaktowe[] = getTable(podmiot1.DaneKontaktowe);
|
|
27
|
+
const podmiot1K: (Podmiot2K & { Adres?: Adres }) | undefined = podmiot2KDto.podmiot2KDto;
|
|
28
|
+
const result: Content[] = createHeader(`Podmiot inny ${index + 1}`);
|
|
29
|
+
|
|
30
|
+
if (
|
|
31
|
+
hasValue(podmiot1.NrEORI) ||
|
|
32
|
+
hasValue(podmiot1.Rola) ||
|
|
33
|
+
hasValue(podmiot1.OpisRoli) ||
|
|
34
|
+
hasValue(podmiot1?.Udzial)
|
|
35
|
+
) {
|
|
36
|
+
result.push(
|
|
37
|
+
...createHeader('Dane identyfikacyjne'),
|
|
38
|
+
createLabelText('Numer EORI: ', podmiot1.NrEORI),
|
|
39
|
+
createLabelText('Rola: ', getRolaString(podmiot1.Rola, 2)),
|
|
40
|
+
createLabelText('Rola inna: ', podmiot1.OpisRoli),
|
|
41
|
+
createLabelText('Udział: ', podmiot1.Udzial, FormatTyp.Currency6)
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (podmiot1DaneKontaktowe.length > 0 || hasValue(podmiot1.NrKlienta)) {
|
|
46
|
+
result.push(generateDaneKontaktowe(podmiot1.DaneKontaktowe ?? []));
|
|
47
|
+
result.push(createLabelText('Numer klienta: ', podmiot1.NrKlienta));
|
|
48
|
+
}
|
|
49
|
+
const columns1: Content[] = [
|
|
50
|
+
...createHeader('Treść korygowana'),
|
|
51
|
+
createLabelText('Identyfikator nabywcy: ', podmiot1K?.IDNabywcy),
|
|
52
|
+
];
|
|
53
|
+
|
|
54
|
+
if (podmiot1K?.DaneIdentyfikacyjne) {
|
|
55
|
+
columns1.push(generateDaneIdentyfikacyjneTPodmiot2Dto(podmiot1K.DaneIdentyfikacyjne));
|
|
56
|
+
}
|
|
57
|
+
if (podmiot1K?.Adres) {
|
|
58
|
+
columns1.push(generatePodmiotAdres(podmiot1K.Adres));
|
|
59
|
+
}
|
|
60
|
+
const columns2: Content[] = [
|
|
61
|
+
...createHeader('Treść korygująca'),
|
|
62
|
+
createLabelText('Identyfikator nabywcy: ', podmiot1?.IDNabywcy),
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
if (podmiot1?.DaneIdentyfikacyjne) {
|
|
66
|
+
columns2.push(generateDaneIdentyfikacyjneTPodmiot2Dto(podmiot1.DaneIdentyfikacyjne));
|
|
67
|
+
}
|
|
68
|
+
if (podmiot1?.Adres) {
|
|
69
|
+
columns2.push(generatePodmiotAdres(podmiot1.Adres));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (podmiot1.AdresKoresp != null) {
|
|
73
|
+
columns2.push(generatePodmiotAdres(podmiot1.AdresKoresp, 'Adres korespondencyjny'));
|
|
74
|
+
}
|
|
75
|
+
result.push(generateTwoColumns(columns1, columns2));
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Content, Margins } from 'pdfmake/interfaces';
|
|
2
|
+
import { createHeader, createSubHeader } from '../../../shared/PDF-functions';
|
|
3
|
+
import { Adres } from '../../types/fa2.types';
|
|
4
|
+
import { generateAdres } from './Adres';
|
|
5
|
+
|
|
6
|
+
export function generatePodmiotAdres(
|
|
7
|
+
podmiotAdres: Adres | undefined,
|
|
8
|
+
headerTitle = 'Adres',
|
|
9
|
+
isSubheader = false,
|
|
10
|
+
headerMargin?: Margins
|
|
11
|
+
): Content[] {
|
|
12
|
+
if (!podmiotAdres) {
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
return [
|
|
16
|
+
...(isSubheader ? createSubHeader(headerTitle, headerMargin) : createHeader(headerTitle, headerMargin)),
|
|
17
|
+
...generateAdres(podmiotAdres),
|
|
18
|
+
];
|
|
19
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import { DaneIdentyfikacyjne } from '../../types/fa2.types';
|
|
3
|
+
import { createLabelText } from '../../../shared/PDF-functions';
|
|
4
|
+
|
|
5
|
+
export function generateDaneIdentyfikacyjneTPodmiot1Dto(daneIdentyfikacyjne: DaneIdentyfikacyjne): Content[] {
|
|
6
|
+
return [
|
|
7
|
+
createLabelText('NIP: ', daneIdentyfikacyjne.NIP),
|
|
8
|
+
createLabelText('Nazwa: ', daneIdentyfikacyjne.Nazwa),
|
|
9
|
+
];
|
|
10
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import { createLabelText, createLabelTextArray, formatText } from '../../../shared/PDF-functions';
|
|
3
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
4
|
+
import { DaneIdentyfikacyjneTPodmiot2Dto } from '../../types/fa2-additional-types';
|
|
5
|
+
|
|
6
|
+
export function generateDaneIdentyfikacyjneTPodmiot2Dto(
|
|
7
|
+
daneIdentyfikacyjne: DaneIdentyfikacyjneTPodmiot2Dto
|
|
8
|
+
): Content[] {
|
|
9
|
+
const result: Content[] = [];
|
|
10
|
+
|
|
11
|
+
result.push(createLabelText('NIP: ', daneIdentyfikacyjne.NIP));
|
|
12
|
+
if (daneIdentyfikacyjne.NrVatUE?._text) {
|
|
13
|
+
result.push(
|
|
14
|
+
createLabelTextArray([
|
|
15
|
+
{ value: 'Numer VAT-UE: ', formatTyp: FormatTyp.Label },
|
|
16
|
+
{ value: daneIdentyfikacyjne.KodUE, formatTyp: FormatTyp.Value },
|
|
17
|
+
{ value: ' ' },
|
|
18
|
+
{ value: daneIdentyfikacyjne.NrVatUE, formatTyp: FormatTyp.Value },
|
|
19
|
+
])
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
if (daneIdentyfikacyjne.KodKraju?._text) {
|
|
23
|
+
result.push(
|
|
24
|
+
createLabelTextArray([
|
|
25
|
+
{ value: 'Identyfikator podatkowy inny: ', formatTyp: FormatTyp.Label },
|
|
26
|
+
{ value: daneIdentyfikacyjne.KodKraju, formatTyp: FormatTyp.Value },
|
|
27
|
+
{ value: ' ' },
|
|
28
|
+
{ value: daneIdentyfikacyjne.NrID, formatTyp: FormatTyp.Value },
|
|
29
|
+
])
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
if (daneIdentyfikacyjne.BrakID?._text === '1') {
|
|
33
|
+
result.push(formatText('Brak identyfikatora', FormatTyp.Label));
|
|
34
|
+
}
|
|
35
|
+
result.push(createLabelText('Nazwa: ', daneIdentyfikacyjne.Nazwa));
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import { Podmiot3DaneIdentyfikacyjne } from '../../types/fa2Podmiot3DaneIdentyfikacyjne.types';
|
|
3
|
+
import { createLabelText, createLabelTextArray, hasValue } from '../../../shared/PDF-functions';
|
|
4
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
5
|
+
|
|
6
|
+
export function generateDaneIdentyfikacyjneTPodmiot3Dto(
|
|
7
|
+
daneIdentyfikacyjne: Podmiot3DaneIdentyfikacyjne | undefined
|
|
8
|
+
): Content[] {
|
|
9
|
+
if (!daneIdentyfikacyjne) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const result: Content[] = [];
|
|
13
|
+
|
|
14
|
+
if (hasValue(daneIdentyfikacyjne.NIP)) {
|
|
15
|
+
result.push(createLabelText('NIP: ', daneIdentyfikacyjne.NIP, FormatTyp.Default));
|
|
16
|
+
} else if (hasValue(daneIdentyfikacyjne.IDWew)) {
|
|
17
|
+
result.push(createLabelText('Identyfikator wewnętrzny: ', daneIdentyfikacyjne.IDWew, FormatTyp.Default));
|
|
18
|
+
} else if (hasValue(daneIdentyfikacyjne.KodUE)) {
|
|
19
|
+
result.push(
|
|
20
|
+
createLabelTextArray([
|
|
21
|
+
{ value: 'Numer VAT-UE: ', formatTyp: FormatTyp.Label },
|
|
22
|
+
{ value: daneIdentyfikacyjne.KodUE, formatTyp: FormatTyp.Default },
|
|
23
|
+
{ value: '' },
|
|
24
|
+
{ value: daneIdentyfikacyjne.NrVatUE, formatTyp: FormatTyp.Default },
|
|
25
|
+
])
|
|
26
|
+
);
|
|
27
|
+
} else if (hasValue(daneIdentyfikacyjne.NrID)) {
|
|
28
|
+
result.push(
|
|
29
|
+
createLabelTextArray([
|
|
30
|
+
{ value: 'Identyfikator podatkowy inny: ', formatTyp: FormatTyp.Label },
|
|
31
|
+
{ value: daneIdentyfikacyjne.KodKraju, formatTyp: FormatTyp.Default },
|
|
32
|
+
{ value: '' },
|
|
33
|
+
{ value: daneIdentyfikacyjne.NrID, formatTyp: FormatTyp.Default },
|
|
34
|
+
])
|
|
35
|
+
);
|
|
36
|
+
} else if (daneIdentyfikacyjne.BrakID?._text === '1') {
|
|
37
|
+
result.push(createLabelText('Brak identyfikatora', ' ', FormatTyp.Default));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (hasValue(daneIdentyfikacyjne.Nazwa)) {
|
|
41
|
+
result.push(createLabelText('Nazwa: ', daneIdentyfikacyjne.Nazwa, FormatTyp.Default));
|
|
42
|
+
}
|
|
43
|
+
return result;
|
|
44
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import { createLabelText, getTable } from '../../../shared/PDF-functions';
|
|
3
|
+
import { Podmiot1DaneKontaktowe } from '../../types/fa2.types';
|
|
4
|
+
|
|
5
|
+
export function generateDaneKontaktowe(daneKontaktowe: Podmiot1DaneKontaktowe[]): Content[] {
|
|
6
|
+
return getTable(daneKontaktowe)?.map((daneKontaktowe) => {
|
|
7
|
+
return [
|
|
8
|
+
createLabelText('Email: ', daneKontaktowe.Email),
|
|
9
|
+
createLabelText('Tel.: ', daneKontaktowe.Telefon),
|
|
10
|
+
];
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import { createHeader, createLabelText, hasValue } from '../../../shared/PDF-functions';
|
|
3
|
+
import { PodmiotUpowazniony } from '../../types/fa2.types';
|
|
4
|
+
import { generatePodmiotAdres } from './PodmiotAdres';
|
|
5
|
+
import { generateDaneIdentyfikacyjneTPodmiot1Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot1Dto';
|
|
6
|
+
import { generatePodmiotUpowaznionyDaneKontaktowe } from './PodmiotUpowaznionyDaneKontaktowe';
|
|
7
|
+
import { getRolaUpowaznionegoString } from '../../../shared/generators/common/functions';
|
|
8
|
+
|
|
9
|
+
export function generatePodmiotUpowazniony(podmiotUpowazniony: PodmiotUpowazniony | undefined): Content[] {
|
|
10
|
+
if (!podmiotUpowazniony) {
|
|
11
|
+
return [];
|
|
12
|
+
}
|
|
13
|
+
const result: Content[] = createHeader('Podmiot upoważniony');
|
|
14
|
+
|
|
15
|
+
if (hasValue(podmiotUpowazniony.RolaPU)) {
|
|
16
|
+
result.push(createLabelText('Rola: ', getRolaUpowaznionegoString(podmiotUpowazniony.RolaPU, 2)));
|
|
17
|
+
}
|
|
18
|
+
if (hasValue(podmiotUpowazniony.NrEORI)) {
|
|
19
|
+
result.push(createLabelText('Numer EORI: ', podmiotUpowazniony.NrEORI));
|
|
20
|
+
}
|
|
21
|
+
if (podmiotUpowazniony.DaneIdentyfikacyjne) {
|
|
22
|
+
result.push(generateDaneIdentyfikacyjneTPodmiot1Dto(podmiotUpowazniony.DaneIdentyfikacyjne));
|
|
23
|
+
}
|
|
24
|
+
result.push([
|
|
25
|
+
...generatePodmiotAdres(podmiotUpowazniony.Adres),
|
|
26
|
+
...generatePodmiotAdres(podmiotUpowazniony.AdresKoresp, 'Adres korespondencyjny'),
|
|
27
|
+
...generatePodmiotUpowaznionyDaneKontaktowe(podmiotUpowazniony.DaneKontaktowe),
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
return result;
|
|
31
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import {
|
|
3
|
+
createLabelText,
|
|
4
|
+
formatText,
|
|
5
|
+
getTable,
|
|
6
|
+
hasValue,
|
|
7
|
+
verticalSpacing,
|
|
8
|
+
} from '../../../shared/PDF-functions';
|
|
9
|
+
import FormatTyp from '../../../shared/enums/common.enum';
|
|
10
|
+
import { PodmiotUpowaznionyDaneKontaktowe } from '../../types/fa2.types';
|
|
11
|
+
|
|
12
|
+
export function generatePodmiotUpowaznionyDaneKontaktowe(
|
|
13
|
+
daneKontaktoweSource: PodmiotUpowaznionyDaneKontaktowe[] | undefined
|
|
14
|
+
): Content[] {
|
|
15
|
+
if (!daneKontaktoweSource) {
|
|
16
|
+
return [];
|
|
17
|
+
}
|
|
18
|
+
const result: Content[] = [formatText('Dane kontaktowe', FormatTyp.Description)];
|
|
19
|
+
const daneKontaktowe: PodmiotUpowaznionyDaneKontaktowe[] = getTable(daneKontaktoweSource);
|
|
20
|
+
|
|
21
|
+
if (daneKontaktowe.length === 0) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
daneKontaktowe.forEach((kontakt: PodmiotUpowaznionyDaneKontaktowe): void => {
|
|
25
|
+
if (hasValue(kontakt.EmailPU)) {
|
|
26
|
+
result.push(createLabelText('E-mail: ', kontakt.EmailPU));
|
|
27
|
+
}
|
|
28
|
+
if (hasValue(kontakt.TelefonPU)) {
|
|
29
|
+
result.push(createLabelText('Tel.: ', kontakt.TelefonPU));
|
|
30
|
+
}
|
|
31
|
+
result.push(verticalSpacing(1));
|
|
32
|
+
});
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { Content } from 'pdfmake/interfaces';
|
|
2
|
+
import { createSection, getTable, getValue } from '../../../shared/PDF-functions';
|
|
3
|
+
import { Faktura, Podmiot2K as Podmiot2Kfa2, Podmiot3 } from '../../types/fa2.types';
|
|
4
|
+
import { Podmiot2K as Podmiot2Kfa1 } from '../../types/fa1.types';
|
|
5
|
+
import { Podmiot3Podmiot2KDto } from '../../types/fa2-additional-types';
|
|
6
|
+
import { generatePodmiot1 } from './Podmiot1';
|
|
7
|
+
import { generatePodmiot1Podmiot1K } from './Podmiot1Podmiot1K';
|
|
8
|
+
import { generatePodmiot2 } from './Podmiot2';
|
|
9
|
+
import { generatePodmiot2Podmiot2K } from './Podmiot2Podmiot2k';
|
|
10
|
+
import { generatePodmiot3 } from './Podmiot3';
|
|
11
|
+
import { generateDaneIdentyfikacyjneTPodmiot3Dto } from './Podmiot3Podmiot2k';
|
|
12
|
+
import { generatePodmiotUpowazniony } from './PodmiotUpowazniony';
|
|
13
|
+
|
|
14
|
+
export function generatePodmioty(invoice: Faktura): Content[] {
|
|
15
|
+
const result: Content[] = [];
|
|
16
|
+
const podmiot2K: Podmiot2Kfa2[] = getTable(invoice.Fa?.Podmiot2K);
|
|
17
|
+
const podmiot3: Podmiot3[] = getTable(invoice.Podmiot3);
|
|
18
|
+
|
|
19
|
+
if (invoice.Fa?.Podmiot1K || podmiot2K.length > 0) {
|
|
20
|
+
if (invoice.Fa?.Podmiot1K) {
|
|
21
|
+
result.push(generatePodmiot1Podmiot1K(invoice.Podmiot1 ?? {}, invoice.Fa?.Podmiot1K));
|
|
22
|
+
} else if (invoice.Podmiot1 != null) {
|
|
23
|
+
result.push(generatePodmiot1(invoice.Podmiot1));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (podmiot2K.length > 0) {
|
|
27
|
+
podmiot2K.forEach((podmiot2K: Podmiot2Kfa2): void => {
|
|
28
|
+
result.push(generatePodmiot2Podmiot2K(invoice.Podmiot2 ?? {}, podmiot2K));
|
|
29
|
+
});
|
|
30
|
+
} else if (invoice.Podmiot2) {
|
|
31
|
+
result.push(createSection(generatePodmiot2(invoice.Podmiot2!), true));
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
result.push([
|
|
35
|
+
{
|
|
36
|
+
columns: [generatePodmiot1(invoice.Podmiot1!), generatePodmiot2(invoice.Podmiot2!)],
|
|
37
|
+
margin: [0, 0, 0, 8],
|
|
38
|
+
},
|
|
39
|
+
]);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (podmiot3.length > 0) {
|
|
43
|
+
const podmiot3Podmiot2KDto: Podmiot3Podmiot2KDto[] = getPodmiot3Podmiot2KDto(podmiot2K, podmiot3);
|
|
44
|
+
|
|
45
|
+
if (podmiot3Podmiot2KDto.length > 0) {
|
|
46
|
+
podmiot3Podmiot2KDto.forEach((pdm2KDto: Podmiot3Podmiot2KDto, i: number): void => {
|
|
47
|
+
if (pdm2KDto.podmiot2KDto) {
|
|
48
|
+
result.push(generateDaneIdentyfikacyjneTPodmiot3Dto(pdm2KDto, i));
|
|
49
|
+
} else {
|
|
50
|
+
result.push(generatePodmiot3(pdm2KDto.fakturaPodmiotNDto, i));
|
|
51
|
+
}
|
|
52
|
+
if (i < podmiot3Podmiot2KDto.length - 1) {
|
|
53
|
+
result.push({ margin: [0, 8, 0, 0], text: '' });
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
} else {
|
|
57
|
+
podmiot3.forEach((podmiot: Podmiot3, index: number): void => {
|
|
58
|
+
result.push(generatePodmiot3(podmiot, index));
|
|
59
|
+
if (index < podmiot3.length - 1) {
|
|
60
|
+
result.push({ margin: [0, 8, 0, 0], text: '' });
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
result.push(generatePodmiotUpowazniony(invoice.PodmiotUpowazniony));
|
|
67
|
+
return createSection(result, true);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function getPodmiot3Podmiot2KDto(podmioty2K: Podmiot2Kfa2[], podmioty3: Podmiot3[]): Podmiot3Podmiot2KDto[] {
|
|
71
|
+
const result: Podmiot3Podmiot2KDto[] = [];
|
|
72
|
+
|
|
73
|
+
if (
|
|
74
|
+
podmioty2K.length > 1 &&
|
|
75
|
+
podmioty3.filter((p: Podmiot3): boolean => getValue(p.Rola) === '4').length > 0
|
|
76
|
+
) {
|
|
77
|
+
let idx: number = 1;
|
|
78
|
+
|
|
79
|
+
podmioty3.forEach((podmiot3: Podmiot3): void => {
|
|
80
|
+
if (getValue(podmiot3.Rola) === '4') {
|
|
81
|
+
if (podmioty2K.length > idx) {
|
|
82
|
+
result.push({
|
|
83
|
+
fakturaPodmiotNDto: podmiot3,
|
|
84
|
+
podmiot2KDto: podmioty2K[idx] as Podmiot2Kfa1,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
idx++;
|
|
88
|
+
} else {
|
|
89
|
+
result.push({
|
|
90
|
+
fakturaPodmiotNDto: podmiot3,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return result;
|
|
96
|
+
}
|