Compare commits

...

2 Commits

Author SHA1 Message Date
Kallesh B S
a056c415be Merge updated code for GET manage-fee into current working flow 2025-06-09 17:00:59 +05:30
Kallesh B S
b07e607a48 temp mod 2025-06-07 14:42:21 +05:30
12 changed files with 695 additions and 2975 deletions

View File

@ -73,6 +73,7 @@ export class UpdateHolderContactDTO extends IntersectionType(
USERID_DTO
) { }
export class GetHolderDTO extends IntersectionType(
SPID_DTO,
HOLDERID_DTO

View File

@ -2,10 +2,9 @@ import { Injectable, Logger } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb'
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { closeOracleDbConnection, fetchCursor, handleError, setEmptyStringsToNull } from 'src/utils/helper';
import {
COUNTRYTABLE_DTO, COUNTRYTABLE_ROW_DTO, GLTABLE_DTO, GLTABLE_ROW_DTO,
CarnetProcessingCenterDTO, SaveCarnetApplicationDTO, TransmitApplicationtoProcessDTO,
CreateApplicationDTO,
UpdateExpGoodsAuthRepDTO,
@ -62,15 +61,6 @@ export class CarnetApplicationService {
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
@ -198,8 +188,7 @@ export class CarnetApplicationService {
P_AUTOFLAG: { val: body.P_AUTOFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_HORSEFLAG: { val: body.P_HORSEFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_AUTHREP: { val: body.P_AUTHREP, type: oracledb.DB_TYPE_VARCHAR },
P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' },
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USSETS: { val: body.P_USSETS, type: oracledb.DB_TYPE_NUMBER },
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: 'CARNETSYS.CARNETCOUNTRYTABLE' },
P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },

View File

@ -8,7 +8,6 @@ import { HomePageService } from './home-page.service';
import { ApiTags } from '@nestjs/swagger';
import {
EMAIL_DTO,
GetCarnetDetailsbyCarnetStatusDTO,
SPID_DTO,
USERID_DTO

View File

@ -1,363 +0,0 @@
import { ApiProperty } from '@nestjs/swagger';
import { Type } from 'class-transformer';
import {
IsArray,
IsDefined,
IsInt,
IsNumber,
IsOptional,
IsString,
Length,
Max,
Min,
ValidateNested,
} from 'class-validator';
// export class p_gltableDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property ItemNo must not exceed 999999999' })
// @Min(0, { message: 'Property ItemNo must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property ItemNo must be a number' })
// @IsDefined({ message: 'Property ItemNo is required' })
// ItemNo: number;
// @ApiProperty({ required: true })
// @Length(0, 1000, {
// message: 'Property ItemDescription must be between 1 and 1000 characters',
// })
// @IsString({ message: 'Property ItemDescription should be string' })
// @IsDefined({ message: 'Property ItemDescription is required' })
// ItemDescription: string;
// @ApiProperty({ required: true })
// @IsNumber({}, { message: 'Property ItemValue should be number' })
// @IsDefined({ message: 'Property ItemValue is required' })
// ItemValue: number;
// @ApiProperty({ required: true })
// @Max(99999999999, {
// message: 'Property Noofpieces must not exceed 99999999999',
// })
// @Min(0, { message: 'Property Noofpieces must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property Noofpieces must be a number' })
// @IsDefined({ message: 'Property Noofpieces is required' })
// Noofpieces: number;
// @ApiProperty({ required: false })
// @IsNumber()
// @IsOptional()
// ItemWeight?: number;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property ItemWeightUOM must be between 0 and 10 characters',
// })
// @IsString()
// @IsOptional()
// ItemWeightUOM?: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property GoodsOriginCountry must be between 0 and 2 characters',
// })
// @IsString({ message: 'Property GoodsOriginCountry should be string' })
// @IsDefined({ message: 'Property name is required' })
// GoodsOriginCountry: string;
// }
// export class p_countrytableDTO {
// @ApiProperty({ required: true })
// @Length(0, 1, {
// message: 'Property VisitTransitInd must be 0 to 1 characters',
// })
// @IsString()
// @IsDefined({ message: 'Property VisitTransitInd is required' })
// VisitTransitInd: string;
// @ApiProperty({ required: true })
// @Length(0, 2, {
// message: 'Property CountryCode must be between 0 to 2 characters',
// })
// @IsString()
// @IsDefined({ message: 'Property CountryCode is required' })
// CountryCode: string;
// @ApiProperty({ required: true })
// @Max(999, { message: 'Property NoOfTimesEntLeave must not exceed 999' })
// @Min(0, { message: 'Property NoOfTimesEntLeave must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property NoOfTimesEntLeave must be a number' })
// @IsDefined({ message: 'Property NoOfTimesEntLeave is required' })
// NoOfTimesEntLeave: number;
// }
// export class SaveCarnetApplicationDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_clientid must not exceed 999999999' })
// @Min(0, { message: 'Property p_clientid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_clientid must be a number' })
// p_clientid: number;
// @ApiProperty({ required: true })
// @Max(999999999, {
// message: 'Property p_locationid must not exceed 999999999',
// })
// @Min(0, { message: 'Property p_locationid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_locationid must be a number' })
// p_locationid: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_userid must be between 0 to 50 characters',
// })
// @IsString()
// p_userid: string;
// @ApiProperty({ required: false })
// @Max(999999999, { message: 'Property p_headerid must not exceed 999999999' })
// @Min(0, { message: 'Property p_headerid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_headerid must be a number' })
// @IsOptional()
// p_headerid?: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_applicationname must be between 0 to 50 characters',
// })
// @IsString()
// p_applicationname: string;
// @ApiProperty({ required: false })
// @Max(999999999, { message: 'Property p_holderid must not exceed 999999999' })
// @Min(0, { message: 'Property p_holderid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_holderid must be a number' })
// @IsOptional()
// p_holderid?: number;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message:
// 'Property p_commercialsampleflag must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_commercialsampleflag?: string;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message: 'Property p_profequipmentflag must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_profequipmentflag?: string;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message: 'Property p_exhibitionsfairflag must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_exhibitionsfairflag?: string;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message: 'Property p_autoflag must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_autoflag?: string;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message: 'Property p_horseflag must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_horseflag?: string;
// @ApiProperty({ required: false })
// @Length(0, 200, {
// message: 'Property p_authrep must be between 0 to 200 characters',
// })
// @IsString()
// @IsOptional()
// p_authrep?: string;
// @ApiProperty({ required: false, type: () => [p_gltableDTO] })
// @Type(() => p_gltableDTO)
// @ValidateNested({ each: true })
// @IsArray()
// // @ArrayNotEmpty({message:"Property gltable should not be empty"})
// @IsOptional()
// p_gltable?: p_gltableDTO[];
// @ApiProperty({ required: false })
// @Max(99999, { message: 'Property p_ussets must not exceed 99999' })
// @Min(0, { message: 'Property p_ussets must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_ussets must be a number' })
// @IsOptional()
// p_ussets?: number;
// @ApiProperty({ required: false, type: () => [p_countrytableDTO] })
// @ValidateNested({ each: true })
// @IsArray()
// @Type(() => p_countrytableDTO)
// @IsOptional()
// p_countrytable?: p_countrytableDTO[];
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_shiptotype must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_shiptotype?: string;
// @ApiProperty({ required: false })
// @Max(999999999, {
// message: 'Property p_shipaddrid must not exceed 999999999',
// })
// @Min(0, { message: 'Property p_shipaddrid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_shipaddrid must be a number' })
// @IsOptional()
// p_shipaddrid?: number;
// @ApiProperty({ required: false })
// @Length(0, 1, {
// message: 'Property p_formofsecurity must be between 0 to 1 characters',
// })
// @IsString()
// @IsOptional()
// p_formofsecurity?: string;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_insprotection must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_insprotection?: string;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_ldiprotection must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_ldiprotection?: string;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_deliverytype must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_deliverytype?: string;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_deliverymethod must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_deliverymethod?: string;
// @ApiProperty({ required: false })
// @Length(0, 10, {
// message: 'Property p_paymentmethod must be between 0 to 10 characters',
// })
// @IsString()
// @IsOptional()
// p_paymentmethod?: string;
// @ApiProperty({ required: false })
// @Length(0, 20, {
// message: 'Property p_custcourierno must be between 0 to 20 characters',
// })
// @IsString()
// @IsOptional()
// p_custcourierno?: string;
// @ApiProperty({ required: false })
// @Length(0, 20, {
// message: 'Property p_refno must be between 0 to 20 characters',
// })
// @IsString()
// @IsOptional()
// p_refno?: string;
// @ApiProperty({ required: false })
// @Length(0, 2000, {
// message: 'Property p_notes must be between 0 to 2000 characters',
// })
// @IsString()
// @IsOptional()
// p_notes?: string;
// }
// export class TransmitApplicationtoProcessDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_userid must be between 0 to 50 characters',
// })
// @IsString()
// @IsDefined({ message: 'Property p_userid is required' })
// p_userid: string;
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_headerid must be a number' })
// @IsDefined({ message: 'Property p_headerid is required' })
// p_headerid: number;
// }
// export class GetCarnetDetailsbyCarnetStatusDTO {
// @ApiProperty({ required: true })
// @Max(999999999, { message: 'Property p_spid must not exceed 999999999' })
// @Min(0, { message: 'Property p_spid must be at least 0 or more' })
// @IsInt()
// @IsNumber({}, { message: 'Property p_spid must be a number' })
// @IsDefined({ message: 'Property p_spid is required' })
// p_spid: number;
// @ApiProperty({ required: true })
// @Length(0, 50, {
// message: 'Property p_userid must be between 0 to 50 characters',
// })
// @IsString({ message: 'Property p_userid must be string' })
// @IsDefined({ message: 'Property p_userid is required' })
// p_userid: string;
// @ApiProperty({ required: true })
// @Length(0, 20, {
// message: 'Property p_CarnetStatus must be between 0 to 20 characters',
// })
// @IsString()
// @IsDefined({ message: 'Property p_CarnetStatus is required' })
// p_CarnetStatus: string;
// }

View File

@ -1,890 +1,171 @@
import { Injectable } from '@nestjs/common';
import { Injectable, Logger } from '@nestjs/common';
import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb';
import {
EMAIL_DTO,
GetCarnetDetailsbyCarnetStatusDTO,
SPID_DTO,
USERID_DTO
} from 'src/dto/property.dto';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
@Injectable()
export class HomePageService {
private readonly logger = new Logger(HomePageService.name);
constructor(private readonly oracleDBService: OracleDBService) { }
async GetHomePageData(params: SPID_DTO) {
let connection;
let p_basic_details = [];
let p_contacts = [];
let p_sequence = [];
let p_fees_comm = [];
let p_bf_fee = [];
let p_cf_Fee = [];
let p_cont_sheet_fee = [];
let p_ef_fee = [];
let p_security_deposit = [];
let p_param = [];
let p_region = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
const result = await connection.execute(
`BEGIN
USERLOGIN_PKG.GetHomePageData(
:P_SPID,
:p_basic_details_cur,
:p_contacts_cur,
:p_sequence_cur,
:p_fees_comm_cur,
:p_bf_fee_cur,
:p_cf_Fee_cur,
:p_cont_sheet_fee_cur,
:p_ef_fee_cur,
:p_security_deposit_cur,
:p_param_cur,
:p_region_cur
USERLOGIN_PKG.GETHOMEPAGEDATA(
:P_SPID, :P_BASIC_DETAILS_CUR, :P_CONTACTS_CUR, :P_SEQUENCE_CUR,
:P_FEES_COMM_CUR, :P_BF_FEE_CUR, :P_CF_FEE_CUR, :P_CONT_SHEET_FEE_CUR,
:P_EF_FEE_CUR, :P_SECURITY_DEPOSIT_CUR, :P_PARAM_CUR, :P_REGION_CUR
);
END;`,
END;`,
{
P_SPID: {
val: params.P_SPID,
type: oracledb.DB_TYPE_NUMBER,
},
p_basic_details_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_contacts_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_sequence_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_fees_comm_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_bf_fee_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_cf_Fee_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_cont_sheet_fee_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_ef_fee_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_security_deposit_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_param_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
p_region_cur: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
P_SPID: { val: params.P_SPID, type: oracledb.DB_TYPE_NUMBER },
p_basic_details_cur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
p_contacts_cur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
p_sequence_cur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
p_fees_comm_cur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
p_bf_fee_cur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
p_cf_Fee_cur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
p_cont_sheet_fee_cur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
p_ef_fee_cur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
p_security_deposit_cur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
p_param_cur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT },
p_region_cur: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
if (result.outBinds && result.outBinds.p_basic_details_cur) {
const cursor = result.outBinds.p_basic_details_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_basic_details = p_basic_details.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_contacts_cur) {
const cursor = result.outBinds.p_contacts_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_contacts = p_contacts.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_sequence_cur) {
const cursor = result.outBinds.p_sequence_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_sequence = p_sequence.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_fees_comm_cur) {
const cursor = result.outBinds.p_fees_comm_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_fees_comm = p_fees_comm.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_bf_fee_cur) {
const cursor = result.outBinds.p_bf_fee_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_bf_fee = p_bf_fee.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_cf_Fee_cur) {
const cursor = result.outBinds.p_cf_Fee_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_cf_Fee = p_cf_Fee.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_cont_sheet_fee_cur) {
const cursor = result.outBinds.p_cont_sheet_fee_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_cont_sheet_fee = p_cont_sheet_fee.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_ef_fee_cur) {
const cursor = result.outBinds.p_ef_fee_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_ef_fee = p_ef_fee.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_security_deposit_cur) {
const cursor = result.outBinds.p_security_deposit_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_security_deposit = p_security_deposit.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_param_cur) {
const cursor = result.outBinds.p_param_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_param = p_param.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
}
if (result.outBinds && result.outBinds.p_region_cur) {
const cursor = result.outBinds.p_region_cur;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
p_region = p_region.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
const outBinds: any = result.outBinds;
if (
!outBinds?.p_basic_details_cur ||
!outBinds?.p_contacts_cur ||
!outBinds?.p_sequence_cur ||
!outBinds?.p_fees_comm_cur ||
!outBinds?.p_bf_fee_cur ||
!outBinds?.p_cf_Fee_cur ||
!outBinds?.p_cont_sheet_fee_cur ||
!outBinds?.p_ef_fee_cur ||
!outBinds?.p_security_deposit_cur ||
!outBinds?.p_param_cur ||
!outBinds?.p_region_cur
) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const tableData = {
p_basic_details,
p_contacts,
p_sequence,
p_fees_comm,
p_bf_fee,
p_cf_Fee,
p_cont_sheet_fee,
p_ef_fee,
p_security_deposit,
p_param,
p_region,
p_basic_details: await fetchCursor(outBinds.p_basic_details_cur, HomePageService.name),
p_contacts: await fetchCursor(outBinds.p_contacts_cur, HomePageService.name),
p_sequence: await fetchCursor(outBinds.p_sequence_cur, HomePageService.name),
p_fees_comm: await fetchCursor(outBinds.p_fees_comm_cur, HomePageService.name),
p_bf_fee: await fetchCursor(outBinds.p_bf_fee_cur, HomePageService.name),
p_cf_Fee: await fetchCursor(outBinds.p_cf_Fee_cur, HomePageService.name),
p_cont_sheet_fee: await fetchCursor(outBinds.p_cont_sheet_fee_cur, HomePageService.name),
p_ef_fee: await fetchCursor(outBinds.p_ef_fee_cur, HomePageService.name),
p_security_deposit: await fetchCursor(outBinds.p_security_deposit_cur, HomePageService.name),
p_param: await fetchCursor(outBinds.p_param_cur, HomePageService.name),
p_region: await fetchCursor(outBinds.p_region_cur, HomePageService.name),
};
const output = {};
for (const key in tableData) {
// console.log(key);
output[key] = tableData[key].map((obj) => {
const newObj = { ...obj };
for (const innerKey in obj) {
if (key === 'p_fees_comm') {
if (innerKey.includes(' ')) {
// Check if the key has a space
const newKey = innerKey.replace(/ /g, '_').toUpperCase(); // Replace spaces and convert to uppercase
newObj[newKey] = obj[innerKey]; // Add the new key
delete newObj[innerKey]; // Remove the old key
}
}
}
return newObj;
});
}
return output;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
console.error('Failed to close connection:', closeErr);
}
}
return tableData;
} catch (error) {
handleError(error, HomePageService.name)
} finally {
await closeOracleDbConnection(connection, HomePageService.name)
}
}
async GetCarnetSummaryData(body: USERID_DTO) {
let connection;
let rows: any = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
const result = await connection.execute(
`BEGIN
USERLOGIN_PKG.GetCarnetSummaryData(:P_USERID,:P_CURSOR);
END;`,
{
P_USERID: {
val: body.P_USERID,
type: oracledb.DB_TYPE_NVARCHAR,
},
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
},
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
if (result.outBinds && result.outBinds.P_CURSOR) {
const cursor = result.outBinds.P_CURSOR;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
rows = rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
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.");
}
rows = rows.map((obj) => {
// Create a new object to hold the modified keys
const newObj = {};
const fres: any = await fetchCursor(outBinds.P_CURSOR, HomePageService.name);
// Iterate over the keys of the current object
for (const key in obj) {
// Replace spaces with underscores in the key
const newKey = key.replace(/ /g, '_');
newObj[newKey] = obj[key];
}
return newObj;
});
rows = rows.reduce((acc, curr) => {
// Find if the current item already exists in the accumulator
const existing = acc.find(
(item) =>
item['Service_Provider_Name'] === curr['Service_Provider_Name'] &&
item.SPID === curr.SPID,
);
if (existing) {
// If it exists, push the current "cs" and "c c" values into the arrays
existing.CARNETSTATUS.push(curr.CARNETSTATUS);
existing['Carnet_Count'].push(curr['Carnet_Count']);
} else {
// If it doesn't exist, create a new entry
acc.push({
Service_Provider_Name: curr['Service_Provider_Name'],
SPID: curr.SPID,
CARNETSTATUS: [curr.CARNETSTATUS],
Carnet_Count: [curr['Carnet_Count']],
});
}
return acc;
}, []);
return rows;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
console.error('Failed to close connection:', closeErr);
}
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return fres;
} catch (error) {
handleError(error, HomePageService.name)
} finally {
await closeOracleDbConnection(connection, HomePageService.name)
}
}
// NOTE : this has been moved to carent-application module
// async SaveCarnetApplication(body: SaveCarnetApplicationDTO) {
// const newBody = {
// p_headerid: null,
// p_holderid: null,
// p_commercialsampleflag: null,
// p_profequipmentflag: null,
// p_exhibitionsfairflag: null,
// p_autoflag: null,
// p_horseflag: null,
// p_authrep: null,
// p_gltable: null,
// p_ussets: null,
// p_countrytable: null,
// p_shiptotype: null,
// p_shipaddrid: null,
// p_formofsecurity: null,
// p_insprotection: null,
// p_ldiprotection: null,
// p_deliverytype: null,
// p_deliverymethod: null,
// p_paymentmethod: null,
// p_custcourierno: null,
// p_refno: null,
// p_notes: null,
// };
// const reqBody = JSON.parse(JSON.stringify(body));
// function setEmptyStringsToNull(obj) {
// Object.keys(obj).forEach((key) => {
// if (typeof obj[key] === 'object' && obj[key] !== null) {
// setEmptyStringsToNull(obj[key]);
// } else if (obj[key] === '') {
// obj[key] = null;
// }
// });
// }
// setEmptyStringsToNull(reqBody);
// const finalBody = { ...newBody, ...reqBody };
// let connection;
// let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new Error('No DB Connected');
// }
// console.log('here ------------ 1');
// // const res = await connection.execute(`SELECT CARNETSYS.GLARRAY(1, 'Description for itemno 1', 2500, 20, 12, 'LBS', 'US') FROM dual`);
// async function createGLArrayInstance(
// connection,
// itemNo,
// itemDescription,
// itemValue,
// noOfPieces,
// itemWeight,
// itemWeightUOM,
// goodsOriginCountry,
// ) {
// const result = await connection.execute(
// `SELECT CARNETSYS.GLARRAY(:itemNo, :itemDescription, :itemValue, :noOfPieces, :itemWeight, :itemWeightUOM, :goodsOriginCountry) FROM dual`,
// {
// itemNo,
// itemDescription,
// itemValue,
// noOfPieces,
// itemWeight,
// itemWeightUOM,
// goodsOriginCountry,
// },
// );
// return result.rows[0][0]; // Access the first row and first column to get the GLARRAY instance
// }
// async function createCarnetCountryArrayInstance(
// connection,
// visitTransitInd,
// countryCode,
// noOfTimesEntLeave,
// ) {
// const result = await connection.execute(
// `SELECT CARNETSYS.CARNETCOUNTRYARRAY(:visitTransitInd, :countryCode, :noOfTimesEntLeave) FROM dual`,
// {
// visitTransitInd,
// countryCode,
// noOfTimesEntLeave,
// },
// );
// return result.rows[0][0]; // Access the first row and first column to get the CARNETCOUNTRYARRAY instance
// }
// // let res = await connection.execute(`SELECT owner, type_name FROM all_types WHERE type_name IN ('GLARRAY', 'GLTABLE')`)
// // let GLARRAY = await connection.getDbObjectClass('CARNETSYS.GLARRAY');
// const GLTABLE = await connection.getDbObjectClass('CARNETSYS.GLTABLE');
// // const CARNETCOUNTRYARRAY = await connection.getDbObjectClass('CARNETSYS.CARNETCOUNTRYARRAY');
// const CARNETCOUNTRYTABLE = await connection.getDbObjectClass(
// 'CARNETSYS.CARNETCOUNTRYTABLE',
// );
// // Check if GLTABLE is a constructor
// if (typeof GLTABLE !== 'function') {
// throw new Error('GLTABLE is not a constructor');
// }
// if (typeof CARNETCOUNTRYTABLE !== 'function') {
// throw new Error('CARNETCOUNTRYTABLE is not a constructor');
// }
// const GLTABLE_ARRAY = finalBody.p_gltable
// ? await Promise.all(
// finalBody.p_gltable.map(async (x: p_gltableDTO) => {
// return await createGLArrayInstance(
// connection,
// x.ItemNo,
// x.ItemDescription,
// x.ItemValue,
// x.Noofpieces,
// x.ItemWeight,
// x.ItemWeightUOM,
// x.GoodsOriginCountry,
// );
// }),
// )
// : [];
// const CARNETCOUNTRYTABLE_ARRAY = finalBody.p_countrytable
// ? await Promise.all(
// finalBody.p_countrytable.map(async (x) => {
// return await createCarnetCountryArrayInstance(
// connection,
// x.VisitTransitInd,
// x.CountryCode,
// x.NoOfTimesEntLeave,
// );
// }),
// )
// : [];
// const GLTABLE_INSTANCE = new GLTABLE(GLTABLE_ARRAY);
// const CARNETCOUNTRYTABLE_INSTANCE = new CARNETCOUNTRYTABLE(
// CARNETCOUNTRYTABLE_ARRAY,
// );
// const result = await connection.execute(
// `BEGIN
// CARNETAPPLICATION_PKG.SaveCarnetApplication(
// :P_SPID,
// :p_clientid,
// :p_locationid,
// :P_USERID,
// :p_headerid,
// :p_applicationname,
// :p_holderid,
// :p_commercialsampleflag,
// :p_profequipmentflag,
// :p_exhibitionsfairflag,
// :p_autoflag,
// :p_horseflag,
// :p_authrep,
// :p_gltable,
// :p_ussets,
// :p_countrytable,
// :p_shiptotype,
// :p_shipaddrid,
// :p_formofsecurity,
// :p_insprotection,
// :p_ldiprotection,
// :p_deliverytype,
// :p_deliverymethod,
// :p_paymentmethod,
// :p_custcourierno,
// :p_refno,
// :p_notes,
// :P_CURSOR
// );
// END;`,
// {
// P_SPID: {
// val: finalBody.P_SPID ? finalBody.P_SPID : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_clientid: {
// val: finalBody.p_clientid ? finalBody.p_clientid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_locationid: {
// val: finalBody.p_locationid ? finalBody.p_locationid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// P_USERID: {
// val: finalBody.P_USERID ? finalBody.P_USERID : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_headerid: {
// val: finalBody.p_headerid ? finalBody.p_headerid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_applicationname: {
// val: finalBody.p_applicationname
// ? finalBody.p_applicationname
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_holderid: {
// val: finalBody.p_holderid ? finalBody.p_holderid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_commercialsampleflag: {
// val: finalBody.p_commercialsampleflag
// ? finalBody.p_commercialsampleflag
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_profequipmentflag: {
// val: finalBody.p_profequipmentflag
// ? finalBody.p_profequipmentflag
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_exhibitionsfairflag: {
// val: finalBody.p_exhibitionsfairflag
// ? finalBody.p_exhibitionsfairflag
// : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_autoflag: {
// val: finalBody.p_autoflag ? finalBody.p_autoflag : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_horseflag: {
// val: finalBody.p_horseflag ? finalBody.p_horseflag : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_authrep: {
// val: finalBody.p_authrep ? finalBody.p_authrep : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_gltable: {
// val: GLTABLE_INSTANCE,
// type: oracledb.DB_TYPE_OBJECT,
// },
// p_ussets: {
// val: finalBody.p_ussets ? finalBody.p_ussets : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_countrytable: {
// val: CARNETCOUNTRYTABLE_INSTANCE,
// type: oracledb.DB_TYPE_OBJECT,
// },
// p_shiptotype: {
// val: finalBody.p_shiptotype ? finalBody.p_shiptotype : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_shipaddrid: {
// val: finalBody.p_shipaddrid ? finalBody.p_shipaddrid : null,
// type: oracledb.DB_TYPE_NUMBER,
// },
// p_formofsecurity: {
// val: finalBody.p_formofsecurity ? finalBody.p_formofsecurity : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_insprotection: {
// val: finalBody.p_insprotection ? finalBody.p_insprotection : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_ldiprotection: {
// val: finalBody.p_ldiprotection ? finalBody.p_ldiprotection : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_deliverytype: {
// val: finalBody.p_deliverytype ? finalBody.p_deliverytype : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_deliverymethod: {
// val: finalBody.p_deliverymethod ? finalBody.p_deliverymethod : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_paymentmethod: {
// val: finalBody.p_paymentmethod ? finalBody.p_paymentmethod : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_custcourierno: {
// val: finalBody.p_custcourierno ? finalBody.p_custcourierno : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_refno: {
// val: finalBody.p_refno ? finalBody.p_refno : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// p_notes: {
// val: finalBody.p_notes ? finalBody.p_notes : null,
// type: oracledb.DB_TYPE_NVARCHAR,
// },
// P_CURSOR: {
// type: oracledb.CURSOR,
// dir: oracledb.BIND_OUT,
// },
// },
// {
// outFormat: oracledb.OUT_FORMAT_OBJECT,
// },
// );
// await connection.commit();
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new Error('No cursor returned from the stored procedure');
// }
// return rows;
// } catch (err) {
// if (err instanceof Error) {
// return { error: err.message };
// } else {
// return { error: 'An unknown error occurred' };
// }
// }
// finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// console.error('Failed to close connection:', closeErr);
// }
// }
// }
// }
// NOTE : this has been moved to carent-application module
// async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
// let connection;
// let rows = [];
// try {
// connection = await this.oracleDBService.getConnection();
// if (!connection) {
// throw new Error('No DB Connected');
// }
// const result = await connection.execute(
// `BEGIN
// CARNETAPPLICATION_PKG.TransmitApplicationtoProcess(
// :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,
// },
// );
// await connection.commit();
// if (result.outBinds && result.outBinds.P_CURSOR) {
// const cursor = result.outBinds.P_CURSOR;
// let rowsBatch;
// do {
// rowsBatch = await cursor.getRows(100);
// rows = rows.concat(rowsBatch);
// } while (rowsBatch.length > 0);
// await cursor.close();
// } else {
// throw new Error('No cursor returned from the stored procedure');
// }
// return rows;
// // return fres
// } catch (err) {
// if (err instanceof Error) {
// return { error: err.message };
// } else {
// return { error: 'An unknown error occurred' };
// }
// }
// finally {
// if (connection) {
// try {
// await connection.close();
// } catch (closeErr) {
// console.error('Failed to close connection:', closeErr);
// }
// }
// }
// }
async GetCarnetDetailsbyCarnetStatus(body: GetCarnetDetailsbyCarnetStatusDTO) {
let connection;
let rows: any = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
const result = await connection.execute(
`BEGIN
CARNETCONTROLCENTER_PKG.GetCarnetDetails(:P_SPID,:P_USERID,:P_CARNETSTATUS,: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_CARNETSTATUS: {
val: body.P_CARNETSTATUS,
type: oracledb.DB_TYPE_NVARCHAR,
},
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CARNETSTATUS: { val: body.P_CARNETSTATUS, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
},
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
if (result.outBinds && result.outBinds.P_CURSOR) {
const cursor = result.outBinds.P_CURSOR;
let rowsBatch;
do {
rowsBatch = await cursor.getRows(100);
rows = rows.concat(rowsBatch);
} while (rowsBatch.length > 0);
await cursor.close();
} else {
throw new Error('No cursor returned from the stored procedure');
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 rows;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
finally {
if (connection) {
try {
await connection.close();
} catch (closeErr) {
console.error('Failed to close connection:', closeErr);
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, HomePageService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return fres;
} catch (error) {
handleError(error, HomePageService.name)
} finally {
await closeOracleDbConnection(connection, HomePageService.name)
}
}
}

View File

@ -1,4 +1,4 @@
import { Body, Controller, Get, Patch, Post, Query } from '@nestjs/common';
import { Body, Controller, Get, Param, Patch, Post, Query } from '@nestjs/common';
import { ManageFeeService } from './manage-fee.service';
import { ApiTags } from '@nestjs/swagger';
@ -13,44 +13,44 @@ export class ManageFeeController {
constructor(private readonly manageFeeService: ManageFeeService) { }
@ApiTags('Manage Fee - Oracle')
@Get('/GetBasicFeeRates')
GetBasicFeeRates(@Query() body: GetFeeGeneralDTO) {
@Get('/GetBasicFeeRates/:P_SPID/:P_ACTIVE_INACTIVE')
GetBasicFeeRates(@Param() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETBASICFEERATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetBondRates')
GetBondRates(@Query() body: GetFeeGeneralDTO) {
@Get('/GetBondRates/:P_SPID/:P_ACTIVE_INACTIVE')
GetBondRates(@Param() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETBONDRATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetCargoRates')
GetCargoRates(@Query() body: GetFeeGeneralDTO) {
@Get('/GetCargoRates/:P_SPID/:P_ACTIVE_INACTIVE')
GetCargoRates(@Param() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETCARGORATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetCfFeeRates')
GetCfFeeRates(@Query() body: GetFeeGeneralDTO) {
@Get('/GetCfFeeRates/:P_SPID/:P_ACTIVE_INACTIVE')
GetCfFeeRates(@Param() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETCFFEERATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetCsFeeRates')
GetCsFeeRates(@Query() body: GetFeeGeneralDTO) {
@Get('/GetCsFeeRates/:P_SPID/:P_ACTIVE_INACTIVE')
GetCsFeeRates(@Param() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETCSFEERATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetEfFeeRates')
GetEfFeeRates(@Query() body: GetFeeGeneralDTO) {
@Get('/GetEfFeeRates/:P_SPID/:P_ACTIVE_INACTIVE')
GetEfFeeRates(@Param() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETEFFEERATES(body);
}
@ApiTags('Manage Fee - Oracle')
@Get('/GetFeeComm')
GetFeeComm(@Query() body: GetFeeGeneralDTO) {
@Get('/GetFeeComm/:P_SPID/:P_ACTIVE_INACTIVE')
GetFeeComm(@Param() body: GetFeeGeneralDTO) {
return this.manageFeeService.GETFEECOMM(body);
}

File diff suppressed because it is too large Load Diff

View File

@ -43,95 +43,37 @@ export class ManageHoldersController {
@ApiTags('Manage Holders - Oracle')
@Get('/GetHolderRecord/:P_SPID/:P_HOLDERID')
GetHolderMaster(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
) {
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
return this.manageHoldersService.GetHolderRecord(reqParams);
GetHolderMaster(@Param() body: GetHolderDTO) {
return this.manageHoldersService.GetHolderRecord(body);
}
@ApiTags('Manage Holders - Oracle')
@Get('/GetHolderContacts/:P_SPID/:P_HOLDERID')
GetHolderContacts(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
) {
const reqParams: GetHolderDTO = { P_SPID, P_HOLDERID };
return this.manageHoldersService.GetHolderContacts(reqParams);
GetHolderContacts(@Param() body: GetHolderDTO) {
return this.manageHoldersService.GetHolderContacts(body);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/InactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
InactivateHolder(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
return this.manageHoldersService.InactivateHolder(reqParams);
InactivateHolder(@Param() body: HolderActivateOrInactivateDTO) {
return this.manageHoldersService.InactivateHolder(body);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/ReactivateHolder/:P_SPID/:P_HOLDERID/:P_USERID')
ReactivateHolder(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERID', ParseIntPipe) P_HOLDERID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderActivateOrInactivateDTO = { P_SPID, P_HOLDERID, P_USERID };
return this.manageHoldersService.ReactivateHolder(reqParams);
ReactivateHolder(@Param() body: HolderActivateOrInactivateDTO) {
return this.manageHoldersService.ReactivateHolder(body);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/InactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
InactivateHolderContact(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderContactActivateOrInactivateDTO = {
P_SPID,
P_HOLDERCONTACTID,
P_USERID
};
return this.manageHoldersService.InactivateHolderContact(reqParams);
InactivateHolderContact(@Param() body: HolderContactActivateOrInactivateDTO) {
return this.manageHoldersService.InactivateHolderContact(body);
}
@ApiTags('Manage Holders - Oracle')
@Patch('/ReactivateHolderContact/:P_SPID/:P_HOLDERCONTACTID/:P_USERID')
ReactivateHolderContact(
@Param('P_SPID', ParseIntPipe) P_SPID: number,
@Param('P_HOLDERCONTACTID', ParseIntPipe) P_HOLDERCONTACTID: number,
@Param('P_USERID') P_USERID: string
) {
if (!P_USERID) {
throw new BadRequestException("Bad Request");
}
const reqParams: HolderContactActivateOrInactivateDTO = {
P_SPID,
P_HOLDERCONTACTID,
P_USERID
};
return this.manageHoldersService.ReactivateHolderContact(reqParams);
ReactivateHolderContact(@Param() body: HolderContactActivateOrInactivateDTO) {
return this.manageHoldersService.ReactivateHolderContact(body);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -113,20 +113,12 @@ export class ParamTableService {
const result = await connection.execute(
`BEGIN
MANAGEPARAMTABLE_PKG.CREATEPARAMRECORD(
:P_SPID,
:P_PARAMTYPE,
:P_PARAMDESC,
:P_PARAMVALUE,
:P_ADDLPARAMVALUE1,
:P_ADDLPARAMVALUE2,
:P_ADDLPARAMVALUE3,
:P_ADDLPARAMVALUE4,
:P_ADDLPARAMVALUE5,
:P_SORTSEQ,
:P_USERID,
:P_CURSOR);
END;`,
MANAGEPARAMTABLE_PKG.CREATEPARAMRECORD(
:P_SPID, :P_PARAMTYPE, :P_PARAMDESC, :P_PARAMVALUE,
:P_ADDLPARAMVALUE1, :P_ADDLPARAMVALUE2, :P_ADDLPARAMVALUE3, :P_ADDLPARAMVALUE4,
:P_ADDLPARAMVALUE5, :P_SORTSEQ, :P_USERID, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_PARAMTYPE: { val: body.P_PARAMTYPE, type: oracledb.DB_TYPE_VARCHAR },
@ -176,19 +168,12 @@ export class ParamTableService {
const result = await connection.execute(
`BEGIN
MANAGEPARAMTABLE_PKG.UPDATEPARAMRECORD(
:P_SPID,
:P_PARAMID,
:P_PARAMDESC,
:P_ADDLPARAMVALUE1,
:P_ADDLPARAMVALUE2,
:P_ADDLPARAMVALUE3,
:P_ADDLPARAMVALUE4,
:P_ADDLPARAMVALUE5,
:P_SORTSEQ,
:P_USERID,
:P_CURSOR);
END;`,
MANAGEPARAMTABLE_PKG.UPDATEPARAMRECORD(
:P_SPID, :P_PARAMID, :P_PARAMDESC, :P_ADDLPARAMVALUE1,
:P_ADDLPARAMVALUE2,:P_ADDLPARAMVALUE3, :P_ADDLPARAMVALUE4, :P_ADDLPARAMVALUE5,
:P_SORTSEQ, :P_USERID, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_PARAMID: { val: body.P_PARAMID, type: oracledb.DB_TYPE_NUMBER },

View File

@ -23,39 +23,18 @@ export class CarnetSequenceService {
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.CreateCarnetSequence(
:P_SPID,
:P_REGIONID,
:P_STARTNUMBER,
:P_ENDNUMBER,
:P_CARNETTYPE,
:P_CURSOR);
END;`,
USCIB_Managed_Pkg.CreateCarnetSequence(
:P_SPID, :P_REGIONID, :P_STARTNUMBER, :P_ENDNUMBER,
:P_CARNETTYPE, :P_CURSOR
);
END;`,
{
P_SPID: {
val: body.P_SPID,
type: oracledb.DB_TYPE_NUMBER,
},
P_REGIONID: {
val: body.P_REGIONID,
type: oracledb.DB_TYPE_NUMBER,
},
P_STARTNUMBER: {
val: body.P_STARTNUMBER,
type: oracledb.DB_TYPE_NUMBER,
},
P_ENDNUMBER: {
val: body.P_ENDNUMBER,
type: oracledb.DB_TYPE_NUMBER,
},
P_CARNETTYPE: {
val: body.P_CARNETTYPE,
type: oracledb.DB_TYPE_VARCHAR,
},
P_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_REGIONID: { val: body.P_REGIONID, type: oracledb.DB_TYPE_NUMBER },
P_STARTNUMBER: { val: body.P_STARTNUMBER, type: oracledb.DB_TYPE_NUMBER },
P_ENDNUMBER: { val: body.P_ENDNUMBER, type: oracledb.DB_TYPE_NUMBER },
P_CARNETTYPE: { val: body.P_CARNETTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,

View File

@ -3,7 +3,7 @@ import { OracleDBService } from 'src/db/db.service';
import * as oracledb from 'oracledb';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import { closeOracleDbConnection, fetchCursor, handleError, setEmptyStringsToNull } from 'src/utils/helper';
import {
SPID_DTO, InsertNewServiceProviderDTO,
@ -37,16 +37,6 @@ export class SpService {
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: InsertNewServiceProviderDTO = { ...newBody, ...reqBody };
@ -57,25 +47,14 @@ export class SpService {
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.InsertNewSP(
:P_NAME,
:P_LOOKUPCODE,
:P_ADDRESS1,
:P_ADDRESS2,
:P_CITY,
:P_STATE,
:P_ZIP,
:P_COUNTRY,
:P_ISSUINGREGION,
:P_REPLACEMENTREGION,
:P_BONDSURETY,
:P_CARGOPOLICYNO,
:P_CARGOSURETY,
:P_USER_ID,
:P_NOTES,
:P_FILEIDS,
:P_CURSOR);
END;`,
USCIB_Managed_Pkg.InsertNewSP(
:P_NAME, :P_LOOKUPCODE, :P_ADDRESS1, :P_ADDRESS2,
:P_CITY, :P_STATE, :P_ZIP, :P_COUNTRY,
:P_ISSUINGREGION, :P_REPLACEMENTREGION,:P_BONDSURETY, :P_CARGOPOLICYNO,
:P_CARGOSURETY, :P_USER_ID, :P_NOTES, :P_FILEIDS,
:P_CURSOR
);
END;`,
{
P_NAME: { val: finalBody.P_NAME, type: oracledb.DB_TYPE_VARCHAR },
P_LOOKUPCODE: { val: finalBody.P_LOOKUPCODE, type: oracledb.DB_TYPE_VARCHAR },
@ -143,16 +122,6 @@ export class SpService {
const reqBody = JSON.parse(JSON.stringify(body));
function setEmptyStringsToNull(obj) {
Object.keys(obj).forEach((key) => {
if (typeof obj[key] === 'object' && obj[key] !== null) {
setEmptyStringsToNull(obj[key]);
} else if (obj[key] === '') {
obj[key] = null;
}
});
}
setEmptyStringsToNull(reqBody);
const finalBody: UpdateServiceProviderDTO = { ...newBody, ...reqBody };
@ -163,26 +132,14 @@ export class SpService {
const result = await connection.execute(
`BEGIN
USCIB_Managed_Pkg.UpdateSP(
:P_SPID,
:P_NAME,
:P_LOOKUPCODE,
:P_ADDRESS1,
:P_ADDRESS2,
:P_CITY,
:P_STATE,
:P_ZIP,
:P_COUNTRY,
:P_ISSUINGREGION,
:P_REPLACEMENTREGION,
:P_BONDSURETY,
:P_CARGOPOLICYNO,
:P_CARGOSURETY,
:P_USER_ID,
:P_NOTES,
:P_FILEIDS,
:P_CURSOR);
END;`,
USCIB_Managed_Pkg.UpdateSP(
:P_SPID, :P_NAME, :P_LOOKUPCODE, :P_ADDRESS1,
:P_ADDRESS2, :P_CITY, :P_STATE, :P_ZIP,
:P_COUNTRY, :P_ISSUINGREGION, :P_REPLACEMENTREGION, :P_BONDSURETY,
:P_CARGOPOLICYNO, :P_CARGOSURETY, :P_USER_ID, :P_NOTES,
:P_FILEIDS, :P_CURSOR
);
END;`,
{
P_SPID: { val: finalBody.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_NAME: { val: finalBody.P_NAME, type: oracledb.DB_TYPE_VARCHAR },