shareneus 1.7.325 → 1.7.326
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.
|
@@ -124,6 +124,7 @@ function negateNumericLikeValue(value) {
|
|
|
124
124
|
return String(normalized === 0 ? 0 : -Math.abs(normalized));
|
|
125
125
|
}
|
|
126
126
|
function getFirstFieldValue(item, dbFields = []) {
|
|
127
|
+
console.log('getFirstFieldValue', item, dbFields);
|
|
127
128
|
for (const field of dbFields) {
|
|
128
129
|
const value = readValue(item, field);
|
|
129
130
|
if (value !== undefined && value !== null && value !== '') {
|
package/package.json
CHANGED
|
@@ -59,53 +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' | '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
|
-
}
|
|
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
|
+
}
|
|
82
82
|
const fields = taxKind === 'rate'
|
|
83
83
|
? [`${taxName}Perc`, taxName]
|
|
84
84
|
: [`${taxName}Amt`, taxName];
|
|
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
|
-
}
|
|
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
|
+
}
|
|
109
109
|
|
|
110
110
|
function shouldRenderNegativeTaxAmount(item: any, column: any) {
|
|
111
111
|
return !!item?.Ret && column?.taxKind === 'amount';
|
|
@@ -137,6 +137,7 @@ function negateNumericLikeValue(value: string) {
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
export function getFirstFieldValue(item: any, dbFields: string[] = []) {
|
|
140
|
+
console.log('getFirstFieldValue', item, dbFields);
|
|
140
141
|
for (const field of dbFields) {
|
|
141
142
|
const value = readValue(item, field);
|
|
142
143
|
if (value !== undefined && value !== null && value !== '') {
|
|
@@ -274,23 +275,23 @@ function formatExpiryDateValue(value: string) {
|
|
|
274
275
|
function shouldSkipFixedTo(header: any) {
|
|
275
276
|
const text = String(header?.text ?? '').trim().toUpperCase();
|
|
276
277
|
const normalizedText = text.replace(/\s+/g, '');
|
|
277
|
-
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%') || normalizedText === 'QTY' || normalizedText === 'OFFERQTY' || normalizedText === 'OFQTY' || normalizedText === 'MPN') {
|
|
278
|
-
return true;
|
|
279
|
-
}
|
|
278
|
+
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO' || text.includes('%') || normalizedText === 'QTY' || normalizedText === 'OFFERQTY' || normalizedText === 'OFQTY' || normalizedText === 'MPN') {
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
280
281
|
|
|
281
282
|
const dbFields = Array.isArray(header?.dbFields) ? header.dbFields : [];
|
|
282
283
|
return dbFields.some((field: any) => {
|
|
283
284
|
const normalized = String(field ?? '').trim().toUpperCase();
|
|
284
285
|
return normalized === 'BN'
|
|
285
|
-
|| normalized === 'BNO'
|
|
286
|
-
|| normalized === 'QTY'
|
|
287
|
-
|| normalized === 'OFQTY'
|
|
288
|
-
|| normalized === 'MPN'
|
|
289
|
-
|| normalized.endsWith('.BN')
|
|
290
|
-
|| normalized.endsWith('.QTY')
|
|
291
|
-
|| normalized.endsWith('.OFQTY')
|
|
292
|
-
|| normalized.endsWith('.MPN')
|
|
293
|
-
|| normalized.endsWith('PERC')
|
|
294
|
-
|| normalized.endsWith('.PERC');
|
|
286
|
+
|| normalized === 'BNO'
|
|
287
|
+
|| normalized === 'QTY'
|
|
288
|
+
|| normalized === 'OFQTY'
|
|
289
|
+
|| normalized === 'MPN'
|
|
290
|
+
|| normalized.endsWith('.BN')
|
|
291
|
+
|| normalized.endsWith('.QTY')
|
|
292
|
+
|| normalized.endsWith('.OFQTY')
|
|
293
|
+
|| normalized.endsWith('.MPN')
|
|
294
|
+
|| normalized.endsWith('PERC')
|
|
295
|
+
|| normalized.endsWith('.PERC');
|
|
295
296
|
});
|
|
296
297
|
}
|