gemcap-be-common 1.3.11 → 1.3.13
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/db/new-summary.js +5 -5
- package/db/new-summary.ts +5 -5
- package/helpers/excel.helper.js +20 -5
- package/helpers/excel.helper.ts +25 -5
- package/package.json +1 -1
- package/tsconfig.tsbuildinfo +1 -1
package/db/new-summary.js
CHANGED
|
@@ -396,25 +396,25 @@ class NewSummaryExcel {
|
|
|
396
396
|
const inventoryDataWithStyles = [...inventoryRowDataWithStyles, ...inventoryTotalDataWithStyles];
|
|
397
397
|
// RECEIVABLE
|
|
398
398
|
const receivableRows = [];
|
|
399
|
-
const totalComponents = new decimal_js_1.default(availability.receivable.uninsuredComponent).add(availability.receivable.insuredComponent);
|
|
399
|
+
const totalComponents = new decimal_js_1.default(availability.receivable.uninsuredComponent).add(availability.receivable.insuredComponent).toNumber() ?? 0;
|
|
400
400
|
const grossUninsured = totalComponents
|
|
401
|
-
? new decimal_js_1.default(availability
|
|
401
|
+
? new decimal_js_1.default(availability?.receivable?.uninsuredComponent ?? 0).div(totalComponents).mul(availability?.receivable?.invoiceAmount ?? 0).toDP(4).toNumber()
|
|
402
402
|
: 0;
|
|
403
403
|
const ARUninsuredRow = {
|
|
404
404
|
title: 'AR Uninsured',
|
|
405
405
|
grossValue: grossUninsured, // B
|
|
406
|
-
ineligible: new decimal_js_1.default(availability
|
|
406
|
+
ineligible: new decimal_js_1.default(availability?.receivable?.uninsuredComponent ?? 0).sub(grossUninsured).toNumber(), // C
|
|
407
407
|
netValue: availability.receivable.uninsuredComponent, // D
|
|
408
408
|
advanceRate: availability.receivable.uninsuredAvailability ? new decimal_js_1.default(availability.receivable.uninsuredAvailability).div(availability.receivable.uninsuredComponent).toDP(4).toNumber() : 0, // E
|
|
409
409
|
availability: availability.receivable.uninsuredAvailability, // F
|
|
410
410
|
};
|
|
411
411
|
const grossInsured = totalComponents
|
|
412
|
-
? new decimal_js_1.default(availability
|
|
412
|
+
? new decimal_js_1.default(availability?.receivable?.insuredComponent ?? 0).div(totalComponents).mul(availability?.receivable?.invoiceAmount ?? 0).toDP(4).toNumber()
|
|
413
413
|
: 0;
|
|
414
414
|
const ARInsuredRow = {
|
|
415
415
|
title: 'AR Insured',
|
|
416
416
|
grossValue: grossInsured, // B
|
|
417
|
-
ineligible: new decimal_js_1.default(availability
|
|
417
|
+
ineligible: new decimal_js_1.default(availability?.receivable?.insuredComponent ?? 0).sub(grossInsured).toNumber(), // C
|
|
418
418
|
netValue: availability.receivable.insuredComponent, // D
|
|
419
419
|
advanceRate: availability.receivable.insuredAvailability ? new decimal_js_1.default(availability.receivable.insuredAvailability).div(availability.receivable.insuredComponent).toDP(4).toNumber() : 0, // E
|
|
420
420
|
availability: availability.receivable.insuredAvailability, // F
|
package/db/new-summary.ts
CHANGED
|
@@ -479,26 +479,26 @@ export class NewSummaryExcel {
|
|
|
479
479
|
|
|
480
480
|
// RECEIVABLE
|
|
481
481
|
const receivableRows: BorrowerSummaryRow[] = [];
|
|
482
|
-
const totalComponents = new Decimal(availability.receivable.uninsuredComponent).add(availability.receivable.insuredComponent);
|
|
482
|
+
const totalComponents = new Decimal(availability.receivable.uninsuredComponent).add(availability.receivable.insuredComponent).toNumber() ?? 0;
|
|
483
483
|
|
|
484
484
|
const grossUninsured = totalComponents
|
|
485
|
-
? new Decimal(availability
|
|
485
|
+
? new Decimal(availability?.receivable?.uninsuredComponent ?? 0).div(totalComponents).mul(availability?.receivable?.invoiceAmount ?? 0).toDP(4).toNumber()
|
|
486
486
|
: 0;
|
|
487
487
|
const ARUninsuredRow: BorrowerSummaryRow = {
|
|
488
488
|
title: 'AR Uninsured',
|
|
489
489
|
grossValue: grossUninsured, // B
|
|
490
|
-
ineligible: new Decimal(availability
|
|
490
|
+
ineligible: new Decimal(availability?.receivable?.uninsuredComponent ?? 0).sub(grossUninsured).toNumber(), // C
|
|
491
491
|
netValue: availability.receivable.uninsuredComponent, // D
|
|
492
492
|
advanceRate: availability.receivable.uninsuredAvailability ? new Decimal(availability.receivable.uninsuredAvailability).div(availability.receivable.uninsuredComponent).toDP(4).toNumber() : 0, // E
|
|
493
493
|
availability: availability.receivable.uninsuredAvailability, // F
|
|
494
494
|
};
|
|
495
495
|
const grossInsured = totalComponents
|
|
496
|
-
? new Decimal(availability
|
|
496
|
+
? new Decimal(availability?.receivable?.insuredComponent ?? 0).div(totalComponents).mul(availability?.receivable?.invoiceAmount ?? 0).toDP(4).toNumber()
|
|
497
497
|
: 0;
|
|
498
498
|
const ARInsuredRow: BorrowerSummaryRow = {
|
|
499
499
|
title: 'AR Insured',
|
|
500
500
|
grossValue: grossInsured, // B
|
|
501
|
-
ineligible: new Decimal(availability
|
|
501
|
+
ineligible: new Decimal(availability?.receivable?.insuredComponent ?? 0).sub(grossInsured).toNumber(), // C
|
|
502
502
|
netValue: availability.receivable.insuredComponent, // D
|
|
503
503
|
advanceRate: availability.receivable.insuredAvailability ? new Decimal(availability.receivable.insuredAvailability).div(availability.receivable.insuredComponent).toDP(4).toNumber() : 0, // E
|
|
504
504
|
availability: availability.receivable.insuredAvailability, // F
|
package/helpers/excel.helper.js
CHANGED
|
@@ -71,14 +71,29 @@ const checkData = (dataToConvert) => {
|
|
|
71
71
|
for (const [sheetName, data] of Object.entries(dataToConvert)) {
|
|
72
72
|
data.forEach((row, rowIndex) => {
|
|
73
73
|
row.forEach((cell, colIndex) => {
|
|
74
|
-
|
|
75
|
-
|
|
74
|
+
const pos = `${sheetName} [${rowIndex + 1}, ${colIndex + 1}]`;
|
|
75
|
+
if (cell.t === 'n') {
|
|
76
|
+
if (cell.v === null) {
|
|
77
|
+
console.warn(`❌ cell.t === 'n' but v === null at ${pos}:`, cell);
|
|
78
|
+
}
|
|
79
|
+
else if (typeof cell.v !== 'number') {
|
|
80
|
+
console.warn(`❌ cell.t === 'n' but v is not a number at ${pos}:`, cell);
|
|
81
|
+
}
|
|
76
82
|
}
|
|
77
|
-
if (cell.v === Infinity) {
|
|
78
|
-
console.warn(
|
|
83
|
+
if (cell.v === Infinity || (typeof cell.v === 'number' && !isFinite(cell.v))) {
|
|
84
|
+
console.warn(`❌ Non-finite number at ${pos}:`, cell);
|
|
79
85
|
}
|
|
80
86
|
if (cell.v === null && cell.z) {
|
|
81
|
-
console.warn(`❌
|
|
87
|
+
console.warn(`❌ Null value with format (z) at ${pos}:`, cell);
|
|
88
|
+
}
|
|
89
|
+
if (cell.t === 'd' && !(cell.v instanceof Date) && typeof cell.v !== 'number') {
|
|
90
|
+
console.warn(`❌ cell.t === 'd' but v is not Date or number at ${pos}:`, cell);
|
|
91
|
+
}
|
|
92
|
+
if (cell.t === 's' && typeof cell.v !== 'string') {
|
|
93
|
+
console.warn(`❌ cell.t === 's' but v is not string at ${pos}:`, cell);
|
|
94
|
+
}
|
|
95
|
+
if (cell.t === 'b' && typeof cell.v !== 'boolean') {
|
|
96
|
+
console.warn(`❌ cell.t === 'b' but v is not boolean at ${pos}:`, cell);
|
|
82
97
|
}
|
|
83
98
|
});
|
|
84
99
|
});
|
package/helpers/excel.helper.ts
CHANGED
|
@@ -63,14 +63,34 @@ const checkData = (dataToConvert: { [sheetName: string]: IExcelDataCellWithStyle
|
|
|
63
63
|
for (const [sheetName, data] of Object.entries(dataToConvert)) {
|
|
64
64
|
data.forEach((row, rowIndex) => {
|
|
65
65
|
row.forEach((cell, colIndex) => {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
const pos = `${sheetName} [${rowIndex + 1}, ${colIndex + 1}]`;
|
|
67
|
+
|
|
68
|
+
if (cell.t === 'n') {
|
|
69
|
+
if (cell.v === null) {
|
|
70
|
+
console.warn(`❌ cell.t === 'n' but v === null at ${pos}:`, cell);
|
|
71
|
+
} else if (typeof cell.v !== 'number') {
|
|
72
|
+
console.warn(`❌ cell.t === 'n' but v is not a number at ${pos}:`, cell);
|
|
73
|
+
}
|
|
68
74
|
}
|
|
69
|
-
|
|
70
|
-
|
|
75
|
+
|
|
76
|
+
if (cell.v === Infinity || (typeof cell.v === 'number' && !isFinite(cell.v))) {
|
|
77
|
+
console.warn(`❌ Non-finite number at ${pos}:`, cell);
|
|
71
78
|
}
|
|
79
|
+
|
|
72
80
|
if (cell.v === null && cell.z) {
|
|
73
|
-
console.warn(`❌
|
|
81
|
+
console.warn(`❌ Null value with format (z) at ${pos}:`, cell);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (cell.t === 'd' && !(cell.v instanceof Date) && typeof cell.v !== 'number') {
|
|
85
|
+
console.warn(`❌ cell.t === 'd' but v is not Date or number at ${pos}:`, cell);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (cell.t === 's' && typeof cell.v !== 'string') {
|
|
89
|
+
console.warn(`❌ cell.t === 's' but v is not string at ${pos}:`, cell);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (cell.t === 'b' && typeof cell.v !== 'boolean') {
|
|
93
|
+
console.warn(`❌ cell.t === 'b' but v is not boolean at ${pos}:`, cell);
|
|
74
94
|
}
|
|
75
95
|
});
|
|
76
96
|
});
|