makeapps-transformer 1.0.2 → 1.0.3

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.
@@ -8,7 +8,7 @@ exports.getSummaryTaxRate = getSummaryTaxRate;
8
8
  const PDF_functions_1 = require("../../../shared/PDF-functions");
9
9
  const common_enum_1 = __importDefault(require("../../../shared/enums/common.enum"));
10
10
  function generatePodsumowanieStawekPodatkuVat(faktura) {
11
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
11
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11;
12
12
  const AnyP13P14_5Diff0 = (0, PDF_functions_1.hasValue)((_a = faktura.Fa) === null || _a === void 0 ? void 0 : _a.P_13_1) ||
13
13
  (0, PDF_functions_1.hasValue)((_b = faktura.Fa) === null || _b === void 0 ? void 0 : _b.P_13_2) ||
14
14
  (0, PDF_functions_1.hasValue)((_c = faktura.Fa) === null || _c === void 0 ? void 0 : _c.P_13_3) ||
@@ -55,27 +55,53 @@ function generatePodsumowanieStawekPodatkuVat(faktura) {
55
55
  };
56
56
  const definedHeader = [
57
57
  ...[{ text: 'Lp.', style: common_enum_1.default.GrayBoldTitle }],
58
- ...(AnyP13P14_5Diff0 ? [{ text: 'Stawka podatku', style: common_enum_1.default.GrayBoldTitle }] : []),
58
+ ...(AnyP13P14_5Diff0 || (0, PDF_functions_1.hasValue)((_8 = faktura.Fa) === null || _8 === void 0 ? void 0 : _8.P_14_5)
59
+ ? [
60
+ {
61
+ text: 'Stawka podatku',
62
+ style: common_enum_1.default.GrayBoldTitle,
63
+ },
64
+ ]
65
+ : []),
59
66
  ...(AnyP13 ? [{ text: 'Kwota netto', style: common_enum_1.default.GrayBoldTitle }] : []),
60
- ...(AnyP13P14_5Diff0 ? [{ text: 'Kwota podatku', style: common_enum_1.default.GrayBoldTitle }] : []),
67
+ ...(AnyP13P14_5Diff0 || (0, PDF_functions_1.hasValue)((_9 = faktura.Fa) === null || _9 === void 0 ? void 0 : _9.P_14_5)
68
+ ? [
69
+ {
70
+ text: 'Kwota podatku',
71
+ style: common_enum_1.default.GrayBoldTitle,
72
+ },
73
+ ]
74
+ : []),
61
75
  ...(AnyP13 ? [{ text: 'Kwota brutto', style: common_enum_1.default.GrayBoldTitle }] : []),
62
76
  ...(AnyP_14xW ? [{ text: 'Kwota podatku PLN', style: common_enum_1.default.GrayBoldTitle }] : []),
63
77
  ];
64
78
  const widths = [
65
79
  ...['auto'],
66
- ...(AnyP13P14_5Diff0 ? ['*'] : []),
80
+ ...(AnyP13P14_5Diff0 || (0, PDF_functions_1.hasValue)((_10 = faktura.Fa) === null || _10 === void 0 ? void 0 : _10.P_14_5) ? ['*'] : []),
67
81
  ...(AnyP13 ? ['*'] : []),
68
- ...(AnyP13P14_5Diff0 ? ['*'] : []),
82
+ ...(AnyP13P14_5Diff0 || (0, PDF_functions_1.hasValue)((_11 = faktura.Fa) === null || _11 === void 0 ? void 0 : _11.P_14_5) ? ['*'] : []),
69
83
  ...(AnyP13 ? ['*'] : []),
70
84
  ...(AnyP_14xW ? ['*'] : []),
71
85
  ];
72
86
  if (faktura === null || faktura === void 0 ? void 0 : faktura.Fa) {
73
87
  const summary = getSummaryTaxRate(faktura.Fa);
74
88
  tableBody = summary.map((item) => {
89
+ var _a, _b, _c, _d;
75
90
  const data = [];
76
91
  data.push(item.no);
77
92
  if (AnyP13P14_5Diff0) {
78
- data.push(item.taxRateString);
93
+ if (item.taxRateString) {
94
+ data.push(item.taxRateString);
95
+ }
96
+ else if ((0, PDF_functions_1.getValue)((_a = faktura.Fa) === null || _a === void 0 ? void 0 : _a.P_13_5)) {
97
+ data.push('OSS');
98
+ }
99
+ else {
100
+ data.push('');
101
+ }
102
+ }
103
+ else if ((0, PDF_functions_1.hasValue)((_b = faktura.Fa) === null || _b === void 0 ? void 0 : _b.P_14_5)) {
104
+ data.push('OSS');
79
105
  }
80
106
  if (AnyP13) {
81
107
  data.push((0, PDF_functions_1.formatText)(item.net, common_enum_1.default.Currency));
@@ -83,6 +109,9 @@ function generatePodsumowanieStawekPodatkuVat(faktura) {
83
109
  if (AnyP13P14_5Diff0) {
84
110
  data.push((0, PDF_functions_1.formatText)(item.tax, common_enum_1.default.Currency));
85
111
  }
112
+ else if ((0, PDF_functions_1.hasValue)((_c = faktura.Fa) === null || _c === void 0 ? void 0 : _c.P_14_5)) {
113
+ data.push((0, PDF_functions_1.getValue)((_d = faktura.Fa) === null || _d === void 0 ? void 0 : _d.P_14_5));
114
+ }
86
115
  if (AnyP13) {
87
116
  data.push((0, PDF_functions_1.formatText)(item.gross, common_enum_1.default.Currency));
88
117
  }
@@ -154,7 +183,7 @@ function getSummaryTaxRate(fa) {
154
183
  gross: ((0, PDF_functions_1.getNumberRounded)(fa.P_13_4) + (0, PDF_functions_1.getNumberRounded)(fa.P_14_4)).toFixed(2),
155
184
  tax: (0, PDF_functions_1.getNumberRounded)(fa.P_14_4).toFixed(2),
156
185
  taxPLN: (0, PDF_functions_1.getNumberRounded)(fa.P_14_4W).toFixed(2),
157
- taxRateString: '4% lub 3% lub oo',
186
+ taxRateString: '4% lub 3%',
158
187
  });
159
188
  no++;
160
189
  }
@@ -162,10 +191,10 @@ function getSummaryTaxRate(fa) {
162
191
  summary.push({
163
192
  no,
164
193
  net: (0, PDF_functions_1.getNumberRounded)(fa.P_13_5).toFixed(2),
165
- gross: (0, PDF_functions_1.getNumberRounded)(fa.P_13_5).toFixed(2),
194
+ gross: ((0, PDF_functions_1.getNumberRounded)(fa.P_13_5) + (0, PDF_functions_1.getNumberRounded)(fa.P_14_5)).toFixed(2),
166
195
  tax: (0, PDF_functions_1.getNumberRounded)(fa.P_14_5).toFixed(2),
167
196
  taxPLN: '',
168
- taxRateString: (0, PDF_functions_1.getValue)(fa.P_14_5) != 0 ? 'niepodlegające opodatkowaniu' : '',
197
+ taxRateString: (0, PDF_functions_1.getValue)(fa.P_14_5) != 0 ? 'OSS' : '',
169
198
  });
170
199
  no++;
171
200
  }
@@ -176,7 +205,7 @@ function getSummaryTaxRate(fa) {
176
205
  gross: (0, PDF_functions_1.getNumberRounded)(fa.P_13_6_1).toFixed(2),
177
206
  tax: '0.00',
178
207
  taxPLN: '',
179
- taxRateString: '0% - krajowe',
208
+ taxRateString: '0% w przypadku sprzedaży towarów i świadczenia usług na terytorium kraju (z wyłączeniem WDT i eksportu)',
180
209
  });
181
210
  no++;
182
211
  }
@@ -187,18 +216,18 @@ function getSummaryTaxRate(fa) {
187
216
  gross: (0, PDF_functions_1.getNumberRounded)(fa.P_13_6_2).toFixed(2),
188
217
  tax: '0.00',
189
218
  taxPLN: '',
190
- taxRateString: '0% - wdt',
219
+ taxRateString: '0% w przypadku wewnątrzwspólnotowej dostawy towarów (WDT)',
191
220
  });
192
221
  no++;
193
222
  }
194
223
  if (AnyP13_6_3Diff0) {
195
224
  summary.push({
196
225
  no,
197
- net: (0, PDF_functions_1.getNumberRounded)(fa.P_13_6_2).toFixed(2),
198
- gross: (0, PDF_functions_1.getNumberRounded)(fa.P_13_6_2).toFixed(2),
226
+ net: (0, PDF_functions_1.getNumberRounded)(fa.P_13_6_3).toFixed(2),
227
+ gross: (0, PDF_functions_1.getNumberRounded)(fa.P_13_6_3).toFixed(2),
199
228
  tax: '0.00',
200
229
  taxPLN: '',
201
- taxRateString: '0% - eksport',
230
+ taxRateString: '0% w przypadku eksportu towarów',
202
231
  });
203
232
  no++;
204
233
  }
@@ -209,7 +238,7 @@ function getSummaryTaxRate(fa) {
209
238
  gross: (0, PDF_functions_1.getNumberRounded)(fa.P_13_7).toFixed(2),
210
239
  tax: '0.00',
211
240
  taxPLN: '',
212
- taxRateString: 'zwolnione z opodatkowania',
241
+ taxRateString: 'zwolnione od podatku',
213
242
  });
214
243
  no++;
215
244
  }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "makeapps-transformer",
3
3
  "main": "dist/index.js",
4
4
  "types": "dist/index.d.ts",
5
- "version": "1.0.2",
5
+ "version": "1.0.3",
6
6
  "scripts": {
7
7
  "build": "tsc"
8
8
  },
@@ -46,7 +46,7 @@ export function generatePodsumowanieStawekPodatkuVat(faktura: Faktura): Content[
46
46
  hasValue(faktura.Fa?.P_14_3W) ||
47
47
  hasValue(faktura.Fa?.P_14_4W);
48
48
 
49
- let tableBody: TableCell[] = [];
49
+ let tableBody: any[] = [];
50
50
  const table: ContentTable = {
51
51
  table: {
52
52
  headerRows: 1,
@@ -63,18 +63,32 @@ export function generatePodsumowanieStawekPodatkuVat(faktura: Faktura): Content[
63
63
 
64
64
  const definedHeader: Content[] = [
65
65
  ...[{ text: 'Lp.', style: FormatTyp.GrayBoldTitle }],
66
- ...(AnyP13P14_5Diff0 ? [{ text: 'Stawka podatku', style: FormatTyp.GrayBoldTitle }] : []),
66
+ ...(AnyP13P14_5Diff0 || hasValue(faktura.Fa?.P_14_5)
67
+ ? [
68
+ {
69
+ text: 'Stawka podatku',
70
+ style: FormatTyp.GrayBoldTitle,
71
+ },
72
+ ]
73
+ : []),
67
74
  ...(AnyP13 ? [{ text: 'Kwota netto', style: FormatTyp.GrayBoldTitle }] : []),
68
- ...(AnyP13P14_5Diff0 ? [{ text: 'Kwota podatku', style: FormatTyp.GrayBoldTitle }] : []),
75
+ ...(AnyP13P14_5Diff0 || hasValue(faktura.Fa?.P_14_5)
76
+ ? [
77
+ {
78
+ text: 'Kwota podatku',
79
+ style: FormatTyp.GrayBoldTitle,
80
+ },
81
+ ]
82
+ : []),
69
83
  ...(AnyP13 ? [{ text: 'Kwota brutto', style: FormatTyp.GrayBoldTitle }] : []),
70
84
  ...(AnyP_14xW ? [{ text: 'Kwota podatku PLN', style: FormatTyp.GrayBoldTitle }] : []),
71
85
  ];
72
86
 
73
87
  const widths: Content[] = [
74
88
  ...['auto'],
75
- ...(AnyP13P14_5Diff0 ? ['*'] : []),
89
+ ...(AnyP13P14_5Diff0 || hasValue(faktura.Fa?.P_14_5) ? ['*'] : []),
76
90
  ...(AnyP13 ? ['*'] : []),
77
- ...(AnyP13P14_5Diff0 ? ['*'] : []),
91
+ ...(AnyP13P14_5Diff0 || hasValue(faktura.Fa?.P_14_5) ? ['*'] : []),
78
92
  ...(AnyP13 ? ['*'] : []),
79
93
  ...(AnyP_14xW ? ['*'] : []),
80
94
  ];
@@ -87,13 +101,23 @@ export function generatePodsumowanieStawekPodatkuVat(faktura: Faktura): Content[
87
101
 
88
102
  data.push(item.no);
89
103
  if (AnyP13P14_5Diff0) {
90
- data.push(item.taxRateString);
104
+ if (item.taxRateString) {
105
+ data.push(item.taxRateString);
106
+ } else if (getValue(faktura.Fa?.P_13_5)) {
107
+ data.push('OSS');
108
+ } else {
109
+ data.push('');
110
+ }
111
+ } else if (hasValue(faktura.Fa?.P_14_5)) {
112
+ data.push('OSS');
91
113
  }
92
114
  if (AnyP13) {
93
115
  data.push(formatText(item.net, FormatTyp.Currency));
94
116
  }
95
117
  if (AnyP13P14_5Diff0) {
96
118
  data.push(formatText(item.tax, FormatTyp.Currency));
119
+ } else if (hasValue(faktura.Fa?.P_14_5)) {
120
+ data.push(getValue(faktura.Fa?.P_14_5));
97
121
  }
98
122
  if (AnyP13) {
99
123
  data.push(formatText(item.gross, FormatTyp.Currency));
@@ -177,7 +201,7 @@ export function getSummaryTaxRate(fa: Fa): TaxSummaryTypes[] {
177
201
  gross: (getNumberRounded(fa.P_13_4) + getNumberRounded(fa.P_14_4)).toFixed(2),
178
202
  tax: getNumberRounded(fa.P_14_4).toFixed(2),
179
203
  taxPLN: getNumberRounded(fa.P_14_4W).toFixed(2),
180
- taxRateString: '4% lub 3% lub oo',
204
+ taxRateString: '4% lub 3%',
181
205
  });
182
206
  no++;
183
207
  }
@@ -186,10 +210,10 @@ export function getSummaryTaxRate(fa: Fa): TaxSummaryTypes[] {
186
210
  summary.push({
187
211
  no,
188
212
  net: getNumberRounded(fa.P_13_5).toFixed(2),
189
- gross: getNumberRounded(fa.P_13_5).toFixed(2),
213
+ gross: (getNumberRounded(fa.P_13_5) + getNumberRounded(fa.P_14_5)).toFixed(2),
190
214
  tax: getNumberRounded(fa.P_14_5).toFixed(2),
191
215
  taxPLN: '',
192
- taxRateString: getValue(fa.P_14_5) != 0 ? 'niepodlegające opodatkowaniu' : '',
216
+ taxRateString: getValue(fa.P_14_5) != 0 ? 'OSS' : '',
193
217
  });
194
218
  no++;
195
219
  }
@@ -201,7 +225,8 @@ export function getSummaryTaxRate(fa: Fa): TaxSummaryTypes[] {
201
225
  gross: getNumberRounded(fa.P_13_6_1).toFixed(2),
202
226
  tax: '0.00',
203
227
  taxPLN: '',
204
- taxRateString: '0% - krajowe',
228
+ taxRateString:
229
+ '0% w przypadku sprzedaży towarów i świadczenia usług na terytorium kraju (z wyłączeniem WDT i eksportu)',
205
230
  });
206
231
  no++;
207
232
  }
@@ -213,7 +238,7 @@ export function getSummaryTaxRate(fa: Fa): TaxSummaryTypes[] {
213
238
  gross: getNumberRounded(fa.P_13_6_2).toFixed(2),
214
239
  tax: '0.00',
215
240
  taxPLN: '',
216
- taxRateString: '0% - wdt',
241
+ taxRateString: '0% w przypadku wewnątrzwspólnotowej dostawy towarów (WDT)',
217
242
  });
218
243
  no++;
219
244
  }
@@ -221,11 +246,11 @@ export function getSummaryTaxRate(fa: Fa): TaxSummaryTypes[] {
221
246
  if (AnyP13_6_3Diff0) {
222
247
  summary.push({
223
248
  no,
224
- net: getNumberRounded(fa.P_13_6_2).toFixed(2),
225
- gross: getNumberRounded(fa.P_13_6_2).toFixed(2),
249
+ net: getNumberRounded(fa.P_13_6_3).toFixed(2),
250
+ gross: getNumberRounded(fa.P_13_6_3).toFixed(2),
226
251
  tax: '0.00',
227
252
  taxPLN: '',
228
- taxRateString: '0% - eksport',
253
+ taxRateString: '0% w przypadku eksportu towarów',
229
254
  });
230
255
  no++;
231
256
  }
@@ -237,7 +262,7 @@ export function getSummaryTaxRate(fa: Fa): TaxSummaryTypes[] {
237
262
  gross: getNumberRounded(fa.P_13_7).toFixed(2),
238
263
  tax: '0.00',
239
264
  taxPLN: '',
240
- taxRateString: 'zwolnione z opodatkowania',
265
+ taxRateString: 'zwolnione od podatku',
241
266
  });
242
267
  no++;
243
268
  }
@@ -295,4 +320,4 @@ export function getSummaryTaxRate(fa: Fa): TaxSummaryTypes[] {
295
320
 
296
321
  function hasValueAndDiff0(value: FP | string | number | undefined): boolean {
297
322
  return hasValue(value) && getValue(value) != 0;
298
- }
323
+ }