shareneus 1.7.18 → 1.7.19
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.
|
@@ -14,7 +14,7 @@ function buildDataRow(item, index, headerConfig, fixedTo = 2) {
|
|
|
14
14
|
const signedTaxValue = shouldRenderNegativeTaxAmount(item, column)
|
|
15
15
|
? negateNumericLikeValue(taxValue)
|
|
16
16
|
: taxValue;
|
|
17
|
-
const renderedTaxValue = formatNumericLikeValue(signedTaxValue, fixedTo);
|
|
17
|
+
const renderedTaxValue = formatNumericLikeValue(signedTaxValue, fixedTo, column.taxKind === 'rate');
|
|
18
18
|
return { text: renderedTaxValue, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: getNumericAlignment(renderedTaxValue) };
|
|
19
19
|
}
|
|
20
20
|
const header = column.header;
|
|
@@ -208,12 +208,16 @@ function formatExpiryDateValue(value) {
|
|
|
208
208
|
function shouldSkipFixedTo(header) {
|
|
209
209
|
var _a;
|
|
210
210
|
const text = String((_a = header === null || header === void 0 ? void 0 : header.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
|
|
211
|
-
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO') {
|
|
211
|
+
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%')) {
|
|
212
212
|
return true;
|
|
213
213
|
}
|
|
214
214
|
const dbFields = Array.isArray(header === null || header === void 0 ? void 0 : header.dbFields) ? header.dbFields : [];
|
|
215
215
|
return dbFields.some((field) => {
|
|
216
216
|
const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
|
|
217
|
-
return normalized === 'BN'
|
|
217
|
+
return normalized === 'BN'
|
|
218
|
+
|| normalized === 'BNO'
|
|
219
|
+
|| normalized.endsWith('.BN')
|
|
220
|
+
|| normalized.endsWith('PERC')
|
|
221
|
+
|| normalized.endsWith('.PERC');
|
|
218
222
|
});
|
|
219
223
|
}
|
|
@@ -19,7 +19,8 @@ function buildInvoiceTableData(PDFInvoiceData, PrintConfig, availableWidth) {
|
|
|
19
19
|
const sType = (_a = PDFInvoiceData === null || PDFInvoiceData === void 0 ? void 0 : PDFInvoiceData.SType) !== null && _a !== void 0 ? _a : '';
|
|
20
20
|
const taxMode = resolveInvoiceTaxMode(PDFInvoiceData);
|
|
21
21
|
const showSectionSummaryRows = !resolveIsPoSPrint(PrintConfig);
|
|
22
|
-
const
|
|
22
|
+
const tableConfig = normalizeTableConfig(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.TableConfig, PDFInvoiceData);
|
|
23
|
+
const headerConfig = (0, pdf_table_header_1.GetTableHeader)(tableConfig, taxMode)[0];
|
|
23
24
|
const renderColumns = (0, pdf_table_header_1.getRenderableColumns)(headerConfig, sType);
|
|
24
25
|
const headerRows = (0, pdf_table_header_1.buildHeaderRows)(headerConfig, sType);
|
|
25
26
|
const fixedTo = resolveFixedTo(PrintConfig === null || PrintConfig === void 0 ? void 0 : PrintConfig.fixedTo);
|
|
@@ -187,7 +188,7 @@ function buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo) {
|
|
|
187
188
|
if (header.text === 'CGST') {
|
|
188
189
|
if (header.taxKind === 'rate') {
|
|
189
190
|
const value = (0, pdf_table_row_1.getFirstFieldValue)(item, ['CGSTPerc']);
|
|
190
|
-
const renderedValue = formatNumericLikeValue(value, fixedTo);
|
|
191
|
+
const renderedValue = formatNumericLikeValue(value, fixedTo, true);
|
|
191
192
|
return { text: renderedValue, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(renderedValue) };
|
|
192
193
|
}
|
|
193
194
|
else if (header.taxKind === 'amount') {
|
|
@@ -199,7 +200,7 @@ function buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo) {
|
|
|
199
200
|
if (header.text === 'SGST') {
|
|
200
201
|
if (header.taxKind === 'rate') {
|
|
201
202
|
const value = (0, pdf_table_row_1.getFirstFieldValue)(item, ['SGSTPerc']);
|
|
202
|
-
const renderedValue = formatNumericLikeValue(value, fixedTo);
|
|
203
|
+
const renderedValue = formatNumericLikeValue(value, fixedTo, true);
|
|
203
204
|
return { text: renderedValue, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(renderedValue) };
|
|
204
205
|
}
|
|
205
206
|
else if (header.taxKind === 'amount') {
|
|
@@ -210,7 +211,7 @@ function buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo) {
|
|
|
210
211
|
}
|
|
211
212
|
if (header.text === 'IGST %') {
|
|
212
213
|
const value = (0, pdf_table_row_1.getFirstFieldValue)(item, ['IGSTPerc']);
|
|
213
|
-
const renderedValue = formatNumericLikeValue(value, fixedTo);
|
|
214
|
+
const renderedValue = formatNumericLikeValue(value, fixedTo, true);
|
|
214
215
|
return { text: renderedValue, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(renderedValue) };
|
|
215
216
|
}
|
|
216
217
|
if (header.text === 'IGST Amt') {
|
|
@@ -222,10 +223,10 @@ function buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo) {
|
|
|
222
223
|
const value = String(index + 1);
|
|
223
224
|
return { text: value, fontSize: pdf_table_config_1.pdfTableStyleConfig.bodyFontSize, color: pdf_table_config_1.pdfTableStyleConfig.bodyFontColor, alignment: (0, pdf_table_row_1.getNumericAlignment)(value) };
|
|
224
225
|
}
|
|
225
|
-
const mainValue = formatNumericLikeValue(getDisplayValueForFallbackRow(item, header.dbFields, shouldNegateFallbackHeaderValue(item, header.text)), fixedTo);
|
|
226
|
+
const mainValue = formatNumericLikeValue(getDisplayValueForFallbackRow(item, header.dbFields, shouldNegateFallbackHeaderValue(item, header.text)), fixedTo, shouldSkipFixedTo(header));
|
|
226
227
|
const stackedLines = ((_a = header.stackFields) !== null && _a !== void 0 ? _a : [])
|
|
227
228
|
.map((stackField) => {
|
|
228
|
-
const stackValue = formatNumericLikeValue((0, pdf_table_row_1.getFirstFieldValue)(item, stackField.dbFields), fixedTo);
|
|
229
|
+
const stackValue = formatNumericLikeValue((0, pdf_table_row_1.getFirstFieldValue)(item, stackField.dbFields), fixedTo, shouldSkipFixedTo(stackField));
|
|
229
230
|
if (!stackValue) {
|
|
230
231
|
return null;
|
|
231
232
|
}
|
|
@@ -355,6 +356,25 @@ function resolveInvoiceTaxMode(pdfInvoiceData) {
|
|
|
355
356
|
var _a, _b;
|
|
356
357
|
return String((_b = (_a = pdfInvoiceData === null || pdfInvoiceData === void 0 ? void 0 : pdfInvoiceData.Settings) === null || _a === void 0 ? void 0 : _a.Tax) !== null && _b !== void 0 ? _b : '').trim().toUpperCase();
|
|
357
358
|
}
|
|
359
|
+
function normalizeTableConfig(tableConfig, pdfInvoiceData) {
|
|
360
|
+
if (!Array.isArray(tableConfig) || tableConfig.length === 0) {
|
|
361
|
+
return Array.isArray(tableConfig) ? tableConfig : [];
|
|
362
|
+
}
|
|
363
|
+
if (!(pdfInvoiceData === null || pdfInvoiceData === void 0 ? void 0 : pdfInvoiceData.ShowDiscountColumn)) {
|
|
364
|
+
return tableConfig;
|
|
365
|
+
}
|
|
366
|
+
return tableConfig.map((column) => {
|
|
367
|
+
if (!isDiscountColumnConfig(column)) {
|
|
368
|
+
return column;
|
|
369
|
+
}
|
|
370
|
+
return Object.assign(Object.assign({}, column), { show: true, Show: true });
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
function isDiscountColumnConfig(column) {
|
|
374
|
+
var _a, _b, _c;
|
|
375
|
+
const title = String((_c = (_b = (_a = column === null || column === void 0 ? void 0 : column.title) !== null && _a !== void 0 ? _a : column === null || column === void 0 ? void 0 : column.CustTitle) !== null && _b !== void 0 ? _b : column === null || column === void 0 ? void 0 : column.Tital) !== null && _c !== void 0 ? _c : '').trim();
|
|
376
|
+
return title === 'Disc %' || title === 'Disc Amount' || title === 'Adisc Amount';
|
|
377
|
+
}
|
|
358
378
|
function buildSectionRows({ rows, columnsOrHeaders, descriptionColumnIndex, label, buildRow, buildTotalRow, showSectionSummaryRows }) {
|
|
359
379
|
const sectionRows = rows.map((row, index) => buildRow(row, index));
|
|
360
380
|
if (!showSectionSummaryRows) {
|
|
@@ -376,6 +396,22 @@ function shouldNegateFallbackHeaderValue(item, headerText) {
|
|
|
376
396
|
|| normalized === 'PRICE'
|
|
377
397
|
|| normalized === 'LINE TOTAL';
|
|
378
398
|
}
|
|
399
|
+
function shouldSkipFixedTo(header) {
|
|
400
|
+
var _a;
|
|
401
|
+
const text = String((_a = header === null || header === void 0 ? void 0 : header.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
|
|
402
|
+
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%')) {
|
|
403
|
+
return true;
|
|
404
|
+
}
|
|
405
|
+
const dbFields = Array.isArray(header === null || header === void 0 ? void 0 : header.dbFields) ? header.dbFields : [];
|
|
406
|
+
return dbFields.some((field) => {
|
|
407
|
+
const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
|
|
408
|
+
return normalized === 'BN'
|
|
409
|
+
|| normalized === 'BNO'
|
|
410
|
+
|| normalized.endsWith('.BN')
|
|
411
|
+
|| normalized.endsWith('PERC')
|
|
412
|
+
|| normalized.endsWith('.PERC');
|
|
413
|
+
});
|
|
414
|
+
}
|
|
379
415
|
function getDisplayValueForFallbackRow(item, dbFields = [], shouldNegate = false) {
|
|
380
416
|
const value = (0, pdf_table_row_1.getFirstFieldValue)(item, dbFields);
|
|
381
417
|
if (!shouldNegate) {
|
|
@@ -387,7 +423,10 @@ function getDisplayValueForFallbackRow(item, dbFields = [], shouldNegate = false
|
|
|
387
423
|
}
|
|
388
424
|
return String(normalized === 0 ? 0 : -Math.abs(normalized));
|
|
389
425
|
}
|
|
390
|
-
function formatNumericLikeValue(value, fixedTo) {
|
|
426
|
+
function formatNumericLikeValue(value, fixedTo, skipFixedTo = false) {
|
|
427
|
+
if (skipFixedTo) {
|
|
428
|
+
return value;
|
|
429
|
+
}
|
|
391
430
|
if (!value) {
|
|
392
431
|
return value;
|
|
393
432
|
}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@ export function buildDataRow(item: any, index: number, headerConfig: any[], fixe
|
|
|
8
8
|
const signedTaxValue = shouldRenderNegativeTaxAmount(item, column)
|
|
9
9
|
? negateNumericLikeValue(taxValue)
|
|
10
10
|
: taxValue;
|
|
11
|
-
const renderedTaxValue = formatNumericLikeValue(signedTaxValue, fixedTo);
|
|
11
|
+
const renderedTaxValue = formatNumericLikeValue(signedTaxValue, fixedTo, column.taxKind === 'rate');
|
|
12
12
|
return { text: renderedTaxValue, fontSize: pdfTableStyleConfig.bodyFontSize, color: pdfTableStyleConfig.bodyFontColor, alignment: getNumericAlignment(renderedTaxValue) };
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -236,13 +236,17 @@ function formatExpiryDateValue(value: string) {
|
|
|
236
236
|
|
|
237
237
|
function shouldSkipFixedTo(header: any) {
|
|
238
238
|
const text = String(header?.text ?? '').trim().toUpperCase();
|
|
239
|
-
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO') {
|
|
239
|
+
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%')) {
|
|
240
240
|
return true;
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
const dbFields = Array.isArray(header?.dbFields) ? header.dbFields : [];
|
|
244
244
|
return dbFields.some((field: any) => {
|
|
245
245
|
const normalized = String(field ?? '').trim().toUpperCase();
|
|
246
|
-
return normalized === 'BN'
|
|
246
|
+
return normalized === 'BN'
|
|
247
|
+
|| normalized === 'BNO'
|
|
248
|
+
|| normalized.endsWith('.BN')
|
|
249
|
+
|| normalized.endsWith('PERC')
|
|
250
|
+
|| normalized.endsWith('.PERC');
|
|
247
251
|
});
|
|
248
252
|
}
|
|
@@ -13,7 +13,8 @@ export function buildInvoiceTableData(PDFInvoiceData: any, PrintConfig: any, ava
|
|
|
13
13
|
const sType = PDFInvoiceData?.SType ?? '';
|
|
14
14
|
const taxMode = resolveInvoiceTaxMode(PDFInvoiceData);
|
|
15
15
|
const showSectionSummaryRows = !resolveIsPoSPrint(PrintConfig);
|
|
16
|
-
const
|
|
16
|
+
const tableConfig = normalizeTableConfig(PrintConfig?.TableConfig, PDFInvoiceData);
|
|
17
|
+
const headerConfig = GetTableHeader(tableConfig, taxMode)[0];
|
|
17
18
|
const renderColumns = getRenderableColumns(headerConfig, sType);
|
|
18
19
|
const headerRows = buildHeaderRows(headerConfig, sType);
|
|
19
20
|
const fixedTo = resolveFixedTo(PrintConfig?.fixedTo);
|
|
@@ -201,7 +202,7 @@ function buildFallbackDataRow(item: any, index: number, fallbackHeaderRow: any[]
|
|
|
201
202
|
if (header.text === 'CGST') {
|
|
202
203
|
if (header.taxKind === 'rate') {
|
|
203
204
|
const value = getFirstFieldValue(item, ['CGSTPerc']);
|
|
204
|
-
const renderedValue = formatNumericLikeValue(value, fixedTo);
|
|
205
|
+
const renderedValue = formatNumericLikeValue(value, fixedTo, true);
|
|
205
206
|
return { text: renderedValue, fontSize: pdfTableStyleConfig.bodyFontSize, color: pdfTableStyleConfig.bodyFontColor, alignment: getNumericAlignment(renderedValue) };
|
|
206
207
|
} else if (header.taxKind === 'amount') {
|
|
207
208
|
const value = getDisplayValueForFallbackRow(item, ['CGSTAmt'], true);
|
|
@@ -212,7 +213,7 @@ function buildFallbackDataRow(item: any, index: number, fallbackHeaderRow: any[]
|
|
|
212
213
|
if (header.text === 'SGST') {
|
|
213
214
|
if (header.taxKind === 'rate') {
|
|
214
215
|
const value = getFirstFieldValue(item, ['SGSTPerc']);
|
|
215
|
-
const renderedValue = formatNumericLikeValue(value, fixedTo);
|
|
216
|
+
const renderedValue = formatNumericLikeValue(value, fixedTo, true);
|
|
216
217
|
return { text: renderedValue, fontSize: pdfTableStyleConfig.bodyFontSize, color: pdfTableStyleConfig.bodyFontColor, alignment: getNumericAlignment(renderedValue) };
|
|
217
218
|
} else if (header.taxKind === 'amount') {
|
|
218
219
|
const value = getDisplayValueForFallbackRow(item, ['SGSTAmt'], true);
|
|
@@ -222,7 +223,7 @@ function buildFallbackDataRow(item: any, index: number, fallbackHeaderRow: any[]
|
|
|
222
223
|
}
|
|
223
224
|
if (header.text === 'IGST %') {
|
|
224
225
|
const value = getFirstFieldValue(item, ['IGSTPerc']);
|
|
225
|
-
const renderedValue = formatNumericLikeValue(value, fixedTo);
|
|
226
|
+
const renderedValue = formatNumericLikeValue(value, fixedTo, true);
|
|
226
227
|
return { text: renderedValue, fontSize: pdfTableStyleConfig.bodyFontSize, color: pdfTableStyleConfig.bodyFontColor, alignment: getNumericAlignment(renderedValue) };
|
|
227
228
|
}
|
|
228
229
|
if (header.text === 'IGST Amt') {
|
|
@@ -236,11 +237,12 @@ function buildFallbackDataRow(item: any, index: number, fallbackHeaderRow: any[]
|
|
|
236
237
|
}
|
|
237
238
|
const mainValue = formatNumericLikeValue(
|
|
238
239
|
getDisplayValueForFallbackRow(item, header.dbFields, shouldNegateFallbackHeaderValue(item, header.text)),
|
|
239
|
-
fixedTo
|
|
240
|
+
fixedTo,
|
|
241
|
+
shouldSkipFixedTo(header)
|
|
240
242
|
);
|
|
241
243
|
const stackedLines = (header.stackFields ?? [])
|
|
242
244
|
.map((stackField: any) => {
|
|
243
|
-
const stackValue = formatNumericLikeValue(getFirstFieldValue(item, stackField.dbFields), fixedTo);
|
|
245
|
+
const stackValue = formatNumericLikeValue(getFirstFieldValue(item, stackField.dbFields), fixedTo, shouldSkipFixedTo(stackField));
|
|
244
246
|
if (!stackValue) {
|
|
245
247
|
return null;
|
|
246
248
|
}
|
|
@@ -379,6 +381,33 @@ function resolveInvoiceTaxMode(pdfInvoiceData: any) {
|
|
|
379
381
|
return String(pdfInvoiceData?.Settings?.Tax ?? '').trim().toUpperCase();
|
|
380
382
|
}
|
|
381
383
|
|
|
384
|
+
function normalizeTableConfig(tableConfig: any[], pdfInvoiceData: any) {
|
|
385
|
+
if (!Array.isArray(tableConfig) || tableConfig.length === 0) {
|
|
386
|
+
return Array.isArray(tableConfig) ? tableConfig : [];
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if (!pdfInvoiceData?.ShowDiscountColumn) {
|
|
390
|
+
return tableConfig;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
return tableConfig.map((column: any) => {
|
|
394
|
+
if (!isDiscountColumnConfig(column)) {
|
|
395
|
+
return column;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
return {
|
|
399
|
+
...column,
|
|
400
|
+
show: true,
|
|
401
|
+
Show: true
|
|
402
|
+
};
|
|
403
|
+
});
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
function isDiscountColumnConfig(column: any) {
|
|
407
|
+
const title = String(column?.title ?? column?.CustTitle ?? column?.Tital ?? '').trim();
|
|
408
|
+
return title === 'Disc %' || title === 'Disc Amount' || title === 'Adisc Amount';
|
|
409
|
+
}
|
|
410
|
+
|
|
382
411
|
function buildSectionRows({
|
|
383
412
|
rows,
|
|
384
413
|
columnsOrHeaders,
|
|
@@ -420,6 +449,23 @@ function shouldNegateFallbackHeaderValue(item: any, headerText: string) {
|
|
|
420
449
|
|| normalized === 'LINE TOTAL';
|
|
421
450
|
}
|
|
422
451
|
|
|
452
|
+
function shouldSkipFixedTo(header: any) {
|
|
453
|
+
const text = String(header?.text ?? '').trim().toUpperCase();
|
|
454
|
+
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%')) {
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
const dbFields = Array.isArray(header?.dbFields) ? header.dbFields : [];
|
|
459
|
+
return dbFields.some((field: any) => {
|
|
460
|
+
const normalized = String(field ?? '').trim().toUpperCase();
|
|
461
|
+
return normalized === 'BN'
|
|
462
|
+
|| normalized === 'BNO'
|
|
463
|
+
|| normalized.endsWith('.BN')
|
|
464
|
+
|| normalized.endsWith('PERC')
|
|
465
|
+
|| normalized.endsWith('.PERC');
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
|
|
423
469
|
function getDisplayValueForFallbackRow(item: any, dbFields: string[] = [], shouldNegate: boolean = false) {
|
|
424
470
|
const value = getFirstFieldValue(item, dbFields);
|
|
425
471
|
if (!shouldNegate) {
|
|
@@ -434,7 +480,10 @@ function getDisplayValueForFallbackRow(item: any, dbFields: string[] = [], shoul
|
|
|
434
480
|
return String(normalized === 0 ? 0 : -Math.abs(normalized));
|
|
435
481
|
}
|
|
436
482
|
|
|
437
|
-
function formatNumericLikeValue(value: string, fixedTo: number) {
|
|
483
|
+
function formatNumericLikeValue(value: string, fixedTo: number, skipFixedTo: boolean = false) {
|
|
484
|
+
if (skipFixedTo) {
|
|
485
|
+
return value;
|
|
486
|
+
}
|
|
438
487
|
if (!value) {
|
|
439
488
|
return value;
|
|
440
489
|
}
|