BE/src/oracle/manage-fee/manage-fee.service.ts

906 lines
31 KiB
TypeScript

import { Injectable, Logger } from '@nestjs/common';
import * as oracledb from 'oracledb';
import { OracleDBService } from 'src/db/db.service';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
import { closeOracleDbConnection, fetchCursor, handleError } from 'src/utils/helper';
import {
CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO,
CreateEfFeeDTO, CreateFeeCommDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO,
UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO, UpdateEfFeeDTO, UpdateFeeCommDTO
} from 'src/dto/property.dto';
@Injectable()
export class ManageFeeService {
private readonly logger = new Logger(ManageFeeService.name);
constructor(private readonly oracleDBService: OracleDBService) { }
// basic fee
async GETBASICFEERATES(body: GetFeeGeneralDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.GETBASICFEERATES(:P_SPID, :P_ACTIVE_INACTIVE, :P_CURSOR);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_ACTIVE_INACTIVE: { val: body.P_ACTIVE_INACTIVE, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
const outBinds: any = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ManageFeeService.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, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async CREATEBASICFEE(body: CreateBasicFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.CREATEBASICFEE(
:P_SPID, :P_STARTCARNETVALUE, :P_ENDCARNETVALUE, :P_EFFDATE,
:P_FEES, :P_USERID, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_STARTCARNETVALUE: { val: body.P_STARTNUMBER, type: oracledb.DB_TYPE_NUMBER },
P_ENDCARNETVALUE: { val: body.P_ENDNUMBER, type: oracledb.DB_TYPE_NUMBER },
P_EFFDATE: { val: body.P_EFFDATE, type: oracledb.DB_TYPE_VARCHAR },
P_FEES: { val: body.P_FEES, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Created Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async UPDATEBASICFEE(body: UpdateBasicFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.UPDATEBASICFEE(
:P_BASICFEESETUPID, :P_FEES, :P_EFFDATE, :P_USERID,
:P_CURSOR
);
END;`,
{
P_BASICFEESETUPID: { val: body.P_BASICFEESETUPID, type: oracledb.DB_TYPE_NUMBER },
P_FEES: { val: body.P_FEES, 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_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Updated Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
// bond rate
async GETBONDRATES(body: GetFeeGeneralDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.GETBONDRATES(:P_SPID,:P_ACTIVE_INACTIVE,:P_CURSOR);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_ACTIVE_INACTIVE: { val: body.P_ACTIVE_INACTIVE, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
const outBinds: any = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ManageFeeService.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, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async CREATEBONDRATE(body: CreateBondRateDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
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;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_HOLDERTYPE: { val: body.P_HOLDERTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_USCIBMEMBERFLAG: { val: body.P_USCIBMEMBERFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_SPCLCOMMODITY: { val: body.P_SPCLCOMMODITY, type: oracledb.DB_TYPE_VARCHAR },
P_SPCLCOUNTRY: { val: body.P_SPCLCOUNTRY, 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_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 }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Created Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async UPDATEBONDRATE(body: UpdateBondRateDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.UPDATEBONDRATE(
:P_BONDRATESETUPID, :P_RATE, :P_EFFDATE, :P_USERID, :P_PCT_VALUE,
:P_CURSOR
);
END;`,
{
P_BONDRATESETUPID: { val: body.P_BONDRATESETUPID, 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_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 }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Updated Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
// cargo rate
async GETCARGORATES(body: GetFeeGeneralDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.GETCARGORATES(:P_SPID,:P_ACTIVE_INACTIVE,:P_CURSOR);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_ACTIVE_INACTIVE: { val: body.P_ACTIVE_INACTIVE, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
const outBinds: any = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ManageFeeService.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, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async CREATECARGORATE(body: CreateCargoRateDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.CREATECARGORATE(
:P_SPID, :P_CARNETTYPE, :P_STARTSETS, :P_ENDSETS,
:P_EFFDATE, :P_RATE, :P_USERID, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CARNETTYPE: { val: body.P_CARNETTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_STARTSETS: { val: body.P_STARTSETS, type: oracledb.DB_TYPE_NUMBER },
P_ENDSETS: { val: body.P_ENDSETS, type: oracledb.DB_TYPE_NUMBER },
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_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Created Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async UPDATECARGORATE(body: UpdateCargoRateDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.UPDATECARGORATE(
:P_CARGORATESETUPID, :P_RATE, :P_EFFDATE, :P_USERID,
:P_CURSOR
);
END;`,
{
P_CARGORATESETUPID: { val: body.P_CARGORATESETUPID, 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_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Updated Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
// counter foil
async GETCFFEERATES(body: GetFeeGeneralDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.GETCFFEERATES(:P_SPID,:P_ACTIVE_INACTIVE,:P_CURSOR);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_ACTIVE_INACTIVE: { val: body.P_ACTIVE_INACTIVE, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
const outBinds: any = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ManageFeeService.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, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async CREATECFFEE(body: CreateCfFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.CREATECFFEE(
:P_SPID, :P_STARTSETS, :P_ENDSETS, :P_EFFDATE,
:P_CUSTOMERTYPE, :P_CARNETTYPE, :P_RATE, :P_USERID,
:P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_STARTSETS: { val: body.P_STARTSETS, type: oracledb.DB_TYPE_NUMBER },
P_ENDSETS: { val: body.P_ENDSETS, type: oracledb.DB_TYPE_NUMBER },
P_EFFDATE: { val: body.P_EFFDATE, type: oracledb.DB_TYPE_VARCHAR },
P_CUSTOMERTYPE: { val: body.P_CUSTOMERTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_CARNETTYPE: { val: body.P_CARNETTYPE, 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_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Created Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async UPDATECFFEE(body: UpdateCfFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.UPDATECFFEE(
:P_CFFEESETUPID, :P_RATE, :P_EFFDATE, :P_USERID,
:P_CURSOR
);
END;`,
{
P_CFFEESETUPID: { val: body.P_CFFEESETUPID, 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_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Updated Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
// continuation sheet
async GETCSFEERATES(body: GetFeeGeneralDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.GETCSFEERATES(:P_SPID,:P_ACTIVE_INACTIVE,:P_CURSOR);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_ACTIVE_INACTIVE: { val: body.P_ACTIVE_INACTIVE, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
const outBinds: any = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ManageFeeService.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, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async CREATECSFEE(body: CreateCsFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.CREATECSFEE(
:P_SPID, :P_CUSTOMERTYPE, :P_CARNETTYPE, :P_EFFDATE,
:P_RATE, :P_USERID, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CUSTOMERTYPE: { val: body.P_CUSTOMERTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_CARNETTYPE: { val: body.P_CARNETTYPE, 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_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Created Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async UPDATECSFEE(body: UpdateCsFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.UPDATECSFEE(
:P_CSFEESETUPID, :P_RATE, :P_EFFDATE, :P_USERID,
:P_CURSOR
);
END;`,
{
P_CSFEESETUPID: { val: body.P_CSFEESETUPID, 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_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Updated Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
// expedited fee
async GETEFFEERATES(body: GetFeeGeneralDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.GETEFFEERATES(:P_SPID,:P_ACTIVE_INACTIVE,:P_CURSOR);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_ACTIVE_INACTIVE: { val: body.P_ACTIVE_INACTIVE, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
const outBinds: any = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ManageFeeService.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, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async CREATEEFFEE(body: CreateEfFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.CREATEEFFEE(
:P_SPID, :P_CUSTOMERTYPE, :P_DELIVERYTYPE, :P_STARTTIME,
:P_ENDTIME, :P_TIMEZONE, :P_EFFDATE, :P_FEES,
:P_USERID, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CUSTOMERTYPE: { val: body.P_CUSTOMERTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_DELIVERYTYPE: { val: body.P_DELIVERYTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_STARTTIME: { val: body.P_STARTTIME, type: oracledb.DB_TYPE_NUMBER },
P_ENDTIME: { val: body.P_ENDTIME, type: oracledb.DB_TYPE_NUMBER },
P_TIMEZONE: { val: body.P_TIMEZONE, type: oracledb.DB_TYPE_VARCHAR },
P_EFFDATE: { val: body.P_EFFDATE, type: oracledb.DB_TYPE_VARCHAR },
P_FEES: { val: body.P_FEES, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Created Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async UPDATEEFFEE(body: UpdateEfFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.UPDATEEFFEE(
:P_EFFEESETUPID, :P_FEES, :P_EFFDATE, :P_USERID,
:P_CURSOR
);
END;`,
{
P_EFFEESETUPID: { val: body.P_EFFEESETUPID, type: oracledb.DB_TYPE_NUMBER },
P_FEES: { val: body.P_FEES, 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_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Updated Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
// fee comm
async GETFEECOMM(body: GetFeeGeneralDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.GETFEECOMM(:P_SPID,:P_ACTIVE_INACTIVE,:P_CURSOR);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_ACTIVE_INACTIVE: { val: body.P_ACTIVE_INACTIVE, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
const outBinds: any = result.outBinds;
if (!outBinds?.P_CURSOR) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
const fres: any = await fetchCursor(outBinds.P_CURSOR, ManageFeeService.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, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async CREATEFEECOMM(body: CreateFeeCommDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.CREATEFEECOMM(
:P_SPID, :P_PARAMID, :P_COMMRATE, :P_EFFDATE,
: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 },
P_COMMRATE: { val: body.P_COMMRATE, 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_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Created Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
async UPDATEFEECOMM(body: UpdateFeeCommDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.UPDATEFEECOMM(
:P_FEECOMMID, :P_RATE, :P_EFFDATE, :P_USERID,
:P_CURSOR
);
END;`,
{
P_FEECOMMID: { val: body.P_FEECOMMID, type: oracledb.DB_TYPE_NUMBER },
P_RATE: { val: Number(body.P_RATE) | 0, 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_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT
}
);
await connection.commit();
const fres = await result.outBinds.P_CURSOR.getRows();
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Updated Successfully" };
} catch (error) {
handleError(error, ManageFeeService.name)
} finally {
await closeOracleDbConnection(connection, ManageFeeService.name)
}
}
}