shareneus 1.7.315 → 1.7.316
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.
- package/dist/shared/table-section/pdf-table.header.js +23 -24
- package/dist/shared/table-section/pdf-table.row.js +31 -0
- package/dist/shared/table-section/pdf-table.section.js +3 -0
- package/package.json +1 -1
- package/src/shared/table-section/pdf-table.header.ts +83 -101
- package/src/shared/table-section/pdf-table.row.ts +44 -7
- package/src/shared/table-section/pdf-table.section.ts +8 -5
|
@@ -107,7 +107,7 @@ function getRenderableColumns(headerConfig, sType = '') {
|
|
|
107
107
|
columns.push({
|
|
108
108
|
type: 'tax',
|
|
109
109
|
taxKind: 'rate',
|
|
110
|
-
dbField: '
|
|
110
|
+
dbField: 'GST',
|
|
111
111
|
width: header.width,
|
|
112
112
|
});
|
|
113
113
|
continue;
|
|
@@ -116,7 +116,7 @@ function getRenderableColumns(headerConfig, sType = '') {
|
|
|
116
116
|
columns.push({
|
|
117
117
|
type: 'tax',
|
|
118
118
|
taxKind: 'amount',
|
|
119
|
-
dbField: '
|
|
119
|
+
dbField: 'GST',
|
|
120
120
|
width: header.width,
|
|
121
121
|
});
|
|
122
122
|
continue;
|
|
@@ -154,13 +154,8 @@ function getRenderableColumns(headerConfig, sType = '') {
|
|
|
154
154
|
columns.push({
|
|
155
155
|
type: 'tax',
|
|
156
156
|
taxKind: 'rate',
|
|
157
|
-
dbField: '
|
|
158
|
-
width:
|
|
159
|
-
}, {
|
|
160
|
-
type: 'tax',
|
|
161
|
-
taxKind: 'rate',
|
|
162
|
-
dbField: 'SGST',
|
|
163
|
-
width: getTaxSubWidth(header.width, 'rate'),
|
|
157
|
+
dbField: 'GST',
|
|
158
|
+
width: header.width,
|
|
164
159
|
});
|
|
165
160
|
continue;
|
|
166
161
|
}
|
|
@@ -168,13 +163,8 @@ function getRenderableColumns(headerConfig, sType = '') {
|
|
|
168
163
|
columns.push({
|
|
169
164
|
type: 'tax',
|
|
170
165
|
taxKind: 'amount',
|
|
171
|
-
dbField: '
|
|
172
|
-
width:
|
|
173
|
-
}, {
|
|
174
|
-
type: 'tax',
|
|
175
|
-
taxKind: 'amount',
|
|
176
|
-
dbField: 'SGST',
|
|
177
|
-
width: getTaxSubWidth(header.width, 'amount'),
|
|
166
|
+
dbField: 'GST',
|
|
167
|
+
width: header.width,
|
|
178
168
|
});
|
|
179
169
|
continue;
|
|
180
170
|
}
|
|
@@ -194,9 +184,9 @@ function buildHeaderRows(headerConfig, sType = '') {
|
|
|
194
184
|
const hasDiscPercent = headerConfig.some((header) => header.text === 'Disc %');
|
|
195
185
|
const hasDiscAmount = headerConfig.some((header) => isDiscountAmountHeader(header.text));
|
|
196
186
|
const hasDiscGroup = hasDiscPercent && hasDiscAmount;
|
|
197
|
-
const hasGroupedHeaders =
|
|
187
|
+
const hasGroupedHeaders = hasTaxGroup || hasDiscGroup;
|
|
198
188
|
if (!hasGroupedHeaders) {
|
|
199
|
-
const singleRow = headerConfig.map((header) => (Object.assign({ text: header
|
|
189
|
+
const singleRow = headerConfig.map((header) => (Object.assign({ text: getSingleTaxHeaderText(header), alignment: header.alignment, dbFields: header.dbFields, stackFields: header.stackFields }, getHeaderCellStyle())));
|
|
200
190
|
return [singleRow];
|
|
201
191
|
}
|
|
202
192
|
const topRow = [];
|
|
@@ -213,12 +203,12 @@ function buildHeaderRows(headerConfig, sType = '') {
|
|
|
213
203
|
continue;
|
|
214
204
|
}
|
|
215
205
|
if (isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
|
|
216
|
-
topRow.push(Object.assign({ text:
|
|
206
|
+
topRow.push(Object.assign({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
|
|
217
207
|
subRow.push({});
|
|
218
208
|
continue;
|
|
219
209
|
}
|
|
220
210
|
if (isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
|
|
221
|
-
topRow.push(Object.assign({ text:
|
|
211
|
+
topRow.push(Object.assign({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
|
|
222
212
|
subRow.push({});
|
|
223
213
|
continue;
|
|
224
214
|
}
|
|
@@ -234,13 +224,13 @@ function buildHeaderRows(headerConfig, sType = '') {
|
|
|
234
224
|
continue;
|
|
235
225
|
}
|
|
236
226
|
if (!isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
|
|
237
|
-
topRow.push(Object.assign({ text: header
|
|
238
|
-
subRow.push(
|
|
227
|
+
topRow.push(Object.assign({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
|
|
228
|
+
subRow.push({});
|
|
239
229
|
continue;
|
|
240
230
|
}
|
|
241
231
|
if (!isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
|
|
242
|
-
topRow.push(Object.assign({ text: header
|
|
243
|
-
subRow.push(
|
|
232
|
+
topRow.push(Object.assign({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center' }, getHeaderCellStyle()));
|
|
233
|
+
subRow.push({});
|
|
244
234
|
continue;
|
|
245
235
|
}
|
|
246
236
|
if (hasDiscGroup && header.text === 'Disc %') {
|
|
@@ -272,6 +262,15 @@ function isTaxPercentHeader(header) {
|
|
|
272
262
|
function isTaxAmountHeader(header) {
|
|
273
263
|
return normalizeHeaderText(header === null || header === void 0 ? void 0 : header.text) === 'TAXAMOUNT';
|
|
274
264
|
}
|
|
265
|
+
function getSingleTaxHeaderText(header) {
|
|
266
|
+
if (isTaxPercentHeader(header)) {
|
|
267
|
+
return 'GST(%)';
|
|
268
|
+
}
|
|
269
|
+
if (isTaxAmountHeader(header)) {
|
|
270
|
+
return 'GST Amt';
|
|
271
|
+
}
|
|
272
|
+
return header.text;
|
|
273
|
+
}
|
|
275
274
|
function isTaxHeaderConfig(header) {
|
|
276
275
|
var _a, _b, _c;
|
|
277
276
|
const title = (_c = (_b = (_a = header === null || header === void 0 ? void 0 : header.title) !== null && _a !== void 0 ? _a : header === null || header === void 0 ? void 0 : header.CustTitle) !== null && _b !== void 0 ? _b : header === null || header === void 0 ? void 0 : header.Tital) !== null && _c !== void 0 ? _c : header === null || header === void 0 ? void 0 : header.text;
|
|
@@ -59,6 +59,20 @@ function formatFieldValue(item, fieldConfig, fixedTo) {
|
|
|
59
59
|
return formatNumericLikeValue(signedValue, fixedTo, shouldSkipFixedTo(fieldConfig));
|
|
60
60
|
}
|
|
61
61
|
function getTaxValue(item, taxName, taxKind) {
|
|
62
|
+
if (taxName === 'GST') {
|
|
63
|
+
if (taxKind === 'rate') {
|
|
64
|
+
return getCombinedTaxValue(item, ['CombinedTaxPercentage', 'GSTPerc'], [
|
|
65
|
+
['CGSTPerc', 'CGST'],
|
|
66
|
+
['SGSTPerc', 'SGST'],
|
|
67
|
+
['IGSTPerc', 'IGST']
|
|
68
|
+
]);
|
|
69
|
+
}
|
|
70
|
+
return getCombinedTaxValue(item, ['TotalTaxAmount', 'TaxAmount', 'GSTAmt'], [
|
|
71
|
+
['CGSTAmt', 'CGST'],
|
|
72
|
+
['SGSTAmt', 'SGST'],
|
|
73
|
+
['IGSTAmt', 'IGST']
|
|
74
|
+
]);
|
|
75
|
+
}
|
|
62
76
|
if (taxName === 'IGST') {
|
|
63
77
|
const fields = taxKind === 'rate' ? ['IGSTPerc'] : ['IGSTAmt'];
|
|
64
78
|
return getFirstFieldValue(item, fields);
|
|
@@ -68,6 +82,23 @@ function getTaxValue(item, taxName, taxKind) {
|
|
|
68
82
|
: [`${taxName}Amt`, taxName];
|
|
69
83
|
return getFirstFieldValue(item, fields);
|
|
70
84
|
}
|
|
85
|
+
function getCombinedTaxValue(item, combinedFields, componentFieldGroups) {
|
|
86
|
+
const combinedValue = getFirstFieldValue(item, combinedFields);
|
|
87
|
+
if (combinedValue) {
|
|
88
|
+
return combinedValue;
|
|
89
|
+
}
|
|
90
|
+
const values = componentFieldGroups
|
|
91
|
+
.map((fields) => getFirstFieldValue(item, fields))
|
|
92
|
+
.filter((value) => value !== '');
|
|
93
|
+
if (values.length === 0) {
|
|
94
|
+
return '';
|
|
95
|
+
}
|
|
96
|
+
const numericValues = values.map((value) => Number(value.replace(/,/g, '').trim()));
|
|
97
|
+
if (numericValues.some((value) => !Number.isFinite(value))) {
|
|
98
|
+
return values[0];
|
|
99
|
+
}
|
|
100
|
+
return String(numericValues.reduce((sum, value) => sum + value, 0));
|
|
101
|
+
}
|
|
71
102
|
function shouldRenderNegativeTaxAmount(item, column) {
|
|
72
103
|
return !!(item === null || item === void 0 ? void 0 : item.Ret) && (column === null || column === void 0 ? void 0 : column.taxKind) === 'amount';
|
|
73
104
|
}
|
|
@@ -262,6 +262,9 @@ function buildSectionTotalRow(columns, label, totals, fixedTo) {
|
|
|
262
262
|
if (column.dbField === 'IGST' && column.taxKind === 'amount') {
|
|
263
263
|
return buildTotalValueCell(formatAmount(totals.igstAmount, fixedTo));
|
|
264
264
|
}
|
|
265
|
+
if (column.dbField === 'GST' && column.taxKind === 'amount') {
|
|
266
|
+
return buildTotalValueCell(formatAmount(totals.cgstAmount + totals.sgstAmount + totals.igstAmount, fixedTo));
|
|
267
|
+
}
|
|
265
268
|
return buildTotalValueCell('');
|
|
266
269
|
}
|
|
267
270
|
const headerText = (_b = (_a = column.header) === null || _a === void 0 ? void 0 : _a.text) !== null && _b !== void 0 ? _b : '';
|
package/package.json
CHANGED
|
@@ -113,25 +113,25 @@ export function getRenderableColumns(headerConfig: any[], sType: string = '') {
|
|
|
113
113
|
continue;
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
if (isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
|
|
117
|
-
columns.push({
|
|
118
|
-
type: 'tax',
|
|
119
|
-
taxKind: 'rate',
|
|
120
|
-
dbField: '
|
|
121
|
-
width: header.width,
|
|
122
|
-
});
|
|
123
|
-
continue;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
|
|
127
|
-
columns.push({
|
|
128
|
-
type: 'tax',
|
|
129
|
-
taxKind: 'amount',
|
|
130
|
-
dbField: '
|
|
131
|
-
width: header.width,
|
|
132
|
-
});
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
116
|
+
if (isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
|
|
117
|
+
columns.push({
|
|
118
|
+
type: 'tax',
|
|
119
|
+
taxKind: 'rate',
|
|
120
|
+
dbField: 'GST',
|
|
121
|
+
width: header.width,
|
|
122
|
+
});
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
|
|
127
|
+
columns.push({
|
|
128
|
+
type: 'tax',
|
|
129
|
+
taxKind: 'amount',
|
|
130
|
+
dbField: 'GST',
|
|
131
|
+
width: header.width,
|
|
132
|
+
});
|
|
133
|
+
continue;
|
|
134
|
+
}
|
|
135
135
|
|
|
136
136
|
// --- Intra / CGST + SGST ---
|
|
137
137
|
if (!isInter && hasTaxGroup && isTaxPercentHeader(header)) {
|
|
@@ -170,41 +170,25 @@ export function getRenderableColumns(headerConfig: any[], sType: string = '') {
|
|
|
170
170
|
continue;
|
|
171
171
|
}
|
|
172
172
|
|
|
173
|
-
if (!isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
|
|
174
|
-
columns.push(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
columns.push(
|
|
193
|
-
{
|
|
194
|
-
type: 'tax',
|
|
195
|
-
taxKind: 'amount',
|
|
196
|
-
dbField: 'CGST',
|
|
197
|
-
width: getTaxSubWidth(header.width, 'amount'),
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
type: 'tax',
|
|
201
|
-
taxKind: 'amount',
|
|
202
|
-
dbField: 'SGST',
|
|
203
|
-
width: getTaxSubWidth(header.width, 'amount'),
|
|
204
|
-
}
|
|
205
|
-
);
|
|
206
|
-
continue;
|
|
207
|
-
}
|
|
173
|
+
if (!isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
|
|
174
|
+
columns.push({
|
|
175
|
+
type: 'tax',
|
|
176
|
+
taxKind: 'rate',
|
|
177
|
+
dbField: 'GST',
|
|
178
|
+
width: header.width,
|
|
179
|
+
});
|
|
180
|
+
continue;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (!isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
|
|
184
|
+
columns.push({
|
|
185
|
+
type: 'tax',
|
|
186
|
+
taxKind: 'amount',
|
|
187
|
+
dbField: 'GST',
|
|
188
|
+
width: header.width,
|
|
189
|
+
});
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
208
192
|
|
|
209
193
|
columns.push({
|
|
210
194
|
type: 'normal',
|
|
@@ -223,16 +207,16 @@ export function buildHeaderRows(headerConfig: any[], sType: string = '') {
|
|
|
223
207
|
const hasDiscPercent = headerConfig.some((header: any) => header.text === 'Disc %');
|
|
224
208
|
const hasDiscAmount = headerConfig.some((header: any) => isDiscountAmountHeader(header.text));
|
|
225
209
|
const hasDiscGroup = hasDiscPercent && hasDiscAmount;
|
|
226
|
-
const hasGroupedHeaders =
|
|
227
|
-
|
|
228
|
-
if (!hasGroupedHeaders) {
|
|
229
|
-
const singleRow = headerConfig.map((header: any) => ({
|
|
230
|
-
text: header
|
|
231
|
-
alignment: header.alignment,
|
|
232
|
-
dbFields: header.dbFields,
|
|
233
|
-
stackFields: header.stackFields,
|
|
234
|
-
...getHeaderCellStyle()
|
|
235
|
-
}));
|
|
210
|
+
const hasGroupedHeaders = hasTaxGroup || hasDiscGroup;
|
|
211
|
+
|
|
212
|
+
if (!hasGroupedHeaders) {
|
|
213
|
+
const singleRow = headerConfig.map((header: any) => ({
|
|
214
|
+
text: getSingleTaxHeaderText(header),
|
|
215
|
+
alignment: header.alignment,
|
|
216
|
+
dbFields: header.dbFields,
|
|
217
|
+
stackFields: header.stackFields,
|
|
218
|
+
...getHeaderCellStyle()
|
|
219
|
+
}));
|
|
236
220
|
return [singleRow];
|
|
237
221
|
}
|
|
238
222
|
|
|
@@ -258,17 +242,17 @@ export function buildHeaderRows(headerConfig: any[], sType: string = '') {
|
|
|
258
242
|
continue;
|
|
259
243
|
}
|
|
260
244
|
|
|
261
|
-
if (isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
|
|
262
|
-
topRow.push({ text:
|
|
263
|
-
subRow.push({});
|
|
264
|
-
continue;
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
if (isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
|
|
268
|
-
topRow.push({ text:
|
|
269
|
-
subRow.push({});
|
|
270
|
-
continue;
|
|
271
|
-
}
|
|
245
|
+
if (isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
|
|
246
|
+
topRow.push({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center', ...getHeaderCellStyle() });
|
|
247
|
+
subRow.push({});
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
|
|
252
|
+
topRow.push({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center', ...getHeaderCellStyle() });
|
|
253
|
+
subRow.push({});
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
272
256
|
|
|
273
257
|
// --- Intra / CGST + SGST ---
|
|
274
258
|
if (!isInter && hasTaxGroup && isTaxPercentHeader(header)) {
|
|
@@ -295,29 +279,17 @@ export function buildHeaderRows(headerConfig: any[], sType: string = '') {
|
|
|
295
279
|
continue;
|
|
296
280
|
}
|
|
297
281
|
|
|
298
|
-
if (!isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
|
|
299
|
-
topRow.push(
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
);
|
|
307
|
-
continue;
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
if (!isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
|
|
311
|
-
topRow.push(
|
|
312
|
-
{ text: header.text, colSpan: 2, alignment: 'center', ...getHeaderCellStyle() },
|
|
313
|
-
{}
|
|
314
|
-
);
|
|
315
|
-
subRow.push(
|
|
316
|
-
{ text: 'CGST', alignment: 'center', ...getHeaderCellStyle() },
|
|
317
|
-
{ text: 'SGST/UGST', alignment: 'center', ...getHeaderCellStyle() }
|
|
318
|
-
);
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
282
|
+
if (!isInter && !hasTaxGroup && isTaxPercentHeader(header)) {
|
|
283
|
+
topRow.push({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center', ...getHeaderCellStyle() });
|
|
284
|
+
subRow.push({});
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (!isInter && !hasTaxGroup && isTaxAmountHeader(header)) {
|
|
289
|
+
topRow.push({ text: getSingleTaxHeaderText(header), rowSpan: 2, alignment: 'center', ...getHeaderCellStyle() });
|
|
290
|
+
subRow.push({});
|
|
291
|
+
continue;
|
|
292
|
+
}
|
|
321
293
|
|
|
322
294
|
if (hasDiscGroup && header.text === 'Disc %') {
|
|
323
295
|
topRow.push(
|
|
@@ -358,9 +330,19 @@ function isTaxPercentHeader(header: any) {
|
|
|
358
330
|
return normalizeHeaderText(header?.text) === 'TAX%';
|
|
359
331
|
}
|
|
360
332
|
|
|
361
|
-
function isTaxAmountHeader(header: any) {
|
|
362
|
-
return normalizeHeaderText(header?.text) === 'TAXAMOUNT';
|
|
363
|
-
}
|
|
333
|
+
function isTaxAmountHeader(header: any) {
|
|
334
|
+
return normalizeHeaderText(header?.text) === 'TAXAMOUNT';
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
function getSingleTaxHeaderText(header: any) {
|
|
338
|
+
if (isTaxPercentHeader(header)) {
|
|
339
|
+
return 'GST(%)';
|
|
340
|
+
}
|
|
341
|
+
if (isTaxAmountHeader(header)) {
|
|
342
|
+
return 'GST Amt';
|
|
343
|
+
}
|
|
344
|
+
return header.text;
|
|
345
|
+
}
|
|
364
346
|
|
|
365
347
|
function isTaxHeaderConfig(header: any) {
|
|
366
348
|
const title = header?.title ?? header?.CustTitle ?? header?.Tital ?? header?.text;
|
|
@@ -59,16 +59,53 @@ function formatFieldValue(item: any, fieldConfig: any, fixedTo: number) {
|
|
|
59
59
|
return formatNumericLikeValue(signedValue, fixedTo, shouldSkipFixedTo(fieldConfig));
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
function getTaxValue(item: any, taxName: 'CGST' | 'SGST' | 'IGST', taxKind: 'rate' | 'amount') {
|
|
63
|
-
if (taxName === '
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
function getTaxValue(item: any, taxName: 'CGST' | 'SGST' | 'IGST' | 'GST', taxKind: 'rate' | 'amount') {
|
|
63
|
+
if (taxName === 'GST') {
|
|
64
|
+
if (taxKind === 'rate') {
|
|
65
|
+
return getCombinedTaxValue(item, ['CombinedTaxPercentage', 'GSTPerc'], [
|
|
66
|
+
['CGSTPerc', 'CGST'],
|
|
67
|
+
['SGSTPerc', 'SGST'],
|
|
68
|
+
['IGSTPerc', 'IGST']
|
|
69
|
+
]);
|
|
70
|
+
}
|
|
71
|
+
return getCombinedTaxValue(item, ['TotalTaxAmount', 'TaxAmount', 'GSTAmt'], [
|
|
72
|
+
['CGSTAmt', 'CGST'],
|
|
73
|
+
['SGSTAmt', 'SGST'],
|
|
74
|
+
['IGSTAmt', 'IGST']
|
|
75
|
+
]);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (taxName === 'IGST') {
|
|
79
|
+
const fields = taxKind === 'rate' ? ['IGSTPerc'] : ['IGSTAmt'];
|
|
80
|
+
return getFirstFieldValue(item, fields);
|
|
81
|
+
}
|
|
67
82
|
const fields = taxKind === 'rate'
|
|
68
83
|
? [`${taxName}Perc`, taxName]
|
|
69
84
|
: [`${taxName}Amt`, taxName];
|
|
70
|
-
return getFirstFieldValue(item, fields);
|
|
71
|
-
}
|
|
85
|
+
return getFirstFieldValue(item, fields);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function getCombinedTaxValue(item: any, combinedFields: string[], componentFieldGroups: string[][]) {
|
|
89
|
+
const combinedValue = getFirstFieldValue(item, combinedFields);
|
|
90
|
+
if (combinedValue) {
|
|
91
|
+
return combinedValue;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
const values = componentFieldGroups
|
|
95
|
+
.map((fields: string[]) => getFirstFieldValue(item, fields))
|
|
96
|
+
.filter((value: string) => value !== '');
|
|
97
|
+
|
|
98
|
+
if (values.length === 0) {
|
|
99
|
+
return '';
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const numericValues = values.map((value: string) => Number(value.replace(/,/g, '').trim()));
|
|
103
|
+
if (numericValues.some((value: number) => !Number.isFinite(value))) {
|
|
104
|
+
return values[0];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return String(numericValues.reduce((sum: number, value: number) => sum + value, 0));
|
|
108
|
+
}
|
|
72
109
|
|
|
73
110
|
function shouldRenderNegativeTaxAmount(item: any, column: any) {
|
|
74
111
|
return !!item?.Ret && column?.taxKind === 'amount';
|
|
@@ -275,11 +275,14 @@ function buildSectionTotalRow(columns: any[], label: string, totals: any, fixedT
|
|
|
275
275
|
if (column.dbField === 'SGST' && column.taxKind === 'amount') {
|
|
276
276
|
return buildTotalValueCell(formatAmount(totals.sgstAmount, fixedTo));
|
|
277
277
|
}
|
|
278
|
-
if (column.dbField === 'IGST' && column.taxKind === 'amount') {
|
|
279
|
-
return buildTotalValueCell(formatAmount(totals.igstAmount, fixedTo));
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
|
|
278
|
+
if (column.dbField === 'IGST' && column.taxKind === 'amount') {
|
|
279
|
+
return buildTotalValueCell(formatAmount(totals.igstAmount, fixedTo));
|
|
280
|
+
}
|
|
281
|
+
if (column.dbField === 'GST' && column.taxKind === 'amount') {
|
|
282
|
+
return buildTotalValueCell(formatAmount(totals.cgstAmount + totals.sgstAmount + totals.igstAmount, fixedTo));
|
|
283
|
+
}
|
|
284
|
+
return buildTotalValueCell('');
|
|
285
|
+
}
|
|
283
286
|
|
|
284
287
|
const headerText = column.header?.text ?? '';
|
|
285
288
|
if (headerText === 'Description') {
|