makeapps-transformer 1.0.3 → 1.0.5
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.
|
@@ -122,15 +122,24 @@ function generateFakturaZaliczkowa(fakturaZaliczkowaData) {
|
|
|
122
122
|
return [];
|
|
123
123
|
}
|
|
124
124
|
const fakturaZaliczkowa = (0, PDF_functions_1.getTable)(fakturaZaliczkowaData);
|
|
125
|
+
const fakturaZaliczkowaMapped = fakturaZaliczkowa.map((item) => {
|
|
126
|
+
if ('NrFaZaliczkowej' in item && item.NrFaZaliczkowej) {
|
|
127
|
+
return { ...item, NrFaZaliczkowej: item.NrFaZaliczkowej };
|
|
128
|
+
}
|
|
129
|
+
if ('NrKSeFFaZaliczkowej' in item && item.NrKSeFFaZaliczkowej) {
|
|
130
|
+
return { ...item, NrFaZaliczkowej: item.NrKSeFFaZaliczkowej };
|
|
131
|
+
}
|
|
132
|
+
return { ...item, NrFaZaliczkowej: { _text: '' } };
|
|
133
|
+
});
|
|
125
134
|
const table = [];
|
|
126
135
|
const fakturaZaliczkowaHeader = [
|
|
127
136
|
{
|
|
128
|
-
name: '
|
|
137
|
+
name: 'NrFaZaliczkowej',
|
|
129
138
|
title: 'Numery wcześniejszych faktur zaliczkowych',
|
|
130
139
|
format: common_enum_1.default.Default,
|
|
131
140
|
},
|
|
132
141
|
];
|
|
133
|
-
const tableFakturaZaliczkowa = (0, PDF_functions_1.getContentTable)(fakturaZaliczkowaHeader,
|
|
142
|
+
const tableFakturaZaliczkowa = (0, PDF_functions_1.getContentTable)(fakturaZaliczkowaHeader, fakturaZaliczkowaMapped, 'auto', [0, 4, 0, 0]);
|
|
134
143
|
if (tableFakturaZaliczkowa.content) {
|
|
135
144
|
table.push(tableFakturaZaliczkowa.content);
|
|
136
145
|
}
|
|
@@ -92,10 +92,19 @@ function generateTable(array, keys) {
|
|
|
92
92
|
}
|
|
93
93
|
function formatValue(item, result, value, currency = '') {
|
|
94
94
|
switch (item) {
|
|
95
|
-
case common_enum_1.default.Currency:
|
|
96
|
-
|
|
95
|
+
case common_enum_1.default.Currency: {
|
|
96
|
+
const uVal = String(value || '').replace(/,/, '.');
|
|
97
|
+
if (!isNaN(Number(uVal))) {
|
|
98
|
+
const [, second = undefined] = uVal.split(/[,.]/);
|
|
99
|
+
const length = (second || '00').length;
|
|
100
|
+
result.text = `${Number(uVal).toFixed(length)} ${currency}`;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
result.text = value;
|
|
104
|
+
}
|
|
97
105
|
result.alignment = common_enum_1.Position.RIGHT;
|
|
98
106
|
break;
|
|
107
|
+
}
|
|
99
108
|
case common_enum_1.default.CurrencyAbs:
|
|
100
109
|
result.text = isNaN(Number(value))
|
|
101
110
|
? value
|
package/package.json
CHANGED
|
@@ -160,11 +160,21 @@ function generateFakturaZaliczkowa(fakturaZaliczkowaData: ObjectKeysOfFP[] | und
|
|
|
160
160
|
return [];
|
|
161
161
|
}
|
|
162
162
|
const fakturaZaliczkowa = getTable(fakturaZaliczkowaData) as unknown as FA3FakturaZaliczkowaData[];
|
|
163
|
-
const
|
|
163
|
+
const fakturaZaliczkowaMapped = fakturaZaliczkowa.map((item) => {
|
|
164
|
+
if ('NrFaZaliczkowej' in item && item.NrFaZaliczkowej) {
|
|
165
|
+
return { ...item, NrFaZaliczkowej: item.NrFaZaliczkowej };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if ('NrKSeFFaZaliczkowej' in item && item.NrKSeFFaZaliczkowej) {
|
|
169
|
+
return { ...item, NrFaZaliczkowej: item.NrKSeFFaZaliczkowej };
|
|
170
|
+
}
|
|
164
171
|
|
|
172
|
+
return { ...item, NrFaZaliczkowej: { _text: '' } };
|
|
173
|
+
});
|
|
174
|
+
const table: Content[] = [];
|
|
165
175
|
const fakturaZaliczkowaHeader: HeaderDefine[] = [
|
|
166
176
|
{
|
|
167
|
-
name: '
|
|
177
|
+
name: 'NrFaZaliczkowej',
|
|
168
178
|
title: 'Numery wcześniejszych faktur zaliczkowych',
|
|
169
179
|
format: FormatTyp.Default,
|
|
170
180
|
},
|
|
@@ -172,7 +182,7 @@ function generateFakturaZaliczkowa(fakturaZaliczkowaData: ObjectKeysOfFP[] | und
|
|
|
172
182
|
|
|
173
183
|
const tableFakturaZaliczkowa = getContentTable<(typeof fakturaZaliczkowa)[0]>(
|
|
174
184
|
fakturaZaliczkowaHeader,
|
|
175
|
-
|
|
185
|
+
fakturaZaliczkowaMapped,
|
|
176
186
|
'auto',
|
|
177
187
|
[0, 4, 0, 0]
|
|
178
188
|
);
|
|
@@ -74,10 +74,19 @@ function formatValue(
|
|
|
74
74
|
currency = ''
|
|
75
75
|
): void {
|
|
76
76
|
switch (item) {
|
|
77
|
-
case FormatTyp.Currency:
|
|
78
|
-
|
|
77
|
+
case FormatTyp.Currency: {
|
|
78
|
+
const uVal = String(value || '').replace(/,/, '.');
|
|
79
|
+
if (!isNaN(Number(uVal))) {
|
|
80
|
+
const [, second = undefined] = uVal.split(/[,.]/);
|
|
81
|
+
const length = (second || '00').length;
|
|
82
|
+
result.text = `${Number(uVal).toFixed(length)} ${currency}`;
|
|
83
|
+
} else {
|
|
84
|
+
result.text = value as string;
|
|
85
|
+
}
|
|
86
|
+
// result.text = isNaN(Number(value)) ? (value as string) : `${Number(value).toFixed(2)} ${currency}`;
|
|
79
87
|
result.alignment = Position.RIGHT;
|
|
80
88
|
break;
|
|
89
|
+
}
|
|
81
90
|
case FormatTyp.CurrencyAbs:
|
|
82
91
|
result.text = isNaN(Number(value))
|
|
83
92
|
? (value as string)
|
|
@@ -361,7 +370,7 @@ export function getContentTable<T>(
|
|
|
361
370
|
const fieldsWithValue: HeaderDefine[] = headers.filter((header: HeaderDefine): boolean => {
|
|
362
371
|
return data.some((d: T): boolean => {
|
|
363
372
|
const name = header.name as keyof T;
|
|
364
|
-
|
|
373
|
+
|
|
365
374
|
if (name === '' && (d as FP)?._text) {
|
|
366
375
|
return true;
|
|
367
376
|
}
|