28-08-2025 API changes, return specific value in applicationName from login API, payment data persist changes

This commit is contained in:
Kallesh B S 2025-08-28 15:03:45 +05:30
parent 3616b57a73
commit ed7603b445
16 changed files with 188 additions and 62 deletions

View File

@ -1,5 +1,9 @@
GET http://192.168.1.96:3006 GET http://192.168.1.96:3006
###
GET http://localhost:3000/oracle/GetRegions/1
### ###
GET http://localhost:3000/oracle/SearchHolder/1 GET http://localhost:3000/oracle/SearchHolder/1

View File

@ -1,7 +1,7 @@
import { Body, Controller, Get, HttpCode, Post, Put, Req, Res, UseGuards, UseInterceptors } from '@nestjs/common'; import { Body, Controller, Get, HttpCode, Post, Put, Req, Res, UseGuards, UseInterceptors } from '@nestjs/common';
import { AuthService } from './auth.service'; import { AuthService } from './auth.service';
import { ApiTags } from '@nestjs/swagger'; import { ApiTags } from '@nestjs/swagger';
import { AuthLoginDTO, SendMailDTO } from './auth.dto'; import { AuthLoginDTO, AuthLoginOnlyDTO, SendMailDTO } from './auth.dto';
import { Request, Response } from 'express'; import { Request, Response } from 'express';
import { LogoutInterceptor } from 'src/interceptors/logout.interceptor'; import { LogoutInterceptor } from 'src/interceptors/logout.interceptor';
import { RegisterGuard } from 'src/guards/register.guard'; import { RegisterGuard } from 'src/guards/register.guard';
@ -18,9 +18,9 @@ export class AuthController {
@Post('login') @Post('login')
@HttpCode(200) @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) { if (k.access_token) {
res.cookie('access_token', 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) // @UseGuards(RegisterGuard)

View File

@ -1,6 +1,7 @@
import { ApiProperty } from '@nestjs/swagger'; import { ApiProperty, IntersectionType } from '@nestjs/swagger';
import { Transform, Type } from 'class-transformer'; import { Transform, Type } from 'class-transformer';
import { IsEmail, IsEnum, IsObject, IsOptional, IsString, ValidateNested } from 'class-validator'; import { IsEmail, IsEnum, IsObject, IsOptional, IsString, ValidateNested } from 'class-validator';
import { APPLICATIONNAME_DTO } from 'src/dto/property.dto';
export class AuthLoginDTO { export class AuthLoginDTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@ -12,6 +13,8 @@ export class AuthLoginDTO {
P_PASSWORD: string; P_PASSWORD: string;
} }
export class AuthLoginOnlyDTO extends IntersectionType(AuthLoginDTO, APPLICATIONNAME_DTO) { }
export enum MailTypeDTO { export enum MailTypeDTO {
REGISTER_CLIENT = "REGISTER_CLIENT", REGISTER_CLIENT = "REGISTER_CLIENT",
REGISTER_SP = "REGISTER_SP", REGISTER_SP = "REGISTER_SP",

View File

@ -245,7 +245,7 @@ export class AuthService {
return verified; return verified;
} }
async loginUser(username: string, password: string, req: Request): Promise<any> { async loginUser(username: string, password: string, applicationName: string, req: Request): Promise<any> {
const access_token = req.cookies?.access_token; const access_token = req.cookies?.access_token;
const refresh_token = req.cookies?.refresh_token; const refresh_token = req.cookies?.refresh_token;
@ -270,12 +270,22 @@ export class AuthService {
if (Array.isArray(emailVerifyResponse) && !emailVerifyResponse[0].ERRORMESG) { if (Array.isArray(emailVerifyResponse) && !emailVerifyResponse[0].ERRORMESG) {
switch (emailVerifyResponse[0].SOURCE) { switch (emailVerifyResponse[0].SOURCE) {
case "USCIB": ROLE = 'POLICY'; break; case "USCIB": ROLE = 'ua'; break;
case "SP": ROLE = 'SP'; break; case "SP": ROLE = 'sa'; break;
case "CLIENT": ROLE = 'CLIENT'; 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') { // if (ROLE === 'ua' && req.headers.origin !== 'https://policy.alphaomegainfosys.com') {
// throw new BadRequestException("Invalid username or password") // throw new BadRequestException("Invalid username or password")
// } // }
@ -307,10 +317,13 @@ export class AuthService {
headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
}); });
let k = { ...response.data, email: username, applicationName: ROLE }; let k = { ...response.data, email: username };
return k; return k;
} catch (error) { } catch (error) {
if (error instanceof BadRequestException || error instanceof UnauthorizedException) {
throw error
}
throw new BadRequestException('Invalid username or password'); throw new BadRequestException('Invalid username or password');
} }
} }

View File

@ -43,7 +43,7 @@ export class ORDERID_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString() @IsString()
@IsDefined({ message: 'Property P_ORDERID is required' }) @IsDefined({ message: 'Property P_ORDERID is required' })
P_ORDERID: string; P_ORDERID: string | null;
} }
export class PRICE_DTO { export class PRICE_DTO {

View File

@ -71,8 +71,8 @@ export class SaveExtensionApplicationDTO extends (IntersectionType(
export class PrintCarnetDTO extends (IntersectionType(SPID_DTO, HEADERID_DTO, PRINTGL_DTO)) { } export class PrintCarnetDTO extends (IntersectionType(SPID_DTO, HEADERID_DTO, PRINTGL_DTO)) { }
export class PrintGLDTO extends (IntersectionType(SPID_DTO, HEADERID_DTO)) { } export class PrintGLDTO extends (IntersectionType(SPID_DTO, HEADERID_DTO)) { }
export class CapturePaymentDTO extends (IntersectionType(ORDERID_DTO)) { } export class CapturePaymentDTO extends (IntersectionType(ORDERID_DTO, APPLICATIONNAME_DTO, PRICE_DTO, USERID_DTO)) { }
export class InitiatePaymentDTO extends (IntersectionType(PRICE_DTO, DESCRIPTION_DTO)) { } export class InitiatePaymentDTO extends (IntersectionType(APPLICATIONNAME_DTO, PRICE_DTO, DESCRIPTION_DTO, USERID_DTO)) { }
export class GetOrderDetailsDTO extends (IntersectionType(ORDERID_DTO)) { } export class GetOrderDetailsDTO extends (IntersectionType(ORDERID_DTO)) { }
export class GetPaymentHistoryDTO extends (IntersectionType(APPLICATIONNAME_DTO, USERID_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))) { } export class SaveHistoryDTO extends (IntersectionType(APPLICATIONNAME_DTO, ORDERID_DTO, PAYMENTAMOUNT_DTO, PAYMENTSTATUS_DTO, USERID_DTO, PartialType(PAYMENTERROR_DTO))) { }

View File

@ -60,6 +60,13 @@ export class CLIENTNAME_DTO {
P_CLIENTNAME: string; 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 { export class REVENUELOCATION_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@Length(0, 2, { @Length(0, 2, {

View File

@ -9,7 +9,7 @@ import {
import { import {
CLIENT_CONTACTID_DTO, CLIENTID_DTO, CLIENTLOCADDRESSTABLE_DTO, CLIENTLOCATIONID_DTO, 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"; } from "./manage-clients-property.dto";
import { import {
@ -34,7 +34,8 @@ export class CreateClientDataDTO extends IntersectionType(
PartialType(COUNTRY_DTO), PartialType(COUNTRY_DTO),
ISSUING_REGION_DTO, ISSUING_REGION_DTO,
REVENUELOCATION_DTO, REVENUELOCATION_DTO,
USERID_DTO USERID_DTO,
INDUSTRY_TYPE_DTO
) { } ) { }
@ -49,7 +50,8 @@ export class UpdateClientDTO extends IntersectionType(
ZIP_DTO, ZIP_DTO,
COUNTRY_DTO, COUNTRY_DTO,
REVENUELOCATION_DTO, REVENUELOCATION_DTO,
USERID_DTO USERID_DTO,
INDUSTRY_TYPE_DTO
) { } ) { }
export class UpdateClientContactsDTO extends IntersectionType( export class UpdateClientContactsDTO extends IntersectionType(

View File

@ -1,6 +1,13 @@
import { ApiProperty } from "@nestjs/swagger"; import { ApiProperty } from "@nestjs/swagger";
import { IsNumber, IsString } from "class-validator"; import { IsNumber, IsString } from "class-validator";
export class PCT_VALUE_DTO {
@ApiProperty({ required: true })
@IsString()
P_PCT_VALUE: string;
}
export class EFFDATE_DTO { export class EFFDATE_DTO {
@ApiProperty({ required: true }) @ApiProperty({ required: true })
@IsString() @IsString()

View File

@ -6,7 +6,7 @@ import { HOLDERTYPE_DTO, USCIBMEMBERFLAG_DTO } from "../manage-holders/manage-ho
import { import {
BASICFEESETUPID_DTO, BONDRATESETUPID_DTO, CARGORATESETUPID_DTO, CFFEESETUPID_DTO, BASICFEESETUPID_DTO, BONDRATESETUPID_DTO, CARGORATESETUPID_DTO, CFFEESETUPID_DTO,
COMMRATE_DTO, CSFEESETUPID_DTO, CUSTOMERTYPE_DTO, EFFDATE_DTO, EFFEESETUPID_DTO, ENDSETS_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 STARTSETS_DTO, STARTTIME_DTO, TIMEZONE_DTO
} from "./manage-fee-property.dto"; } from "./manage-fee-property.dto";
@ -36,7 +36,8 @@ export class CreateBondRateDTO extends IntersectionType(
SPCLCOUNTRY_DTO, SPCLCOUNTRY_DTO,
EFFDATE_DTO, EFFDATE_DTO,
RATE_DTO, RATE_DTO,
USERID_DTO USERID_DTO,
PCT_VALUE_DTO
) { } ) { }
export class CreateCargoRateDTO extends IntersectionType( export class CreateCargoRateDTO extends IntersectionType(
@ -100,7 +101,8 @@ export class UpdateBondRateDTO extends IntersectionType(
BONDRATESETUPID_DTO, BONDRATESETUPID_DTO,
RATE_DTO, RATE_DTO,
EFFDATE_DTO, EFFDATE_DTO,
USERID_DTO USERID_DTO,
PCT_VALUE_DTO
) { } ) { }
export class UpdateCargoRateDTO extends IntersectionType( export class UpdateCargoRateDTO extends IntersectionType(

View File

@ -1,7 +1,7 @@
import { IntersectionType } from '@nestjs/swagger'; import { IntersectionType } from '@nestjs/swagger';
import { REGION_CODE_DTO, REGIONID_DTO } from './region-property.dto'; 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) { } export class UpdateRegionDto extends IntersectionType(REGIONID_DTO, NAME_DTO) { }

View File

@ -1605,12 +1605,11 @@ export class CarnetApplicationService {
return amount.toFixed(2); // Always returns a string with 2 decimal places return amount.toFixed(2); // Always returns a string with 2 decimal places
} }
async InitiatePayment(body: InitiatePaymentDTO) { async InitiatePayment(body: InitiatePaymentDTO) {
// console.log(body); // console.log(body);
const quantity = 1; const quantity = 1;
let orderID: string | null = null
const formattedAmount = await this.formatAmount(body.P_PRICE * quantity); 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 headers:', response.headers);
// console.log('PayPal create order response data:', response.data); // console.log('PayPal create order response data:', response.data);
return { const save_result = await this.SaveHistory(
id: response.data.id, href: response?.data?.links?.find(obj => obj.rel === 'approve')?.href {
}; 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 }; // return { id: response.data.id };
} catch (error) { } 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(); throw new InternalServerException();
// return {
// error: true,
// message: 'Failed to create PayPal order',
// details: error.response?.data || error.message || error
// };
} }
} }
async CapturePayment(body: CapturePaymentDTO) { async CapturePayment(body: CapturePaymentDTO) {
try { try {
const accessToken = await this.payPalService.generateAccessToken();
const response = await axios({ const approve_result = await this.OrderDetails({ P_ORDERID: body.P_ORDERID });
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]; if (approve_result.data.id === body.P_ORDERID
// console.log(JSON.stringify(response?.data)); && 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 { const accessToken = await this.payPalService.generateAccessToken();
statusCode: 200,
message: "Payment successful", const response = await axios({
amount: `${capture?.amount?.value} ${capture?.amount?.currency_code}`, 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) { } catch (error: any) {
const status = error.response?.status || 500; const status = error.response?.status || 500;
@ -1724,9 +1783,26 @@ export class CarnetApplicationService {
}); });
if (status === 404) { 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") 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(); throw new InternalServerException();
} }
} }
@ -1837,6 +1913,7 @@ export class CarnetApplicationService {
await closeOracleDbConnection(connection, CarnetApplicationService.name) await closeOracleDbConnection(connection, CarnetApplicationService.name)
} }
} }
async SaveHistory(body: SaveHistoryDTO) { async SaveHistory(body: SaveHistoryDTO) {
let connection; let connection;
try { try {

View File

@ -39,6 +39,7 @@ export class ManageClientsService {
P_ISSUINGREGION: null, P_ISSUINGREGION: null,
P_REVENUELOCATION: null, P_REVENUELOCATION: null,
P_USERID: null, P_USERID: null,
P_INDUSTRYTYPE: null
}; };
const reqBody = JSON.parse(JSON.stringify(body)); const reqBody = JSON.parse(JSON.stringify(body));
@ -57,7 +58,8 @@ export class ManageClientsService {
MANAGEPREPARER_PKG.CreateClientData( MANAGEPREPARER_PKG.CreateClientData(
:P_SPID, :P_CLIENTNAME, :P_LOOKUPCODE, :P_ADDRESS1, :P_SPID, :P_CLIENTNAME, :P_LOOKUPCODE, :P_ADDRESS1,
:P_ADDRESS2, :P_CITY, :P_STATE, :P_ZIP, :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 :P_CLIENTCURSOR
); );
END;`, END;`,
@ -74,6 +76,7 @@ export class ManageClientsService {
P_ISSUINGREGION: { val: finalBody.P_ISSUINGREGION, type: oracledb.DB_TYPE_NVARCHAR }, P_ISSUINGREGION: { val: finalBody.P_ISSUINGREGION, type: oracledb.DB_TYPE_NVARCHAR },
P_REVENUELOCATION: { val: finalBody.P_REVENUELOCATION, 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_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 } P_CLIENTCURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ {
@ -118,6 +121,7 @@ export class ManageClientsService {
P_COUNTRY: null, P_COUNTRY: null,
P_REVENUELOCATION: null, P_REVENUELOCATION: null,
P_USERID: null, P_USERID: null,
P_INDUSTRYTYPE: null
}; };
const reqBody = JSON.parse(JSON.stringify(body)); const reqBody = JSON.parse(JSON.stringify(body));
@ -135,7 +139,8 @@ export class ManageClientsService {
MANAGEPREPARER_PKG.UpdateClient( MANAGEPREPARER_PKG.UpdateClient(
:P_SPID, :P_CLIENTID, :P_PREPARERNAME, :P_ADDRESS1, :P_SPID, :P_CLIENTID, :P_PREPARERNAME, :P_ADDRESS1,
:P_ADDRESS2, :P_CITY, :P_STATE, :P_ZIP, :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;`, END;`,
{ {
@ -150,6 +155,7 @@ export class ManageClientsService {
P_COUNTRY: { val: finalBody.P_COUNTRY, type: oracledb.DB_TYPE_NVARCHAR }, P_COUNTRY: { val: finalBody.P_COUNTRY, type: oracledb.DB_TYPE_NVARCHAR },
P_REVENUELOCATION: { val: finalBody.P_REVENUELOCATION, 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_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 } P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ {

View File

@ -195,6 +195,7 @@ export class ManageFeeService {
MANAGEFEE_SETUP_PKG.CREATEBONDRATE( MANAGEFEE_SETUP_PKG.CREATEBONDRATE(
:P_SPID, :P_HOLDERTYPE, :P_USCIBMEMBERFLAG, :P_SPCLCOMMODITY, :P_SPID, :P_HOLDERTYPE, :P_USCIBMEMBERFLAG, :P_SPCLCOMMODITY,
:P_SPCLCOUNTRY, :P_EFFDATE, :P_RATE, :P_USERID, :P_SPCLCOUNTRY, :P_EFFDATE, :P_RATE, :P_USERID,
:P_PCT_VALUE,
:P_CURSOR :P_CURSOR
); );
END;`, END;`,
@ -207,6 +208,7 @@ export class ManageFeeService {
P_EFFDATE: { val: body.P_EFFDATE, type: oracledb.DB_TYPE_VARCHAR }, P_EFFDATE: { val: body.P_EFFDATE, type: oracledb.DB_TYPE_VARCHAR },
P_RATE: { val: body.P_RATE, type: oracledb.DB_TYPE_NUMBER }, P_RATE: { val: body.P_RATE, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR }, 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 } P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ {
@ -238,7 +240,7 @@ export class ManageFeeService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
MANAGEFEE_SETUP_PKG.UPDATEBONDRATE( 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 :P_CURSOR
); );
END;`, END;`,
@ -247,6 +249,7 @@ export class ManageFeeService {
P_RATE: { val: body.P_RATE, type: oracledb.DB_TYPE_NUMBER }, P_RATE: { val: body.P_RATE, type: oracledb.DB_TYPE_NUMBER },
P_EFFDATE: { val: body.P_EFFDATE, type: oracledb.DB_TYPE_NVARCHAR }, P_EFFDATE: { val: body.P_EFFDATE, type: oracledb.DB_TYPE_NVARCHAR },
P_USERID: { val: body.P_USERID, 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 } P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ {

View File

@ -1,11 +1,11 @@
import { RegionService } from './region.service'; 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 { ApiTags } from '@nestjs/swagger';
import { Roles } from 'src/decorators/roles.decorator'; 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 { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
import { RolesGuard } from 'src/guards/roles.guard'; import { RolesGuard } from 'src/guards/roles.guard';
@ -26,9 +26,9 @@ export class RegionController {
return this.regionService.updateRegions(body); return this.regionService.updateRegions(body);
} }
@Get('/GetRegions') @Get('/GetRegions/:P_SPID')
getRegions() { getRegions(@Param() param: SPID_DTO) {
return this.regionService.getRegions(); return this.regionService.getRegions(param);
} }
} }

View File

@ -5,7 +5,7 @@ import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception'; import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper'; 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() @Injectable()
export class RegionService { export class RegionService {
@ -21,11 +21,12 @@ export class RegionService {
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.InsertNewRegion(:P_REGION,:P_NAME,:P_CURSOR); USCIB_Managed_Pkg.InsertNewRegion(:P_REGION, :P_NAME, :P_SPID, :P_CURSOR);
END;`, END;`,
{ {
P_REGION: { val: body.P_REGION, type: oracledb.DB_TYPE_VARCHAR }, P_REGION: { val: body.P_REGION, type: oracledb.DB_TYPE_VARCHAR },
P_NAME: { val: body.P_NAME, 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 }, P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT } { outFormat: oracledb.OUT_FORMAT_OBJECT }
@ -94,17 +95,18 @@ export class RegionService {
await closeOracleDbConnection(connection, RegionService.name) await closeOracleDbConnection(connection, RegionService.name)
} }
} }
async getRegions() { async getRegions(body: SPID_DTO) {
let connection; let connection;
try { try {
connection = await this.oracleDBService.getConnection(); connection = await this.oracleDBService.getConnection();
const result = await connection.execute( const result = await connection.execute(
`BEGIN `BEGIN
USCIB_Managed_Pkg.GetRegions(:P_CURSOR); USCIB_Managed_Pkg.GetRegions(:P_SPID, :P_CURSOR);
END;`, END;`,
{ {
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT } P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
}, },
{ outFormat: oracledb.OUT_FORMAT_OBJECT } { outFormat: oracledb.OUT_FORMAT_OBJECT }