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 12:54:49 +05:30
parent 3616b57a73
commit 115662a899
14 changed files with 165 additions and 55 deletions

View File

@ -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

View File

@ -270,9 +270,9 @@ 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 = 'policy'; break;
case "SP": ROLE = 'service-provider'; break;
case "CLIENT": ROLE = 'client'; break;
}
}

View File

@ -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 {

View File

@ -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))) { }

View File

@ -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, {

View File

@ -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(

View File

@ -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()

View File

@ -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(

View File

@ -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) { }

View File

@ -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,31 +1666,69 @@ 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);
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
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 approve_result = await this.OrderDetails({ P_ORDERID: body.P_ORDERID });
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}`
});
const accessToken = await this.payPalService.generateAccessToken();
const response = await axios({
@ -1706,11 +1743,33 @@ export class CarnetApplicationService {
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 {

View File

@ -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));
@ -58,6 +59,7 @@ export class ManageClientsService {
: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_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 }
},
{

View File

@ -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 }
},
{

View File

@ -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);
}
}

View File

@ -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 }
@ -95,16 +96,17 @@ export class RegionService {
}
}
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 }