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,298 @@
1
+ import { Content, ContentTable, TableCell } from 'pdfmake/interfaces';
2
+ import {
3
+ createHeader,
4
+ createSection,
5
+ formatText,
6
+ getNumberRounded,
7
+ getValue,
8
+ hasValue,
9
+ } from '../../../shared/PDF-functions';
10
+ import FormatTyp from '../../../shared/enums/common.enum';
11
+ import { Fa, Faktura, FP } from '../../types/fa3.types';
12
+ import { TaxSummaryTypes } from '../../types/tax-summary.types';
13
+
14
+ export function generatePodsumowanieStawekPodatkuVat(faktura: Faktura): Content[] {
15
+ const AnyP13P14_5Diff0 =
16
+ hasValue(faktura.Fa?.P_13_1) ||
17
+ hasValue(faktura.Fa?.P_13_2) ||
18
+ hasValue(faktura.Fa?.P_13_3) ||
19
+ hasValue(faktura.Fa?.P_13_4) ||
20
+ (hasValue(faktura.Fa?.P_13_5) && (!hasValue(faktura.Fa?.P_14_5) || getValue(faktura.Fa?.P_14_5) == 0)) ||
21
+ hasValue(faktura.Fa?.P_13_6_1) ||
22
+ hasValue(faktura.Fa?.P_13_6_2) ||
23
+ hasValue(faktura.Fa?.P_13_6_3) ||
24
+ hasValue(faktura.Fa?.P_13_7) ||
25
+ hasValue(faktura.Fa?.P_13_8) ||
26
+ hasValue(faktura.Fa?.P_13_9) ||
27
+ hasValue(faktura.Fa?.P_13_10) ||
28
+ hasValue(faktura.Fa?.P_13_11);
29
+ const AnyP13 =
30
+ hasValue(faktura.Fa?.P_13_1) ||
31
+ hasValue(faktura.Fa?.P_13_2) ||
32
+ hasValue(faktura.Fa?.P_13_3) ||
33
+ hasValue(faktura.Fa?.P_13_4) ||
34
+ hasValue(faktura.Fa?.P_13_5) ||
35
+ hasValue(faktura.Fa?.P_13_6_1) ||
36
+ hasValue(faktura.Fa?.P_13_6_2) ||
37
+ hasValue(faktura.Fa?.P_13_6_3) ||
38
+ hasValue(faktura.Fa?.P_13_7) ||
39
+ hasValue(faktura.Fa?.P_13_8) ||
40
+ hasValue(faktura.Fa?.P_13_9) ||
41
+ hasValue(faktura.Fa?.P_13_10) ||
42
+ hasValue(faktura.Fa?.P_13_11);
43
+ const AnyP_14xW =
44
+ hasValue(faktura.Fa?.P_14_1W) ||
45
+ hasValue(faktura.Fa?.P_14_2W) ||
46
+ hasValue(faktura.Fa?.P_14_3W) ||
47
+ hasValue(faktura.Fa?.P_14_4W);
48
+
49
+ let tableBody: TableCell[] = [];
50
+ const table: ContentTable = {
51
+ table: {
52
+ headerRows: 1,
53
+ widths: [],
54
+ body: [] as TableCell[][],
55
+ },
56
+ layout: {
57
+ hLineWidth: () => 1,
58
+ hLineColor: () => '#BABABA',
59
+ vLineWidth: () => 1,
60
+ vLineColor: () => '#BABABA',
61
+ },
62
+ };
63
+
64
+ const definedHeader: Content[] = [
65
+ ...[{ text: 'Lp.', style: FormatTyp.GrayBoldTitle }],
66
+ ...(AnyP13P14_5Diff0 ? [{ text: 'Stawka podatku', style: FormatTyp.GrayBoldTitle }] : []),
67
+ ...(AnyP13 ? [{ text: 'Kwota netto', style: FormatTyp.GrayBoldTitle }] : []),
68
+ ...(AnyP13P14_5Diff0 ? [{ text: 'Kwota podatku', style: FormatTyp.GrayBoldTitle }] : []),
69
+ ...(AnyP13 ? [{ text: 'Kwota brutto', style: FormatTyp.GrayBoldTitle }] : []),
70
+ ...(AnyP_14xW ? [{ text: 'Kwota podatku PLN', style: FormatTyp.GrayBoldTitle }] : []),
71
+ ];
72
+
73
+ const widths: Content[] = [
74
+ ...['auto'],
75
+ ...(AnyP13P14_5Diff0 ? ['*'] : []),
76
+ ...(AnyP13 ? ['*'] : []),
77
+ ...(AnyP13P14_5Diff0 ? ['*'] : []),
78
+ ...(AnyP13 ? ['*'] : []),
79
+ ...(AnyP_14xW ? ['*'] : []),
80
+ ];
81
+
82
+ if (faktura?.Fa) {
83
+ const summary = getSummaryTaxRate(faktura.Fa);
84
+
85
+ tableBody = summary.map((item) => {
86
+ const data = [];
87
+
88
+ data.push(item.no);
89
+ if (AnyP13P14_5Diff0) {
90
+ data.push(item.taxRateString);
91
+ }
92
+ if (AnyP13) {
93
+ data.push(formatText(item.net, FormatTyp.Currency));
94
+ }
95
+ if (AnyP13P14_5Diff0) {
96
+ data.push(formatText(item.tax, FormatTyp.Currency));
97
+ }
98
+ if (AnyP13) {
99
+ data.push(formatText(item.gross, FormatTyp.Currency));
100
+ }
101
+ if (AnyP_14xW) {
102
+ data.push(formatText(item.taxPLN, FormatTyp.Currency));
103
+ }
104
+ return data;
105
+ });
106
+ }
107
+ table.table.body = [[...definedHeader], ...tableBody] as TableCell[][];
108
+ table.table.widths = [...widths] as never[];
109
+
110
+ return tableBody.length
111
+ ? createSection([...createHeader('Podsumowanie stawek podatku', [0, 0, 0, 8]), table], false)
112
+ : [];
113
+ }
114
+
115
+ export function getSummaryTaxRate(fa: Fa): TaxSummaryTypes[] {
116
+ const summary: TaxSummaryTypes[] = [];
117
+
118
+ const AnyP13_1P14_1P14_1WDiff0 =
119
+ hasValueAndDiff0(fa?.P_13_1) || hasValueAndDiff0(fa?.P_14_1) || hasValueAndDiff0(fa?.P_14_1W);
120
+ const AnyP13_2P14_2P14_2WDiff0 =
121
+ hasValueAndDiff0(fa?.P_13_2) || hasValueAndDiff0(fa?.P_14_2) || hasValueAndDiff0(fa?.P_14_2W);
122
+ const AnyP13_3P14_3P14_3WDiff0 =
123
+ hasValueAndDiff0(fa?.P_13_3) || hasValueAndDiff0(fa?.P_14_3) || hasValueAndDiff0(fa?.P_14_3W);
124
+ const AnyP13_4P14_4P14_4WDiff0 =
125
+ hasValueAndDiff0(fa?.P_13_4) || hasValueAndDiff0(fa?.P_14_4) || hasValueAndDiff0(fa?.P_14_4W);
126
+ const AnyP13_5P14_5Diff0 = hasValueAndDiff0(fa?.P_13_5) || hasValueAndDiff0(fa?.P_14_5);
127
+ const AnyP13_6_1Diff0 = hasValueAndDiff0(fa?.P_13_6_1);
128
+ const AnyP13_6_2Diff0 = hasValueAndDiff0(fa?.P_13_6_2);
129
+ const AnyP13_6_3Diff0 = hasValueAndDiff0(fa?.P_13_6_3);
130
+ const AnyP13_7Diff0 = hasValueAndDiff0(fa?.P_13_7);
131
+ const AnyP13_8Diff0 = hasValueAndDiff0(fa?.P_13_8);
132
+ const AnyP13_9Diff0 = hasValueAndDiff0(fa?.P_13_9);
133
+ const AnyP13_10Diff0 = hasValueAndDiff0(fa?.P_13_10);
134
+ const AnyP13_11Diff0 = hasValueAndDiff0(fa?.P_13_11);
135
+ let no = 1;
136
+
137
+ if (AnyP13_1P14_1P14_1WDiff0) {
138
+ summary.push({
139
+ no,
140
+ net: getNumberRounded(fa.P_13_1).toFixed(2),
141
+ gross: (getNumberRounded(fa.P_13_1) + getNumberRounded(fa.P_14_1)).toFixed(2),
142
+ tax: getNumberRounded(fa.P_14_1).toFixed(2),
143
+ taxPLN: getNumberRounded(fa.P_14_1W).toFixed(2),
144
+ taxRateString: '23% lub 22%',
145
+ });
146
+ no++;
147
+ }
148
+
149
+ if (AnyP13_2P14_2P14_2WDiff0) {
150
+ summary.push({
151
+ no,
152
+ net: getNumberRounded(fa.P_13_2).toFixed(2),
153
+ gross: (getNumberRounded(fa.P_13_2) + getNumberRounded(fa.P_14_2)).toFixed(2),
154
+ tax: getNumberRounded(fa.P_14_2).toFixed(2),
155
+ taxPLN: getNumberRounded(fa.P_14_2W).toFixed(2),
156
+ taxRateString: '8% lub 7%',
157
+ });
158
+ no++;
159
+ }
160
+
161
+ if (AnyP13_3P14_3P14_3WDiff0) {
162
+ summary.push({
163
+ no,
164
+ net: getNumberRounded(fa.P_13_3).toFixed(2),
165
+ gross: (getNumberRounded(fa.P_13_3) + getNumberRounded(fa.P_14_3)).toFixed(2),
166
+ tax: getNumberRounded(fa.P_14_3).toFixed(2),
167
+ taxPLN: getNumberRounded(fa.P_14_3W).toFixed(2),
168
+ taxRateString: '5%',
169
+ });
170
+ no++;
171
+ }
172
+
173
+ if (AnyP13_4P14_4P14_4WDiff0) {
174
+ summary.push({
175
+ no,
176
+ net: getNumberRounded(fa.P_13_4).toFixed(2),
177
+ gross: (getNumberRounded(fa.P_13_4) + getNumberRounded(fa.P_14_4)).toFixed(2),
178
+ tax: getNumberRounded(fa.P_14_4).toFixed(2),
179
+ taxPLN: getNumberRounded(fa.P_14_4W).toFixed(2),
180
+ taxRateString: '4% lub 3% lub oo',
181
+ });
182
+ no++;
183
+ }
184
+
185
+ if (AnyP13_5P14_5Diff0) {
186
+ summary.push({
187
+ no,
188
+ net: getNumberRounded(fa.P_13_5).toFixed(2),
189
+ gross: getNumberRounded(fa.P_13_5).toFixed(2),
190
+ tax: getNumberRounded(fa.P_14_5).toFixed(2),
191
+ taxPLN: '',
192
+ taxRateString: getValue(fa.P_14_5) != 0 ? 'niepodlegające opodatkowaniu' : '',
193
+ });
194
+ no++;
195
+ }
196
+
197
+ if (AnyP13_6_1Diff0) {
198
+ summary.push({
199
+ no,
200
+ net: getNumberRounded(fa.P_13_6_1).toFixed(2),
201
+ gross: getNumberRounded(fa.P_13_6_1).toFixed(2),
202
+ tax: '0.00',
203
+ taxPLN: '',
204
+ taxRateString: '0% - krajowe',
205
+ });
206
+ no++;
207
+ }
208
+
209
+ if (AnyP13_6_2Diff0) {
210
+ summary.push({
211
+ no,
212
+ net: getNumberRounded(fa.P_13_6_2).toFixed(2),
213
+ gross: getNumberRounded(fa.P_13_6_2).toFixed(2),
214
+ tax: '0.00',
215
+ taxPLN: '',
216
+ taxRateString: '0% - wdt',
217
+ });
218
+ no++;
219
+ }
220
+
221
+ if (AnyP13_6_3Diff0) {
222
+ summary.push({
223
+ no,
224
+ net: getNumberRounded(fa.P_13_6_2).toFixed(2),
225
+ gross: getNumberRounded(fa.P_13_6_2).toFixed(2),
226
+ tax: '0.00',
227
+ taxPLN: '',
228
+ taxRateString: '0% - eksport',
229
+ });
230
+ no++;
231
+ }
232
+
233
+ if (AnyP13_7Diff0) {
234
+ summary.push({
235
+ no,
236
+ net: getNumberRounded(fa.P_13_7).toFixed(2),
237
+ gross: getNumberRounded(fa.P_13_7).toFixed(2),
238
+ tax: '0.00',
239
+ taxPLN: '',
240
+ taxRateString: 'zwolnione z opodatkowania',
241
+ });
242
+ no++;
243
+ }
244
+
245
+ if (AnyP13_8Diff0) {
246
+ summary.push({
247
+ no,
248
+ net: getNumberRounded(fa.P_13_8).toFixed(2),
249
+ gross: getNumberRounded(fa.P_13_8).toFixed(2),
250
+ tax: '0.00',
251
+ taxPLN: '',
252
+ taxRateString: 'np z wyłączeniem art. 100 ust 1 pkt 4 ustawy',
253
+ });
254
+ no++;
255
+ }
256
+
257
+ if (AnyP13_9Diff0) {
258
+ summary.push({
259
+ no,
260
+ net: getNumberRounded(fa.P_13_9).toFixed(2),
261
+ gross: getNumberRounded(fa.P_13_9).toFixed(2),
262
+ tax: '0.00',
263
+ taxPLN: '',
264
+ taxRateString: 'np na podstawie art. 100 ust. 1 pkt 4 ustawy',
265
+ });
266
+ no++;
267
+ }
268
+
269
+ if (AnyP13_10Diff0) {
270
+ summary.push({
271
+ no,
272
+ net: getNumberRounded(fa.P_13_10).toFixed(2),
273
+ gross: getNumberRounded(fa.P_13_10).toFixed(2),
274
+ tax: '0.00',
275
+ taxPLN: '',
276
+ taxRateString: 'odwrotne obciążenie',
277
+ });
278
+ no++;
279
+ }
280
+
281
+ if (AnyP13_11Diff0) {
282
+ summary.push({
283
+ no,
284
+ net: getNumberRounded(fa.P_13_11).toFixed(2),
285
+ gross: getNumberRounded(fa.P_13_11).toFixed(2),
286
+ tax: '0.00',
287
+ taxPLN: '',
288
+ taxRateString: 'marża',
289
+ });
290
+ no++;
291
+ }
292
+
293
+ return summary;
294
+ }
295
+
296
+ function hasValueAndDiff0(value: FP | string | number | undefined): boolean {
297
+ return hasValue(value) && getValue(value) != 0;
298
+ }
@@ -0,0 +1,24 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import { createHeader, generateTwoColumns } from '../../../shared/PDF-functions';
3
+ import { Przewoznik } from '../../types/fa3.types';
4
+ import { generatePodmiotAdres } from './PodmiotAdres';
5
+ import { generateDaneIdentyfikacyjneTPodmiot2Dto } from './PodmiotDaneIdentyfikacyjneTPodmiot2Dto';
6
+ import { DaneIdentyfikacyjneTPodmiot2Dto } from '../../types/fa2-additional-types';
7
+
8
+ export function generatePrzewoznik(przewoznik: Przewoznik | undefined): Content {
9
+ if (!przewoznik) {
10
+ return [];
11
+ }
12
+ return [
13
+ ...createHeader('Przewoźnik'),
14
+ [
15
+ generateTwoColumns(
16
+ generateDaneIdentyfikacyjneTPodmiot2Dto(
17
+ przewoznik.DaneIdentyfikacyjne as DaneIdentyfikacyjneTPodmiot2Dto
18
+ ),
19
+ generatePodmiotAdres(przewoznik.AdresPrzewoznika, 'Adres przewoźnika', true, [0, 0, 0, 0]),
20
+ [0, 0, 0, 8]
21
+ ),
22
+ ],
23
+ ];
24
+ }
@@ -0,0 +1,45 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import {
3
+ createHeader,
4
+ createLabelText,
5
+ createSection,
6
+ formatText,
7
+ generateTwoColumns,
8
+ getContentTable,
9
+ getTable,
10
+ } from '../../../shared/PDF-functions';
11
+ import { HeaderDefine } from '../../../shared/types/pdf-types';
12
+ import { Fa } from '../../types/fa3.types';
13
+ import FormatTyp, { Position } from '../../../shared/enums/common.enum';
14
+
15
+ export function generateRabat(invoice: Fa): Content[] {
16
+ const faRows = getTable(invoice!.FaWiersz);
17
+ const result: Content[] = [];
18
+ const definedHeader: HeaderDefine[] = [
19
+ { name: 'NrWierszaFay', title: 'Lp.', format: FormatTyp.Default },
20
+ { name: 'P_7', title: 'Nazwa towaru lub usługi', format: FormatTyp.Default },
21
+ { name: 'P_8B', title: 'Ilość', format: FormatTyp.Default },
22
+ { name: 'P_8A', title: 'Miara', format: FormatTyp.Default },
23
+ ];
24
+ const tabRabat = getContentTable<(typeof faRows)[0]>(definedHeader, faRows, '*');
25
+ const isNrWierszaFa = tabRabat.fieldsWithValue.includes('NrWierszaFa');
26
+
27
+ result.push(
28
+ ...createHeader('Rabat'),
29
+ ...createLabelText('Wartość rabatu ogółem: ', invoice.P_15, FormatTyp.Currency, {
30
+ alignment: Position.RIGHT,
31
+ }),
32
+ generateTwoColumns(
33
+ formatText(
34
+ `Rabat ${isNrWierszaFa ? 'nie ' : ''}dotyczy wszystkich dostaw towarów i wykonanych usług na rzecz tego nabywcy w danym okresie.`,
35
+ FormatTyp.Default
36
+ ),
37
+ ''
38
+ )
39
+ );
40
+ if (tabRabat.fieldsWithValue.length > 0 && tabRabat.content) {
41
+ result.push(tabRabat.content);
42
+ }
43
+
44
+ return createSection(result, true);
45
+ }
@@ -0,0 +1,60 @@
1
+ import { Content, ContentTable } from 'pdfmake/interfaces';
2
+ import { createHeader, createSection, formatText } from '../../../shared/PDF-functions';
3
+ import FormatTyp from '../../../shared/enums/common.enum';
4
+ import { RachunekBankowy } from '../../types/fa3.types';
5
+ import { getTypRachunkowWlasnych } from '../../../shared/generators/common/functions';
6
+
7
+ export const generujRachunekBankowy = (accounts?: RachunekBankowy[], title?: string): Content[] => {
8
+ const result: Content[] = [];
9
+
10
+ if (!accounts?.length) {
11
+ return [];
12
+ }
13
+
14
+ accounts.forEach((account, index) => {
15
+ const table: Content[][] = [];
16
+ const base: Content[] = createHeader(
17
+ title ? `${title} ${accounts?.length > 1 ? ++index : ''}` : '',
18
+ [0, 12, 0, 8]
19
+ );
20
+
21
+ table.push([
22
+ formatText('Pełny numer rachunku', FormatTyp.GrayBoldTitle),
23
+ formatText(account.NrRB?._text, FormatTyp.Default),
24
+ ]);
25
+ table.push([
26
+ formatText('Kod SWIFT', FormatTyp.GrayBoldTitle),
27
+ formatText(account.SWIFT?._text, FormatTyp.Default),
28
+ ]);
29
+ table.push([
30
+ formatText('Rachunek własny banku', FormatTyp.GrayBoldTitle),
31
+ formatText(getTypRachunkowWlasnych(account.RachunekWlasnyBanku), FormatTyp.Default),
32
+ ]);
33
+ table.push([
34
+ formatText('Nazwa banku', FormatTyp.GrayBoldTitle),
35
+ formatText(account.NazwaBanku?._text, FormatTyp.Default),
36
+ ]);
37
+ table.push([
38
+ formatText('Opis rachunku', FormatTyp.GrayBoldTitle),
39
+ formatText(account.OpisRachunku?._text, FormatTyp.Default),
40
+ ]);
41
+ result.push([
42
+ ...base,
43
+ {
44
+ unbreakable: true,
45
+ table: {
46
+ body: table,
47
+ widths: ['*', 'auto'],
48
+ },
49
+ layout: {
50
+ hLineWidth: () => 1,
51
+ hLineColor: () => '#BABABA',
52
+ vLineWidth: () => 1,
53
+ vLineColor: () => '#BABABA',
54
+ },
55
+ } as ContentTable,
56
+ ]);
57
+ });
58
+
59
+ return createSection(result, false);
60
+ };
@@ -0,0 +1,184 @@
1
+ import { Content } from 'pdfmake/interfaces';
2
+ import {
3
+ createHeader,
4
+ createLabelText,
5
+ createLabelTextArray,
6
+ createSection,
7
+ generateTwoColumns,
8
+ getContentTable,
9
+ getDifferentColumnsValue,
10
+ getTable,
11
+ getValue,
12
+ hasColumnsValue,
13
+ hasValue,
14
+ } from '../../../shared/PDF-functions';
15
+ import { HeaderDefine } from '../../../shared/types/pdf-types';
16
+ import { TRodzajFaktury } from '../../../shared/consts/const';
17
+ import { Fa, ZaliczkaCzesciowa } from '../../types/fa3.types';
18
+ import { ObjectKeysOfFP, TypesOfValues } from '../../../shared/types/universal.types';
19
+ import FormatTyp from '../../../shared/enums/common.enum';
20
+ import { FA3FakturaZaliczkowaData } from '../../types/common.types';
21
+
22
+ export function generateSzczegoly(faVat: Fa): Content[] {
23
+ const faWiersze = getTable(faVat.FaWiersz);
24
+ const zamowieniaWiersze = getTable(faVat.Zamowienie?.ZamowienieWiersz);
25
+ const LabelP_6 =
26
+ faVat.RodzajFaktury == TRodzajFaktury.ZAL || faVat.RodzajFaktury == TRodzajFaktury.KOR_ZAL
27
+ ? 'Data otrzymania zapłaty: '
28
+ : 'Data dokonania lub zakończenia dostawy towarów lub wykonania usługi: ';
29
+
30
+ const P_6Scope: Content[] = generateP_6Scope(faVat.OkresFa?.P_6_Od, faVat.OkresFa?.P_6_Do);
31
+
32
+ const cenyLabel1: Content[] = [];
33
+ const cenyLabel2: Content[] = [];
34
+
35
+ if (!(faWiersze.length > 0 || zamowieniaWiersze.length > 0)) {
36
+ const Any_P_11 = hasColumnsValue('P_11', faWiersze) || hasColumnsValue('P_11', zamowieniaWiersze);
37
+
38
+ if (Any_P_11) {
39
+ cenyLabel1.push(createLabelText('Faktura wystawiona w cenach: ', 'netto'));
40
+ } else {
41
+ cenyLabel1.push(createLabelText('Faktura wystawiona w cenach: ', 'brutto'));
42
+ }
43
+ cenyLabel2.push(createLabelText('Kod waluty: ', faVat.KodWaluty));
44
+ }
45
+
46
+ const P_12_XIILabel: Content[] = [];
47
+
48
+ if (hasColumnsValue('P_12_XII', faWiersze) || hasColumnsValue('P_12_XII', zamowieniaWiersze)) {
49
+ P_12_XIILabel.push(createLabelText('Procedura One Stop Shop', ' '));
50
+ }
51
+
52
+ const kodWalutyLabel1: Content[] = [];
53
+ const kodWalutyLabel2: Content[] = [];
54
+
55
+ if (hasValue(faVat.KodWaluty) && getValue(faVat.KodWaluty) != 'PLN') {
56
+ if (hasValue(faVat.KursWalutyZ)) {
57
+ kodWalutyLabel1.push(createLabelText('Kurs waluty wspólny dla wszystkich wierszy faktury', ' '));
58
+ kodWalutyLabel2.push(createLabelText('Kurs waluty: ', faVat.KursWalutyZ, FormatTyp.Currency6));
59
+ } else {
60
+ const Common_KursWaluty = getDifferentColumnsValue('KursWaluty', faWiersze);
61
+
62
+ if (Common_KursWaluty.length === 1) {
63
+ kodWalutyLabel1.push(createLabelText('Kurs waluty wspólny dla wszystkich wierszy faktury', ' '));
64
+ kodWalutyLabel2.push(
65
+ createLabelText('Kurs waluty: ', Common_KursWaluty[0].value, FormatTyp.Currency6)
66
+ );
67
+ }
68
+ }
69
+ }
70
+ const tpLabel1: Content[] = [];
71
+ const tpLabel2: Content[] = [];
72
+
73
+ const forColumns = [
74
+ createLabelText('Data wystawienia, z zastrzeżeniem art. 106na ust. 1 ustawy: ', faVat.P_1),
75
+ createLabelText('Miejsce wystawienia: ', faVat.P_1M),
76
+ createLabelText('Okres, którego dotyczy rabat: ', faVat.OkresFaKorygowanej),
77
+ createLabelText(LabelP_6, faVat.P_6),
78
+ P_6Scope,
79
+ cenyLabel1,
80
+ cenyLabel2,
81
+ P_12_XIILabel,
82
+ kodWalutyLabel1,
83
+ kodWalutyLabel2,
84
+ tpLabel1,
85
+ tpLabel2,
86
+ ].filter((el) => el.length > 0);
87
+ const columns1: Content[] = [];
88
+ const columns2: Content[] = [];
89
+
90
+ forColumns.forEach((tab, index) => {
91
+ if (index % 2) {
92
+ columns2.push(tab);
93
+ } else {
94
+ columns1.push(tab);
95
+ }
96
+ });
97
+ const table: Content[] = [
98
+ ...createHeader('Szczegóły'),
99
+ generateTwoColumns(columns1, columns2),
100
+ ...generateZaliczkaCzesciowa(faVat.ZaliczkaCzesciowa),
101
+ ...generateFakturaZaliczkowa(faVat.FakturaZaliczkowa),
102
+ ];
103
+
104
+ return createSection(table, true);
105
+ }
106
+
107
+ function generateP_6Scope(P_6_Od: TypesOfValues, P_6_Do: TypesOfValues): Content[] {
108
+ const table: Content[] = [];
109
+
110
+ if (hasValue(P_6_Od) && hasValue(P_6_Do)) {
111
+ table.push(
112
+ createLabelTextArray([
113
+ {
114
+ value: 'Data dokonania lub zakończenia dostawy towarów lub wykonania usługi: od ',
115
+ },
116
+ { value: P_6_Od, formatTyp: FormatTyp.Value },
117
+ { value: ' do ' },
118
+ { value: P_6_Do, formatTyp: FormatTyp.Value },
119
+ ])
120
+ );
121
+ } else if (hasValue(P_6_Od)) {
122
+ table.push(
123
+ createLabelText('Data dokonania lub zakończenia dostawy towarów lub wykonania usługi: od ', P_6_Od)
124
+ );
125
+ } else if (hasValue(P_6_Do)) {
126
+ table.push(
127
+ createLabelText('Data dokonania lub zakończenia dostawy towarów lub wykonania usługi: do ', P_6_Do)
128
+ );
129
+ }
130
+ return table;
131
+ }
132
+
133
+ function generateZaliczkaCzesciowa(zaliczkaCzesciowaData: ZaliczkaCzesciowa[] | undefined): Content[] {
134
+ if (!zaliczkaCzesciowaData) {
135
+ return [];
136
+ }
137
+ const zaplataCzesciowa = getTable(zaliczkaCzesciowaData);
138
+ const table: Content[] = [];
139
+
140
+ const zaplataCzesciowaHeader: HeaderDefine[] = [
141
+ { name: 'P_6Z', title: 'Data otrzymania płatności', format: FormatTyp.Default },
142
+ { name: 'P_15Z', title: 'Kwota płatności', format: FormatTyp.Default },
143
+ { name: 'KursWalutyZW', title: 'Kurs waluty', format: FormatTyp.Currency6 },
144
+ ];
145
+
146
+ const tableZaliczkaCzesciowa = getContentTable<(typeof zaplataCzesciowa)[0]>(
147
+ zaplataCzesciowaHeader,
148
+ zaplataCzesciowa,
149
+ 'auto'
150
+ );
151
+
152
+ if (tableZaliczkaCzesciowa.content) {
153
+ table.push(tableZaliczkaCzesciowa.content);
154
+ }
155
+ return table;
156
+ }
157
+
158
+ function generateFakturaZaliczkowa(fakturaZaliczkowaData: ObjectKeysOfFP[] | undefined): Content[] {
159
+ if (!fakturaZaliczkowaData) {
160
+ return [];
161
+ }
162
+ const fakturaZaliczkowa = getTable(fakturaZaliczkowaData) as unknown as FA3FakturaZaliczkowaData[];
163
+ const table: Content[] = [];
164
+
165
+ const fakturaZaliczkowaHeader: HeaderDefine[] = [
166
+ {
167
+ name: 'NrKSeFFaZaliczkowej',
168
+ title: 'Numery wcześniejszych faktur zaliczkowych',
169
+ format: FormatTyp.Default,
170
+ },
171
+ ];
172
+
173
+ const tableFakturaZaliczkowa = getContentTable<(typeof fakturaZaliczkowa)[0]>(
174
+ fakturaZaliczkowaHeader,
175
+ fakturaZaliczkowa,
176
+ 'auto',
177
+ [0, 4, 0, 0]
178
+ );
179
+
180
+ if (tableFakturaZaliczkowa.content) {
181
+ table.push(tableFakturaZaliczkowa.content);
182
+ }
183
+ return table;
184
+ }