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,108 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import { Kraj } from '../../../shared/consts/const';
3
+ import {
4
+ createHeader,
5
+ createLabelText,
6
+ createSection,
7
+ createSubHeader,
8
+ formatText,
9
+ generateTwoColumns,
10
+ getTable,
11
+ hasValue,
12
+ } from '../../../shared/PDF-functions';
13
+ import { Transport } from '../../types/fa3.types';
14
+ import {
15
+ getDateTimeWithoutSeconds,
16
+ getOpisTransportuString,
17
+ getRodzajTransportuString,
18
+ } from '../../../shared/generators/common/functions';
19
+ import { generatePrzewoznik } from './Przewoznik';
20
+ import FormatTyp from '../../../shared/enums/common.enum';
21
+
22
+ export function generateTransport(transport: Transport, index?: number | null): Content {
23
+ const table: Content[] = [];
24
+ const columns = {
25
+ transport: [] as Content[],
26
+ dane: [] as Content[],
27
+ wysylkaZ: [] as Content[],
28
+ wysylkaDo: [] as Content[],
29
+ wysylkaPrzez: [] as Content[],
30
+ };
31
+
32
+ table.push(createHeader(index ? `Transport ${index}` : 'Transport'));
33
+ if (transport.RodzajTransportu?._text) {
34
+ columns.transport.push(
35
+ createLabelText('Rodzaj transportu: ', getRodzajTransportuString(transport.RodzajTransportu))
36
+ );
37
+ } else if (transport.TransportInny?._text == '1' && transport.OpisInnegoTransportu?._text) {
38
+ columns.transport.push(createLabelText('Rodzaj transportu: ', 'Transport inny'));
39
+ columns.transport.push(
40
+ createLabelText('Opis innego rodzaju transportu: ', transport.OpisInnegoTransportu)
41
+ );
42
+ }
43
+ columns.dane.push(createLabelText('Numer zlecenia transportu: ', transport.NrZleceniaTransportu));
44
+ if (hasValue(transport.OpisLadunku)) {
45
+ columns.dane.push(createLabelText('Opis ładunku: ', getOpisTransportuString(transport.OpisLadunku)));
46
+ if (transport.LadunekInny?._text === '1' && transport.OpisInnegoLadunku?._text) {
47
+ columns.dane.push(createLabelText('Opis ładunku: ', 'Ładunek inny'));
48
+ columns.dane.push(createLabelText('Opis innego ładunku: ', transport.OpisInnegoLadunku));
49
+ }
50
+ }
51
+ columns.dane.push(createLabelText('Jednostka opakowania: ', transport.JednostkaOpakowania));
52
+ columns.dane.push(
53
+ createLabelText(
54
+ 'Data i godzina rozpoczęcia transportu: ',
55
+ getDateTimeWithoutSeconds(transport.DataGodzRozpTransportu)
56
+ )
57
+ );
58
+ columns.dane.push(
59
+ createLabelText(
60
+ 'Data i godzina zakończenia transportu: ',
61
+ getDateTimeWithoutSeconds(transport.DataGodzZakTransportu)
62
+ )
63
+ );
64
+ if (columns.dane.length > 0) {
65
+ columns.dane.unshift(createSubHeader('Dane transportu', [0, 0, 0, 0]));
66
+ }
67
+ table.push(generateTwoColumns(columns.transport, columns.dane));
68
+
69
+ table.push(generatePrzewoznik(transport.Przewoznik));
70
+
71
+ if (transport.WysylkaZ?.AdresL1) {
72
+ columns.wysylkaZ.push(createSubHeader('Adres miejsca wysyłki', [0, 0, 0, 0]));
73
+ columns.wysylkaZ.push(formatText(transport.WysylkaZ?.AdresL1?._text, FormatTyp.Default));
74
+ columns.wysylkaZ.push(formatText(transport.WysylkaZ?.AdresL2?._text, FormatTyp.Default));
75
+ columns.wysylkaZ.push(formatText(Kraj[transport.WysylkaZ?.KodKraju?._text ?? ''], FormatTyp.Default));
76
+ columns.wysylkaZ.push(createLabelText('GLN: ', transport.WysylkaZ?.GLN?._text));
77
+ }
78
+
79
+ if (transport.WysylkaDo?.AdresL1) {
80
+ columns.wysylkaDo.push(
81
+ createSubHeader('Adres miejsca docelowego, do którego został zlecony transport', [0, 0, 0, 0])
82
+ );
83
+ columns.wysylkaDo.push(formatText(transport.WysylkaDo?.AdresL1?._text, FormatTyp.Default));
84
+ columns.wysylkaDo.push(formatText(transport.WysylkaDo?.AdresL2?._text, FormatTyp.Default));
85
+ columns.wysylkaDo.push(formatText(Kraj[transport.WysylkaDo?.KodKraju?._text ?? ''], FormatTyp.Default));
86
+ columns.wysylkaDo.push(createLabelText('GLN: ', transport.WysylkaDo?.GLN?._text));
87
+ }
88
+
89
+ const wysylkaPrzez = getTable(transport.WysylkaPrzez);
90
+
91
+ wysylkaPrzez.forEach((adres, index) => {
92
+ if (index) {
93
+ columns.wysylkaPrzez.push('\n');
94
+ }
95
+ columns.wysylkaPrzez.push(createSubHeader('Adres pośredni wysyłki', [0, 4, 0, 0]));
96
+ columns.wysylkaPrzez.push(formatText(adres.AdresL1?._text, FormatTyp.Default));
97
+ columns.wysylkaPrzez.push(formatText(adres?.AdresL2?._text, FormatTyp.Default));
98
+ columns.wysylkaPrzez.push(formatText(Kraj[adres?.KodKraju?._text ?? ''], FormatTyp.Default));
99
+ columns.wysylkaPrzez.push(createLabelText('GLN: ', adres?.GLN?._text));
100
+ });
101
+
102
+ if (transport.WysylkaZ?.AdresL1 || transport.WysylkaDo?.AdresL1 || transport.WysylkaPrzez?.length) {
103
+ table.push(createHeader('Wysyłka'));
104
+ table.push(generateTwoColumns(columns.wysylkaZ, columns.wysylkaDo));
105
+ table.push(generateTwoColumns(columns.wysylkaPrzez, []));
106
+ }
107
+ return createSection(table, true);
108
+ }
@@ -0,0 +1,100 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import {
3
+ createHeader,
4
+ createLabelText,
5
+ createSection,
6
+ createSubHeader,
7
+ formatText,
8
+ generateTwoColumns,
9
+ getContentTable,
10
+ getTable,
11
+ } from '../../../shared/PDF-functions';
12
+ import { HeaderDefine } from '../../../shared/types/pdf-types';
13
+ import { FP, Umowy, WarunkiTransakcji, Zamowienia } from '../../types/fa3.types';
14
+ import { generateTransport } from './Transport';
15
+ import FormatTyp from '../../../shared/enums/common.enum';
16
+
17
+ export function generateWarunkiTransakcji(warunkiTransakcji: WarunkiTransakcji | undefined): Content {
18
+ if (!warunkiTransakcji) {
19
+ return [];
20
+ }
21
+ const table: Content[] = [];
22
+ const Kolumny = { umowy: [] as Content[], zamowienia: [] as Content[] };
23
+ const umowy: Umowy[] = getTable(warunkiTransakcji?.Umowy);
24
+ const zamowienia: Zamowienia[] = getTable(warunkiTransakcji?.Zamowienia);
25
+ const partiaTowaru: FP[] = getTable(warunkiTransakcji?.NrPartiiTowaru);
26
+ const definedHeaderUmowy: HeaderDefine[] = [
27
+ { name: 'DataUmowy', title: 'Data umowy', format: FormatTyp.Default },
28
+ { name: 'NrUmowy', title: 'Numer umowy', format: FormatTyp.Default },
29
+ ];
30
+ const definedHeaderZamowienia: HeaderDefine[] = [
31
+ { name: 'DataZamowienia', title: 'Data zamówienia', format: FormatTyp.Default },
32
+ { name: 'NrZamowienia', title: 'Numer zamówienia', format: FormatTyp.Default },
33
+ ];
34
+ const definedHeaderPartiaTowaru: HeaderDefine[] = [
35
+ { name: '', title: 'Numer partii towaru', format: FormatTyp.Default },
36
+ ];
37
+
38
+ table.push(createHeader('Warunki transakcji', [0, 8, 0, 4]));
39
+
40
+ if (umowy.length > 0) {
41
+ const tabUmowy = getContentTable<(typeof umowy)[0]>(definedHeaderUmowy, umowy, '*');
42
+
43
+ if (tabUmowy.content) {
44
+ Kolumny.umowy = [createSubHeader('Umowa'), tabUmowy.content];
45
+ }
46
+ }
47
+ if (zamowienia.length > 0) {
48
+ const tabZamowienia = getContentTable<(typeof zamowienia)[0]>(definedHeaderZamowienia, zamowienia, '*');
49
+
50
+ if (tabZamowienia.content && tabZamowienia.fieldsWithValue.length > 0) {
51
+ Kolumny.zamowienia = [createSubHeader('Zamówienie'), tabZamowienia.content];
52
+ }
53
+ }
54
+
55
+ if (Kolumny.zamowienia.length > 0 || Kolumny.umowy.length > 0) {
56
+ table.push(generateTwoColumns(Kolumny.umowy, Kolumny.zamowienia));
57
+ }
58
+ if (warunkiTransakcji.WalutaUmowna?._text || warunkiTransakcji.KursUmowny?._text) {
59
+ table.push(createHeader('Waluta umowna i kurs umowny', [0, 8, 0, 4]));
60
+
61
+ table.push(createLabelText('Waluta umowna: ', warunkiTransakcji.WalutaUmowna));
62
+ table.push(createLabelText('Kurs umowny: ', warunkiTransakcji.KursUmowny));
63
+ }
64
+
65
+ if (partiaTowaru.length > 0) {
66
+ const tabPartiaTowaru = getContentTable<(typeof partiaTowaru)[0]>(
67
+ definedHeaderPartiaTowaru,
68
+ partiaTowaru,
69
+ '*',
70
+ [0, 4]
71
+ );
72
+
73
+ if (tabPartiaTowaru.content) {
74
+ table.push(generateTwoColumns(tabPartiaTowaru.content, ''));
75
+ }
76
+ }
77
+
78
+ table.push(
79
+ createLabelText('Warunki dostawy towarów: ', warunkiTransakcji.WarunkiDostawy, FormatTyp.MarginTop4)
80
+ );
81
+
82
+ if (warunkiTransakcji.PodmiotPosredniczacy?._text === '1') {
83
+ table.push(
84
+ formatText(
85
+ 'Dostawa dokonana przez podmiot, o którym mowa w art. 22 ust. 2d ustawy. Pole dotyczy sytuacji, w której podmiot uczestniczy w transakcji łańcuchowej innej niż procedura trójstronna uproszczona, o której mowa w art. 135 ust. 1 pkt 4 ustawy',
86
+ [FormatTyp.Label, FormatTyp.MarginTop4]
87
+ )
88
+ );
89
+ }
90
+
91
+ if (warunkiTransakcji.Transport) {
92
+ getTable(warunkiTransakcji.Transport).forEach((transport, index) => {
93
+ table.push(
94
+ generateTransport(transport, getTable(warunkiTransakcji.Transport).length !== 0 ? index + 1 : null)
95
+ );
96
+ });
97
+ }
98
+
99
+ return createSection(table, true);
100
+ }
@@ -0,0 +1,126 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import {
3
+ createHeader,
4
+ createLabelTextArray,
5
+ createSection,
6
+ formatText,
7
+ getContentTable,
8
+ getTable,
9
+ getValue,
10
+ } from '../../../shared/PDF-functions';
11
+ import { HeaderDefine } from '../../../shared/types/pdf-types';
12
+ import { TRodzajFaktury } from '../../../shared/consts/const';
13
+ import { Fa, FP } from '../../types/fa3.types';
14
+ import FormatTyp, { Position } from '../../../shared/enums/common.enum';
15
+ import { shouldAddMarza } from '../common/Wiersze';
16
+
17
+ export function generateWiersze(faVat: Fa): Content {
18
+ const table: Content[] = [];
19
+ const rodzajFaktury: string | number | undefined = getValue(faVat.RodzajFaktury);
20
+ const isP_PMarzy: boolean = Boolean(Number(getValue(faVat.Adnotacje?.PMarzy?.P_PMarzy)));
21
+ const faWiersze: Record<string, FP>[] = getTable(faVat.FaWiersz).map(
22
+ (wiersz: Record<string, FP>): Record<string, FP> => {
23
+ const marza: Record<string, FP> = shouldAddMarza(rodzajFaktury, isP_PMarzy, wiersz)!;
24
+ return marza ? { ...wiersz, ...marza } : wiersz;
25
+ }
26
+ );
27
+ const definedHeaderLp: HeaderDefine[] = [
28
+ { name: 'NrWierszaFa', title: 'Lp.', format: FormatTyp.Default, width: 'auto' },
29
+ ];
30
+ const definedHeader1: HeaderDefine[] = [
31
+ { name: 'UU_ID', title: 'Unikalny numer wiersza', format: FormatTyp.Default, width: 'auto' },
32
+ { name: 'P_7', title: 'Nazwa towaru lub usługi', format: FormatTyp.Default, width: '*' },
33
+ { name: 'P_9A', title: 'Cena jedn. netto', format: FormatTyp.Currency, width: 'auto' },
34
+ { name: 'P_9B', title: 'Cena jedn. brutto', format: FormatTyp.Currency, width: 'auto' },
35
+ { name: 'P_8B', title: 'Ilość', format: FormatTyp.Right, width: 'auto' },
36
+ { name: 'P_8A', title: 'Miara', format: FormatTyp.Default, width: 'auto' },
37
+ { name: 'P_10', title: 'Rabat', format: FormatTyp.Currency, width: 'auto' },
38
+ { name: 'P_12', title: 'Stawka podatku', format: FormatTyp.Default, width: 'auto' },
39
+ { name: 'P_12_XII', title: 'Stawka podatku OSS', format: FormatTyp.Default, width: 'auto' },
40
+ {
41
+ name: 'P_12_Zal_15',
42
+ title: 'Znacznik dla towaru lub usługi z zał. nr 15 do ustawy',
43
+ format: FormatTyp.Default,
44
+ width: 'auto',
45
+ },
46
+ { name: 'P_11', title: 'Wartość sprzedaży netto', format: FormatTyp.Currency, width: 'auto' },
47
+ { name: 'P_11A', title: 'Wartość sprzedaży brutto', format: FormatTyp.Currency, width: 'auto' },
48
+ { name: 'P_11Vat', title: 'Wartość sprzedaży vat', format: FormatTyp.Currency, width: 'auto' },
49
+ { name: 'KursWaluty', title: 'Kurs waluty', format: FormatTyp.Currency6, width: 'auto' },
50
+ { name: 'StanPrzed', title: 'Stan przed', format: FormatTyp.Boolean, width: 'auto' },
51
+ ];
52
+ const definedHeader2: HeaderDefine[] = [
53
+ { name: 'GTIN', title: 'GTIN', format: FormatTyp.Default, width: 'auto' },
54
+ { name: 'PKWiU', title: 'PKWiU', format: FormatTyp.Default, width: 'auto' },
55
+ { name: 'CN', title: 'CN', format: FormatTyp.Default, width: 'auto' },
56
+ { name: 'PKOB', title: 'PKOB', format: FormatTyp.Default, width: 'auto' },
57
+ { name: 'KwotaAkcyzy', title: 'KwotaAkcyzy', format: FormatTyp.Default, width: 'auto' },
58
+ { name: 'GTU', title: 'GTU', format: FormatTyp.Default, width: 'auto' },
59
+ { name: 'Procedura', title: 'Procedura', format: FormatTyp.Default, width: '*' },
60
+ { name: 'P_6A', title: 'Data dostawy / wykonania', format: FormatTyp.Default, width: 'auto' },
61
+ { name: 'Indeks', title: 'Indeks', format: FormatTyp.Default, width: 'auto' },
62
+ ];
63
+ let content = getContentTable<(typeof faWiersze)[0]>(
64
+ [...definedHeaderLp, ...definedHeader1, ...definedHeader2],
65
+ faWiersze,
66
+ 'auto'
67
+ );
68
+ const ceny = formatText(
69
+ `Faktura wystawiona w cenach ${content.fieldsWithValue.includes('P_11') ? 'netto' : 'brutto'} w walucie ${faVat.KodWaluty?._text}`,
70
+ [FormatTyp.Label, FormatTyp.MarginBottom8]
71
+ );
72
+
73
+ const p_15 = getValue(faVat.P_15);
74
+ let opis: Content = '';
75
+
76
+ if (rodzajFaktury == TRodzajFaktury.ROZ && Number(p_15) !== 0) {
77
+ opis = {
78
+ stack: createLabelTextArray([
79
+ { value: 'Kwota pozostała do zapłaty: ', formatTyp: FormatTyp.LabelGreater },
80
+ {
81
+ value: p_15,
82
+ formatTyp: FormatTyp.CurrencyGreater,
83
+ currency: getValue(faVat.KodWaluty)?.toString() ?? '',
84
+ },
85
+ ]),
86
+ alignment: Position.RIGHT,
87
+ margin: [0, 8, 0, 0],
88
+ };
89
+ } else if (
90
+ (rodzajFaktury == TRodzajFaktury.VAT ||
91
+ rodzajFaktury == TRodzajFaktury.KOR ||
92
+ rodzajFaktury == TRodzajFaktury.KOR_ROZ ||
93
+ rodzajFaktury == TRodzajFaktury.UPR) &&
94
+ Number(p_15) !== 0
95
+ ) {
96
+ opis = {
97
+ stack: createLabelTextArray([
98
+ { value: 'Kwota należności ogółem: ', formatTyp: FormatTyp.LabelGreater },
99
+ {
100
+ value: p_15,
101
+ formatTyp: [FormatTyp.CurrencyGreater, FormatTyp.HeaderContent, FormatTyp.Value],
102
+ currency: getValue(faVat.KodWaluty)?.toString() ?? '',
103
+ },
104
+ ]),
105
+ alignment: Position.RIGHT,
106
+ margin: [0, 8, 0, 0],
107
+ };
108
+ }
109
+ if (content.fieldsWithValue.length <= 8 && content.content) {
110
+ table.push(content.content);
111
+ } else {
112
+ content = getContentTable<(typeof faWiersze)[0]>([...definedHeaderLp, ...definedHeader1], faWiersze, '*');
113
+ if (content.content) {
114
+ table.push(content.content);
115
+ }
116
+ content = getContentTable<(typeof faWiersze)[0]>([...definedHeaderLp, ...definedHeader2], faWiersze, '*');
117
+ if (content.content && content.fieldsWithValue.length > 1) {
118
+ table.push('\n');
119
+ table.push(content.content);
120
+ }
121
+ }
122
+ if (table.length < 1) {
123
+ return [];
124
+ }
125
+ return createSection([...createHeader('Pozycje'), ceny, ...table, opis], true);
126
+ }
@@ -0,0 +1,143 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import {
3
+ createHeader,
4
+ createLabelTextArray,
5
+ formatText,
6
+ getContentTable,
7
+ getTable,
8
+ } from '../../../shared/PDF-functions';
9
+ import { HeaderDefine } from '../../../shared/types/pdf-types';
10
+ import { TRodzajFaktury } from '../../../shared/consts/const';
11
+ import { Zamowienie } from '../../types/fa3.types';
12
+ import FormatTyp, { Position } from '../../../shared/enums/common.enum';
13
+ import { ZamowienieKorekta } from '../../enums/invoice.enums';
14
+
15
+ export function generateZamowienie(
16
+ orderData: Zamowienie | undefined,
17
+ zamowienieKorekta: ZamowienieKorekta,
18
+ p_15: string,
19
+ rodzajFaktury: string,
20
+ KodWaluty: string
21
+ ): Content[] {
22
+ if (!orderData) {
23
+ return [];
24
+ }
25
+ const formatAbs =
26
+ zamowienieKorekta === ZamowienieKorekta.BeforeCorrection ? FormatTyp.CurrencyAbs : FormatTyp.Currency;
27
+ const orderTable = getTable(orderData?.ZamowienieWiersz).map((el, index) => {
28
+ if (!el.NrWierszaZam._text) {
29
+ el.NrWierszaZam._text = (index + 1).toString();
30
+ }
31
+ return el;
32
+ });
33
+ const definedHeaderLp: HeaderDefine[] = [
34
+ { name: 'NrWierszaZam', title: 'Lp.', format: FormatTyp.Default, width: 'auto' },
35
+ ];
36
+ const definedHeader1: HeaderDefine[] = [
37
+ { name: 'UU_ID', title: 'Unikalny numer wiersza', format: FormatTyp.Default, width: 'auto' },
38
+ { name: 'P_7Z', title: 'Nazwa towaru lub usługi', format: FormatTyp.Default, width: '*' },
39
+ {
40
+ name: 'P_9AZ',
41
+ title: 'Cena jedn. netto',
42
+ format: formatAbs,
43
+ width: 'auto',
44
+ },
45
+ { name: 'P_8BZ', title: 'Ilość', format: FormatTyp.Right, width: 'auto' },
46
+ { name: 'P_8AZ', title: 'Miara', format: FormatTyp.Default, width: 'auto' },
47
+ { name: 'P_12Z', title: 'Stawka podatku', format: FormatTyp.Default, width: 'auto' },
48
+ { name: 'P_12Z_XII', title: 'Stawka podatku OSS', format: FormatTyp.Default, width: 'auto' },
49
+ {
50
+ name: 'P_12Z_Zal_15',
51
+ title: 'Znacznik dla towaru lub usługi z zał. nr 15 do ustawy',
52
+ format: FormatTyp.Default,
53
+ width: 'auto',
54
+ },
55
+ { name: 'P_11NettoZ', title: 'Wartość sprzedaży netto', format: formatAbs, width: 'auto' },
56
+ { name: 'P_11VatZ', title: 'Kwota podatku', format: formatAbs, width: 'auto' },
57
+ ];
58
+ const definedHeader2: HeaderDefine[] = [
59
+ { name: 'UU_IDZ', title: 'Numer umowy / Zamów.', format: FormatTyp.Default, width: 'auto' },
60
+ { name: 'GTINZ', title: 'GTIN', format: FormatTyp.Default, width: 'auto' },
61
+ { name: 'PKWiUZ', title: 'PKWiU', format: FormatTyp.Default, width: 'auto' },
62
+ { name: 'CNZ', title: 'CN', format: FormatTyp.Default, width: 'auto' },
63
+ { name: 'PKOBZ', title: 'PKOB', format: FormatTyp.Default, width: 'auto' },
64
+ { name: 'KwotaAkcyzyZ', title: 'Kwota podatku akcyzowego', format: FormatTyp.Currency, width: 'auto' },
65
+ { name: 'GTUZ', title: 'GTU', format: FormatTyp.Default, width: 'auto' },
66
+ { name: 'ProceduraZ', title: 'Oznaczenia dotyczące procedur', format: FormatTyp.Default, width: '*' },
67
+ { name: 'IndeksZ', title: 'Indeks', format: FormatTyp.Default, width: 'auto' },
68
+ { name: 'StanPrzedZ', title: 'Stan przed', format: FormatTyp.Boolean, width: 'auto' },
69
+ ];
70
+
71
+ let content = getContentTable<(typeof orderTable)[0]>(
72
+ [...definedHeaderLp, ...definedHeader1, ...definedHeader2],
73
+ orderTable,
74
+ '*'
75
+ );
76
+ const table: Content[] = [];
77
+
78
+ if (content.fieldsWithValue.length <= 8) {
79
+ if (content.content) {
80
+ table.push(content.content);
81
+ }
82
+ } else {
83
+ content = getContentTable<(typeof orderTable)[0]>(
84
+ [...definedHeaderLp, ...definedHeader1],
85
+ orderTable,
86
+ '*'
87
+ );
88
+ if (content.content) {
89
+ table.push(content.content);
90
+ }
91
+ content = getContentTable<(typeof orderTable)[0]>(
92
+ [...definedHeaderLp, ...definedHeader2],
93
+ orderTable,
94
+ '*'
95
+ );
96
+ if (content.content && content.fieldsWithValue.length > 1) {
97
+ table.push(content.content);
98
+ }
99
+ }
100
+ const ceny = `Faktura wystawiona w cenach ${content.fieldsWithValue.includes('P_11') ? 'netto' : 'brutto'} w walucie ${KodWaluty}`;
101
+ let opis: Content = '';
102
+
103
+ if (Number(p_15) > 0 && rodzajFaktury == TRodzajFaktury.ZAL) {
104
+ opis = {
105
+ stack: createLabelTextArray([
106
+ { value: 'Otrzymana kwota zapłaty (zaliczki): ', formatTyp: FormatTyp.LabelGreater },
107
+ { value: p_15, formatTyp: FormatTyp.CurrencyGreater },
108
+ ]),
109
+ alignment: Position.RIGHT,
110
+ margin: [0, 8, 0, 0],
111
+ };
112
+ } else if (
113
+ zamowienieKorekta !== ZamowienieKorekta.BeforeCorrection &&
114
+ rodzajFaktury == TRodzajFaktury.KOR_ZAL &&
115
+ Number(p_15) >= 0
116
+ ) {
117
+ opis = {
118
+ stack: createLabelTextArray([
119
+ { value: 'Kwota należności ogółem: ', formatTyp: FormatTyp.LabelGreater },
120
+ { value: p_15, formatTyp: FormatTyp.CurrencyGreater },
121
+ ]),
122
+ alignment: Position.RIGHT,
123
+ margin: [0, 8, 0, 0],
124
+ };
125
+ }
126
+ return [
127
+ {
128
+ stack: [
129
+ createHeader(zamowienieKorekta),
130
+ ceny,
131
+ {
132
+ text: [
133
+ 'Wartość zamówienia lub umowy z uwzględnieniem kwoty podatku: ',
134
+ formatText(orderData.WartoscZamowienia?._text, FormatTyp.Currency),
135
+ ],
136
+ marginBottom: 4,
137
+ },
138
+ ...table,
139
+ opis,
140
+ ],
141
+ },
142
+ ];
143
+ }
@@ -0,0 +1,91 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import { TypKorekty } from '../../../shared/consts/const';
3
+ import {
4
+ createHeader,
5
+ createLabelText,
6
+ createSection,
7
+ generateTwoColumns,
8
+ getTable,
9
+ } from '../../../shared/PDF-functions';
10
+ import { DaneFaKorygowanej, Fa as Fa1 } from '../../types/fa1.types';
11
+ import { Fa as Fa2 } from '../../types/fa2.types';
12
+ import { Fa as Fa3 } from '../../types/fa3.types';
13
+
14
+ export function generateDaneFaKorygowanej(invoice?: Fa1 | Fa2 | Fa3): Content[] {
15
+ const result: Content[] = [];
16
+ let firstColumn: Content[] = [];
17
+ let secondColumn: Content[] = [];
18
+ let previousSection: boolean = false;
19
+
20
+ if (invoice) {
21
+ const daneFakturyKorygowanej: DaneFaKorygowanej[] = getTable(invoice.DaneFaKorygowanej ?? []);
22
+
23
+ if (invoice.NrFaKorygowany) {
24
+ firstColumn.push(createLabelText('Poprawny numer faktury korygowanej: ', invoice.NrFaKorygowany));
25
+ }
26
+ if (invoice.PrzyczynaKorekty) {
27
+ firstColumn.push(
28
+ createLabelText('Przyczyna korekty dla faktur korygujących: ', invoice.PrzyczynaKorekty)
29
+ );
30
+ }
31
+ if (invoice.TypKorekty?._text) {
32
+ firstColumn.push(createLabelText('Typ skutku korekty: ', TypKorekty[invoice.TypKorekty._text]));
33
+ }
34
+
35
+ if (firstColumn.length) {
36
+ firstColumn.unshift(createHeader('Dane faktury korygowanej'));
37
+ }
38
+
39
+ if (daneFakturyKorygowanej?.length === 1) {
40
+ secondColumn.push(createHeader('Dane identyfikacyjne faktury korygowanej'));
41
+ generateCorrectiveData(daneFakturyKorygowanej[0], secondColumn);
42
+ if (firstColumn.length > 0 || secondColumn.length) {
43
+ if (firstColumn.length) {
44
+ result.push(generateTwoColumns(firstColumn, secondColumn));
45
+ } else {
46
+ result.push(generateTwoColumns(secondColumn, []));
47
+ }
48
+ previousSection = true;
49
+ }
50
+ firstColumn = [];
51
+ secondColumn = [];
52
+ } else {
53
+ if (firstColumn.length > 1) {
54
+ result.push(generateTwoColumns(firstColumn, []));
55
+ previousSection = true;
56
+ }
57
+ firstColumn = [];
58
+ daneFakturyKorygowanej?.forEach((item: DaneFaKorygowanej, index: number): void => {
59
+ if (index % 2 === 0) {
60
+ firstColumn.push(createHeader(`Dane identyfikacyjne faktury korygowanej ${index + 1}`));
61
+ generateCorrectiveData(item, firstColumn);
62
+ } else {
63
+ secondColumn.push(createHeader(`Dane identyfikacyjne faktury korygowanej ${index + 1}`));
64
+ generateCorrectiveData(item, secondColumn);
65
+ }
66
+ });
67
+ }
68
+ }
69
+
70
+ if (firstColumn.length && secondColumn.length) {
71
+ result.push(createSection([generateTwoColumns(firstColumn, secondColumn)], previousSection));
72
+ }
73
+ return createSection(result, true);
74
+ }
75
+
76
+ function generateCorrectiveData(data: DaneFaKorygowanej, column: Content[]): void {
77
+ if (data.DataWystFaKorygowanej) {
78
+ column.push(
79
+ createLabelText(
80
+ 'Data wystawienia faktury, której dotyczy faktura korygująca: ',
81
+ data.DataWystFaKorygowanej
82
+ )
83
+ );
84
+ }
85
+ if (data.NrFaKorygowanej) {
86
+ column.push(createLabelText('Numer faktury korygowanej: ', data.NrFaKorygowanej));
87
+ }
88
+ if (data.NrKSeFFaKorygowanej) {
89
+ column.push(createLabelText('Numer KSeF faktury korygowanej: ', data.NrKSeFFaKorygowanej));
90
+ }
91
+ }
@@ -0,0 +1,84 @@
1
+ import { Content, ContentText } from 'pdfmake/interfaces';
2
+ import { formatText, generateLine } from '../../../shared/PDF-functions';
3
+ import { TRodzajFaktury } from '../../../shared/consts/const';
4
+ import { Fa as Fa1 } from '../../types/fa1.types';
5
+ import { Fa as Fa2 } from '../../types/fa2.types';
6
+ import { Fa as Fa3, Zalacznik } from '../../types/fa3.types';
7
+ import FormatTyp, { Position } from '../../../shared/enums/common.enum';
8
+ import { AdditionalDataTypes } from '../../types/common.types';
9
+
10
+ export function generateNaglowek(
11
+ fa?: Fa2 | Fa3 | Fa1,
12
+ additionalData?: AdditionalDataTypes,
13
+ zalacznik?: Zalacznik
14
+ ): Content[] {
15
+ let invoiceName = '???';
16
+
17
+ switch (fa?.RodzajFaktury?._text) {
18
+ case TRodzajFaktury.VAT:
19
+ invoiceName = 'Faktura podstawowa';
20
+ break;
21
+ case TRodzajFaktury.ZAL:
22
+ invoiceName = 'Faktura zaliczkowa';
23
+ break;
24
+ case TRodzajFaktury.ROZ:
25
+ invoiceName = 'Faktura rozliczeniowa';
26
+ break;
27
+ case TRodzajFaktury.KOR_ROZ:
28
+ invoiceName = 'Faktura korygująca rozliczeniową';
29
+ break;
30
+ case TRodzajFaktury.KOR_ZAL:
31
+ invoiceName = 'Faktura korygująca zaliczkową';
32
+ break;
33
+ case TRodzajFaktury.KOR:
34
+ if (fa?.OkresFaKorygowanej != null) {
35
+ invoiceName = 'Faktura korygująca zbiorcza (rabat)';
36
+ } else {
37
+ invoiceName = 'Faktura korygująca';
38
+ }
39
+ break;
40
+ case TRodzajFaktury.UPR:
41
+ invoiceName = 'Faktura uproszczona';
42
+ break;
43
+ }
44
+
45
+ return [
46
+ // {
47
+ // text: [
48
+ // { text: 'Krajowy System ', fontSize: 18 },
49
+ // { text: 'e', color: 'red', bold: true, fontSize: 18 },
50
+ // { text: '-Faktur', bold: true, fontSize: 18 },
51
+ // ],
52
+ // },
53
+ { ...(formatText('Numer Faktury:', FormatTyp.ValueMedium) as ContentText), alignment: Position.RIGHT },
54
+ { ...(formatText(fa?.P_2?._text, FormatTyp.HeaderPosition) as ContentText), alignment: Position.RIGHT },
55
+ {
56
+ ...(formatText(invoiceName, [FormatTyp.ValueMedium, FormatTyp.Default]) as ContentText),
57
+ alignment: Position.RIGHT,
58
+ },
59
+ ...(additionalData?.nrKSeF
60
+ ? [
61
+ {
62
+ text: [
63
+ formatText('Numer KSEF:', FormatTyp.LabelMedium) as ContentText,
64
+ formatText(additionalData?.nrKSeF, FormatTyp.ValueMedium),
65
+ ],
66
+ alignment: Position.RIGHT,
67
+ } as Content,
68
+ ]
69
+ : []),
70
+ ...(additionalData?.isMobile && zalacznik
71
+ ? [
72
+ { stack: [generateLine()], margin: [0, 8, 0, 8] } as Content,
73
+ {
74
+ text: [
75
+ formatText(
76
+ 'Uwaga, faktura zawiera załącznik, jednak ze względu na ograniczenia wizualizacji, nie został on uwzględniony w pliku PDF',
77
+ FormatTyp.Bold
78
+ ),
79
+ ],
80
+ },
81
+ ]
82
+ : []),
83
+ ];
84
+ }