BE/src/oracle/manage-fee/manage-fee.service.ts
2025-04-02 13:29:06 +05:30

1315 lines
34 KiB
TypeScript

import { Injectable } from '@nestjs/common';
import * as oracledb from 'oracledb';
import { OracleDBService } from 'src/db/db.service';
import {
CreateBasicFeeDTO,
CreateBondRateDTO,
CreateCargoRateDTO,
CreateCfFeeDTO,
CreateCsFeeDTO,
CreateEfFeeDTO,
CreateFeeCommDTO,
GetFeeGeneralDTO,
UpdateBasicFeeDTO,
UpdateBondRateDTO,
UpdateCargoRateDTO,
UpdateCfFeeDTO,
UpdateCsFeeDTO,
UpdateEfFeeDTO,
UpdateFeeCommBodyDTO,
} from './manage-fee.dto';
@Injectable()
export class ManageFeeService {
constructor(private readonly oracleDBService: OracleDBService) {}
// get
async GETBASICFEERATES(body: GetFeeGeneralDTO) {
let connection;
let rows = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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,
},
);
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' };
}
}
}
async GETBONDRATES(body: GetFeeGeneralDTO) {
let connection;
let rows = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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,
},
);
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' };
}
}
}
async GETCARGORATES(body: GetFeeGeneralDTO) {
let connection;
let rows = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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,
},
);
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' };
}
}
}
async GETCFFEERATES(body: GetFeeGeneralDTO) {
let connection;
let rows = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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,
},
);
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' };
}
}
}
async GETCSFEERATES(body: GetFeeGeneralDTO) {
let connection;
let rows = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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,
},
);
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' };
}
}
}
async GETEFFEERATES(body: GetFeeGeneralDTO) {
let connection;
let rows = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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,
},
);
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' };
}
}
}
async GETFEECOMM(body: GetFeeGeneralDTO) {
let connection;
let rows = [];
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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,
},
);
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' };
}
}
}
// post
async CREATEBASICFEE(body: CreateBasicFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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_STARTCARNETVALUE,
type: oracledb.DB_TYPE_NUMBER,
},
P_ENDCARNETVALUE: {
val: body.P_ENDCARNETVALUE,
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();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async CREATEBONDRATE(body: CreateBondRateDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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_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_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
},
);
await connection.commit();
const fres = await result.outBinds.p_cursor.getRows();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async CREATECARGORATE(body: CreateCargoRateDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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_EFFDATE,
type: oracledb.DB_TYPE_VARCHAR,
},
P_STARTSETS: {
val: body.P_SPID,
type: oracledb.DB_TYPE_NUMBER,
},
P_ENDSETS: {
val: body.P_SPID,
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();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async CREATECFFEE(body: CreateCfFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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_SPID,
type: oracledb.DB_TYPE_NUMBER,
},
P_ENDSETS: {
val: body.P_SPID,
type: oracledb.DB_TYPE_NUMBER,
},
P_EFFDATE: {
val: body.P_EFFDATE,
type: oracledb.DB_TYPE_VARCHAR,
},
P_CUSTOMERTYPE: {
val: body.P_EFFDATE,
type: oracledb.DB_TYPE_VARCHAR,
},
P_CARNETTYPE: {
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();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async CREATECSFEE(body: CreateCsFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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_EFFDATE,
type: oracledb.DB_TYPE_VARCHAR,
},
P_CARNETTYPE: {
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_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();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async CREATEEFFEE(body: CreateEfFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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_EFFDATE,
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();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async CREATEFEECOMM(body: CreateFeeCommDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
// update
async UPDATEBASICFEE(body: UpdateBasicFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async UPDATEBONDRATE(body: UpdateBondRateDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
const result = await connection.execute(
`BEGIN
MANAGEFEE_SETUP_PKG.UPDATEBONDRATE(
:P_BONDRATESETUPID,
:P_RATE,
:P_EFFDATE,
:P_USERID,
: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_CURSOR: {
type: oracledb.CURSOR,
dir: oracledb.BIND_OUT,
},
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
},
);
await connection.commit();
const fres = await result.outBinds.p_cursor.getRows();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async UPDATECARGORATE(body: UpdateCargoRateDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async UPDATECFFEE(body: UpdateCfFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async UPDATECSFEE(body: UpdateCsFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async UPDATEEFFEE(body: UpdateEfFeeDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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();
return fres;
} catch (err) {
if (err instanceof Error) {
return { error: err.message };
} else {
return { error: 'An unknown error occurred' };
}
}
}
async UPDATEFEECOMM(body: UpdateFeeCommBodyDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
if (!connection) {
throw new Error('No DB Connected');
}
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_fees_comm.P_FEECOMMID,
type: oracledb.DB_TYPE_NUMBER,
},
P_RATE: {
val: Number(body.p_fees_comm.P_RATE) | 0,
type: oracledb.DB_TYPE_NUMBER,
},
P_EFFDATE: {
val: body.p_fees_comm.P_EFFDATE,
type: oracledb.DB_TYPE_NVARCHAR,
},
P_USERID: {
val: body.p_fees_comm.P_USERID,
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 fres = await result.outBinds.P_CURSOR.getRows();
console.log('pcursor: ', fres);
return fres;
} else {
console.log('No cursor returned....');
return { error: 'No cursor found' };
}
} catch (err) {
return { error: err.message };
// return {error: err.message}
}
}
}