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,32 @@
1
+ import { generateFA3 } from './FA3-generator';
2
+ import { Faktura as Faktura3 } from './types/fa3.types';
3
+ import { parseXML } from '../shared/XML-parser';
4
+ import { TCreatedPdf } from 'pdfmake/build/pdfmake';
5
+ import { AdditionalDataTypes } from './types/common.types';
6
+
7
+ export async function generateInvoice(
8
+ xmlString: string,
9
+ additionalData: AdditionalDataTypes
10
+ ) {
11
+ const xml = parseXML(xmlString);
12
+ const wersja: any = xml.Faktura?.Naglowek?.KodFormularza?._attributes?.kodSystemowy;
13
+
14
+ let pdf: TCreatedPdf;
15
+
16
+ return new Promise<string>(res => {
17
+ switch (wersja) {
18
+ // case 'FA (1)':
19
+ // pdf = generateFA1((xml as any).Faktura as Faktura1, additionalData);
20
+ // break;
21
+ // case 'FA (2)':
22
+ // pdf = generateFA2((xml as any).Faktura as Faktura2, additionalData);
23
+ // break;
24
+ case 'FA (3)':
25
+ pdf = generateFA3(xml.Faktura as Faktura3, additionalData);
26
+ break;
27
+ }
28
+ pdf.getBase64(result => {
29
+ res(result);
30
+ });
31
+ });
32
+ }
@@ -0,0 +1,206 @@
1
+ import { Content, ContentTable, ContentText, TableCell } from 'pdfmake/interfaces';
2
+ import {
3
+ createHeader,
4
+ createLabelText,
5
+ formatText,
6
+ getTable,
7
+ hasValue,
8
+ verticalSpacing,
9
+ } from '../../../shared/PDF-functions';
10
+ import { Adnotacje, NoweSrodkiTransportu, Zwolnienie } from '../../types/fa2.types';
11
+ import FormatTyp from '../../../shared/enums/common.enum';
12
+ import { DEFAULT_TABLE_LAYOUT } from '../../../shared/consts/const';
13
+ import { FP } from '../../types/fa1.types';
14
+
15
+ export function generateAdnotacje(adnotacje?: Adnotacje): Content[] {
16
+ const result: Content[] = [];
17
+ let firstColumn: Content[] = [];
18
+ const secondColumn: Content[] = [];
19
+
20
+ if (adnotacje) {
21
+ const zwolnienie: Zwolnienie | undefined = adnotacje.Zwolnienie;
22
+
23
+ if (zwolnienie?.P_19?._text === '1') {
24
+ firstColumn.push({
25
+ text: 'Dostawa towarów lub świadczenie usług zwolnionych od podatku na podstawie art. 43 ust. 1, art. 113 ust. 1 i 9 albo przepisów wydanych na podstawie art. 82 ust. 3 lub na podstawie innych przepisów',
26
+ });
27
+ if (zwolnienie.P_19A?._text) {
28
+ firstColumn.push(
29
+ createLabelText(
30
+ 'Podstawa zwolnienia od podatku: ',
31
+ 'Przepis ustawy albo aktu wydanego na podstawie ustawy, na podstawie którego podatnik stosuje zwolnienie od podatku'
32
+ )
33
+ );
34
+ firstColumn.push(
35
+ createLabelText('Przepis ustawy albo aktu wydanego na podstawie ustawy: ', zwolnienie.P_19A._text)
36
+ );
37
+ }
38
+ if (zwolnienie.P_19B?._text) {
39
+ firstColumn.push(
40
+ createLabelText(
41
+ 'Podstawa zwolnienia od podatku: ',
42
+ 'Przepis dyrektywy 2006/112/WE, który zwalnia od podatku taką dostawę towarów lub takie świadczenie usług'
43
+ )
44
+ );
45
+ firstColumn.push(createLabelText('Przepis dyrektywy: ', zwolnienie.P_19B._text));
46
+ }
47
+ if (zwolnienie.P_19C?._text) {
48
+ firstColumn.push(
49
+ createLabelText(
50
+ 'Podstawa zwolnienia od podatku: ',
51
+ 'Inna podstawa prawna wskazującą na to, że dostawa towarów lub świadczenie usług korzysta ze zwolnienia'
52
+ )
53
+ );
54
+ firstColumn.push(createLabelText('Inna podstawa prawna: ', zwolnienie.P_19C._text));
55
+ }
56
+ }
57
+
58
+ if (
59
+ adnotacje.NoweSrodkiTransportu?.P_42_5?._text === '1' ||
60
+ adnotacje.NoweSrodkiTransportu?.P_42_5?._text === '2'
61
+ ) {
62
+ let obowiazekVAT: Content[] = [];
63
+ let value: string = ' ';
64
+
65
+ if (adnotacje.NoweSrodkiTransportu.P_42_5?._text === '1') {
66
+ value = 'Istnieje obowiązek wystawienia dokumentu VAT-22';
67
+ } else if (adnotacje.NoweSrodkiTransportu.P_42_5?._text === '2') {
68
+ value = 'Nie istnieje obowiązek wystawienia dokumentu VAT-22';
69
+ }
70
+ obowiazekVAT = [
71
+ ...createLabelText('Wewnątrzwspólnotowe dostawy nowych środków transportu: ', value ?? ''),
72
+ ];
73
+ if (obowiazekVAT) {
74
+ firstColumn = [firstColumn, ...obowiazekVAT];
75
+ }
76
+ }
77
+
78
+ if (adnotacje.P_18A?._text === '1') {
79
+ secondColumn.push({ text: 'Mechanizm podzielonej płatności' });
80
+ }
81
+ if (adnotacje.P_16?._text === '1') {
82
+ secondColumn.push({ text: 'Metoda kasowa' });
83
+ }
84
+ if (adnotacje.P_18?._text === '1') {
85
+ secondColumn.push({ text: 'Odwrotne obciążenie' });
86
+ }
87
+ if (adnotacje.P_23?._text === '1') {
88
+ secondColumn.push({ text: 'Procedura trójstronna uproszczona' });
89
+ }
90
+ if (adnotacje.PMarzy?.P_PMarzy?._text === '1') {
91
+ let valueMarzy: string = '';
92
+
93
+ if (adnotacje.PMarzy.P_PMarzy_3_1?._text === '1') {
94
+ valueMarzy = 'towary używane';
95
+ } else if (adnotacje.PMarzy.P_PMarzy_3_2?._text === '1') {
96
+ valueMarzy = 'dzieła sztuki';
97
+ } else if (adnotacje.PMarzy.P_PMarzy_2?._text === '1') {
98
+ valueMarzy = 'biura podróży';
99
+ } else if (adnotacje.PMarzy.P_PMarzy_3_3?._text === '1') {
100
+ valueMarzy = 'przedmioty kolekcjonerskie i antyki';
101
+ }
102
+ secondColumn.push(createLabelText('Procedura marży: ', valueMarzy));
103
+ }
104
+ if (adnotacje.P_17?._text === '1') {
105
+ secondColumn.push({ text: 'Samofakturowanie' });
106
+ }
107
+ if (firstColumn.length || secondColumn.length) {
108
+ result.push({ columns: [firstColumn, secondColumn], columnGap: 20 });
109
+ }
110
+
111
+ if (result.length) {
112
+ result.unshift(verticalSpacing(1));
113
+ result.unshift(createHeader('Adnotacje'));
114
+ result.unshift(verticalSpacing(1));
115
+ result.push(verticalSpacing(1));
116
+ }
117
+
118
+ if (
119
+ adnotacje.NoweSrodkiTransportu?.P_42_5?._text === '1' ||
120
+ adnotacje.NoweSrodkiTransportu?.P_42_5?._text === '2'
121
+ ) {
122
+ result.push(generateDostawy(adnotacje.NoweSrodkiTransportu));
123
+ }
124
+ }
125
+ return result;
126
+ }
127
+
128
+ export function generateDostawy(noweSrodkiTransportu: NoweSrodkiTransportu): Content[] {
129
+ const nowySrodekTransportu: Record<string, FP>[] = getTable(noweSrodkiTransportu.NowySrodekTransportu);
130
+ let tableBody: TableCell[] = [];
131
+ const table: ContentTable = {
132
+ table: {
133
+ headerRows: 1,
134
+ widths: [100, '*'],
135
+ body: [] as TableCell[][],
136
+ },
137
+ layout: DEFAULT_TABLE_LAYOUT,
138
+ marginTop: 4,
139
+ };
140
+
141
+ if (nowySrodekTransportu?.length) {
142
+ const definedHeader: Content[] = [
143
+ { text: 'Data dopuszczenia do użytku', style: FormatTyp.GrayBoldTitle },
144
+ { text: 'Opis', style: FormatTyp.GrayBoldTitle },
145
+ ];
146
+
147
+ tableBody = nowySrodekTransportu.map((item: Record<string, FP>): (string | ContentText)[] => {
148
+ const value: string[] = [];
149
+ const anyP22B =
150
+ hasValue(item.P_22B) ||
151
+ hasValue(item.P_22BT) ||
152
+ hasValue(item.P_22B1) ||
153
+ hasValue(item.P_22B2) ||
154
+ hasValue(item.P_22B3) ||
155
+ hasValue(item.P_22B4);
156
+ const anyP22C: boolean = hasValue(item.P_22C) || hasValue(item.P_22C1);
157
+ const anyP22D: boolean = hasValue(item.P_22D) || hasValue(item.P_22D1);
158
+ const anyP22N: boolean =
159
+ hasValue(item.P_22B1) || hasValue(item.P_22B2) || hasValue(item.P_22B3) || hasValue(item.P_22B4);
160
+
161
+ if (item.P_NrWierszaNST?._text) {
162
+ value.push(item.P_NrWierszaNST._text);
163
+ }
164
+ if (anyP22B) {
165
+ value.push('Dostawa dotyczy pojazdów lądowych, o których mowa w art. 2 pkt 10 lit. a ustawy');
166
+ } else if (anyP22C) {
167
+ value.push('Dostawa dotyczy jednostek pływających, o których mowa w art. 2 pkt 10 lit. b ustawy');
168
+ } else if (anyP22D) {
169
+ value.push('Dostawa dotyczy statków powietrznych, o których mowa w art. 2 pkt 10 lit. c ustawy');
170
+ }
171
+ if (item.DetailsString?._text) {
172
+ value.push(item.DetailsString._text);
173
+ }
174
+ if (anyP22B || anyP22C || anyP22D) {
175
+ value.push(item.P_22B?._text ?? item.P_22C?._text ?? item.P_22D?._text ?? '');
176
+ }
177
+ if (item.P_22C1?._text) {
178
+ value.push(`Numer kadłuba nowego środka transportu: ${item.P_22C1._text}`);
179
+ }
180
+ if (item.P_22D1?._text) {
181
+ value.push(`Numer fabryczny nowego środka transportu: ${item.P_22D1._text}`);
182
+ }
183
+ if (anyP22N) {
184
+ if (item.P_22B1?._text) {
185
+ value.push(`Numer VIN: ${item.P_22B1._text}`);
186
+ }
187
+ if (item.P_22B2?._text) {
188
+ value.push(`Numer nadwozia: ${item.P_22B2._text}`);
189
+ }
190
+ if (item.P_22B3?._text) {
191
+ value.push(`Numer podwozia: ${item.P_22B3._text}`);
192
+ }
193
+ if (item.P_22B4?._text) {
194
+ value.push(`Numer ramy: ${item.P_22B4._text}`);
195
+ }
196
+ }
197
+ if (item.P_22BT?._text) {
198
+ value.push(item.P_22BT._text);
199
+ }
200
+ return [formatText(item.P_22A?._text), { text: value.join('\n') }];
201
+ });
202
+ table.table.body = [[...definedHeader], ...tableBody] as TableCell[][];
203
+ }
204
+
205
+ return tableBody.length ? [table, verticalSpacing(1)] : [];
206
+ }
@@ -0,0 +1,20 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import { createLabelText, formatText, getKraj } from '../../../shared/PDF-functions';
3
+ import FormatTyp from '../../../shared/enums/common.enum';
4
+ import { Adres } from '../../types/fa2.types';
5
+
6
+ export function generateAdres(adres: Adres): Content[] {
7
+ const result: Content[] = [];
8
+
9
+ if (adres?.AdresL1) {
10
+ result.push(formatText(adres.AdresL1._text, FormatTyp.Value));
11
+ }
12
+ if (adres?.AdresL2) {
13
+ result.push(formatText(adres.AdresL2._text, FormatTyp.Value));
14
+ }
15
+ if (adres?.KodKraju) {
16
+ result.push(formatText(getKraj(adres.KodKraju._text ?? ''), FormatTyp.Value));
17
+ }
18
+ result.push(...createLabelText('GLN: ', adres.GLN));
19
+ return result;
20
+ }
@@ -0,0 +1,97 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import {
3
+ createHeader,
4
+ createSection,
5
+ createSubHeader,
6
+ formatText,
7
+ getContentTable,
8
+ getTable,
9
+ getValue,
10
+ } from '../../../shared/PDF-functions';
11
+ import { HeaderDefine } from '../../../shared/types/pdf-types';
12
+ import { DodatkowyOpi, Fa } from '../../types/fa2.types';
13
+ import FormatTyp from '../../../shared/enums/common.enum';
14
+ import { FormContentState } from '../../../shared/types/additional-data.types';
15
+
16
+ export function generateDodatkoweInformacje(faVat: Fa): Content[] {
17
+ const tpLabel1: Content[] = [];
18
+ const tpLabel2: Content[] = [];
19
+
20
+ if (getValue(faVat.TP) === '1') {
21
+ tpLabel1.push(
22
+ formatText('- Istniejące powiązania między nabywcą a dokonującym dostawy towarów lub usługodawcą')
23
+ );
24
+ tpLabel2.push(formatText('- Faktura, o której mowa w art. 109 ust. 3d ustawy'));
25
+ }
26
+ const zwrotAkcyzyLabel: Content[] = [];
27
+
28
+ if (getValue(faVat.ZwrotAkcyzy) === '1') {
29
+ zwrotAkcyzyLabel.push(
30
+ formatText(
31
+ '- Informacja dodatkowa związana ze zwrotem podatku akcyzowego zawartego w cenie oleju napędowego'
32
+ )
33
+ );
34
+ }
35
+
36
+ const labels: Content[][] = [tpLabel1, tpLabel2, zwrotAkcyzyLabel].filter(
37
+ (el: Content[]): boolean => el.length > 0
38
+ );
39
+ const table: Content[] = [
40
+ ...createHeader('Dodatkowe informacje'),
41
+ ...labels,
42
+ ...generateDodatkowyOpis(faVat.DodatkowyOpis),
43
+ ];
44
+
45
+ return table.length > 1 ? createSection(table, true) : [];
46
+ }
47
+
48
+ function generateDodatkowyOpis(fakturaZaliczkowaData: DodatkowyOpi[] | undefined): Content[] {
49
+ if (!fakturaZaliczkowaData) {
50
+ return [];
51
+ }
52
+ const fakturaZaliczkowa: DodatkowyOpi[] = getTable(fakturaZaliczkowaData)?.map(
53
+ (item: DodatkowyOpi, index: number) => ({
54
+ ...item,
55
+ lp: { _text: index + 1 },
56
+ })
57
+ );
58
+ const table: Content[] = createSubHeader('Dodatkowy opis');
59
+
60
+ const fakturaZaliczkowaHeader: HeaderDefine[] = [
61
+ {
62
+ name: 'lp',
63
+ title: 'Lp.',
64
+ format: FormatTyp.Default,
65
+ width: 'auto',
66
+ },
67
+ {
68
+ name: 'NrWiersza',
69
+ title: 'Numer wiersza',
70
+ format: FormatTyp.Default,
71
+ width: 'auto',
72
+ },
73
+ {
74
+ name: 'Klucz',
75
+ title: 'Rodzaj informacji',
76
+ format: FormatTyp.Default,
77
+ width: 'auto',
78
+ },
79
+ {
80
+ name: 'Wartosc',
81
+ title: 'Treść informacji',
82
+ format: FormatTyp.Default,
83
+ width: '*',
84
+ },
85
+ ];
86
+ const tableFakturaZaliczkowa: FormContentState = getContentTable<(typeof fakturaZaliczkowa)[0]>(
87
+ fakturaZaliczkowaHeader,
88
+ fakturaZaliczkowa,
89
+ '*',
90
+ [0, 0, 0, 0]
91
+ );
92
+
93
+ if (tableFakturaZaliczkowa.content) {
94
+ table.push(tableFakturaZaliczkowa.content);
95
+ }
96
+ return table;
97
+ }
@@ -0,0 +1,131 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import {
3
+ createHeader,
4
+ createLabelText,
5
+ generateLine,
6
+ generateTwoColumns,
7
+ getContentTable,
8
+ getTable,
9
+ hasValue,
10
+ } from '../../../shared/PDF-functions';
11
+ import { HeaderDefine } from '../../../shared/types/pdf-types';
12
+ import { Platnosc, TerminPlatnosci, ZaplataCzesciowa } from '../../types/fa2.types';
13
+ import { getFormaPlatnosciString } from '../../../shared/generators/common/functions';
14
+ import { generujRachunekBankowy } from './RachunekBankowy';
15
+ import FormatTyp from '../../../shared/enums/common.enum';
16
+ import { FP } from '../../types/fa1.types';
17
+ import { FormContentState } from '../../../shared/types/additional-data.types';
18
+
19
+ export function generatePlatnosc(platnosc: Platnosc | undefined): Content {
20
+ if (!platnosc) {
21
+ return [];
22
+ }
23
+
24
+ const terminPlatnosci: TerminPlatnosci[] = getTable(platnosc.TerminPlatnosci);
25
+
26
+ const zaplataCzesciowaHeader: HeaderDefine[] = [
27
+ {
28
+ name: 'Termin',
29
+ title: 'Termin płatności',
30
+ format: FormatTyp.Default,
31
+ },
32
+ ];
33
+
34
+ if (terminPlatnosci.some((termin: TerminPlatnosci): FP | undefined => termin.TerminOpis)) {
35
+ zaplataCzesciowaHeader.push({ name: 'TerminOpis', title: 'Opis płatności', format: FormatTyp.Default });
36
+ }
37
+
38
+ const zaplataCzesciowaNaglowek: HeaderDefine[] = [
39
+ {
40
+ name: 'DataZaplatyCzesciowej',
41
+ title: 'Data zapłaty częściowej',
42
+ format: FormatTyp.Default,
43
+ },
44
+ { name: 'KwotaZaplatyCzesciowej', title: 'Kwota zapłaty częściowej', format: FormatTyp.Currency },
45
+ { name: 'FormaPlatnosci', title: 'Forma płatności', format: FormatTyp.FormOfPayment },
46
+ ];
47
+
48
+ const table: Content[] = [generateLine(), ...createHeader('Płatność')];
49
+
50
+ if (platnosc.Zaplacono?._text === '1') {
51
+ table.push(createLabelText('Informacja o płatności: ', 'Zapłacono'));
52
+ table.push(createLabelText('Data zapłaty: ', platnosc.DataZaplaty));
53
+ } else if (platnosc.ZnacznikZaplatyCzesciowej?._text === '1') {
54
+ table.push(createLabelText('Informacja o płatności: ', 'Zapłata częściowa'));
55
+ } else {
56
+ table.push(createLabelText('Informacja o płatności: ', 'Brak zapłaty'));
57
+ }
58
+
59
+ if (hasValue(platnosc.FormaPlatnosci)) {
60
+ table.push(createLabelText('Forma płatności: ', getFormaPlatnosciString(platnosc.FormaPlatnosci)));
61
+ } else {
62
+ if (platnosc.OpisPlatnosci?._text) {
63
+ table.push(createLabelText('Forma płatności: ', 'Płatność inna'));
64
+ table.push(createLabelText('Opis płatności innej: ', platnosc.OpisPlatnosci));
65
+ }
66
+ }
67
+
68
+ const zaplataCzesciowa: ZaplataCzesciowa[] = getTable(platnosc.ZaplataCzesciowa);
69
+ const tableZaplataCzesciowa: FormContentState = getContentTable<(typeof zaplataCzesciowa)[0]>(
70
+ zaplataCzesciowaNaglowek,
71
+ zaplataCzesciowa,
72
+ '*'
73
+ );
74
+
75
+ const terminPatnosciContent: TerminPlatnosci[] = terminPlatnosci.map(
76
+ (platnosc: TerminPlatnosci): TerminPlatnosci => {
77
+ if (!terminPlatnosci.some((termin: TerminPlatnosci): FP | undefined => termin.TerminOpis)) {
78
+ return platnosc;
79
+ } else {
80
+ return {
81
+ ...platnosc,
82
+ TerminOpis: {
83
+ _text: `${platnosc.Termin?._text ?? ''}`,
84
+ } as any,
85
+ };
86
+ }
87
+ }
88
+ );
89
+
90
+ const tableTerminPlatnosci: FormContentState = getContentTable<(typeof terminPlatnosci)[0]>(
91
+ zaplataCzesciowaHeader,
92
+ terminPatnosciContent,
93
+ '*'
94
+ );
95
+
96
+ if (zaplataCzesciowa.length > 0 && terminPlatnosci.length > 0) {
97
+ table.push(
98
+ generateTwoColumns(
99
+ tableZaplataCzesciowa.content ?? [],
100
+ tableTerminPlatnosci.content ?? [],
101
+ [0, 4, 0, 0]
102
+ )
103
+ );
104
+ } else if (terminPlatnosci.length > 0) {
105
+ if (tableTerminPlatnosci.content) {
106
+ table.push(generateTwoColumns([], tableTerminPlatnosci.content));
107
+ }
108
+ } else if (zaplataCzesciowa.length > 0 && tableZaplataCzesciowa.content) {
109
+ table.push(tableZaplataCzesciowa.content);
110
+ }
111
+
112
+ table.push(
113
+ generateTwoColumns(
114
+ generujRachunekBankowy(
115
+ getTable(platnosc.RachunekBankowy as Record<string, FP>[]),
116
+ 'Numer rachunku bankowego'
117
+ ),
118
+ generujRachunekBankowy(
119
+ getTable(platnosc.RachunekBankowyFaktora as Record<string, FP>[]),
120
+ 'Numer rachunku bankowego faktora'
121
+ )
122
+ )
123
+ );
124
+
125
+ if (platnosc.Skonto) {
126
+ table.push(createHeader('Skonto', [0, 0]));
127
+ table.push(createLabelText('Warunki skonta: ', platnosc.Skonto.WarunkiSkonta));
128
+ table.push(createLabelText('Wysokość skonta: ', platnosc.Skonto.WysokoscSkonta));
129
+ }
130
+ return table;
131
+ }
@@ -0,0 +1,40 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import { createHeader, createLabelText, formatText } from '../../../shared/PDF-functions';
3
+ import { Podmiot1 } from '../../types/fa2.types';
4
+ import { generateAdres } from './Adres';
5
+ import { generateDaneIdentyfikacyjneTPodmiot1Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot1Dto';
6
+ import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
7
+ import FormatTyp from '../../../shared/enums/common.enum';
8
+
9
+ export function generatePodmiot1(podmiot1: Podmiot1): Content[] {
10
+ const result: Content[] = createHeader('Sprzedawca');
11
+
12
+ result.push(
13
+ createLabelText('NrEORI: ', podmiot1.NrEORI),
14
+ createLabelText('Prefiks VAT: ', podmiot1.PrefiksPodatnika)
15
+ );
16
+ if (podmiot1.DaneIdentyfikacyjne) {
17
+ result.push(...generateDaneIdentyfikacyjneTPodmiot1Dto(podmiot1.DaneIdentyfikacyjne));
18
+ }
19
+
20
+ if (podmiot1.Adres) {
21
+ result.push(formatText('Adres', [FormatTyp.Label, FormatTyp.LabelMargin]), generateAdres(podmiot1.Adres));
22
+ }
23
+ if (podmiot1.AdresKoresp) {
24
+ result.push(
25
+ formatText('Adres do korespondencji', [FormatTyp.Label, FormatTyp.LabelMargin]),
26
+ ...generateAdres(podmiot1.AdresKoresp)
27
+ );
28
+ }
29
+ if (podmiot1.DaneKontaktowe) {
30
+ result.push(
31
+ formatText('Dane kontaktowe', [FormatTyp.Label, FormatTyp.LabelMargin]),
32
+ ...generateDaneKontaktowe(podmiot1.DaneKontaktowe)
33
+ );
34
+
35
+ result.push(createLabelText('Status podatnika: ', podmiot1.StatusInfoPodatnika));
36
+ } else if (podmiot1.StatusInfoPodatnika) {
37
+ result.push(createLabelText('Status podatnika: ', podmiot1.StatusInfoPodatnika));
38
+ }
39
+ return result;
40
+ }
@@ -0,0 +1,73 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import {
3
+ createHeader,
4
+ createLabelText,
5
+ formatText,
6
+ getTable,
7
+ verticalSpacing,
8
+ } from '../../../shared/PDF-functions';
9
+ import FormatTyp from '../../../shared/enums/common.enum';
10
+ import { Podmiot1, Podmiot1K } from '../../types/fa2.types';
11
+ import { generateAdres } from './Adres';
12
+ import { generateDaneIdentyfikacyjneTPodmiot1Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot1Dto';
13
+ import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
14
+
15
+ export function generatePodmiot1Podmiot1K(podmiot1: Podmiot1, podmiot1K: Podmiot1K): Content[] {
16
+ const result: Content[] = createHeader('Sprzedawca');
17
+ let firstColumn: Content[] = [];
18
+ let secondColumn: Content[] = [];
19
+
20
+ firstColumn.push(createHeader('Dane identyfikacyjne'), createLabelText('Numer EORI: ', podmiot1.NrEORI));
21
+ if (podmiot1.DaneIdentyfikacyjne) {
22
+ firstColumn.push(...generateDaneIdentyfikacyjneTPodmiot1Dto(podmiot1.DaneIdentyfikacyjne));
23
+ }
24
+
25
+ if (podmiot1.DaneKontaktowe) {
26
+ firstColumn.push(generateDaneKontaktowe(getTable(podmiot1.DaneKontaktowe)));
27
+ }
28
+ if (podmiot1.StatusInfoPodatnika) {
29
+ firstColumn.push(createLabelText('Status podatnika: ', podmiot1.StatusInfoPodatnika));
30
+ }
31
+ if (firstColumn.length) {
32
+ result.push({
33
+ columns: [firstColumn, []],
34
+ columnGap: 20,
35
+ });
36
+ }
37
+ firstColumn = generateCorrectedContent(podmiot1K);
38
+ secondColumn = generateCorrectedContent(podmiot1);
39
+
40
+ if (podmiot1.AdresKoresp) {
41
+ secondColumn.push(
42
+ formatText('Adres do korespondencji', [FormatTyp.Label, FormatTyp.LabelMargin]),
43
+ generateAdres(podmiot1.AdresKoresp)
44
+ );
45
+ }
46
+ if (firstColumn.length || secondColumn.length) {
47
+ result.push({
48
+ columns: [firstColumn, secondColumn],
49
+ columnGap: 20,
50
+ });
51
+ }
52
+ if (result.length) {
53
+ result.push(verticalSpacing(1));
54
+ }
55
+ return result;
56
+ }
57
+
58
+ export function generateCorrectedContent(podmiot: Podmiot1 | Podmiot1K): Content[] {
59
+ const result: Content[] = [];
60
+
61
+ result.push(createHeader('Treść korygowana'));
62
+
63
+ if (podmiot.PrefiksPodatnika?._text) {
64
+ result.push(createLabelText('Prefiks VAT: ', podmiot.PrefiksPodatnika));
65
+ }
66
+ if (podmiot.DaneIdentyfikacyjne) {
67
+ result.push(...generateDaneIdentyfikacyjneTPodmiot1Dto(podmiot.DaneIdentyfikacyjne));
68
+ }
69
+ if (podmiot.Adres) {
70
+ result.push(formatText('Adres', [FormatTyp.Label, FormatTyp.LabelMargin]), generateAdres(podmiot.Adres));
71
+ }
72
+ return result;
73
+ }
@@ -0,0 +1,42 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import { createHeader, createLabelText, formatText } from '../../../shared/PDF-functions';
3
+ import FormatTyp from '../../../shared/enums/common.enum';
4
+ import { Podmiot2 } from '../../types/fa2.types';
5
+ import { generateAdres } from './Adres';
6
+ import { generateDaneIdentyfikacyjneTPodmiot2Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot2Dto';
7
+ import { generateDaneKontaktowe } from './PodmiotDaneKontaktowe';
8
+ import { DaneIdentyfikacyjneTPodmiot2Dto } from '../../types/fa2-additional-types';
9
+
10
+ export function generatePodmiot2(podmiot2: Podmiot2): Content[] {
11
+ const result: Content[] = createHeader('Nabywca');
12
+
13
+ result.push(
14
+ createLabelText('Identyfikator nabywcy: ', podmiot2.IDNabywcy),
15
+ createLabelText('NrEORI: ', podmiot2.NrEORI)
16
+ );
17
+ if (podmiot2.DaneIdentyfikacyjne) {
18
+ result.push(
19
+ ...generateDaneIdentyfikacyjneTPodmiot2Dto(
20
+ podmiot2.DaneIdentyfikacyjne as DaneIdentyfikacyjneTPodmiot2Dto
21
+ )
22
+ );
23
+ }
24
+
25
+ if (podmiot2.Adres) {
26
+ result.push(formatText('Adres', [FormatTyp.Label, FormatTyp.LabelMargin]), generateAdres(podmiot2.Adres));
27
+ }
28
+ if (podmiot2.AdresKoresp) {
29
+ result.push(
30
+ formatText('Adres do korespondencji', [FormatTyp.Label, FormatTyp.LabelMargin]),
31
+ ...generateAdres(podmiot2.AdresKoresp)
32
+ );
33
+ }
34
+ if (podmiot2.DaneKontaktowe) {
35
+ result.push(
36
+ formatText('Dane kontaktowe', [FormatTyp.Label, FormatTyp.LabelMargin]),
37
+ ...generateDaneKontaktowe(podmiot2.DaneKontaktowe),
38
+ createLabelText('Numer klienta: ', podmiot2.NrKlienta)
39
+ );
40
+ }
41
+ return result;
42
+ }