Compare commits
No commits in common. "d6286d98ba1dbf2447689b22ada9ab231b7b45f6" and "439c986583cb64c6841940e11156f17f34f4e074" have entirely different histories.
d6286d98ba
...
439c986583
@ -53,40 +53,40 @@ export class CarnetApplicationController {
|
|||||||
return this.carnetApplicationService.UpdateHolder(body);
|
return this.carnetApplicationService.UpdateHolder(body);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Patch('UpdateExpGoodsAuthRep')
|
// @Patch('UpdateExpGoodsAuthRep')
|
||||||
UpdateExpGoodsAuthRep(@Body() body: UpdateExpGoodsAuthRepDTO) {
|
// UpdateExpGoodsAuthRep(@Body() body: UpdateExpGoodsAuthRepDTO) {
|
||||||
return this.carnetApplicationService.UpdateExpGoodsAuthRep(body);
|
// return this.carnetApplicationService.UpdateExpGoodsAuthRep(body);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Post('AddGenerallistItems')
|
// @Post('AddGenerallistItems')
|
||||||
AddGenerallistItems(@Body() body: AddGenerallistItemsDTO) {
|
// AddGenerallistItems(@Body() body: AddGenerallistItemsDTO) {
|
||||||
return this.carnetApplicationService.AddGenerallistItems(body);
|
// return this.carnetApplicationService.AddGenerallistItems(body);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Post('AddCountries')
|
// @Post('AddCountries')
|
||||||
AddCountries(@Body() body: AddCountriesDTO) {
|
// AddCountries(@Body() body: AddCountriesDTO) {
|
||||||
return this.carnetApplicationService.AddCountries(body);
|
// return this.carnetApplicationService.AddCountries(body);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Put('EditGenerallistItems')
|
// @Put('EditGenerallistItems')
|
||||||
EditGenerallistItems(@Body() body: EditGenerallistItemsDTO) {
|
// EditGenerallistItems(@Body() body: EditGenerallistItemsDTO) {
|
||||||
return this.carnetApplicationService.EditGenerallistItems(body);
|
// return this.carnetApplicationService.EditGenerallistItems(body);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Delete('DeleteGenerallistItems')
|
// @Delete('DeleteGenerallistItems')
|
||||||
DeleteGenerallistItems(@Body() body: DeleteGenerallistItemsDTO) {
|
// DeleteGenerallistItems(@Body() body: DeleteGenerallistItemsDTO) {
|
||||||
return this.carnetApplicationService.DeleteGenerallistItems(body);
|
// return this.carnetApplicationService.DeleteGenerallistItems(body);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Patch('UpdateShippingDetails')
|
// @Patch('UpdateShippingDetails')
|
||||||
UpdateShippingDetails(@Body() body: UpdateShippingDetailsDTO) {
|
// UpdateShippingDetails(@Body() body: UpdateShippingDetailsDTO) {
|
||||||
return this.carnetApplicationService.UpdateShippingDetails(body);
|
// return this.carnetApplicationService.UpdateShippingDetails(body);
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Get('EstimatedFees/:P_SPID/:P_USERID/:P_HEADERID')
|
// @Get('EstimatedFees/:P_SPID/:P_USERID/:P_HEADERID')
|
||||||
EstimatedFees(@Param() body: GetCarnetControlCenterDTO) {
|
// EstimatedFees(@Param() body: GetCarnetControlCenterDTO) {
|
||||||
return this.carnetApplicationService.EstimatedFees(body);
|
// return this.carnetApplicationService.EstimatedFees(body);
|
||||||
}
|
// }
|
||||||
|
|
||||||
// // processing [ PROCESSINGCENTER_PKG ]
|
// // processing [ PROCESSINGCENTER_PKG ]
|
||||||
|
|
||||||
|
|||||||
@ -26,7 +26,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, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
|
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class CarnetApplicationService {
|
export class CarnetApplicationService {
|
||||||
@ -63,7 +63,7 @@ export class CarnetApplicationService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.transmitted,
|
message: ResponseStatus.transmitted,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -101,7 +101,7 @@ export class CarnetApplicationService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -123,7 +123,7 @@ export class CarnetApplicationService {
|
|||||||
await client.query('BEGIN');
|
await client.query('BEGIN');
|
||||||
|
|
||||||
const callProcQuery = `
|
const callProcQuery = `
|
||||||
CALL "CARNETSYS".carnetapplication_pkg_updateholder($1, $2, $3)
|
CALL "CARNETSYS".carnetapplication_pkg_createapplication($1, $2, $3)
|
||||||
`;
|
`;
|
||||||
await client.query(callProcQuery, [body.P_HEADERID, body.P_HOLDERID, cursorName]);
|
await client.query(callProcQuery, [body.P_HEADERID, body.P_HOLDERID, cursorName]);
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ export class CarnetApplicationService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -150,375 +150,13 @@ export class CarnetApplicationService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async UpdateExpGoodsAuthRep(body: UpdateExpGoodsAuthRepDTO) {
|
async UpdateExpGoodsAuthRep(body: UpdateExpGoodsAuthRepDTO) { }
|
||||||
let client: PoolClient | null = null;
|
async AddGenerallistItems(body: AddGenerallistItemsDTO) { }
|
||||||
|
async EditGenerallistItems(body: AddGenerallistItemsDTO) { }
|
||||||
const cursorName = 'p_cursor';
|
async DeleteGenerallistItems(body: DeleteGenerallistItemsDTO) { }
|
||||||
|
async AddCountries(body: AddCountriesDTO) { }
|
||||||
try {
|
async UpdateShippingDetails(body: UpdateShippingDetailsDTO) { }
|
||||||
client = await this.pgDBService.getConnection();
|
async EstimatedFees(body: GetCarnetControlCenterDTO) { }
|
||||||
|
|
||||||
await client.query('BEGIN');
|
|
||||||
|
|
||||||
const callProcQuery = `
|
|
||||||
CALL "CARNETSYS".carnetapplication_pkg_updateexpgoodsauthrep($1, $2, $3, $4, $5, $6, $7, $8)
|
|
||||||
`;
|
|
||||||
await client.query(callProcQuery, [body.P_HEADERID, body.P_COMMERCIALSAMPLEFLAG, body.P_PROFEQUIPMENTFLAG, body.P_EXHIBITIONSFAIRFLAG, body.P_AUTOFLAG, body.P_HORSEFLAG, body.P_AUTHREP, cursorName]);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in FETCH
|
|
||||||
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in CLOSE
|
|
||||||
await client.query(`CLOSE ${cursorName}`);
|
|
||||||
await client.query('COMMIT');
|
|
||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
|
||||||
|
|
||||||
return {
|
|
||||||
statusCode: 200,
|
|
||||||
message: ResponseStatus.updated,
|
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
if (client) await client.query('ROLLBACK');
|
|
||||||
handlePgError(error, CarnetApplicationService.name)
|
|
||||||
} finally {
|
|
||||||
releasePgClient(client)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async AddGenerallistItems(body: AddGenerallistItemsDTO) {
|
|
||||||
let client: PoolClient | null = null;
|
|
||||||
|
|
||||||
const cursorName = 'p_cursor';
|
|
||||||
|
|
||||||
try {
|
|
||||||
client = await this.pgDBService.getConnection();
|
|
||||||
|
|
||||||
await client.query('BEGIN');
|
|
||||||
|
|
||||||
function escapePostgresString(str: string): string {
|
|
||||||
if (str == null) return '';
|
|
||||||
return `"${str.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function escapePostgresValue(val: any): string {
|
|
||||||
if (val == null || val === '') return ''; // NULL or empty becomes empty string
|
|
||||||
if (typeof val === 'number') return String(val); // pass numbers as-is
|
|
||||||
return escapePostgresString(String(val)); // quote and escape strings
|
|
||||||
}
|
|
||||||
|
|
||||||
const contactLiterals = body.P_GLTABLE.map(c => {
|
|
||||||
const fields = [
|
|
||||||
escapePostgresValue(c.ITEMNO), // integer
|
|
||||||
escapePostgresValue(c.ITEMDESCRIPTION), // varchar
|
|
||||||
escapePostgresValue(c.ITEMVALUE), // numeric
|
|
||||||
escapePostgresValue(c.NOOFPIECES), // integer
|
|
||||||
escapePostgresValue(c.ITEMWEIGHT), // numeric
|
|
||||||
escapePostgresValue(c.ITEMWEIGHTUOM), // varchar
|
|
||||||
escapePostgresValue(c.GOODSORIGINCOUNTRY), // varchar
|
|
||||||
];
|
|
||||||
|
|
||||||
return `(${fields.join(',')})`; // composite literal without outer double quotes
|
|
||||||
});
|
|
||||||
|
|
||||||
const pgArrayLiteral = `{${contactLiterals.join(',')}}`;
|
|
||||||
|
|
||||||
const callProcQuery = `
|
|
||||||
CALL "CARNETSYS".carnetapplication_pkg_addgenerallistitems($1, $2::"CARNETSYS".gltable[], $3, $4)
|
|
||||||
`;
|
|
||||||
await client.query(callProcQuery, [body.P_HEADERID, pgArrayLiteral, body.P_USERID, cursorName]);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in FETCH
|
|
||||||
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in CLOSE
|
|
||||||
await client.query(`CLOSE ${cursorName}`);
|
|
||||||
await client.query('COMMIT');
|
|
||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
|
||||||
|
|
||||||
return {
|
|
||||||
statusCode: 200,
|
|
||||||
message: ResponseStatus.added,
|
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
if (client) await client.query('ROLLBACK');
|
|
||||||
handlePgError(error, CarnetApplicationService.name)
|
|
||||||
} finally {
|
|
||||||
releasePgClient(client)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async EditGenerallistItems(body: AddGenerallistItemsDTO) {
|
|
||||||
let client: PoolClient | null = null;
|
|
||||||
|
|
||||||
const cursorName = 'p_cursor';
|
|
||||||
|
|
||||||
try {
|
|
||||||
client = await this.pgDBService.getConnection();
|
|
||||||
|
|
||||||
await client.query('BEGIN');
|
|
||||||
|
|
||||||
function escapePostgresString(str: string): string {
|
|
||||||
if (str == null) return '';
|
|
||||||
return `"${str.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function escapePostgresValue(val: any): string {
|
|
||||||
if (val == null || val === '') return ''; // NULL or empty becomes empty string
|
|
||||||
if (typeof val === 'number') return String(val); // pass numbers as-is
|
|
||||||
return escapePostgresString(String(val)); // quote and escape strings
|
|
||||||
}
|
|
||||||
|
|
||||||
const contactLiterals = body.P_GLTABLE.map(c => {
|
|
||||||
const fields = [
|
|
||||||
escapePostgresValue(c.ITEMNO), // integer
|
|
||||||
escapePostgresValue(c.ITEMDESCRIPTION), // varchar
|
|
||||||
escapePostgresValue(c.ITEMVALUE), // numeric
|
|
||||||
escapePostgresValue(c.NOOFPIECES), // integer
|
|
||||||
escapePostgresValue(c.ITEMWEIGHT), // numeric
|
|
||||||
escapePostgresValue(c.ITEMWEIGHTUOM), // varchar
|
|
||||||
escapePostgresValue(c.GOODSORIGINCOUNTRY), // varchar
|
|
||||||
];
|
|
||||||
|
|
||||||
return `(${fields.join(',')})`; // composite literal without outer double quotes
|
|
||||||
});
|
|
||||||
|
|
||||||
const pgArrayLiteral = `{${contactLiterals.join(',')}}`;
|
|
||||||
|
|
||||||
const callProcQuery = `
|
|
||||||
CALL "CARNETSYS".carnetapplication_pkg_editgenerallistitems($1, $2::"CARNETSYS".gltable[], $3, $4)
|
|
||||||
`;
|
|
||||||
await client.query(callProcQuery, [body.P_HEADERID, pgArrayLiteral, body.P_USERID, cursorName]);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in FETCH
|
|
||||||
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in CLOSE
|
|
||||||
await client.query(`CLOSE ${cursorName}`);
|
|
||||||
await client.query('COMMIT');
|
|
||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
|
||||||
|
|
||||||
return {
|
|
||||||
statusCode: 200,
|
|
||||||
message: ResponseStatus.updated,
|
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
if (client) await client.query('ROLLBACK');
|
|
||||||
handlePgError(error, CarnetApplicationService.name)
|
|
||||||
} finally {
|
|
||||||
releasePgClient(client)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async DeleteGenerallistItems(body: DeleteGenerallistItemsDTO) {
|
|
||||||
let client: PoolClient | null = null;
|
|
||||||
|
|
||||||
const cursorName = 'p_cursor';
|
|
||||||
|
|
||||||
try {
|
|
||||||
client = await this.pgDBService.getConnection();
|
|
||||||
|
|
||||||
await client.query('BEGIN');
|
|
||||||
|
|
||||||
const callProcQuery = `
|
|
||||||
CALL "CARNETSYS".carnetapplication_pkg_deletegenerallistitems($1, $2, $3, $4)
|
|
||||||
`;
|
|
||||||
await client.query(callProcQuery, [body.P_HEADERID, body.P_ITEMNO, body.P_USERID, cursorName]);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in FETCH
|
|
||||||
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in CLOSE
|
|
||||||
await client.query(`CLOSE ${cursorName}`);
|
|
||||||
await client.query('COMMIT');
|
|
||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
|
||||||
|
|
||||||
return {
|
|
||||||
statusCode: 200,
|
|
||||||
message: ResponseStatus.deleted,
|
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
if (client) await client.query('ROLLBACK');
|
|
||||||
handlePgError(error, CarnetApplicationService.name)
|
|
||||||
} finally {
|
|
||||||
releasePgClient(client)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async AddCountries(body: AddCountriesDTO) {
|
|
||||||
let client: PoolClient | null = null;
|
|
||||||
|
|
||||||
const cursorName = 'p_cursor';
|
|
||||||
|
|
||||||
try {
|
|
||||||
client = await this.pgDBService.getConnection();
|
|
||||||
|
|
||||||
await client.query('BEGIN');
|
|
||||||
|
|
||||||
function escapePostgresString(str: string): string {
|
|
||||||
if (str == null) return '';
|
|
||||||
return `"${str.replace(/\\/g, '\\\\').replace(/"/g, '\\"')}"`;
|
|
||||||
}
|
|
||||||
|
|
||||||
function escapePostgresValue(val: any): string {
|
|
||||||
if (val == null || val === '') return ''; // NULL or empty becomes empty string
|
|
||||||
if (typeof val === 'number') return String(val); // pass numbers as-is
|
|
||||||
return escapePostgresString(String(val)); // quote and escape strings
|
|
||||||
}
|
|
||||||
|
|
||||||
const contactLiterals = body.P_COUNTRYTABLE.map(c => {
|
|
||||||
const fields = [
|
|
||||||
escapePostgresValue(c.P_VISISTTRANSITIND), // integer
|
|
||||||
escapePostgresValue(c.COUNTRYCODE), // varchar
|
|
||||||
escapePostgresValue(c.NOOFTIMESENTLEAVE), // numeric
|
|
||||||
];
|
|
||||||
|
|
||||||
return `(${fields.join(',')})`; // composite literal without outer double quotes
|
|
||||||
});
|
|
||||||
|
|
||||||
const pgArrayLiteral = `{${contactLiterals.join(',')}}`;
|
|
||||||
|
|
||||||
const callProcQuery = `
|
|
||||||
CALL "CARNETSYS".carnetapplication_pkg_addcountries($1, $2, $3::"CARNETSYS".carnetcountrytable[], $4, $5)
|
|
||||||
`;
|
|
||||||
await client.query(callProcQuery, [body.P_HEADERID, body.P_USSETS, pgArrayLiteral, body.P_USERID, cursorName]);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in FETCH
|
|
||||||
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in CLOSE
|
|
||||||
await client.query(`CLOSE ${cursorName}`);
|
|
||||||
await client.query('COMMIT');
|
|
||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
|
||||||
|
|
||||||
return {
|
|
||||||
statusCode: 200,
|
|
||||||
message: ResponseStatus.added,
|
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
if (client) await client.query('ROLLBACK');
|
|
||||||
handlePgError(error, CarnetApplicationService.name)
|
|
||||||
} finally {
|
|
||||||
releasePgClient(client)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async UpdateShippingDetails(body: UpdateShippingDetailsDTO) {
|
|
||||||
let client: PoolClient | null = null;
|
|
||||||
|
|
||||||
const cursorName = 'p_cursor';
|
|
||||||
|
|
||||||
try {
|
|
||||||
client = await this.pgDBService.getConnection();
|
|
||||||
|
|
||||||
await client.query('BEGIN');
|
|
||||||
|
|
||||||
const callProcQuery = `
|
|
||||||
CALL "CARNETSYS".carnetapplication_pkg_updateshippingdetails($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29)
|
|
||||||
`;
|
|
||||||
await client.query(callProcQuery,
|
|
||||||
[
|
|
||||||
body.P_HEADERID,
|
|
||||||
body.P_SHIPTOTYPE,
|
|
||||||
body.P_SHIPCONTACTID,
|
|
||||||
body.P_SHIPNAME,
|
|
||||||
body.P_ADDRESS1,
|
|
||||||
body.P_ADDRESS2,
|
|
||||||
body.P_CITY,
|
|
||||||
body.P_STATE,
|
|
||||||
body.P_ZIP,
|
|
||||||
body.P_COUNTRY,
|
|
||||||
body.P_FIRSTNAME,
|
|
||||||
body.P_LASTNAME,
|
|
||||||
body.P_TITLE,
|
|
||||||
body.P_PHONENO,
|
|
||||||
body.P_MOBILENO,
|
|
||||||
body.P_FAXNO,
|
|
||||||
body.P_EMAILADDRESS,
|
|
||||||
body.P_MIDDLEINITIAL,
|
|
||||||
body.P_FORMOFSECURITY,
|
|
||||||
body.P_INSPROTECTION,
|
|
||||||
body.P_LDIPROTECTION,
|
|
||||||
body.P_DELIVERYTYPE,
|
|
||||||
body.P_DELIVERYMETHOD,
|
|
||||||
body.P_PAYMENTMETHOD,
|
|
||||||
body.P_CUSTCOURIERNO,
|
|
||||||
body.P_REFNO,
|
|
||||||
body.P_NOTES,
|
|
||||||
body.P_USERID,
|
|
||||||
cursorName
|
|
||||||
]);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in FETCH
|
|
||||||
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in CLOSE
|
|
||||||
await client.query(`CLOSE ${cursorName}`);
|
|
||||||
await client.query('COMMIT');
|
|
||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
|
||||||
|
|
||||||
return {
|
|
||||||
statusCode: 200,
|
|
||||||
message: ResponseStatus.updated,
|
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
|
||||||
};
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
if (client) await client.query('ROLLBACK');
|
|
||||||
handlePgError(error, CarnetApplicationService.name)
|
|
||||||
} finally {
|
|
||||||
releasePgClient(client)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async EstimatedFees(body: GetCarnetControlCenterDTO) {
|
|
||||||
|
|
||||||
let client: PoolClient | null = null;
|
|
||||||
|
|
||||||
const cursorName = 'p_cursor';
|
|
||||||
|
|
||||||
try {
|
|
||||||
client = await this.pgDBService.getConnection();
|
|
||||||
|
|
||||||
await client.query('BEGIN');
|
|
||||||
|
|
||||||
const callProcQuery = `
|
|
||||||
CALL "CARNETSYS".carnetapplication_pkg_estimatedfees($1, $2, $3, $4)
|
|
||||||
`;
|
|
||||||
await client.query(callProcQuery, [body.P_SPID, body.P_USERID, body.P_HEADERID, cursorName]);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in FETCH
|
|
||||||
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
|
||||||
|
|
||||||
// 🚫 DON'T quote the cursor name in CLOSE
|
|
||||||
await client.query(`CLOSE ${cursorName}`);
|
|
||||||
await client.query('COMMIT');
|
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
if (client) await client.query('ROLLBACK');
|
|
||||||
handlePgError(error, CarnetApplicationService.name)
|
|
||||||
} finally {
|
|
||||||
releasePgClient(client)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// processing [ PROCESSINGCENTER_PKG ]
|
// processing [ PROCESSINGCENTER_PKG ]
|
||||||
|
|
||||||
@ -561,7 +199,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);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -593,7 +231,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);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -625,7 +263,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);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -657,7 +295,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);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -689,7 +327,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);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { Injectable } from '@nestjs/common';
|
import { Injectable } from '@nestjs/common';
|
||||||
import { ClientContactControlsDTO, CreateClientContactsDTO, CreateClientDataDTO, CreateClientLocationsDTO, GetClientContactByLacationIdDTO, GetClientDTO, GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO } from 'src/dto/property.dto';
|
import { ClientContactControlsDTO, CreateClientContactsDTO, CreateClientDataDTO, CreateClientLocationsDTO, GetClientContactByLacationIdDTO, GetClientDTO, GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO } from 'src/dto/property.dto';
|
||||||
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
|
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper';
|
||||||
import { PoolClient } from 'pg';
|
import { PoolClient } from 'pg';
|
||||||
import { PgDBService } from 'src/db/db.service';
|
import { PgDBService } from 'src/db/db.service';
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ export class ManageClientsService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -105,7 +105,7 @@ export class ManageClientsService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -157,7 +157,7 @@ export class ManageClientsService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -208,7 +208,7 @@ export class ManageClientsService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -278,7 +278,7 @@ export class ManageClientsService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -316,7 +316,7 @@ export class ManageClientsService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -354,7 +354,7 @@ export class ManageClientsService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.inActivate,
|
message: ResponseStatus.inActivate,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -392,7 +392,7 @@ export class ManageClientsService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.reActivate,
|
message: ResponseStatus.reActivate,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -459,7 +459,7 @@ export class ManageClientsService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -494,7 +494,7 @@ export class ManageClientsService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -528,7 +528,7 @@ export class ManageClientsService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -562,7 +562,7 @@ export class ManageClientsService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -596,7 +596,7 @@ export class ManageClientsService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -630,7 +630,7 @@ export class ManageClientsService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import { PgDBService } from 'src/db/db.service';
|
|||||||
import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/dto/property.dto';
|
import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO } from 'src/dto/property.dto';
|
||||||
|
|
||||||
import { PoolClient } from 'pg';
|
import { PoolClient } from 'pg';
|
||||||
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
|
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ManageFeeService {
|
export class ManageFeeService {
|
||||||
@ -35,7 +35,7 @@ export class ManageFeeService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -82,7 +82,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -129,7 +129,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -168,7 +168,7 @@ export class ManageFeeService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -219,7 +219,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -266,7 +266,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -305,7 +305,7 @@ export class ManageFeeService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -353,7 +353,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -400,7 +400,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -438,7 +438,7 @@ export class ManageFeeService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -488,7 +488,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -535,7 +535,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -575,7 +575,7 @@ export class ManageFeeService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -622,7 +622,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -668,7 +668,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -707,7 +707,7 @@ export class ManageFeeService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -757,7 +757,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -803,7 +803,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -842,7 +842,7 @@ export class ManageFeeService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -888,7 +888,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -934,7 +934,7 @@ export class ManageFeeService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Injectable } from '@nestjs/common';
|
|||||||
import { PgDBService } from 'src/db/db.service';
|
import { PgDBService } from 'src/db/db.service';
|
||||||
import { CONTACTSTABLE_ROW_DTO, CreateHolderContactsDTO, CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/property.dto';
|
import { CONTACTSTABLE_ROW_DTO, CreateHolderContactsDTO, CreateHoldersDTO, GetHolderDTO, HolderActivateOrInactivateDTO, HolderContactActivateOrInactivateDTO, UpdateHolderContactDTO, UpdateHolderDTO } from 'src/dto/property.dto';
|
||||||
import { PoolClient } from 'pg';
|
import { PoolClient } from 'pg';
|
||||||
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
|
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ManageHolderService {
|
export class ManageHolderService {
|
||||||
@ -55,7 +55,7 @@ export class ManageHolderService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -122,7 +122,7 @@ export class ManageHolderService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0],
|
...fetchResult?.rows?.[0] || {},
|
||||||
};
|
};
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -179,7 +179,7 @@ export class ManageHolderService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -214,7 +214,7 @@ export class ManageHolderService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -265,7 +265,7 @@ export class ManageHolderService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -300,7 +300,7 @@ export class ManageHolderService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -337,7 +337,7 @@ export class ManageHolderService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.inActivate,
|
message: ResponseStatus.inActivate,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -375,7 +375,7 @@ export class ManageHolderService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.reActivate,
|
message: ResponseStatus.reActivate,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -413,7 +413,7 @@ export class ManageHolderService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.inActivate,
|
message: ResponseStatus.inActivate,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -451,7 +451,7 @@ export class ManageHolderService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.reActivate,
|
message: ResponseStatus.reActivate,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -486,7 +486,7 @@ export class ManageHolderService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
|
|||||||
@ -2,7 +2,7 @@ import { Injectable, Logger } from '@nestjs/common';
|
|||||||
import { PoolClient } from 'pg';
|
import { PoolClient } from 'pg';
|
||||||
import { PgDBService } from 'src/db/db.service';
|
import { PgDBService } from 'src/db/db.service';
|
||||||
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, SPID_DTO, UpdateParamRecordDTO } from 'src/dto/property.dto';
|
import { ActivateOrInactivateParamRecordDTO, CreateParamRecordDTO, CreateTableRecordDTO, getParamValuesDTO, SPID_DTO, UpdateParamRecordDTO } from 'src/dto/property.dto';
|
||||||
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
|
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ParamTableService {
|
export class ParamTableService {
|
||||||
@ -32,7 +32,7 @@ export class ParamTableService {
|
|||||||
await client.query(`CLOSE ${cursorName}`);
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
await client.query('COMMIT');
|
await client.query('COMMIT');
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -64,7 +64,7 @@ export class ParamTableService {
|
|||||||
await client.query(`CLOSE ${cursorName}`);
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
await client.query('COMMIT');
|
await client.query('COMMIT');
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -95,7 +95,7 @@ export class ParamTableService {
|
|||||||
await client.query(`CLOSE ${cursorName}`);
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
await client.query('COMMIT');
|
await client.query('COMMIT');
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -129,10 +129,8 @@ export class ParamTableService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
let fr: any = toUpperCaseKeys(fetchResult?.rows)
|
|
||||||
|
|
||||||
// return fetchResult.rows;
|
// return fetchResult.rows;
|
||||||
return { statusCode: 201, message: ResponseStatus.created, ...fr[0] };
|
return { statusCode: 201, message: ResponseStatus.created, ...fetchResult?.rows[0] };
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -183,13 +181,11 @@ export class ParamTableService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
let fr: any = toUpperCaseKeys(fetchResult?.rows)
|
|
||||||
|
|
||||||
// Return response
|
// Return response
|
||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...fr[0] || {}
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -243,7 +239,7 @@ export class ParamTableService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { CreateCarnetSequenceDTO, SPID_DTO } from 'src/dto/property.dto';
|
|||||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||||
|
|
||||||
import { PoolClient } from 'pg';
|
import { PoolClient } from 'pg';
|
||||||
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
|
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper';
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
@ -37,7 +37,7 @@ export class CarnetSequenceService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return { statusCode: 201, message: ResponseStatus.created, ...toUpperCaseKeys(fetchResult?.rows)[0] };
|
return { statusCode: 201, message: ResponseStatus.created, ...fetchResult?.rows[0] };
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -69,7 +69,7 @@ export class CarnetSequenceService {
|
|||||||
await client.query(`CLOSE ${cursorName}`);
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
await client.query('COMMIT');
|
await client.query('COMMIT');
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { InsertRegionsDto, SPID_DTO, UpdateRegionDto } from 'src/dto/property.dt
|
|||||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||||
|
|
||||||
import { PoolClient } from 'pg';
|
import { PoolClient } from 'pg';
|
||||||
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
|
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class RegionService {
|
export class RegionService {
|
||||||
@ -39,7 +39,7 @@ export class RegionService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -74,7 +74,7 @@ export class RegionService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return { statusCode: 200, message: ResponseStatus.updated, ...toUpperCaseKeys(fetchResult?.rows)[0] || {} };
|
return { statusCode: 200, message: ResponseStatus.updated, ...fetchResult?.rows[0] || {} };
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -107,7 +107,7 @@ export class RegionService {
|
|||||||
await client.query(`CLOSE ${cursorName}`);
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
await client.query('COMMIT');
|
await client.query('COMMIT');
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { InternalServerException } from 'src/exceptions/internalServerError.exce
|
|||||||
|
|
||||||
import { PoolClient } from 'pg';
|
import { PoolClient } from 'pg';
|
||||||
import { PgDBService } from 'src/db/db.service';
|
import { PgDBService } from 'src/db/db.service';
|
||||||
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
|
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SpContactsService {
|
export class SpContactsService {
|
||||||
@ -52,7 +52,7 @@ export class SpContactsService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -128,7 +128,7 @@ export class SpContactsService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 200,
|
statusCode: 200,
|
||||||
message: ResponseStatus.updated,
|
message: ResponseStatus.updated,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -194,7 +194,7 @@ export class SpContactsService {
|
|||||||
await client.query(`CLOSE ${cursorName}`);
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
await client.query('COMMIT');
|
await client.query('COMMIT');
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -228,7 +228,7 @@ export class SpContactsService {
|
|||||||
await client.query(`CLOSE ${cursorName}`);
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
await client.query('COMMIT');
|
await client.query('COMMIT');
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
|
|||||||
@ -4,7 +4,7 @@ import { InsertNewServiceProviderDTO, SPID_DTO, UpdateServiceProviderDTO } from
|
|||||||
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||||
|
|
||||||
import { PoolClient } from 'pg';
|
import { PoolClient } from 'pg';
|
||||||
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
|
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class SpService {
|
export class SpService {
|
||||||
@ -67,7 +67,7 @@ export class SpService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return { statusCode: 201, message: ResponseStatus.created, ...toUpperCaseKeys(fetchResult?.rows)[0] || {} };
|
return { statusCode: 201, message: ResponseStatus.created, ...fetchResult?.rows[0] || {} };
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -125,7 +125,7 @@ export class SpService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return { statusCode: 201, message: ResponseStatus.created, ...toUpperCaseKeys(fetchResult?.rows)[0] || {} };
|
return { statusCode: 201, message: ResponseStatus.created, ...fetchResult?.rows[0] || {} };
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -158,7 +158,7 @@ export class SpService {
|
|||||||
await client.query(`CLOSE ${cursorName}`);
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
await client.query('COMMIT');
|
await client.query('COMMIT');
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -192,7 +192,7 @@ export class SpService {
|
|||||||
await client.query(`CLOSE ${cursorName}`);
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
await client.query('COMMIT');
|
await client.query('COMMIT');
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult.rows;
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
|
|||||||
@ -16,7 +16,7 @@ export class UserMaintenanceController {
|
|||||||
|
|
||||||
// SP_USER_DETAILS
|
// SP_USER_DETAILS
|
||||||
|
|
||||||
@Get('GetUserDetails/:P_USERID')
|
// @Get('GetUserDetails/:P_USERID')
|
||||||
async GetPreparers(@Param() params: USERID_DTO) {
|
async GetPreparers(@Param() params: USERID_DTO) {
|
||||||
return await this.userMaintenanceService.GetSPUserDetails(params);
|
return await this.userMaintenanceService.GetSPUserDetails(params);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common';
|
import { forwardRef, Inject, Injectable, Logger } from '@nestjs/common';
|
||||||
import { CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, EMAIL_DTO, SPID_CLIENTID_DTO, SPID_DTO, SPID_EMAIL_DTO, USERID_DTO } from 'src/dto/property.dto';
|
import { CreateClientLoginsDTO, CreateSPLoginsDTO, CreateUSCIBLoginsDTO, EMAIL_DTO, SPID_CLIENTID_DTO, SPID_DTO, SPID_EMAIL_DTO, USERID_DTO } from 'src/dto/property.dto';
|
||||||
import { checkPgUserDefinedErrors, handlePgError, normalizeKeysToUpperCase, releasePgClient, ResponseStatus, toUpperCaseKeys } from 'src/utils/helper';
|
import { checkPgUserDefinedErrors, handlePgError, normalizeKeysToUpperCase, releasePgClient, ResponseStatus } from 'src/utils/helper';
|
||||||
|
|
||||||
import { PoolClient } from 'pg';
|
import { PoolClient } from 'pg';
|
||||||
import { PgDBService } from 'src/db/db.service';
|
import { PgDBService } from 'src/db/db.service';
|
||||||
@ -22,53 +22,48 @@ export class UserMaintenanceService {
|
|||||||
async GetSPUserDetails(body: USERID_DTO): Promise<any> {
|
async GetSPUserDetails(body: USERID_DTO): Promise<any> {
|
||||||
let client: PoolClient | null = null;
|
let client: PoolClient | null = null;
|
||||||
|
|
||||||
// Assign unique names to each cursor
|
const cursorName = 'p_cursor';
|
||||||
const roleCursor = 'role_cursor';
|
|
||||||
const menuCursor = 'menu_cursor';
|
|
||||||
const menuPageCursor = 'menu_page_cursor';
|
|
||||||
const userDetailsCursor = 'user_details_cursor';
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
client = await this.pgDBService.getConnection();
|
client = await this.pgDBService.getConnection();
|
||||||
|
|
||||||
await client.query('BEGIN');
|
await client.query('BEGIN');
|
||||||
|
|
||||||
const callProcQuery = `
|
const callProcQuery = `
|
||||||
CALL "CARNETSYS".spclientuser_pkg_getspuserdetails($1, $2, $3, $4, $5)
|
CALL "CARNETSYS".userlogin_pkg_createclientlogins($1, $2, $3, $4, $5)
|
||||||
`;
|
`;
|
||||||
|
await client.query(callProcQuery,
|
||||||
await client.query(callProcQuery, [
|
[
|
||||||
body.P_USERID,
|
body.P_USERID,
|
||||||
roleCursor,
|
cursorName
|
||||||
menuCursor,
|
|
||||||
menuPageCursor,
|
|
||||||
userDetailsCursor
|
|
||||||
]);
|
]);
|
||||||
|
|
||||||
// Fetch all data from each cursor
|
// 🚫 DON'T quote the cursor name in FETCH
|
||||||
const roleResult = await client.query(`FETCH ALL FROM ${roleCursor}`);
|
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
||||||
const menuResult = await client.query(`FETCH ALL FROM ${menuCursor}`);
|
|
||||||
const menuPageResult = await client.query(`FETCH ALL FROM ${menuPageCursor}`);
|
|
||||||
const userDetailsResult = await client.query(`FETCH ALL FROM ${userDetailsCursor}`);
|
|
||||||
|
|
||||||
// Close all cursors
|
|
||||||
await client.query(`CLOSE ${roleCursor}`);
|
|
||||||
await client.query(`CLOSE ${menuCursor}`);
|
|
||||||
await client.query(`CLOSE ${menuPageCursor}`);
|
|
||||||
await client.query(`CLOSE ${userDetailsCursor}`);
|
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in CLOSE
|
||||||
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
await client.query('COMMIT');
|
await client.query('COMMIT');
|
||||||
|
|
||||||
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
|
const mailRes = await this.authService.sendMail({ P_TO: body.P_USERID, P_MAIL_TYPE: MailTypeDTO.REGISTER_CLIENT })
|
||||||
|
|
||||||
|
if (mailRes.statusCode !== 200) {
|
||||||
|
throw new InternalServerException();
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
roleDetails: toUpperCaseKeys(roleResult.rows),
|
statusCode: 201,
|
||||||
menuDetails: toUpperCaseKeys(menuResult.rows),
|
message: ResponseStatus.clientRegistrationDone,
|
||||||
menuPageDetails: toUpperCaseKeys(menuPageResult.rows),
|
...fetchResult?.rows?.[0] || {}
|
||||||
userDetails: toUpperCaseKeys(userDetailsResult.rows),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
handlePgError(error, 'getSpUserDetails');
|
handlePgError(error, UserMaintenanceService.name)
|
||||||
} finally {
|
} finally {
|
||||||
releasePgClient(client);
|
releasePgClient(client)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,7 +100,7 @@ export class UserMaintenanceService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.lockedUserDone,
|
message: ResponseStatus.lockedUserDone,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -143,7 +138,7 @@ export class UserMaintenanceService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -188,7 +183,7 @@ export class UserMaintenanceService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -226,7 +221,7 @@ export class UserMaintenanceService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -274,7 +269,7 @@ export class UserMaintenanceService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.created,
|
message: ResponseStatus.created,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -312,7 +307,7 @@ export class UserMaintenanceService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -346,7 +341,7 @@ export class UserMaintenanceService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
@ -397,7 +392,7 @@ export class UserMaintenanceService {
|
|||||||
return {
|
return {
|
||||||
statusCode: 201,
|
statusCode: 201,
|
||||||
message: ResponseStatus.clientRegistrationDone,
|
message: ResponseStatus.clientRegistrationDone,
|
||||||
...toUpperCaseKeys(fetchResult?.rows)[0]
|
...fetchResult?.rows?.[0] || {}
|
||||||
};
|
};
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -436,7 +431,7 @@ export class UserMaintenanceService {
|
|||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
if (fetchResult?.rows.length > 0) {
|
if (fetchResult?.rows.length > 0) {
|
||||||
return toUpperCaseKeys(fetchResult.rows)[0]
|
return [normalizeKeysToUpperCase(fetchResult?.rows[0])]
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return [];
|
return [];
|
||||||
@ -478,7 +473,7 @@ export class UserMaintenanceService {
|
|||||||
|
|
||||||
checkPgUserDefinedErrors(fetchResult);
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
return toUpperCaseKeys(fetchResult.rows);
|
return fetchResult?.rows ? fetchResult?.rows : []
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (client) await client.query('ROLLBACK');
|
if (client) await client.query('ROLLBACK');
|
||||||
|
|||||||
@ -25,10 +25,7 @@ export enum ResponseStatus {
|
|||||||
reActivate = 'Reactivated Successfully',
|
reActivate = 'Reactivated Successfully',
|
||||||
clientRegistrationDone = 'Client registration initiated successfully',
|
clientRegistrationDone = 'Client registration initiated successfully',
|
||||||
lockedUserDone = 'Locked Successfully',
|
lockedUserDone = 'Locked Successfully',
|
||||||
transmitted = 'Transmitted Successfully',
|
transmitted = 'Transmitted Successfully'
|
||||||
added = 'Added Successfully',
|
|
||||||
deleted = 'Deleted Successfully',
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function normalizeKeysToUpperCase(obj) {
|
export function normalizeKeysToUpperCase(obj) {
|
||||||
@ -38,17 +35,6 @@ export function normalizeKeysToUpperCase(obj) {
|
|||||||
}, {});
|
}, {});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function toUpperCaseKeys(rows: Record<string, any>[]): Record<string, any>[] {
|
|
||||||
return rows.map(row => {
|
|
||||||
const transformedRow: Record<string, any> = {};
|
|
||||||
for (const key in row) {
|
|
||||||
transformedRow[key.toUpperCase()] = row[key];
|
|
||||||
}
|
|
||||||
return transformedRow;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export const handleError = (error: any, context: string = 'UnknownService'): never => {
|
export const handleError = (error: any, context: string = 'UnknownService'): never => {
|
||||||
if (error instanceof BadRequestException || error instanceof BR) {
|
if (error instanceof BadRequestException || error instanceof BR) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user