shareneus 1.6.95 → 1.6.96
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.
|
@@ -11,6 +11,6 @@ export declare function buildDataRow(item: any, index: number, headerConfig: any
|
|
|
11
11
|
color?: undefined;
|
|
12
12
|
alignment?: undefined;
|
|
13
13
|
})[];
|
|
14
|
-
export declare function getFirstFieldValue(item: any, dbFields?: string[]): string;
|
|
14
|
+
export declare function getFirstFieldValue(item: any, dbFields?: string[] | string): string;
|
|
15
15
|
export declare function getNumericAlignment(value: string): "left" | "right";
|
|
16
16
|
export declare function getCellAlignment(headerText: string, value: string): "left" | "right";
|
|
@@ -49,7 +49,7 @@ function buildDataRow(item, index, headerConfig, fixedTo = 2) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
function formatFieldValue(item, fieldConfig, fixedTo) {
|
|
52
|
-
const rawValue =
|
|
52
|
+
const rawValue = getDisplayFieldValue(item, fieldConfig);
|
|
53
53
|
if (isExpiryField(fieldConfig)) {
|
|
54
54
|
return formatExpiryDateValue(rawValue);
|
|
55
55
|
}
|
|
@@ -58,6 +58,17 @@ function formatFieldValue(item, fieldConfig, fixedTo) {
|
|
|
58
58
|
: rawValue;
|
|
59
59
|
return formatNumericLikeValue(signedValue, fixedTo, shouldSkipFixedTo(fieldConfig));
|
|
60
60
|
}
|
|
61
|
+
function getDisplayFieldValue(item, fieldConfig) {
|
|
62
|
+
const directValue = getFirstFieldValue(item, fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.dbFields);
|
|
63
|
+
if (directValue) {
|
|
64
|
+
return directValue;
|
|
65
|
+
}
|
|
66
|
+
const fallbackFields = getFallbackDbFields(fieldConfig);
|
|
67
|
+
if (fallbackFields.length === 0) {
|
|
68
|
+
return '';
|
|
69
|
+
}
|
|
70
|
+
return getFirstFieldValue(item, fallbackFields);
|
|
71
|
+
}
|
|
61
72
|
function getTaxValue(item, taxName, taxKind) {
|
|
62
73
|
if (taxName === 'IGST') {
|
|
63
74
|
const fields = taxKind === 'rate' ? ['IGSTPerc'] : ['IGSTAmt'];
|
|
@@ -93,7 +104,8 @@ function negateNumericLikeValue(value) {
|
|
|
93
104
|
return String(normalized === 0 ? 0 : -Math.abs(normalized));
|
|
94
105
|
}
|
|
95
106
|
function getFirstFieldValue(item, dbFields = []) {
|
|
96
|
-
|
|
107
|
+
const normalizedFields = normalizeDbFields(dbFields);
|
|
108
|
+
for (const field of normalizedFields) {
|
|
97
109
|
const value = readValue(item, field);
|
|
98
110
|
if (value !== undefined && value !== null && value !== '') {
|
|
99
111
|
return String(value);
|
|
@@ -119,6 +131,15 @@ function readValue(item, field) {
|
|
|
119
131
|
}
|
|
120
132
|
return deepFindByKey(item, field);
|
|
121
133
|
}
|
|
134
|
+
function normalizeDbFields(dbFields) {
|
|
135
|
+
if (Array.isArray(dbFields)) {
|
|
136
|
+
return dbFields;
|
|
137
|
+
}
|
|
138
|
+
if (typeof dbFields === 'string') {
|
|
139
|
+
return dbFields ? [dbFields] : [];
|
|
140
|
+
}
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
122
143
|
function deepFindByKey(source, field) {
|
|
123
144
|
if (!source || typeof source !== 'object') {
|
|
124
145
|
return undefined;
|
|
@@ -198,18 +219,26 @@ function formatExpiryDateValue(value) {
|
|
|
198
219
|
}
|
|
199
220
|
return my_date_1.MyDate.ConvertUTCDateToReadableExDate(input) || input;
|
|
200
221
|
}
|
|
222
|
+
function getFallbackDbFields(fieldConfig) {
|
|
223
|
+
var _a;
|
|
224
|
+
const text = String((_a = fieldConfig === null || fieldConfig === void 0 ? void 0 : fieldConfig.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
|
|
225
|
+
if (text === 'BN' || text === 'BATCH' || text === 'BATCH NO' || text === 'BATCH NO.') {
|
|
226
|
+
return ['Batch.BN', 'Batch.MBN', 'BN'];
|
|
227
|
+
}
|
|
228
|
+
if (text === 'EXDT' || text === 'EXPIRY' || text === 'EXPIRY DATE') {
|
|
229
|
+
return ['Batch.ExDt', 'ExDt'];
|
|
230
|
+
}
|
|
231
|
+
return [];
|
|
232
|
+
}
|
|
201
233
|
function shouldSkipFixedTo(header) {
|
|
202
234
|
var _a;
|
|
203
235
|
const text = String((_a = header === null || header === void 0 ? void 0 : header.text) !== null && _a !== void 0 ? _a : '').trim().toUpperCase();
|
|
204
|
-
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO'
|
|
236
|
+
if (text === 'HSN/SAC' || text === 'BN' || text === 'BNO') {
|
|
205
237
|
return true;
|
|
206
238
|
}
|
|
207
239
|
const dbFields = Array.isArray(header === null || header === void 0 ? void 0 : header.dbFields) ? header.dbFields : [];
|
|
208
240
|
return dbFields.some((field) => {
|
|
209
241
|
const normalized = String(field !== null && field !== void 0 ? field : '').trim().toUpperCase();
|
|
210
|
-
return normalized === 'BNO'
|
|
211
|
-
|| normalized.endsWith('.BNO')
|
|
212
|
-
|| normalized.endsWith('.BN')
|
|
213
|
-
|| normalized.includes('BATCH');
|
|
242
|
+
return normalized === 'BN' || normalized === 'BNO' || normalized.endsWith('.BN');
|
|
214
243
|
});
|
|
215
244
|
}
|