shareneus 1.5.92 → 1.5.93
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.
|
@@ -73,38 +73,31 @@ function getHeadersBySequence(headers) {
|
|
|
73
73
|
.map((entry) => entry.header);
|
|
74
74
|
}
|
|
75
75
|
function getRenderableColumns(headerConfig) {
|
|
76
|
-
const hasTaxPercent = headerConfig.some((header) => header.text === 'Tax %');
|
|
77
|
-
const hasTaxAmount = headerConfig.some((header) => header.text === 'Tax Amount');
|
|
78
|
-
const hasTaxGroup = hasTaxPercent && hasTaxAmount;
|
|
79
76
|
const columns = [];
|
|
80
77
|
for (const header of headerConfig) {
|
|
81
|
-
if (
|
|
78
|
+
if (isTaxPercentHeader(header)) {
|
|
82
79
|
columns.push({
|
|
83
80
|
type: 'tax',
|
|
84
81
|
taxKind: 'rate',
|
|
85
|
-
taxName: '%',
|
|
86
82
|
dbField: 'CGST',
|
|
87
83
|
width: getTaxSubWidth(header.width),
|
|
88
84
|
}, {
|
|
89
85
|
type: 'tax',
|
|
90
|
-
taxKind: '
|
|
91
|
-
dbField: '
|
|
92
|
-
taxName: 'Amount',
|
|
86
|
+
taxKind: 'rate',
|
|
87
|
+
dbField: 'SGST',
|
|
93
88
|
width: getTaxSubWidth(header.width),
|
|
94
89
|
});
|
|
95
90
|
continue;
|
|
96
91
|
}
|
|
97
|
-
if (
|
|
92
|
+
if (isTaxAmountHeader(header)) {
|
|
98
93
|
columns.push({
|
|
99
94
|
type: 'tax',
|
|
100
|
-
taxKind: '
|
|
101
|
-
|
|
102
|
-
dbField: 'SGST',
|
|
95
|
+
taxKind: 'amount',
|
|
96
|
+
dbField: 'CGST',
|
|
103
97
|
width: getTaxSubWidth(header.width),
|
|
104
98
|
}, {
|
|
105
99
|
type: 'tax',
|
|
106
100
|
taxKind: 'amount',
|
|
107
|
-
taxName: 'Amount',
|
|
108
101
|
dbField: 'SGST',
|
|
109
102
|
width: getTaxSubWidth(header.width),
|
|
110
103
|
});
|
|
@@ -119,9 +112,7 @@ function getRenderableColumns(headerConfig) {
|
|
|
119
112
|
return columns;
|
|
120
113
|
}
|
|
121
114
|
function buildHeaderRows(headerConfig) {
|
|
122
|
-
const
|
|
123
|
-
const hasTaxAmount = headerConfig.some((header) => header.text === 'Tax Amount');
|
|
124
|
-
const hasTaxGroup = hasTaxPercent && hasTaxAmount;
|
|
115
|
+
const hasTaxGroup = headerConfig.some((header) => isTaxPercentHeader(header) || isTaxAmountHeader(header));
|
|
125
116
|
const hasDiscPercent = headerConfig.some((header) => header.text === 'Disc %');
|
|
126
117
|
const hasDiscAmount = headerConfig.some((header) => isDiscountAmountHeader(header.text));
|
|
127
118
|
const hasDiscGroup = hasDiscPercent && hasDiscAmount;
|
|
@@ -133,14 +124,14 @@ function buildHeaderRows(headerConfig) {
|
|
|
133
124
|
const topRow = [];
|
|
134
125
|
const subRow = [];
|
|
135
126
|
for (const header of headerConfig) {
|
|
136
|
-
if (
|
|
137
|
-
topRow.push(Object.assign({ text:
|
|
138
|
-
subRow.push(Object.assign({ text: '
|
|
127
|
+
if (isTaxPercentHeader(header)) {
|
|
128
|
+
topRow.push(Object.assign({ text: header.text, colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
|
|
129
|
+
subRow.push(Object.assign({ text: 'CGST', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'SGST/UGST', alignment: 'center' }, getHeaderCellStyle()));
|
|
139
130
|
continue;
|
|
140
131
|
}
|
|
141
|
-
if (
|
|
142
|
-
topRow.push(Object.assign({ text:
|
|
143
|
-
subRow.push(Object.assign({ text: '
|
|
132
|
+
if (isTaxAmountHeader(header)) {
|
|
133
|
+
topRow.push(Object.assign({ text: header.text, colSpan: 2, alignment: 'center' }, getHeaderCellStyle()), {});
|
|
134
|
+
subRow.push(Object.assign({ text: 'CGST', alignment: 'center' }, getHeaderCellStyle()), Object.assign({ text: 'SGST/UGST', alignment: 'center' }, getHeaderCellStyle()));
|
|
144
135
|
continue;
|
|
145
136
|
}
|
|
146
137
|
if (hasDiscGroup && header.text === 'Disc %') {
|
|
@@ -165,6 +156,18 @@ function getTaxSubWidth(width) {
|
|
|
165
156
|
function isDiscountAmountHeader(text) {
|
|
166
157
|
return text === 'Disc Amount' || text === 'Adisc Amount';
|
|
167
158
|
}
|
|
159
|
+
function isTaxPercentHeader(header) {
|
|
160
|
+
return normalizeHeaderText(header === null || header === void 0 ? void 0 : header.text) === 'TAX%';
|
|
161
|
+
}
|
|
162
|
+
function isTaxAmountHeader(header) {
|
|
163
|
+
return normalizeHeaderText(header === null || header === void 0 ? void 0 : header.text) === 'TAXAMOUNT';
|
|
164
|
+
}
|
|
165
|
+
function normalizeHeaderText(value) {
|
|
166
|
+
return String(value !== null && value !== void 0 ? value : '')
|
|
167
|
+
.replace(/\s+/g, '')
|
|
168
|
+
.trim()
|
|
169
|
+
.toUpperCase();
|
|
170
|
+
}
|
|
168
171
|
function getHeaderCellStyle() {
|
|
169
172
|
return {
|
|
170
173
|
bold: true,
|
|
@@ -46,12 +46,6 @@ function buildDataRow(item, index, headerConfig, fixedTo = 2) {
|
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
function formatFieldValue(item, fieldConfig, fixedTo) {
|
|
49
|
-
if (isTaxPercentHeader(fieldConfig)) {
|
|
50
|
-
return formatCombinedTaxValue(item, 'rate', fixedTo);
|
|
51
|
-
}
|
|
52
|
-
if (isTaxAmountHeader(fieldConfig)) {
|
|
53
|
-
return formatCombinedTaxValue(item, 'amount', fixedTo);
|
|
54
|
-
}
|
|
55
49
|
const rawValue = getFirstFieldValue(item, fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.dbFields);
|
|
56
50
|
if (isExpiryField(fieldConfig)) {
|
|
57
51
|
return formatExpiryDateValue(rawValue);
|
|
@@ -182,33 +176,3 @@ function shouldSkipFixedTo(header) {
|
|
|
182
176
|
return normalized === 'BN' || normalized === 'BNO' || normalized.endsWith('.BN');
|
|
183
177
|
});
|
|
184
178
|
}
|
|
185
|
-
function isTaxPercentHeader(fieldConfig) {
|
|
186
|
-
const normalized = normalizeHeaderText(fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.text);
|
|
187
|
-
return normalized === 'TAX%';
|
|
188
|
-
}
|
|
189
|
-
function isTaxAmountHeader(fieldConfig) {
|
|
190
|
-
const normalized = normalizeHeaderText(fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.text);
|
|
191
|
-
return normalized === 'TAXAMOUNT';
|
|
192
|
-
}
|
|
193
|
-
function normalizeHeaderText(value) {
|
|
194
|
-
return String(value !== null && value !== void 0 ? value : '')
|
|
195
|
-
.replace(/\s+/g, '')
|
|
196
|
-
.trim()
|
|
197
|
-
.toUpperCase();
|
|
198
|
-
}
|
|
199
|
-
function formatCombinedTaxValue(item, kind, fixedTo) {
|
|
200
|
-
const cgstField = kind === 'rate' ? 'CGSTPerc' : 'CGSTAmt';
|
|
201
|
-
const sgstField = kind === 'rate' ? 'SGSTPerc' : 'SGSTAmt';
|
|
202
|
-
const cgstValue = formatNumericLikeValue(getFirstFieldValue(item, [cgstField, 'CGST']), fixedTo);
|
|
203
|
-
const sgstValue = formatNumericLikeValue(getFirstFieldValue(item, [sgstField, 'SGST']), fixedTo);
|
|
204
|
-
if (cgstValue && sgstValue) {
|
|
205
|
-
return `CGST: ${cgstValue} | SGST/UGST: ${sgstValue}`;
|
|
206
|
-
}
|
|
207
|
-
if (cgstValue) {
|
|
208
|
-
return `CGST: ${cgstValue}`;
|
|
209
|
-
}
|
|
210
|
-
if (sgstValue) {
|
|
211
|
-
return `SGST/UGST: ${sgstValue}`;
|
|
212
|
-
}
|
|
213
|
-
return '';
|
|
214
|
-
}
|
|
@@ -186,10 +186,10 @@ function buildFallbackDataRow(item, index, fallbackHeaderRow, fixedTo) {
|
|
|
186
186
|
const value = String(index + 1);
|
|
187
187
|
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) };
|
|
188
188
|
}
|
|
189
|
-
const mainValue =
|
|
189
|
+
const mainValue = formatNumericLikeValue((0, pdf_table_row_1.getFirstFieldValue)(item, header.dbFields), fixedTo);
|
|
190
190
|
const stackedLines = ((_a = header.stackFields) !== null && _a !== void 0 ? _a : [])
|
|
191
191
|
.map((stackField) => {
|
|
192
|
-
const stackValue =
|
|
192
|
+
const stackValue = formatNumericLikeValue((0, pdf_table_row_1.getFirstFieldValue)(item, stackField.dbFields), fixedTo);
|
|
193
193
|
if (!stackValue) {
|
|
194
194
|
return null;
|
|
195
195
|
}
|
|
@@ -315,40 +315,3 @@ function formatNumericLikeValue(value, fixedTo) {
|
|
|
315
315
|
}
|
|
316
316
|
return normalized.toFixed(fixedTo);
|
|
317
317
|
}
|
|
318
|
-
function formatFallbackFieldValue(item, fieldConfig, fixedTo) {
|
|
319
|
-
if (isTaxPercentHeader(fieldConfig)) {
|
|
320
|
-
return formatCombinedTaxValue(item, 'rate', fixedTo);
|
|
321
|
-
}
|
|
322
|
-
if (isTaxAmountHeader(fieldConfig)) {
|
|
323
|
-
return formatCombinedTaxValue(item, 'amount', fixedTo);
|
|
324
|
-
}
|
|
325
|
-
return formatNumericLikeValue((0, pdf_table_row_1.getFirstFieldValue)(item, fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.dbFields), fixedTo);
|
|
326
|
-
}
|
|
327
|
-
function isTaxPercentHeader(fieldConfig) {
|
|
328
|
-
return normalizeHeaderText(fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.text) === 'TAX%';
|
|
329
|
-
}
|
|
330
|
-
function isTaxAmountHeader(fieldConfig) {
|
|
331
|
-
return normalizeHeaderText(fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.text) === 'TAXAMOUNT';
|
|
332
|
-
}
|
|
333
|
-
function normalizeHeaderText(value) {
|
|
334
|
-
return String(value !== null && value !== void 0 ? value : '')
|
|
335
|
-
.replace(/\s+/g, '')
|
|
336
|
-
.trim()
|
|
337
|
-
.toUpperCase();
|
|
338
|
-
}
|
|
339
|
-
function formatCombinedTaxValue(item, kind, fixedTo) {
|
|
340
|
-
const cgstField = kind === 'rate' ? 'CGSTPerc' : 'CGSTAmt';
|
|
341
|
-
const sgstField = kind === 'rate' ? 'SGSTPerc' : 'SGSTAmt';
|
|
342
|
-
const cgstValue = formatNumericLikeValue((0, pdf_table_row_1.getFirstFieldValue)(item, [cgstField, 'CGST']), fixedTo);
|
|
343
|
-
const sgstValue = formatNumericLikeValue((0, pdf_table_row_1.getFirstFieldValue)(item, [sgstField, 'SGST']), fixedTo);
|
|
344
|
-
if (cgstValue && sgstValue) {
|
|
345
|
-
return `CGST: ${cgstValue} | SGST/UGST: ${sgstValue}`;
|
|
346
|
-
}
|
|
347
|
-
if (cgstValue) {
|
|
348
|
-
return `CGST: ${cgstValue}`;
|
|
349
|
-
}
|
|
350
|
-
if (sgstValue) {
|
|
351
|
-
return `SGST/UGST: ${sgstValue}`;
|
|
352
|
-
}
|
|
353
|
-
return '';
|
|
354
|
-
}
|