From ed7603b445aa82c894de3eb6c973318941f201e8 Mon Sep 17 00:00:00 2001 From: Kallesh B S Date: Thu, 28 Aug 2025 15:03:45 +0530 Subject: [PATCH] 28-08-2025 API changes, return specific value in applicationName from login API, payment data persist changes --- api.http | 4 + src/auth/auth.controller.ts | 8 +- src/auth/auth.dto.ts | 5 +- src/auth/auth.service.ts | 23 ++- .../carnet-application-property.dto.ts | 2 +- .../carnet-application.dto.ts | 4 +- .../manage-clients-property.dto.ts | 7 + src/dto/manage-clients/manage-clients.dto.ts | 8 +- src/dto/manage-fee/manage-fee-property.dto.ts | 7 + src/dto/manage-fee/manage-fee.dto.ts | 8 +- src/dto/uscib-managed-sp/region/region.dto.ts | 4 +- .../carnet-application.service.ts | 133 ++++++++++++++---- .../manage-clients/manage-clients.service.ts | 10 +- src/oracle/manage-fee/manage-fee.service.ts | 5 +- .../region/region.controller.ts | 10 +- .../uscib-managed-sp/region/region.service.ts | 12 +- 16 files changed, 188 insertions(+), 62 deletions(-) diff --git a/api.http b/api.http index 9da28e5..7ffc062 100644 --- a/api.http +++ b/api.http @@ -1,5 +1,9 @@ GET http://192.168.1.96:3006 + +### + +GET http://localhost:3000/oracle/GetRegions/1 ### GET http://localhost:3000/oracle/SearchHolder/1 diff --git a/src/auth/auth.controller.ts b/src/auth/auth.controller.ts index 4559fce..185d58d 100644 --- a/src/auth/auth.controller.ts +++ b/src/auth/auth.controller.ts @@ -1,7 +1,7 @@ import { Body, Controller, Get, HttpCode, Post, Put, Req, Res, UseGuards, UseInterceptors } from '@nestjs/common'; import { AuthService } from './auth.service'; import { ApiTags } from '@nestjs/swagger'; -import { AuthLoginDTO, SendMailDTO } from './auth.dto'; +import { AuthLoginDTO, AuthLoginOnlyDTO, SendMailDTO } from './auth.dto'; import { Request, Response } from 'express'; import { LogoutInterceptor } from 'src/interceptors/logout.interceptor'; import { RegisterGuard } from 'src/guards/register.guard'; @@ -18,9 +18,9 @@ export class AuthController { @Post('login') @HttpCode(200) - async loginClient(@Body() body: AuthLoginDTO, @Res({ passthrough: true }) res: Response, @Req() req: Request) { + async loginClient(@Body() body: AuthLoginOnlyDTO, @Res({ passthrough: true }) res: Response, @Req() req: Request) { - let k: any = await this.authService.loginUser(body.P_EMAILADDR.toLowerCase(), body.P_PASSWORD, req); + let k: any = await this.authService.loginUser(body.P_EMAILADDR.toLowerCase(), body.P_PASSWORD, body.P_APPLICATIONNAME, req); if (k.access_token) { res.cookie('access_token', k.access_token, { @@ -38,7 +38,7 @@ export class AuthController { }); } - return { statusCode: 200, message: "Logged-In Successfully", email: k.email, applicationName: k.applicationName } + return { statusCode: 200, message: "Logged-In Successfully", email: k.email } } // @UseGuards(RegisterGuard) diff --git a/src/auth/auth.dto.ts b/src/auth/auth.dto.ts index 5de28d9..355d243 100644 --- a/src/auth/auth.dto.ts +++ b/src/auth/auth.dto.ts @@ -1,6 +1,7 @@ -import { ApiProperty } from '@nestjs/swagger'; +import { ApiProperty, IntersectionType } from '@nestjs/swagger'; import { Transform, Type } from 'class-transformer'; import { IsEmail, IsEnum, IsObject, IsOptional, IsString, ValidateNested } from 'class-validator'; +import { APPLICATIONNAME_DTO } from 'src/dto/property.dto'; export class AuthLoginDTO { @ApiProperty({ required: true }) @@ -12,6 +13,8 @@ export class AuthLoginDTO { P_PASSWORD: string; } +export class AuthLoginOnlyDTO extends IntersectionType(AuthLoginDTO, APPLICATIONNAME_DTO) { } + export enum MailTypeDTO { REGISTER_CLIENT = "REGISTER_CLIENT", REGISTER_SP = "REGISTER_SP", diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.ts index a88ab29..21126fa 100644 --- a/src/auth/auth.service.ts +++ b/src/auth/auth.service.ts @@ -245,7 +245,7 @@ export class AuthService { return verified; } - async loginUser(username: string, password: string, req: Request): Promise { + async loginUser(username: string, password: string, applicationName: string, req: Request): Promise { const access_token = req.cookies?.access_token; const refresh_token = req.cookies?.refresh_token; @@ -270,12 +270,22 @@ export class AuthService { if (Array.isArray(emailVerifyResponse) && !emailVerifyResponse[0].ERRORMESG) { switch (emailVerifyResponse[0].SOURCE) { - case "USCIB": ROLE = 'POLICY'; break; - case "SP": ROLE = 'SP'; break; - case "CLIENT": ROLE = 'CLIENT'; break; + case "USCIB": ROLE = 'ua'; break; + case "SP": ROLE = 'sa'; break; + case "CLIENT": ROLE = 'ca'; break; } } + const isValidCombo = + (applicationName === 'policy' && ROLE === 'ua') || + (applicationName === 'service-provider' && ROLE === 'sa') || + (applicationName === 'client' && ROLE === 'ca'); + + if (!isValidCombo) { + throw new UnauthorizedException("Authentication failed") + // console.log(!isValidCombo); + } + // if (ROLE === 'ua' && req.headers.origin !== 'https://policy.alphaomegainfosys.com') { // throw new BadRequestException("Invalid username or password") // } @@ -307,10 +317,13 @@ export class AuthService { headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, }); - let k = { ...response.data, email: username, applicationName: ROLE }; + let k = { ...response.data, email: username }; return k; } catch (error) { + if (error instanceof BadRequestException || error instanceof UnauthorizedException) { + throw error + } throw new BadRequestException('Invalid username or password'); } } diff --git a/src/dto/carnet-application/carnet-application-property.dto.ts b/src/dto/carnet-application/carnet-application-property.dto.ts index c66f1c6..715a212 100644 --- a/src/dto/carnet-application/carnet-application-property.dto.ts +++ b/src/dto/carnet-application/carnet-application-property.dto.ts @@ -43,7 +43,7 @@ export class ORDERID_DTO { @ApiProperty({ required: true }) @IsString() @IsDefined({ message: 'Property P_ORDERID is required' }) - P_ORDERID: string; + P_ORDERID: string | null; } export class PRICE_DTO { diff --git a/src/dto/carnet-application/carnet-application.dto.ts b/src/dto/carnet-application/carnet-application.dto.ts index 594ab32..d377dca 100644 --- a/src/dto/carnet-application/carnet-application.dto.ts +++ b/src/dto/carnet-application/carnet-application.dto.ts @@ -71,8 +71,8 @@ export class SaveExtensionApplicationDTO extends (IntersectionType( export class PrintCarnetDTO extends (IntersectionType(SPID_DTO, HEADERID_DTO, PRINTGL_DTO)) { } export class PrintGLDTO extends (IntersectionType(SPID_DTO, HEADERID_DTO)) { } -export class CapturePaymentDTO extends (IntersectionType(ORDERID_DTO)) { } -export class InitiatePaymentDTO extends (IntersectionType(PRICE_DTO, DESCRIPTION_DTO)) { } +export class CapturePaymentDTO extends (IntersectionType(ORDERID_DTO, APPLICATIONNAME_DTO, PRICE_DTO, USERID_DTO)) { } +export class InitiatePaymentDTO extends (IntersectionType(APPLICATIONNAME_DTO, PRICE_DTO, DESCRIPTION_DTO, USERID_DTO)) { } export class GetOrderDetailsDTO extends (IntersectionType(ORDERID_DTO)) { } export class GetPaymentHistoryDTO extends (IntersectionType(APPLICATIONNAME_DTO, USERID_DTO)) { } export class SaveHistoryDTO extends (IntersectionType(APPLICATIONNAME_DTO, ORDERID_DTO, PAYMENTAMOUNT_DTO, PAYMENTSTATUS_DTO, USERID_DTO, PartialType(PAYMENTERROR_DTO))) { } diff --git a/src/dto/manage-clients/manage-clients-property.dto.ts b/src/dto/manage-clients/manage-clients-property.dto.ts index deff5a9..a6f4046 100644 --- a/src/dto/manage-clients/manage-clients-property.dto.ts +++ b/src/dto/manage-clients/manage-clients-property.dto.ts @@ -60,6 +60,13 @@ export class CLIENTNAME_DTO { P_CLIENTNAME: string; } +export class INDUSTRY_TYPE_DTO { + @ApiProperty({ required: true }) + @IsString({ message: 'Property P_INDUSTRYTYPE must be a string' }) + @IsDefined({ message: 'Property P_INDUSTRYTYPE is required' }) + P_INDUSTRYTYPE: string; +} + export class REVENUELOCATION_DTO { @ApiProperty({ required: true }) @Length(0, 2, { diff --git a/src/dto/manage-clients/manage-clients.dto.ts b/src/dto/manage-clients/manage-clients.dto.ts index 8ac52e5..7922c19 100644 --- a/src/dto/manage-clients/manage-clients.dto.ts +++ b/src/dto/manage-clients/manage-clients.dto.ts @@ -9,7 +9,7 @@ import { import { CLIENT_CONTACTID_DTO, CLIENTID_DTO, CLIENTLOCADDRESSTABLE_DTO, CLIENTLOCATIONID_DTO, - CLIENTNAME_DTO, LOCATIONNAME_DTO, NAMEOF_DTO, PREPARERNAME_DTO, REVENUELOCATION_DTO, STATUS_DTO + CLIENTNAME_DTO, INDUSTRY_TYPE_DTO, LOCATIONNAME_DTO, NAMEOF_DTO, PREPARERNAME_DTO, REVENUELOCATION_DTO, STATUS_DTO } from "./manage-clients-property.dto"; import { @@ -34,7 +34,8 @@ export class CreateClientDataDTO extends IntersectionType( PartialType(COUNTRY_DTO), ISSUING_REGION_DTO, REVENUELOCATION_DTO, - USERID_DTO + USERID_DTO, + INDUSTRY_TYPE_DTO ) { } @@ -49,7 +50,8 @@ export class UpdateClientDTO extends IntersectionType( ZIP_DTO, COUNTRY_DTO, REVENUELOCATION_DTO, - USERID_DTO + USERID_DTO, + INDUSTRY_TYPE_DTO ) { } export class UpdateClientContactsDTO extends IntersectionType( diff --git a/src/dto/manage-fee/manage-fee-property.dto.ts b/src/dto/manage-fee/manage-fee-property.dto.ts index 4f5a5ed..96d5d1f 100644 --- a/src/dto/manage-fee/manage-fee-property.dto.ts +++ b/src/dto/manage-fee/manage-fee-property.dto.ts @@ -1,6 +1,13 @@ import { ApiProperty } from "@nestjs/swagger"; import { IsNumber, IsString } from "class-validator"; + +export class PCT_VALUE_DTO { + @ApiProperty({ required: true }) + @IsString() + P_PCT_VALUE: string; +} + export class EFFDATE_DTO { @ApiProperty({ required: true }) @IsString() diff --git a/src/dto/manage-fee/manage-fee.dto.ts b/src/dto/manage-fee/manage-fee.dto.ts index 7d30861..9ed1aa4 100644 --- a/src/dto/manage-fee/manage-fee.dto.ts +++ b/src/dto/manage-fee/manage-fee.dto.ts @@ -6,7 +6,7 @@ import { HOLDERTYPE_DTO, USCIBMEMBERFLAG_DTO } from "../manage-holders/manage-ho import { BASICFEESETUPID_DTO, BONDRATESETUPID_DTO, CARGORATESETUPID_DTO, CFFEESETUPID_DTO, COMMRATE_DTO, CSFEESETUPID_DTO, CUSTOMERTYPE_DTO, EFFDATE_DTO, EFFEESETUPID_DTO, ENDSETS_DTO, - ENDTIME_DTO, FEECOMMID_DTO, FEES_DTO, RATE_DTO, SPCLCOMMODITY_DTO, SPCLCOUNTRY_DTO, + ENDTIME_DTO, FEECOMMID_DTO, FEES_DTO, PCT_VALUE_DTO, RATE_DTO, SPCLCOMMODITY_DTO, SPCLCOUNTRY_DTO, STARTSETS_DTO, STARTTIME_DTO, TIMEZONE_DTO } from "./manage-fee-property.dto"; @@ -36,7 +36,8 @@ export class CreateBondRateDTO extends IntersectionType( SPCLCOUNTRY_DTO, EFFDATE_DTO, RATE_DTO, - USERID_DTO + USERID_DTO, + PCT_VALUE_DTO ) { } export class CreateCargoRateDTO extends IntersectionType( @@ -100,7 +101,8 @@ export class UpdateBondRateDTO extends IntersectionType( BONDRATESETUPID_DTO, RATE_DTO, EFFDATE_DTO, - USERID_DTO + USERID_DTO, + PCT_VALUE_DTO ) { } export class UpdateCargoRateDTO extends IntersectionType( diff --git a/src/dto/uscib-managed-sp/region/region.dto.ts b/src/dto/uscib-managed-sp/region/region.dto.ts index 4e3144f..6c6bd91 100644 --- a/src/dto/uscib-managed-sp/region/region.dto.ts +++ b/src/dto/uscib-managed-sp/region/region.dto.ts @@ -1,7 +1,7 @@ import { IntersectionType } from '@nestjs/swagger'; import { REGION_CODE_DTO, REGIONID_DTO } from './region-property.dto'; -import { NAME_DTO } from '../../property.dto'; +import { NAME_DTO, SPID_DTO } from '../../property.dto'; -export class InsertRegionsDto extends IntersectionType(REGION_CODE_DTO, NAME_DTO) { } +export class InsertRegionsDto extends IntersectionType(REGION_CODE_DTO, NAME_DTO, SPID_DTO) { } export class UpdateRegionDto extends IntersectionType(REGIONID_DTO, NAME_DTO) { } diff --git a/src/oracle/carnet-application/carnet-application.service.ts b/src/oracle/carnet-application/carnet-application.service.ts index de8b0f2..9d30edc 100644 --- a/src/oracle/carnet-application/carnet-application.service.ts +++ b/src/oracle/carnet-application/carnet-application.service.ts @@ -1605,12 +1605,11 @@ export class CarnetApplicationService { return amount.toFixed(2); // Always returns a string with 2 decimal places } - - async InitiatePayment(body: InitiatePaymentDTO) { // console.log(body); const quantity = 1; + let orderID: string | null = null const formattedAmount = await this.formatAmount(body.P_PRICE * quantity); @@ -1667,50 +1666,110 @@ export class CarnetApplicationService { }) }); + orderID = response?.data?.id; + // console.log('PayPal create order response headers:', response.headers); // console.log('PayPal create order response data:', response.data); - return { - id: response.data.id, href: response?.data?.links?.find(obj => obj.rel === 'approve')?.href - }; + const save_result = await this.SaveHistory( + { + P_APPLICATIONNAME: body.P_APPLICATIONNAME, + P_ORDERID: response?.data?.id, + P_PAYMENTAMOUNT: body.P_PRICE, + P_STATUS: "CREATED", + P_USERID: body.P_USERID + // "P_PAYMENTERROR": {} + } + ); + + if (save_result.statusCode === 200) { + return { + id: response?.data?.id, href: response?.data?.links?.find(obj => obj.rel === 'approve')?.href + }; + } + else { + throw new InternalServerException(); + } // return { id: response.data.id }; } catch (error) { - console.error('Error creating PayPal order:', error.response?.data || error.message || error); + console.error('Error creating PayPal order:', error.response?.data || error?.message || error); + + + await this.SaveHistory({ + P_APPLICATIONNAME: body.P_APPLICATIONNAME, + P_ORDERID: orderID, + P_PAYMENTAMOUNT: body.P_PRICE, + P_STATUS: "FAILED", + P_USERID: body.P_USERID, + P_PAYMENTERROR: orderID ? error?.message : `Error while creating ORDERID : ${error?.message}` + }); - // Return a structured error object or throw to be handled by caller throw new InternalServerException(); - // return { - // error: true, - // message: 'Failed to create PayPal order', - // details: error.response?.data || error.message || error - // }; } } async CapturePayment(body: CapturePaymentDTO) { try { - const accessToken = await this.payPalService.generateAccessToken(); - const response = await axios({ - url: `${process.env.PAYPAL_BASE_URL}/v2/checkout/orders/${body.P_ORDERID}/capture`, - method: 'post', - headers: { - 'Content-Type': 'application/json', - 'Authorization': `Bearer ${accessToken}`, - }, - }); + const approve_result = await this.OrderDetails({ P_ORDERID: body.P_ORDERID }); - const capture = response?.data?.purchase_units?.[0]?.payments?.captures?.[0]; - // console.log(JSON.stringify(response?.data)); + if (approve_result.data.id === body.P_ORDERID + && approve_result.data.status === "APPROVED" + && approve_result.data.purchase_units[0]?.amount?.value === body.P_PRICE + "" + ) { + await this.SaveHistory({ + P_APPLICATIONNAME: body.P_APPLICATIONNAME, + P_ORDERID: body.P_ORDERID, + P_PAYMENTAMOUNT: body.P_PRICE, + P_STATUS: "APPROVED", + P_USERID: body.P_USERID + // P_PAYMENTERROR: `Error while capturing Payment : ${error?.message}` + }); - return { - statusCode: 200, - message: "Payment successful", - amount: `${capture?.amount?.value} ${capture?.amount?.currency_code}`, - }; + const accessToken = await this.payPalService.generateAccessToken(); + + const response = await axios({ + url: `${process.env.PAYPAL_BASE_URL}/v2/checkout/orders/${body.P_ORDERID}/capture`, + method: 'post', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${accessToken}`, + }, + }); + + const capture = response?.data?.purchase_units?.[0]?.payments?.captures?.[0]; + // console.log(JSON.stringify(response?.data)); + + await this.SaveHistory({ + P_APPLICATIONNAME: body.P_APPLICATIONNAME, + P_ORDERID: body.P_ORDERID, + P_PAYMENTAMOUNT: body.P_PRICE, + P_STATUS: "COMPLETED", + P_USERID: body.P_USERID + // P_PAYMENTERROR: `Error while capturing Payment : ${error?.message}` + }); + + return { + statusCode: 200, + message: "Payment successful", + amount: `${capture?.amount?.value} ${capture?.amount?.currency_code}`, + }; + } + else { + await this.SaveHistory({ + P_APPLICATIONNAME: body.P_APPLICATIONNAME, + P_ORDERID: body.P_ORDERID, + P_PAYMENTAMOUNT: body.P_PRICE, + P_STATUS: "FAILED", + P_USERID: body.P_USERID, + P_PAYMENTERROR: `Error while validating user approval` + }); + + throw new InternalServerException(); + } } catch (error: any) { const status = error.response?.status || 500; @@ -1724,9 +1783,26 @@ export class CarnetApplicationService { }); if (status === 404) { + await this.SaveHistory({ + P_APPLICATIONNAME: body.P_APPLICATIONNAME, + P_ORDERID: body.P_ORDERID, + P_PAYMENTAMOUNT: body.P_PRICE, + P_STATUS: "FAILED", + P_USERID: body.P_USERID, + P_PAYMENTERROR: `ORDERID NOT FOUND : ${error?.message}` + }); throw new NotFoundException(error.response?.data?.message || error?.message || "Resource Not Found") } + await this.SaveHistory({ + P_APPLICATIONNAME: body.P_APPLICATIONNAME, + P_ORDERID: body.P_ORDERID, + P_PAYMENTAMOUNT: body.P_PRICE, + P_STATUS: "FAILED", + P_USERID: body.P_USERID, + P_PAYMENTERROR: `Error while capturing Payment : ${error?.message}` + }); + throw new InternalServerException(); } } @@ -1837,6 +1913,7 @@ export class CarnetApplicationService { await closeOracleDbConnection(connection, CarnetApplicationService.name) } } + async SaveHistory(body: SaveHistoryDTO) { let connection; try { diff --git a/src/oracle/manage-clients/manage-clients.service.ts b/src/oracle/manage-clients/manage-clients.service.ts index b23c322..6a68948 100644 --- a/src/oracle/manage-clients/manage-clients.service.ts +++ b/src/oracle/manage-clients/manage-clients.service.ts @@ -39,6 +39,7 @@ export class ManageClientsService { P_ISSUINGREGION: null, P_REVENUELOCATION: null, P_USERID: null, + P_INDUSTRYTYPE: null }; const reqBody = JSON.parse(JSON.stringify(body)); @@ -57,7 +58,8 @@ export class ManageClientsService { MANAGEPREPARER_PKG.CreateClientData( :P_SPID, :P_CLIENTNAME, :P_LOOKUPCODE, :P_ADDRESS1, :P_ADDRESS2, :P_CITY, :P_STATE, :P_ZIP, - :P_COUNTRY, :P_ISSUINGREGION, :P_REVENUELOCATION, :P_USERID, + :P_COUNTRY, :P_ISSUINGREGION, :P_REVENUELOCATION, :P_USERID, + :P_INDUSTRYTYPE, :P_CLIENTCURSOR ); END;`, @@ -74,6 +76,7 @@ export class ManageClientsService { P_ISSUINGREGION: { val: finalBody.P_ISSUINGREGION, type: oracledb.DB_TYPE_NVARCHAR }, P_REVENUELOCATION: { val: finalBody.P_REVENUELOCATION, type: oracledb.DB_TYPE_NVARCHAR }, P_USERID: { val: finalBody.P_USERID, type: oracledb.DB_TYPE_NVARCHAR }, + P_INDUSTRYTYPE: { val: finalBody.P_INDUSTRYTYPE, type: oracledb.DB_TYPE_NVARCHAR }, P_CLIENTCURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } }, { @@ -118,6 +121,7 @@ export class ManageClientsService { P_COUNTRY: null, P_REVENUELOCATION: null, P_USERID: null, + P_INDUSTRYTYPE: null }; const reqBody = JSON.parse(JSON.stringify(body)); @@ -135,7 +139,8 @@ export class ManageClientsService { MANAGEPREPARER_PKG.UpdateClient( :P_SPID, :P_CLIENTID, :P_PREPARERNAME, :P_ADDRESS1, :P_ADDRESS2, :P_CITY, :P_STATE, :P_ZIP, - :P_COUNTRY, :P_REVENUELOCATION, :P_USERID, :P_CURSOR + :P_COUNTRY, :P_REVENUELOCATION, :P_USERID, :P_INDUSTRYTYPE, + :P_CURSOR ); END;`, { @@ -150,6 +155,7 @@ export class ManageClientsService { P_COUNTRY: { val: finalBody.P_COUNTRY, type: oracledb.DB_TYPE_NVARCHAR }, P_REVENUELOCATION: { val: finalBody.P_REVENUELOCATION, type: oracledb.DB_TYPE_NVARCHAR }, P_USERID: { val: finalBody.P_USERID, type: oracledb.DB_TYPE_NVARCHAR }, + P_INDUSTRYTYPE: { val: finalBody.P_INDUSTRYTYPE, type: oracledb.DB_TYPE_NVARCHAR }, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } }, { diff --git a/src/oracle/manage-fee/manage-fee.service.ts b/src/oracle/manage-fee/manage-fee.service.ts index 82a43e3..9580d0c 100644 --- a/src/oracle/manage-fee/manage-fee.service.ts +++ b/src/oracle/manage-fee/manage-fee.service.ts @@ -195,6 +195,7 @@ export class ManageFeeService { MANAGEFEE_SETUP_PKG.CREATEBONDRATE( :P_SPID, :P_HOLDERTYPE, :P_USCIBMEMBERFLAG, :P_SPCLCOMMODITY, :P_SPCLCOUNTRY, :P_EFFDATE, :P_RATE, :P_USERID, + :P_PCT_VALUE, :P_CURSOR ); END;`, @@ -207,6 +208,7 @@ export class ManageFeeService { P_EFFDATE: { val: body.P_EFFDATE, type: oracledb.DB_TYPE_VARCHAR }, P_RATE: { val: body.P_RATE, type: oracledb.DB_TYPE_NUMBER }, P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR }, + P_PCT_VALUE: { val: body.P_PCT_VALUE, type: oracledb.DB_TYPE_NVARCHAR }, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } }, { @@ -238,7 +240,7 @@ export class ManageFeeService { const result = await connection.execute( `BEGIN MANAGEFEE_SETUP_PKG.UPDATEBONDRATE( - :P_BONDRATESETUPID, :P_RATE, :P_EFFDATE, :P_USERID, + :P_BONDRATESETUPID, :P_RATE, :P_EFFDATE, :P_USERID, :P_PCT_VALUE, :P_CURSOR ); END;`, @@ -247,6 +249,7 @@ export class ManageFeeService { P_RATE: { val: body.P_RATE, type: oracledb.DB_TYPE_NUMBER }, P_EFFDATE: { val: body.P_EFFDATE, type: oracledb.DB_TYPE_NVARCHAR }, P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR }, + P_PCT_VALUE: { val: body.P_PCT_VALUE, type: oracledb.DB_TYPE_NVARCHAR }, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } }, { diff --git a/src/oracle/uscib-managed-sp/region/region.controller.ts b/src/oracle/uscib-managed-sp/region/region.controller.ts index 930c765..f769699 100644 --- a/src/oracle/uscib-managed-sp/region/region.controller.ts +++ b/src/oracle/uscib-managed-sp/region/region.controller.ts @@ -1,11 +1,11 @@ import { RegionService } from './region.service'; -import { Get, Post, Body, Controller, Patch, UseGuards } from '@nestjs/common'; +import { Get, Post, Body, Controller, Patch, UseGuards, Param } from '@nestjs/common'; import { ApiTags } from '@nestjs/swagger'; import { Roles } from 'src/decorators/roles.decorator'; -import { InsertRegionsDto, UpdateRegionDto } from 'src/dto/property.dto'; +import { InsertRegionsDto, SPID_DTO, UpdateRegionDto } from 'src/dto/property.dto'; import { JwtAuthGuard } from 'src/guards/jwt-auth.guard'; import { RolesGuard } from 'src/guards/roles.guard'; @@ -26,9 +26,9 @@ export class RegionController { return this.regionService.updateRegions(body); } - @Get('/GetRegions') - getRegions() { - return this.regionService.getRegions(); + @Get('/GetRegions/:P_SPID') + getRegions(@Param() param: SPID_DTO) { + return this.regionService.getRegions(param); } } diff --git a/src/oracle/uscib-managed-sp/region/region.service.ts b/src/oracle/uscib-managed-sp/region/region.service.ts index c6ea636..df766a3 100644 --- a/src/oracle/uscib-managed-sp/region/region.service.ts +++ b/src/oracle/uscib-managed-sp/region/region.service.ts @@ -5,7 +5,7 @@ import { BadRequestException } from 'src/exceptions/badRequest.exception'; import { InternalServerException } from 'src/exceptions/internalServerError.exception'; import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper'; -import { InsertRegionsDto, UpdateRegionDto } from 'src/dto/property.dto'; +import { InsertRegionsDto, SPID_DTO, UpdateRegionDto } from 'src/dto/property.dto'; @Injectable() export class RegionService { @@ -21,11 +21,12 @@ export class RegionService { const result = await connection.execute( `BEGIN - USCIB_Managed_Pkg.InsertNewRegion(:P_REGION,:P_NAME,:P_CURSOR); + USCIB_Managed_Pkg.InsertNewRegion(:P_REGION, :P_NAME, :P_SPID, :P_CURSOR); END;`, { P_REGION: { val: body.P_REGION, type: oracledb.DB_TYPE_VARCHAR }, P_NAME: { val: body.P_NAME, type: oracledb.DB_TYPE_VARCHAR }, + P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER }, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }, }, { outFormat: oracledb.OUT_FORMAT_OBJECT } @@ -94,17 +95,18 @@ export class RegionService { await closeOracleDbConnection(connection, RegionService.name) } } - - async getRegions() { + + async getRegions(body: SPID_DTO) { let connection; try { connection = await this.oracleDBService.getConnection(); const result = await connection.execute( `BEGIN - USCIB_Managed_Pkg.GetRegions(:P_CURSOR); + USCIB_Managed_Pkg.GetRegions(:P_SPID, :P_CURSOR); END;`, { + P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER }, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } }, { outFormat: oracledb.OUT_FORMAT_OBJECT }