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.
Files changed (174) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/dist/index.d.ts +7 -0
  3. package/dist/index.js +4 -0
  4. package/dist/lib-public/FA3-generator.js +50 -0
  5. package/dist/lib-public/enums/invoice.enums.js +9 -0
  6. package/dist/lib-public/generate-invoice.js +21 -0
  7. package/dist/lib-public/generators/FA2/Adnotacje.js +174 -0
  8. package/dist/lib-public/generators/FA2/Adres.js +23 -0
  9. package/dist/lib-public/generators/FA2/DodatkoweInformacje.js +69 -0
  10. package/dist/lib-public/generators/FA2/Platnosc.js +91 -0
  11. package/dist/lib-public/generators/FA2/Podmiot1.js +32 -0
  12. package/dist/lib-public/generators/FA2/Podmiot1Podmiot1K.js +63 -0
  13. package/dist/lib-public/generators/FA2/Podmiot2.js +28 -0
  14. package/dist/lib-public/generators/FA2/Podmiot2Podmiot2k.js +62 -0
  15. package/dist/lib-public/generators/FA2/Podmiot3.js +37 -0
  16. package/dist/lib-public/generators/FA2/Podmiot3Podmiot2k.js +57 -0
  17. package/dist/lib-public/generators/FA2/PodmiotAdres.js +14 -0
  18. package/dist/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.js +10 -0
  19. package/dist/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.js +34 -0
  20. package/dist/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.js +44 -0
  21. package/dist/lib-public/generators/FA2/PodmiotDaneKontaktowe.js +13 -0
  22. package/dist/lib-public/generators/FA2/PodmiotUpowazniony.js +29 -0
  23. package/dist/lib-public/generators/FA2/PodmiotUpowaznionyDaneKontaktowe.js +28 -0
  24. package/dist/lib-public/generators/FA2/Podmioty.js +92 -0
  25. package/dist/lib-public/generators/FA2/PodsumowanieStawekPodatkuVat.js +260 -0
  26. package/dist/lib-public/generators/FA2/Przewoznik.js +17 -0
  27. package/dist/lib-public/generators/FA2/Rabat.js +57 -0
  28. package/dist/lib-public/generators/FA2/RachunekBankowy.js +54 -0
  29. package/dist/lib-public/generators/FA2/Szczegoly.js +138 -0
  30. package/dist/lib-public/generators/FA2/Transport.js +78 -0
  31. package/dist/lib-public/generators/FA2/WarunkiTransakcji.js +68 -0
  32. package/dist/lib-public/generators/FA2/Wiersze.js +140 -0
  33. package/dist/lib-public/generators/FA2/Zamowienie.js +148 -0
  34. package/dist/lib-public/generators/FA3/Adnotacje.js +185 -0
  35. package/dist/lib-public/generators/FA3/Adres.js +23 -0
  36. package/dist/lib-public/generators/FA3/DodatkoweInformacje.js +69 -0
  37. package/dist/lib-public/generators/FA3/Platnosc.js +105 -0
  38. package/dist/lib-public/generators/FA3/Podmiot1.js +32 -0
  39. package/dist/lib-public/generators/FA3/Podmiot1Podmiot1K.js +67 -0
  40. package/dist/lib-public/generators/FA3/Podmiot2.js +34 -0
  41. package/dist/lib-public/generators/FA3/Podmiot2Podmiot2k.js +49 -0
  42. package/dist/lib-public/generators/FA3/Podmiot3.js +37 -0
  43. package/dist/lib-public/generators/FA3/Podmiot3Podmiot2k.js +57 -0
  44. package/dist/lib-public/generators/FA3/PodmiotAdres.js +14 -0
  45. package/dist/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.js +10 -0
  46. package/dist/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.js +34 -0
  47. package/dist/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.js +44 -0
  48. package/dist/lib-public/generators/FA3/PodmiotDaneKontaktowe.js +13 -0
  49. package/dist/lib-public/generators/FA3/PodmiotUpowazniony.js +29 -0
  50. package/dist/lib-public/generators/FA3/PodmiotUpowaznionyDaneKontaktowe.js +28 -0
  51. package/dist/lib-public/generators/FA3/Podmioty.js +92 -0
  52. package/dist/lib-public/generators/FA3/PodsumowanieStawekPodatkuVat.js +264 -0
  53. package/dist/lib-public/generators/FA3/Przewoznik.js +17 -0
  54. package/dist/lib-public/generators/FA3/Rabat.js +57 -0
  55. package/dist/lib-public/generators/FA3/RachunekBankowy.js +58 -0
  56. package/dist/lib-public/generators/FA3/Szczegoly.js +138 -0
  57. package/dist/lib-public/generators/FA3/Transport.js +78 -0
  58. package/dist/lib-public/generators/FA3/WarunkiTransakcji.js +68 -0
  59. package/dist/lib-public/generators/FA3/Wiersze.js +140 -0
  60. package/dist/lib-public/generators/FA3/Zamowienie.js +148 -0
  61. package/dist/lib-public/generators/common/DaneFaKorygowanej.js +74 -0
  62. package/dist/lib-public/generators/common/Naglowek.js +100 -0
  63. package/dist/lib-public/generators/common/Rozliczenie.js +120 -0
  64. package/dist/lib-public/generators/common/Stopka.js +113 -0
  65. package/dist/lib-public/generators/common/Wiersze.js +28 -0
  66. package/dist/lib-public/generators/common/Zalaczniki.js +182 -0
  67. package/dist/lib-public/index.js +5 -0
  68. package/dist/lib-public/types/common.types.js +2 -0
  69. package/dist/lib-public/types/fa1-additional-types.js +2 -0
  70. package/dist/lib-public/types/fa1.types.js +2 -0
  71. package/dist/lib-public/types/fa2-additional-types.js +2 -0
  72. package/dist/lib-public/types/fa2.types.js +2 -0
  73. package/dist/lib-public/types/fa2Podmiot3DaneIdentyfikacyjne.types.js +2 -0
  74. package/dist/lib-public/types/fa3.types.js +2 -0
  75. package/dist/lib-public/types/fa3Podmiot3DaneIdentyfikacyjne.types.js +2 -0
  76. package/dist/lib-public/types/tax-summary.types.js +2 -0
  77. package/dist/lib-public/types/upo-v4_2.types.js +2 -0
  78. package/dist/shared/PDF-functions.js +429 -0
  79. package/dist/shared/XML-parser.js +21 -0
  80. package/dist/shared/consts/const.js +390 -0
  81. package/dist/shared/enums/common.enum.js +48 -0
  82. package/dist/shared/enums/invoice.enums.js +13 -0
  83. package/dist/shared/generators/common/functions.js +95 -0
  84. package/dist/shared/types/additional-data.types.js +2 -0
  85. package/dist/shared/types/pdf-types.js +2 -0
  86. package/dist/shared/types/universal.types.js +2 -0
  87. package/package.json +21 -0
  88. package/src/index.d.ts +7 -0
  89. package/src/index.ts +2 -0
  90. package/src/lib-public/FA3-generator.ts +56 -0
  91. package/src/lib-public/enums/invoice.enums.ts +5 -0
  92. package/src/lib-public/generate-invoice.ts +32 -0
  93. package/src/lib-public/generators/FA2/Adnotacje.ts +206 -0
  94. package/src/lib-public/generators/FA2/Adres.ts +20 -0
  95. package/src/lib-public/generators/FA2/DodatkoweInformacje.ts +97 -0
  96. package/src/lib-public/generators/FA2/Platnosc.ts +131 -0
  97. package/src/lib-public/generators/FA2/Podmiot1.ts +40 -0
  98. package/src/lib-public/generators/FA2/Podmiot1Podmiot1K.ts +73 -0
  99. package/src/lib-public/generators/FA2/Podmiot2.ts +42 -0
  100. package/src/lib-public/generators/FA2/Podmiot2Podmiot2k.ts +74 -0
  101. package/src/lib-public/generators/FA2/Podmiot3.ts +50 -0
  102. package/src/lib-public/generators/FA2/Podmiot3Podmiot2k.ts +77 -0
  103. package/src/lib-public/generators/FA2/PodmiotAdres.ts +19 -0
  104. package/src/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.ts +10 -0
  105. package/src/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.ts +37 -0
  106. package/src/lib-public/generators/FA2/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.ts +44 -0
  107. package/src/lib-public/generators/FA2/PodmiotDaneKontaktowe.ts +12 -0
  108. package/src/lib-public/generators/FA2/PodmiotUpowazniony.ts +31 -0
  109. package/src/lib-public/generators/FA2/PodmiotUpowaznionyDaneKontaktowe.ts +34 -0
  110. package/src/lib-public/generators/FA2/Podmioty.ts +96 -0
  111. package/src/lib-public/generators/FA2/PodsumowanieStawekPodatkuVat.ts +294 -0
  112. package/src/lib-public/generators/FA2/Przewoznik.ts +21 -0
  113. package/src/lib-public/generators/FA2/Rabat.ts +47 -0
  114. package/src/lib-public/generators/FA2/RachunekBankowy.ts +60 -0
  115. package/src/lib-public/generators/FA2/Szczegoly.ts +187 -0
  116. package/src/lib-public/generators/FA2/Transport.ts +108 -0
  117. package/src/lib-public/generators/FA2/WarunkiTransakcji.ts +105 -0
  118. package/src/lib-public/generators/FA2/Wiersze.ts +126 -0
  119. package/src/lib-public/generators/FA2/Zamowienie.ts +144 -0
  120. package/src/lib-public/generators/FA3/Adnotacje.ts +249 -0
  121. package/src/lib-public/generators/FA3/Adres.ts +20 -0
  122. package/src/lib-public/generators/FA3/DodatkoweInformacje.ts +92 -0
  123. package/src/lib-public/generators/FA3/Platnosc.ts +144 -0
  124. package/src/lib-public/generators/FA3/Podmiot1.ts +40 -0
  125. package/src/lib-public/generators/FA3/Podmiot1Podmiot1K.ts +78 -0
  126. package/src/lib-public/generators/FA3/Podmiot2.ts +55 -0
  127. package/src/lib-public/generators/FA3/Podmiot2Podmiot2k.ts +59 -0
  128. package/src/lib-public/generators/FA3/Podmiot3.ts +50 -0
  129. package/src/lib-public/generators/FA3/Podmiot3Podmiot2k.ts +78 -0
  130. package/src/lib-public/generators/FA3/PodmiotAdres.ts +19 -0
  131. package/src/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot1Dto.ts +10 -0
  132. package/src/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot2Dto.ts +37 -0
  133. package/src/lib-public/generators/FA3/PodmiotDaneIdentyfikacyjneTPodmiot3Dto.ts +44 -0
  134. package/src/lib-public/generators/FA3/PodmiotDaneKontaktowe.ts +12 -0
  135. package/src/lib-public/generators/FA3/PodmiotUpowazniony.ts +31 -0
  136. package/src/lib-public/generators/FA3/PodmiotUpowaznionyDaneKontaktowe.ts +34 -0
  137. package/src/lib-public/generators/FA3/Podmioty.ts +96 -0
  138. package/src/lib-public/generators/FA3/PodsumowanieStawekPodatkuVat.ts +298 -0
  139. package/src/lib-public/generators/FA3/Przewoznik.ts +24 -0
  140. package/src/lib-public/generators/FA3/Rabat.ts +45 -0
  141. package/src/lib-public/generators/FA3/RachunekBankowy.ts +60 -0
  142. package/src/lib-public/generators/FA3/Szczegoly.ts +184 -0
  143. package/src/lib-public/generators/FA3/Transport.ts +108 -0
  144. package/src/lib-public/generators/FA3/WarunkiTransakcji.ts +100 -0
  145. package/src/lib-public/generators/FA3/Wiersze.ts +126 -0
  146. package/src/lib-public/generators/FA3/Zamowienie.ts +143 -0
  147. package/src/lib-public/generators/common/DaneFaKorygowanej.ts +91 -0
  148. package/src/lib-public/generators/common/Naglowek.ts +84 -0
  149. package/src/lib-public/generators/common/Rozliczenie.ts +119 -0
  150. package/src/lib-public/generators/common/Stopka.ts +161 -0
  151. package/src/lib-public/generators/common/Wiersze.ts +32 -0
  152. package/src/lib-public/generators/common/Zalaczniki.ts +232 -0
  153. package/src/lib-public/index.ts +3 -0
  154. package/src/lib-public/types/common.types.ts +29 -0
  155. package/src/lib-public/types/fa1-additional-types.ts +26 -0
  156. package/src/lib-public/types/fa1.types.ts +299 -0
  157. package/src/lib-public/types/fa2-additional-types.ts +30 -0
  158. package/src/lib-public/types/fa2.types.ts +307 -0
  159. package/src/lib-public/types/fa2Podmiot3DaneIdentyfikacyjne.types.ts +12 -0
  160. package/src/lib-public/types/fa3.types.ts +384 -0
  161. package/src/lib-public/types/fa3Podmiot3DaneIdentyfikacyjne.types.ts +12 -0
  162. package/src/lib-public/types/tax-summary.types.ts +8 -0
  163. package/src/lib-public/types/upo-v4_2.types.ts +68 -0
  164. package/src/shared/PDF-functions.ts +466 -0
  165. package/src/shared/XML-parser.ts +42 -0
  166. package/src/shared/consts/const.ts +406 -0
  167. package/src/shared/enums/common.enum.ts +45 -0
  168. package/src/shared/enums/invoice.enums.ts +9 -0
  169. package/src/shared/generators/common/functions.ts +101 -0
  170. package/src/shared/types/additional-data.types.ts +15 -0
  171. package/src/shared/types/pdf-types.ts +58 -0
  172. package/src/shared/types/universal.types.ts +16 -0
  173. package/transformer.code-workspace +45 -0
  174. package/tsconfig.json +16 -0
@@ -0,0 +1,59 @@
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 { Podmiot2, Podmiot2K } from '../../types/fa3.types';
11
+ import { generateDaneIdentyfikacyjneTPodmiot1Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot1Dto';
12
+ import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
13
+ import { generateCorrectedContent } from '../FA2/Podmiot2Podmiot2k';
14
+ import { generateAdres } from '../FA2/Adres';
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(formatText('Dane kontaktowe', [FormatTyp.Label, FormatTyp.LabelMargin]));
28
+ if (podmiot2.NrKlienta) {
29
+ firstColumn.push(createLabelText('Numer klienta: ', podmiot2.NrKlienta));
30
+ }
31
+ firstColumn.push(generateDaneKontaktowe(getTable(podmiot2.DaneKontaktowe)));
32
+ }
33
+
34
+ if (firstColumn.length) {
35
+ result.push({
36
+ columns: [firstColumn, []],
37
+ columnGap: 20,
38
+ });
39
+ }
40
+ firstColumn = generateCorrectedContent(podmiot2K);
41
+ secondColumn = generateCorrectedContent(podmiot2);
42
+ if (podmiot2.AdresKoresp) {
43
+ secondColumn.push(
44
+ formatText('Adres do korespondencji', [FormatTyp.Label, FormatTyp.LabelMargin]),
45
+ generateAdres(podmiot2.AdresKoresp)
46
+ );
47
+ }
48
+
49
+ if (firstColumn.length || secondColumn.length) {
50
+ result.push({
51
+ columns: [firstColumn, secondColumn],
52
+ columnGap: 20,
53
+ });
54
+ }
55
+ if (result.length) {
56
+ result.push(verticalSpacing(1));
57
+ }
58
+ return result;
59
+ }
@@ -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 FormatTyp from '../../../shared/enums/common.enum';
10
+ import { Podmiot3 } from '../../types/fa3.types';
11
+ import { generateDaneIdentyfikacyjneTPodmiot3Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot3Dto';
12
+ import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
13
+ import { getRolaString } from '../../../shared/generators/common/functions';
14
+ import { generateAdres } from '../FA2/Adres';
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, 3)),
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,78 @@
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 FormatTyp from '../../../shared/enums/common.enum';
10
+ import { Podmiot3Podmiot2KDto } from '../../types/fa2-additional-types';
11
+ import { getRolaString } from '../../../shared/generators/common/functions';
12
+ import { generatePodmiotAdres } from './PodmiotAdres';
13
+ import { generateDaneIdentyfikacyjneTPodmiot2Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot2Dto';
14
+ import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
15
+ import { Podmiot1DaneKontaktowe, Podmiot3 } from '../../types/fa3.types';
16
+ import { Podmiot2K } from '../../types/fa2.types';
17
+ import { Adres } from '../../types/fa1.types';
18
+
19
+ export function generateDaneIdentyfikacyjneTPodmiot3Dto(
20
+ podmiot2KDto: Podmiot3Podmiot2KDto | undefined,
21
+ index: number
22
+ ): Content[] {
23
+ if (!podmiot2KDto) {
24
+ return [];
25
+ }
26
+ const podmiot1: Podmiot3 = podmiot2KDto.fakturaPodmiotNDto;
27
+ const podmiot1DaneKontaktowe: Podmiot1DaneKontaktowe[] = getTable(podmiot1.DaneKontaktowe);
28
+ const podmiot1K: (Podmiot2K & { Adres?: Adres }) | undefined = podmiot2KDto.podmiot2KDto;
29
+ const result: Content[] = createHeader(`Podmiot inny ${index + 1}`);
30
+
31
+ if (
32
+ hasValue(podmiot1.NrEORI) ||
33
+ hasValue(podmiot1.Rola) ||
34
+ hasValue(podmiot1.OpisRoli) ||
35
+ hasValue(podmiot1?.Udzial)
36
+ ) {
37
+ result.push(
38
+ ...createHeader('Dane identyfikacyjne'),
39
+ createLabelText('Numer EORI: ', podmiot1.NrEORI),
40
+ createLabelText('Rola: ', getRolaString(podmiot1.Rola, 3)),
41
+ createLabelText('Rola inna: ', podmiot1.OpisRoli),
42
+ createLabelText('Udział: ', podmiot1.Udzial, FormatTyp.Currency6)
43
+ );
44
+ }
45
+
46
+ if (podmiot1DaneKontaktowe.length > 0 || hasValue(podmiot1.NrKlienta)) {
47
+ result.push(generateDaneKontaktowe(podmiot1.DaneKontaktowe ?? []));
48
+ result.push(createLabelText('Numer klienta: ', podmiot1.NrKlienta));
49
+ }
50
+ const columns1: Content[] = [
51
+ ...createHeader('Treść korygowana'),
52
+ createLabelText('Identyfikator nabywcy: ', podmiot1K?.IDNabywcy),
53
+ ];
54
+
55
+ if (podmiot1K?.DaneIdentyfikacyjne) {
56
+ columns1.push(generateDaneIdentyfikacyjneTPodmiot2Dto(podmiot1K.DaneIdentyfikacyjne));
57
+ }
58
+ if (podmiot1K?.Adres) {
59
+ columns1.push(generatePodmiotAdres(podmiot1K.Adres));
60
+ }
61
+ const columns2: Content[] = [
62
+ ...createHeader('Treść korygująca'),
63
+ createLabelText('Identyfikator nabywcy: ', podmiot1?.IDNabywcy),
64
+ ];
65
+
66
+ if (podmiot1?.DaneIdentyfikacyjne) {
67
+ columns2.push(generateDaneIdentyfikacyjneTPodmiot2Dto(podmiot1.DaneIdentyfikacyjne));
68
+ }
69
+ if (podmiot1?.Adres) {
70
+ columns2.push(generatePodmiotAdres(podmiot1.Adres));
71
+ }
72
+
73
+ if (podmiot1.AdresKoresp != null) {
74
+ columns2.push(generatePodmiotAdres(podmiot1.AdresKoresp, 'Adres korespondencyjny'));
75
+ }
76
+ result.push(generateTwoColumns(columns1, columns2));
77
+ return result;
78
+ }
@@ -0,0 +1,19 @@
1
+ import { Content, Margins } from 'pdfmake/interfaces';
2
+ import { createHeader, createSubHeader } from '../../../shared/PDF-functions';
3
+ import { Adres } from '../../types/fa3.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 { createLabelText } from '../../../shared/PDF-functions';
3
+ import { DaneIdentyfikacyjne } from '../../types/fa3.types';
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 { createLabelText, createLabelTextArray, hasValue } from '../../../shared/PDF-functions';
3
+ import FormatTyp from '../../../shared/enums/common.enum';
4
+ import { Podmiot3DaneIdentyfikacyjne } from '../../types/fa3Podmiot3DaneIdentyfikacyjne.types';
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/fa3.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/fa3.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, 3)));
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/fa3.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 = getTable(daneKontaktoweSource);
20
+
21
+ if (daneKontaktowe.length === 0) {
22
+ return [];
23
+ }
24
+ daneKontaktowe.forEach((kontakt) => {
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, Podmiot3 } from '../../types/fa3.types';
4
+ import { Podmiot3Podmiot2KDto } from '../../types/fa2-additional-types';
5
+ import { generatePodmiot1 } from './Podmiot1';
6
+ import { generatePodmiot1Podmiot1K } from './Podmiot1Podmiot1K';
7
+ import { generatePodmiot2 } from './Podmiot2';
8
+ import { generatePodmiot2Podmiot2K } from './Podmiot2Podmiot2k';
9
+ import { generatePodmiot3 } from './Podmiot3';
10
+ import { generateDaneIdentyfikacyjneTPodmiot3Dto } from './Podmiot3Podmiot2k';
11
+ import { generatePodmiotUpowazniony } from './PodmiotUpowazniony';
12
+ import { Adres } from '../../types/fa1.types';
13
+
14
+ export function generatePodmioty(invoice: Faktura): Content[] {
15
+ const result: Content[] = [];
16
+ const podmiot2K: Podmiot2K[] = 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: Podmiot2K): 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 = getPodmiot3Podmiot2KDto(podmiot2K, podmiot3);
44
+
45
+ if (podmiot3Podmiot2KDto.length > 0) {
46
+ podmiot3Podmiot2KDto.forEach((pdm2KDto, i) => {
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, index) => {
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, [0, 0, 0, 0]);
68
+ }
69
+
70
+ function getPodmiot3Podmiot2KDto(podmioty2K: Podmiot2K[], 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 Podmiot2K[] & { Adres: Adres },
85
+ });
86
+ }
87
+ idx++;
88
+ } else {
89
+ result.push({
90
+ fakturaPodmiotNDto: podmiot3,
91
+ });
92
+ }
93
+ });
94
+ }
95
+ return result;
96
+ }