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 FormatTyp from '../../../shared/enums/common.enum';
14
+ import { Adres, Transport } from '../../types/fa2.types';
15
+ import {
16
+ getDateTimeWithoutSeconds,
17
+ getOpisTransportuString,
18
+ getRodzajTransportuString,
19
+ } from '../../../shared/generators/common/functions';
20
+ import { generatePrzewoznik } from './Przewoznik';
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: Adres[] = getTable(transport.WysylkaPrzez);
90
+
91
+ wysylkaPrzez.forEach((adres: Adres, index: number): void => {
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,105 @@
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, Transport, Umowy, WarunkiTransakcji, Zamowienia } from '../../types/fa2.types';
14
+ import { generateTransport } from './Transport';
15
+ import FormatTyp from '../../../shared/enums/common.enum';
16
+ import { TableWithFields } from '../../types/fa1-additional-types';
17
+
18
+ export function generateWarunkiTransakcji(warunkiTransakcji: WarunkiTransakcji | undefined): Content {
19
+ if (!warunkiTransakcji) {
20
+ return [];
21
+ }
22
+ const table: Content[] = [];
23
+ const Kolumny = { umowy: [] as Content[], zamowienia: [] as Content[] };
24
+ const umowy: Umowy[] = getTable(warunkiTransakcji?.Umowy);
25
+ const zamowienia: Zamowienia[] = getTable(warunkiTransakcji?.Zamowienia);
26
+ const partiaTowaru: FP[] = getTable(warunkiTransakcji?.NrPartiiTowaru);
27
+ const definedHeaderUmowy: HeaderDefine[] = [
28
+ { name: 'DataUmowy', title: 'Data umowy', format: FormatTyp.Default },
29
+ { name: 'NrUmowy', title: 'Numer umowy', format: FormatTyp.Default },
30
+ ];
31
+ const definedHeaderZamowienia: HeaderDefine[] = [
32
+ { name: 'DataZamowienia', title: 'Data zamówienia', format: FormatTyp.Default },
33
+ { name: 'NrZamowienia', title: 'Numer zamówienia', format: FormatTyp.Default },
34
+ ];
35
+ const definedHeaderPartiaTowaru: HeaderDefine[] = [
36
+ { name: '', title: 'Numer partii towaru', format: FormatTyp.Default },
37
+ ];
38
+
39
+ table.push(createHeader('Warunki transakcji', [0, 8, 0, 4]));
40
+
41
+ if (umowy.length > 0) {
42
+ const tabUmowy: TableWithFields = getContentTable<(typeof umowy)[0]>(definedHeaderUmowy, umowy, '*');
43
+
44
+ if (tabUmowy.content) {
45
+ Kolumny.umowy = [createSubHeader('Umowa'), tabUmowy.content];
46
+ }
47
+ }
48
+ if (zamowienia.length > 0) {
49
+ const tabZamowienia: TableWithFields = getContentTable<(typeof zamowienia)[0]>(
50
+ definedHeaderZamowienia,
51
+ zamowienia,
52
+ '*'
53
+ );
54
+
55
+ if (tabZamowienia.content && tabZamowienia.fieldsWithValue.length > 0) {
56
+ Kolumny.zamowienia = [createSubHeader('Zamówienie'), tabZamowienia.content];
57
+ }
58
+ }
59
+
60
+ if (Kolumny.zamowienia.length > 0 || Kolumny.umowy.length > 0) {
61
+ table.push(generateTwoColumns(Kolumny.umowy, Kolumny.zamowienia));
62
+ }
63
+ if (warunkiTransakcji.WalutaUmowna?._text || warunkiTransakcji.KursUmowny?._text) {
64
+ table.push(createHeader('Waluta umowna i kurs umowny', [0, 8, 0, 4]));
65
+
66
+ table.push(createLabelText('Waluta umowna: ', warunkiTransakcji.WalutaUmowna));
67
+ table.push(createLabelText('Kurs umowny: ', warunkiTransakcji.KursUmowny));
68
+ }
69
+
70
+ if (partiaTowaru.length > 0) {
71
+ const tabPartiaTowaru: TableWithFields = getContentTable<(typeof partiaTowaru)[0]>(
72
+ definedHeaderPartiaTowaru,
73
+ partiaTowaru,
74
+ '*',
75
+ [0, 4]
76
+ );
77
+
78
+ if (tabPartiaTowaru.content) {
79
+ table.push(generateTwoColumns(tabPartiaTowaru.content, ''));
80
+ }
81
+ }
82
+
83
+ table.push(
84
+ createLabelText('Warunki dostawy towarów: ', warunkiTransakcji.WarunkiDostawy, FormatTyp.MarginTop4)
85
+ );
86
+
87
+ if (warunkiTransakcji.PodmiotPosredniczacy?._text === '1') {
88
+ table.push(
89
+ formatText(
90
+ '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',
91
+ [FormatTyp.Label, FormatTyp.MarginTop4]
92
+ )
93
+ );
94
+ }
95
+
96
+ if (warunkiTransakcji.Transport) {
97
+ getTable(warunkiTransakcji.Transport).forEach((transport: Transport, index: number): void => {
98
+ table.push(
99
+ generateTransport(transport, getTable(warunkiTransakcji.Transport).length !== 0 ? index + 1 : null)
100
+ );
101
+ });
102
+ }
103
+
104
+ return createSection(table, true);
105
+ }
@@ -0,0 +1,126 @@
1
+ import { Content, ContentText } 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/fa2.types';
14
+ import FormatTyp, { Position } from '../../../shared/enums/common.enum';
15
+ import { TableWithFields } from '../../types/fa1-additional-types';
16
+ import { shouldAddMarza } from '../common/Wiersze';
17
+
18
+ export function generateWiersze(faVat: Fa): Content {
19
+ const table: Content[] = [];
20
+ const rodzajFaktury: string | number | undefined = getValue(faVat.RodzajFaktury);
21
+ const isP_PMarzy: boolean = Boolean(Number(getValue(faVat.Adnotacje?.PMarzy?.P_PMarzy)));
22
+ const faWiersze: Record<string, FP>[] = getTable(faVat.FaWiersz).map((wiersz) => {
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: TableWithFields = getContentTable<(typeof faWiersze)[0]>(
64
+ [...definedHeaderLp, ...definedHeader1, ...definedHeader2],
65
+ faWiersze,
66
+ 'auto'
67
+ );
68
+ const ceny: string | ContentText = 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: string | number | undefined = 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,144 @@
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 { FP, Zamowienie } from '../../types/fa2.types';
12
+ import FormatTyp, { Position } from '../../../shared/enums/common.enum';
13
+ import { TableWithFields } from '../../types/fa1-additional-types';
14
+ import { ZamowienieKorekta } from '../../enums/invoice.enums';
15
+
16
+ export function generateZamowienie(
17
+ orderData: Zamowienie | undefined,
18
+ zamowienieKorekta: ZamowienieKorekta,
19
+ p_15: string,
20
+ rodzajFaktury: string,
21
+ KodWaluty: string
22
+ ): Content[] {
23
+ if (!orderData) {
24
+ return [];
25
+ }
26
+ const formatAbs: FormatTyp.Currency | FormatTyp.CurrencyAbs =
27
+ zamowienieKorekta === ZamowienieKorekta.BeforeCorrection ? FormatTyp.CurrencyAbs : FormatTyp.Currency;
28
+ const orderTable: Record<string, FP>[] = getTable(orderData?.ZamowienieWiersz).map((el, index) => {
29
+ if (!el.NrWierszaZam._text) {
30
+ el.NrWierszaZam._text = (index + 1).toString();
31
+ }
32
+ return el;
33
+ });
34
+ const definedHeaderLp: HeaderDefine[] = [
35
+ { name: 'NrWierszaZam', title: 'Lp.', format: FormatTyp.Default, width: 'auto' },
36
+ ];
37
+ const definedHeader1: HeaderDefine[] = [
38
+ { name: 'UU_ID', title: 'Unikalny numer wiersza', format: FormatTyp.Default, width: 'auto' },
39
+ { name: 'P_7Z', title: 'Nazwa towaru lub usługi', format: FormatTyp.Default, width: '*' },
40
+ {
41
+ name: 'P_9AZ',
42
+ title: 'Cena jedn. netto',
43
+ format: formatAbs,
44
+ width: 'auto',
45
+ },
46
+ { name: 'P_8BZ', title: 'Ilość', format: FormatTyp.Right, width: 'auto' },
47
+ { name: 'P_8AZ', title: 'Miara', format: FormatTyp.Default, width: 'auto' },
48
+ { name: 'P_12Z', title: 'Stawka podatku', format: FormatTyp.Default, width: 'auto' },
49
+ { name: 'P_12Z_XII', title: 'Stawka podatku OSS', format: FormatTyp.Default, width: 'auto' },
50
+ {
51
+ name: 'P_12Z_Zal_15',
52
+ title: 'Znacznik dla towaru lub usługi z zał. nr 15 do ustawy',
53
+ format: FormatTyp.Default,
54
+ width: 'auto',
55
+ },
56
+ { name: 'P_11NettoZ', title: 'Wartość sprzedaży netto', format: formatAbs, width: 'auto' },
57
+ { name: 'P_11VatZ', title: 'Kwota podatku', format: formatAbs, width: 'auto' },
58
+ ];
59
+ const definedHeader2: HeaderDefine[] = [
60
+ { name: 'UU_IDZ', title: 'Numer umowy / Zamów.', format: FormatTyp.Default, width: 'auto' },
61
+ { name: 'GTINZ', title: 'GTIN', format: FormatTyp.Default, width: 'auto' },
62
+ { name: 'PKWiUZ', title: 'PKWiU', format: FormatTyp.Default, width: 'auto' },
63
+ { name: 'CNZ', title: 'CN', format: FormatTyp.Default, width: 'auto' },
64
+ { name: 'PKOBZ', title: 'PKOB', format: FormatTyp.Default, width: 'auto' },
65
+ { name: 'KwotaAkcyzyZ', title: 'Kwota podatku akcyzowego', format: FormatTyp.Currency, width: 'auto' },
66
+ { name: 'GTUZ', title: 'GTU', format: FormatTyp.Default, width: 'auto' },
67
+ { name: 'ProceduraZ', title: 'Oznaczenia dotyczące procedur', format: FormatTyp.Default, width: '*' },
68
+ { name: 'IndeksZ', title: 'Indeks', format: FormatTyp.Default, width: 'auto' },
69
+ { name: 'StanPrzedZ', title: 'Stan przed', format: FormatTyp.Boolean, width: 'auto' },
70
+ ];
71
+
72
+ let content: TableWithFields = getContentTable<(typeof orderTable)[0]>(
73
+ [...definedHeaderLp, ...definedHeader1, ...definedHeader2],
74
+ orderTable,
75
+ '*'
76
+ );
77
+ const table: Content[] = [];
78
+
79
+ if (content.fieldsWithValue.length <= 8) {
80
+ if (content.content) {
81
+ table.push(content.content);
82
+ }
83
+ } else {
84
+ content = getContentTable<(typeof orderTable)[0]>(
85
+ [...definedHeaderLp, ...definedHeader1],
86
+ orderTable,
87
+ '*'
88
+ );
89
+ if (content.content) {
90
+ table.push(content.content);
91
+ }
92
+ content = getContentTable<(typeof orderTable)[0]>(
93
+ [...definedHeaderLp, ...definedHeader2],
94
+ orderTable,
95
+ '*'
96
+ );
97
+ if (content.content && content.fieldsWithValue.length > 1) {
98
+ table.push(content.content);
99
+ }
100
+ }
101
+ const ceny = `Faktura wystawiona w cenach ${content.fieldsWithValue.includes('P_11') ? 'netto' : 'brutto'} w walucie ${KodWaluty}`;
102
+ let opis: Content = '';
103
+
104
+ if (Number(p_15) > 0 && rodzajFaktury == TRodzajFaktury.ZAL) {
105
+ opis = {
106
+ stack: createLabelTextArray([
107
+ { value: 'Otrzymana kwota zapłaty (zaliczki): ', formatTyp: FormatTyp.LabelGreater },
108
+ { value: p_15, formatTyp: FormatTyp.CurrencyGreater },
109
+ ]),
110
+ alignment: Position.RIGHT,
111
+ margin: [0, 8, 0, 0],
112
+ };
113
+ } else if (
114
+ zamowienieKorekta !== ZamowienieKorekta.BeforeCorrection &&
115
+ rodzajFaktury == TRodzajFaktury.KOR_ZAL &&
116
+ Number(p_15) >= 0
117
+ ) {
118
+ opis = {
119
+ stack: createLabelTextArray([
120
+ { value: 'Kwota należności ogółem: ', formatTyp: FormatTyp.LabelGreater },
121
+ { value: p_15, formatTyp: FormatTyp.CurrencyGreater },
122
+ ]),
123
+ alignment: Position.RIGHT,
124
+ margin: [0, 8, 0, 0],
125
+ };
126
+ }
127
+ return [
128
+ {
129
+ stack: [
130
+ createHeader(zamowienieKorekta),
131
+ ceny,
132
+ {
133
+ text: [
134
+ 'Wartość zamówienia lub umowy z uwzględnieniem kwoty podatku: ',
135
+ formatText(orderData.WartoscZamowienia?._text, FormatTyp.Currency),
136
+ ],
137
+ marginBottom: 4,
138
+ },
139
+ ...table,
140
+ opis,
141
+ ],
142
+ },
143
+ ];
144
+ }