diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index ef4f726..e65c110 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -44,7 +44,7 @@ export class AuthController { return { statusCode: 200, message: "Logged-In Successfully", email: k.email } } - @UseGuards(RegisterGuard) + // @UseGuards(RegisterGuard) @Post('register') async register(@Body() body: AuthLoginDTO, @Req() req: Request) { return this.authService.registerUser(body, req); diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index 2f621a1..23b55d8 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -708,7 +708,7 @@ export class AuthService { template: 'a', context: { to: body.P_TO, - url: `https://client.alphaomegainfosys.com/register/${token}` + url: `https://client.alphaomegainfosys.com/register` } } case MailTypeDTO.FORGOT_PASSWORD: @@ -847,8 +847,6 @@ export class AuthService { token = await this.generateToken({ P_TO: body.P_TO, uuid: uuid }) - - const mailTemplate: MailTemplateDTO | null = await this.getMailTemplate(body, token, ROLE); if (!mailTemplate) { diff --git a/src/dto/manage-clients/manage-clients.dto.ts b/src/dto/manage-clients/manage-clients.dto.ts index e1d494f..8ac52e5 100644 --- a/src/dto/manage-clients/manage-clients.dto.ts +++ b/src/dto/manage-clients/manage-clients.dto.ts @@ -120,6 +120,10 @@ export class GetClientDTO extends IntersectionType( CLIENTID_DTO ) { } +export class GetClientContactByLacationIdDTO extends IntersectionType( + SPID_DTO, LOCATIONID_DTO +){} + export class ClientContactControlsDTO extends IntersectionType( SPID_DTO, CLIENT_CONTACTID_DTO, diff --git a/src/mail/mail.module.ts b/src/mail/mail.module.ts index f763726..e33cbb9 100644 --- a/src/mail/mail.module.ts +++ b/src/mail/mail.module.ts @@ -17,28 +17,32 @@ import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handleba MailerModule.forRootAsync({ imports: [ConfigModule], - useFactory: (configService: ConfigService) => ({ - transport: { - host: 'smtp.gmail.com', - port: 587, - // ignoreTLS: true, - secure: false, - auth: { - user: configService.get('MAIL_USER'), - pass: configService.get('MAIL_PASS'), + useFactory: (configService: ConfigService) => { + const templatePath = join(__dirname, '../../..', 'public', 'mail-templates'); + console.log('Resolved mail template path:', templatePath); + + return { + transport: { + host: 'smtp.gmail.com', + port: 587, + secure: false, + auth: { + user: configService.get('MAIL_USER'), + pass: configService.get('MAIL_PASS'), + }, }, - }, - defaults: { - from: `"Carnet APP" <${configService.get('MAIL_USER')}>`, - }, - template: { - dir: join(__dirname, '../../..', 'public', 'mail-templates'), - adapter: new HandlebarsAdapter(), // import from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter' - options: { - strict: true, + defaults: { + from: `"Carnet APP" <${configService.get('MAIL_USER')}>`, }, - }, - }), + template: { + dir: templatePath, + adapter: new HandlebarsAdapter(), + options: { + strict: true, + }, + }, + }; + }, inject: [ConfigService], }), ], diff --git a/src/oracle/carnet-application/carnet-application.controller.ts b/src/oracle/carnet-application/carnet-application.controller.ts index e777186..69eb98c 100644 --- a/src/oracle/carnet-application/carnet-application.controller.ts +++ b/src/oracle/carnet-application/carnet-application.controller.ts @@ -1,4 +1,4 @@ -import { Body, Controller, Get, Param, Patch, Post, Put, UseGuards } from '@nestjs/common'; +import { Body, Controller, Delete, Get, Param, Patch, Post, Put, UseGuards } from '@nestjs/common'; import { CarnetApplicationService } from './carnet-application.service'; import { ApiTags } from '@nestjs/swagger'; @@ -63,6 +63,16 @@ export class CarnetApplicationController { return this.carnetApplicationService.AddCountries(body); } + @Put('EditGenerallistItems') + EditGenerallistItems(@Body() body: AddGenerallistItemsDTO) { + return this.carnetApplicationService.EditGenerallistItems(body); + } + + @Delete('DeleteGenerallistItems') + DeleteGenerallistItems(@Body() body: AddGenerallistItemsDTO) { + return this.carnetApplicationService.DeleteGenerallistItems(body); + } + @Patch('UpdateShippingDetails') UpdateShippingDetails(@Body() body: UpdateShippingDetailsDTO) { return this.carnetApplicationService.UpdateShippingDetails(body); @@ -110,11 +120,19 @@ export class CarnetApplicationController { return this.carnetApplicationService.GetGoodsDetailstoEdit(body); } + @Get('GetGoodsItemstoEdit/:P_SPID/:P_USERID/:P_HEADERID') + GetGoodsItemstoEdit(@Param() body: GetCarnetControlCenterDTO) { + return this.carnetApplicationService.GetGoodsItemstoEdit(body); + } + @Get('GetCountryDetailstoEdit/:P_SPID/:P_USERID/:P_HEADERID') GetCountryDetailstoEdit(@Param() body: GetCarnetControlCenterDTO) { return this.carnetApplicationService.GetCountryDetailstoEdit(body); } + + + @Get('GetShipPaymentDetailstoEdit/:P_SPID/:P_USERID/:P_HEADERID') GetShipPaymentDetailstoEdit(@Param() body: GetCarnetControlCenterDTO) { return this.carnetApplicationService.GetShipPaymentDetailstoEdit(body); diff --git a/src/oracle/carnet-application/carnet-application.service.ts b/src/oracle/carnet-application/carnet-application.service.ts index 155eea8..5e1d10b 100644 --- a/src/oracle/carnet-application/carnet-application.service.ts +++ b/src/oracle/carnet-application/carnet-application.service.ts @@ -219,7 +219,14 @@ export class CarnetApplicationService { throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Saved Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -256,7 +263,14 @@ export class CarnetApplicationService { throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Transmitted Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -340,7 +354,15 @@ export class CarnetApplicationService { throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name); + // return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Updated Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -383,7 +405,14 @@ export class CarnetApplicationService { throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Updated Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -423,7 +452,109 @@ export class CarnetApplicationService { throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name); + // return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Added Successfully", ...fres[0] }; + } catch (error) { + handleError(error, CarnetApplicationService.name) + } finally { + await closeOracleDbConnection(connection, CarnetApplicationService.name) + } + } + + async EditGenerallistItems(body: AddGenerallistItemsDTO) { + let connection; + try { + connection = await this.oracleDBService.getConnection(); + + const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(body); + + const result = await connection.execute( + `BEGIN + CARNETAPPLICATION_PKG.EditGenerallistItems( + :P_HEADERID, :P_GLTABLE, :P_USERID, :P_CURSOR + ); + END;`, + { + P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER }, + P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' }, + // P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT }, + P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR }, + // P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }, + P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }, + { outFormat: oracledb.OUT_FORMAT_OBJECT } + ); + + await connection.commit(); + + const outBinds = result.outBinds; + if (!outBinds?.P_CURSOR) { + this.logger.error('One or more expected cursors are missing from stored procedure output.'); + throw new InternalServerException("Incomplete data received from the database."); + } + + const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Updated Successfully", ...fres[0] }; + } catch (error) { + handleError(error, CarnetApplicationService.name) + } finally { + await closeOracleDbConnection(connection, CarnetApplicationService.name) + } + } + + async DeleteGenerallistItems(body: AddGenerallistItemsDTO) { + let connection; + try { + connection = await this.oracleDBService.getConnection(); + + const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(body); + + const result = await connection.execute( + `BEGIN + CARNETAPPLICATION_PKG.DeleteGenerallistItems( + :P_HEADERID, :P_GLTABLE, :P_USERID, :P_CURSOR + ); + END;`, + { + P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER }, + P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' }, + // P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT }, + P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR }, + // P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }, + P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }, + { outFormat: oracledb.OUT_FORMAT_OBJECT } + ); + + await connection.commit(); + + const outBinds = result.outBinds; + if (!outBinds?.P_CURSOR) { + this.logger.error('One or more expected cursors are missing from stored procedure output.'); + throw new InternalServerException("Incomplete data received from the database."); + } + + const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Deleted Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -441,7 +572,7 @@ export class CarnetApplicationService { const result = await connection.execute( `BEGIN CARNETAPPLICATION_PKG.AddCountries( - :P_HEADERID, :P_USSETS, :P_COUNTRYTABLE, :P_USERID, :P_ERRORMESG + :P_HEADERID, :P_USSETS, :P_COUNTRYTABLE, :P_USERID, :P_CURSOR ); END;`, { @@ -451,8 +582,8 @@ export class CarnetApplicationService { // P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' }, // P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT }, P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR }, - P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }, - // P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + // P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }, + P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } }, { outFormat: oracledb.OUT_FORMAT_OBJECT } ); @@ -460,12 +591,19 @@ export class CarnetApplicationService { await connection.commit(); const outBinds = result.outBinds; - if (!outBinds?.P_ERRORMESG) { + if (!outBinds?.P_CURSOR) { this.logger.error('One or more expected cursors are missing from stored procedure output.'); throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Added Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -480,10 +618,10 @@ export class CarnetApplicationService { const result = await connection.execute( `BEGIN - CARNETAPPLICATION_PKG.UpdateHolder( + CARNETAPPLICATION_PKG.UpdateShippingDetails( :P_HEADERID, :P_SHIPTOTYPE, :P_SHIPADDRID, :P_FORMOFSECURITY, :P_INSPROTECTION, :P_LDIPROTECTION, :P_DELIVERYTYPE, :P_DELIVERYMETHOD, :P_PAYMENTMETHOD, - :P_CUSTCOURIERNO, :P_REFNO, :P_NOTES, :P_USERID, :P_ERRORMESG + :P_CUSTCOURIERNO, :P_REFNO, :P_NOTES, :P_USERID, :P_CURSOR ); END;`, { @@ -500,8 +638,8 @@ export class CarnetApplicationService { P_REFNO: { val: body.P_REFNO, type: oracledb.DB_TYPE_NVARCHAR }, P_NOTES: { val: body.P_NOTES, type: oracledb.DB_TYPE_NVARCHAR }, P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR }, - P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }, - // P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + // P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }, + P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } }, { outFormat: oracledb.OUT_FORMAT_OBJECT } ); @@ -509,12 +647,19 @@ export class CarnetApplicationService { await connection.commit(); const outBinds = result.outBinds; - if (!outBinds?.P_ERRORMESG) { + if (!outBinds?.P_CURSOR) { this.logger.error('One or more expected cursors are missing from stored procedure output.'); throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Updated Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -552,7 +697,14 @@ export class CarnetApplicationService { throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Processed Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -587,7 +739,14 @@ export class CarnetApplicationService { throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Updated Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -622,7 +781,14 @@ export class CarnetApplicationService { throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Voided Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -657,7 +823,14 @@ export class CarnetApplicationService { throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Duplicated Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -692,7 +865,14 @@ export class CarnetApplicationService { throw new InternalServerException("Incomplete data received from the database."); } - return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + + if (fres.length > 0 && fres[0].ERRORMESG) { + this.logger.warn(fres[0].ERRORMESG); + throw new BadRequestException(fres[0].ERRORMESG) + } + + return { statusCode: 200, message: "Closed Successfully", ...fres[0] }; } catch (error) { handleError(error, CarnetApplicationService.name) } finally { @@ -840,4 +1020,39 @@ export class CarnetApplicationService { await closeOracleDbConnection(connection, CarnetApplicationService.name) } } + async GetGoodsItemstoEdit(body: GetCarnetControlCenterDTO) { + let connection; + + try { + connection = await this.oracleDBService.getConnection(); + + const result = await connection.execute( + `BEGIN + CARNETCONTROLCENTER_PKG.GetGoodsItemstoEdit( + :P_SPID, :P_USERID , :P_HEADERID, :P_CURSOR + ); + END;`, + { + P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER }, + P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR }, + P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER }, + P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }, + { outFormat: oracledb.OUT_FORMAT_OBJECT } + ); + + const outBinds = result.outBinds; + if (!outBinds?.P_CURSOR) { + this.logger.error('One or more expected cursors are missing from stored procedure output.'); + throw new InternalServerException("Incomplete data received from the database."); + } + + return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name); + } catch (error) { + handleError(error, CarnetApplicationService.name) + } finally { + await closeOracleDbConnection(connection, CarnetApplicationService.name) + } + } + } diff --git a/src/oracle/home-page/home-page.service.ts b/src/oracle/home-page/home-page.service.ts index bbc201d..80c4bb0 100644 --- a/src/oracle/home-page/home-page.service.ts +++ b/src/oracle/home-page/home-page.service.ts @@ -132,27 +132,46 @@ export class HomePageService { // Step 2: Group and aggregate const reducedRows = mappedRows.reduce((acc, curr) => { - const existing = acc.find( - (item) => - item['Service_Provider_Name'] === curr['Service_Provider_Name'] && - item.SPID === curr.SPID - ); + let existing; + + if (curr.Service_Provider_Name && curr.SPID) { + existing = acc.find( + (item) => + item.Service_Provider_Name === curr.Service_Provider_Name && + item.SPID === curr.SPID + ); + } else if (curr.Preparer_Name && curr.CLIENTID) { + existing = acc.find( + (item) => + item.Preparer_Name === curr.Preparer_Name && + item.CLIENTID === curr.CLIENTID + ); + } if (existing) { existing.CARNETSTATUS.push(curr.CARNETSTATUS); existing.Carnet_Count.push(curr.Carnet_Count); } else { - acc.push({ - Service_Provider_Name: curr.Service_Provider_Name, - SPID: curr.SPID, + const newItem = { CARNETSTATUS: [curr.CARNETSTATUS], Carnet_Count: [curr.Carnet_Count], - }); + }; + + if (curr.Service_Provider_Name && curr.SPID) { + newItem['Service_Provider_Name'] = curr.Service_Provider_Name; + newItem['SPID'] = curr.SPID; + } else if (curr.Preparer_Name && curr.CLIENTID) { + newItem['Preparer_Name'] = curr.Preparer_Name; + newItem['CLIENTID'] = curr.CLIENTID; + } + + acc.push(newItem); } return acc; }, []); + return reducedRows; } catch (error) { handleError(error, HomePageService.name) diff --git a/src/oracle/manage-clients/manage-clients.controller.ts b/src/oracle/manage-clients/manage-clients.controller.ts index f8f70c6..c146f8d 100644 --- a/src/oracle/manage-clients/manage-clients.controller.ts +++ b/src/oracle/manage-clients/manage-clients.controller.ts @@ -6,6 +6,7 @@ import { ClientContactControlsDTO, CreateClientContactsDTO, CreateClientDataDTO, CreateClientLocationsDTO, + GetClientContactByLacationIdDTO, GetClientDTO, GetPreparersParamDTO, GetPreparersQueryDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO } from 'src/dto/property.dto'; @@ -81,6 +82,11 @@ export class ManageClientsController { return this.manageClientsService.GetPreparerContactsByClientid(body); } + @Get('GetPreparerContactsbyClientLocationID/:P_SPID/:P_LOCATIONID') + GetPreparerContactsbyClientLocationID(@Param() body: GetClientContactByLacationIdDTO) { + return this.manageClientsService.GetPreparerContactsbyClientLocationID(body); + } + @Get('GetPreparerLocByClientid/:P_SPID/:P_CLIENTID') GetPreparerLocByClientid(@Param() body: GetClientDTO) { return this.manageClientsService.GetPreparerLocByClientid(body); diff --git a/src/oracle/manage-clients/manage-clients.service.ts b/src/oracle/manage-clients/manage-clients.service.ts index 654a088..15674d8 100644 --- a/src/oracle/manage-clients/manage-clients.service.ts +++ b/src/oracle/manage-clients/manage-clients.service.ts @@ -10,6 +10,7 @@ import { ClientContactControlsDTO, CreateClientContactsDTO, CreateClientDataDTO, CreateClientLocationsDTO, + GetClientContactByLacationIdDTO, GetClientDTO, GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO, } from 'src/dto/property.dto'; @@ -718,6 +719,43 @@ export class ManageClientsService { } }; + GetPreparerContactsbyClientLocationID = async (body: GetClientContactByLacationIdDTO) => { + let connection; + + try { + connection = await this.oracleDBService.getConnection(); + + const result = await connection.execute( + `BEGIN + MANAGEPREPARER_PKG.GetPreparerContactsByClientid( + :P_SPID, :P_LOCATIONID, :P_CURSOR + ); + END;`, + { + P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER }, + P_LOCATIONID: { val: body.P_LOCATIONID, type: oracledb.DB_TYPE_NUMBER }, + P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } + }, + { + outFormat: oracledb.OUT_FORMAT_OBJECT, + }, + ); + + const outBinds: any = result.outBinds; + if (!outBinds?.P_CURSOR) { + this.logger.error('One or more expected cursors are missing from stored procedure output.'); + throw new InternalServerException("Incomplete data received from the database."); + } + + return await fetchCursor(outBinds.P_CURSOR, ManageClientsService.name); + + } catch (error) { + handleError(error, ManageClientsService.name) + } finally { + await closeOracleDbConnection(connection, ManageClientsService.name) + } + } + GetPreparerLocByClientid = async (body: GetClientDTO) => { let connection; diff --git a/src/oracle/manage-holders/manage-holders.service.ts b/src/oracle/manage-holders/manage-holders.service.ts index ab55155..ec4821b 100644 --- a/src/oracle/manage-holders/manage-holders.service.ts +++ b/src/oracle/manage-holders/manage-holders.service.ts @@ -485,7 +485,7 @@ export class ManageHoldersService { throw new BadRequestException(fres[0].ERRORMESG) } - return { statusCode: 200, message: 'Reactivated holder successfully' }; + return { statusCode: 200, message: 'Inactivated holder successfully' }; } catch (error) { handleError(error, ManageHoldersService.name) } finally {