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