auth bug fix 11

This commit is contained in:
Kallesh B S 2025-09-30 09:52:42 +05:30
parent 2e3a506c81
commit 7a783994fd
2 changed files with 19 additions and 4 deletions

View File

@ -27,7 +27,7 @@ import {
import { BadRequestException } from 'src/exceptions/badRequest.exception'; import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { PoolClient } from 'pg'; import { PoolClient } from 'pg';
import { PgDBService } from 'src/db/db.service'; import { PgDBService } from 'src/db/db.service';
import { checkPgUserDefinedErrors, deleteFilesAsync, fnCounterFoil, fnVochers, generateFinalPDF, generateGL, generateGL1, generateGreenCoverPDF, handlePgError, pdfCarnetData, pdfGLData, releasePgClient, replaceSlashWithDash, ResponseStatus, tnVochers, toUpperCaseKeys, tsCounterFoil, usCounterFoil } from 'src/utils/helper'; import { checkPgUserDefinedErrors, deleteFilesAsync, fnCounterFoil, fnVochers, generateFinalPDF, generateGL, generateGL1, generateGreenCoverPDF, handlePgError, parsePGNumericFields, pdfCarnetData, pdfGLData, releasePgClient, replaceSlashWithDash, ResponseStatus, tnVochers, toUpperCaseKeys, tsCounterFoil, usCounterFoil } from 'src/utils/helper';
import { InternalServerException } from 'src/exceptions/internalServerError.exception'; import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import axios from 'axios'; import axios from 'axios';
import { PaypalService } from 'src/paypal/paypal.service'; import { PaypalService } from 'src/paypal/paypal.service';
@ -509,7 +509,7 @@ export class CarnetApplicationService {
await client.query(`CLOSE ${cursorName}`); await client.query(`CLOSE ${cursorName}`);
await client.query('COMMIT'); await client.query('COMMIT');
return toUpperCaseKeys(fetchResult.rows)[0] ?? []; return parsePGNumericFields(toUpperCaseKeys(fetchResult.rows)[0] ?? []);
} catch (error) { } catch (error) {
if (client) await client.query('ROLLBACK'); if (client) await client.query('ROLLBACK');

View File

@ -65,6 +65,21 @@ export function extractSubdomain(domain: string): string | null {
} }
} }
export function parsePGNumericFields(row) {
const keysToConvert = [
'BASICFEE', 'CFFEE', 'CSFEE', 'EFFEE', 'SHIPFEE',
'SECURITYAMOUNT', 'BONDPREMIUM', 'INSUREDVALUE',
'CARGOPREMIUM', 'LDIPREMIUM'
];
const parsed = { ...row };
for (const key of keysToConvert) {
if (parsed[key] !== null && parsed[key] !== undefined) {
parsed[key] = Number(parsed[key]);
}
}
return parsed;
}
export function normalizeKeysToUpperCase(obj) { export function normalizeKeysToUpperCase(obj) {
return Object.keys(obj).reduce((acc, key) => { return Object.keys(obj).reduce((acc, key) => {
@ -1295,8 +1310,8 @@ export async function processGlDataInBatches(
let totalItemValue = 0; let totalItemValue = 0;
for (const item of glDataArray) { for (const item of glDataArray) {
if (typeof item.itemValue === 'number') { if (typeof Number(item.itemValue) === 'number') {
totalItemValue += item.itemValue; totalItemValue += Number(item.itemValue);
} else { } else {
console.warn(`Non-numeric itemValue encountered for itemNo: ${item.itemNo}. Skipping value.`); console.warn(`Non-numeric itemValue encountered for itemNo: ${item.itemNo}. Skipping value.`);
} }