BE/src/oracle/carnet-application/carnet-application.service.ts

1708 lines
74 KiB
TypeScript
Raw Normal View History

2025-02-24 10:32:41 +05:30
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';
2025-08-12 15:27:32 +05:30
import { closeOracleDbConnection, deleteFilesAsync, fetchCursor, fnCounterFoil, fnVochers, generateFinalPDF, generateGL, generateGL1, generateGreenCoverPDF, handleError, pdfCarnetData, pdfGLData, replaceSlashWithDash, setEmptyStringsToNull, tnVochers, tsCounterFoil, usCounterFoil } from 'src/utils/helper';
2025-02-24 10:32:41 +05:30
import {
CarnetProcessingCenterDTO, SaveCarnetApplicationDTO, TransmitApplicationtoProcessDTO,
CreateApplicationDTO,
UpdateExpGoodsAuthRepDTO,
AddGenerallistItemsDTO,
AddCountriesDTO,
UpdateShippingDetailsDTO,
2025-07-03 16:57:37 +05:30
CA_UpdateHolderDTO,
2025-07-14 20:39:12 +05:30
GetCarnetControlCenterDTO,
DeleteGenerallistItemsDTO,
2025-08-12 15:27:32 +05:30
PrintCarnetDTO,
PrintGLDTO,
2025-08-13 11:51:24 +05:30
YON,
CopyCarnetDTO,
GetExtendedSectionDTO,
SaveExtensionApplicationDTO,
2025-08-18 20:34:44 +05:30
CarnetProcessingCenterDTO2,
CapturePaymentDTO
2025-02-24 10:32:41 +05:30
} from 'src/dto/property.dto';
import { OracleService } from '../oracle.service';
2025-07-08 17:56:39 +05:30
import { BadRequestException } from 'src/exceptions/badRequest.exception';
2025-08-18 20:34:44 +05:30
import axios, { AxiosError, AxiosRequestConfig } from 'axios';
import { PaypalService } from 'src/paypal/paypal.service';
import { NotFoundException } from 'src/exceptions/notFound.exception';
2025-02-24 10:32:41 +05:30
@Injectable()
export class CarnetApplicationService {
private readonly logger = new Logger(CarnetApplicationService.name);
constructor(
private readonly oracleDBService: OracleDBService,
2025-08-18 20:34:44 +05:30
private readonly oracleService: OracleService,
private readonly payPalService: PaypalService
2025-02-24 10:32:41 +05:30
) { }
// [ CARNETAPPLICATION_PKG ]
async SaveCarnetApplication(body: SaveCarnetApplicationDTO) {
const newBody = {
P_SPID: null, //
P_CLIENTID: null,
P_LOCATIONID: null,
P_USERID: null, //
P_HEADERID: null,
P_APPLICATIONNAME: 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));
setEmptyStringsToNull(reqBody);
const finalBody = { ...newBody, ...reqBody };
let connection;
try {
connection = await this.oracleDBService.getConnection();
const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(finalBody);
const COUNTRYTABLE_INSTANCE = await this.oracleService.get_COUNTRY_TABLE_INSTANCE(finalBody);
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: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTID: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_LOCATIONID: { val: body.P_LOCATIONID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_VARCHAR },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_APPLICATIONNAME: { val: body.P_APPLICATIONNAME, type: oracledb.DB_TYPE_VARCHAR },
P_HOLDERID: { val: body.P_HOLDERID, type: oracledb.DB_TYPE_NUMBER },
P_COMMERCIALSAMPLEFLAG: { val: body.P_COMMERCIALSAMPLEFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_PROFEQUIPMENTFLAG: { val: body.P_PROFEQUIPMENTFLAG, type: oracledb.DB_TYPE_VARCHAR },
P_EXHIBITIONSFAIRFLAG: { val: body.P_EXHIBITIONSFAIRFLAG, type: oracledb.DB_TYPE_VARCHAR },
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 },
2025-06-07 14:42:21 +05:30
P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
2025-02-24 10:32:41 +05:30
P_USSETS: { val: body.P_USSETS, type: oracledb.DB_TYPE_NUMBER },
P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_SHIPTOTYPE: { val: body.P_SHIPTOTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_SHIPADDRID: { val: body.P_SHIPADDRID, type: oracledb.DB_TYPE_NUMBER },
P_FORMOFSECURITY: { val: body.P_FORMOFSECURITY, type: oracledb.DB_TYPE_VARCHAR },
P_INSPROTECTION: { val: body.P_INSPROTECTION, type: oracledb.DB_TYPE_VARCHAR },
P_LDIPROTECTION: { val: body.P_LDIPROTECTION, type: oracledb.DB_TYPE_VARCHAR },
P_DELIVERYTYPE: { val: body.P_DELIVERYTYPE, type: oracledb.DB_TYPE_VARCHAR },
P_DELIVERYMETHOD: { val: body.P_DELIVERYMETHOD, type: oracledb.DB_TYPE_VARCHAR },
P_PAYMENTMETHOD: { val: body.P_PAYMENTMETHOD, type: oracledb.DB_TYPE_VARCHAR },
P_CUSTCOURIERNO: { val: body.P_CUSTCOURIERNO, type: oracledb.DB_TYPE_VARCHAR },
P_REFNO: { val: body.P_REFNO, type: oracledb.DB_TYPE_VARCHAR },
P_NOTES: { val: body.P_NOTES, type: oracledb.DB_TYPE_VARCHAR },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Saved Successfully", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.TransmitApplicationtoProcess(
:P_SPID, :P_USERID, :P_HEADERID, :P_CURSOR
2025-02-24 10:32:41 +05:30
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
2025-02-24 10:32:41 +05:30
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }
2025-02-24 10:32:41 +05:30
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Transmitted Successfully", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async CreateApplication(body: CreateApplicationDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.CreateApplication(
:P_SPID, :P_CLIENTID, :P_LOCATIONID, :P_USERID,
2025-07-08 17:56:39 +05:30
:P_APPLICATIONNAME, :P_ORDERTYPE, :P_CURSOR
2025-02-24 10:32:41 +05:30
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_CLIENTID: { val: body.P_CLIENTID, type: oracledb.DB_TYPE_NUMBER },
P_LOCATIONID: { val: body.P_LOCATIONID, type: oracledb.DB_TYPE_NUMBER },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_APPLICATIONNAME: { val: body.P_APPLICATIONNAME, type: oracledb.DB_TYPE_NVARCHAR },
P_ORDERTYPE: { val: body.P_ORDERTYPE, type: oracledb.DB_TYPE_NVARCHAR },
2025-07-08 17:56:39 +05:30
// P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
2025-02-24 10:32:41 +05:30
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
2025-07-08 17:56:39 +05:30
if (!outBinds?.P_CURSOR) {
2025-02-24 10:32:41 +05:30
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
2025-07-08 17:56:39 +05:30
const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 201, message: "Application created successfully", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateHolder(body: CA_UpdateHolderDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.UpdateHolder(
:P_HEADERID, :P_HOLDERID, :P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_HOLDERID: { val: body.P_HOLDERID, type: oracledb.DB_TYPE_NUMBER },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
// return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
const fres: any = await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
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", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateExpGoodsAuthRep(body: UpdateExpGoodsAuthRepDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.UpdateExpGoodsAuthRep(
:P_HEADERID, :P_COMMERCIALSAMPLEFLAG, :P_PROFEQUIPMENTFLAG,
:P_EXHIBITIONSFAIRFLAG, :P_AUTOFLAG, :P_HORSEFLAG, :P_AUTHREP,
:P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_COMMERCIALSAMPLEFLAG: { val: body.P_COMMERCIALSAMPLEFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_PROFEQUIPMENTFLAG: { val: body.P_PROFEQUIPMENTFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_EXHIBITIONSFAIRFLAG: { val: body.P_EXHIBITIONSFAIRFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_AUTOFLAG: { val: body.P_AUTOFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_HORSEFLAG: { val: body.P_HORSEFLAG, type: oracledb.DB_TYPE_NVARCHAR },
P_AUTHREP: { val: body.P_AUTHREP, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR }
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
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_ERRORMESG, CarnetApplicationService.name);
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", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async AddGenerallistItems(body: AddGenerallistItemsDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
2025-08-13 11:51:24 +05:30
const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_OPTIONAL_ITEMNO_INSTANCE(body);
2025-02-24 10:32:41 +05:30
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.AddGenerallistItems(
:P_HEADERID, :P_GLTABLE, :P_USERID, :P_ERRORMESG
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' },
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
this.logger.error('One or more expected cursors are missing from stored procedure output.');
throw new InternalServerException("Incomplete data received from the database.");
}
// return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
const fres: any = await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Added Successfully", ...fres[0] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async EditGenerallistItems(body: AddGenerallistItemsDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(body);
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.EditGenerallistItems(
:P_HEADERID, :P_GLTABLE, :P_USERID, :P_CURSOR
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' },
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
// P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
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", ...fres[0] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
2025-07-14 20:39:12 +05:30
async DeleteGenerallistItems(body: DeleteGenerallistItemsDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const GLTABLE_INSTANCE = await this.oracleService.get_GL_TABLE_INSTANCE(body);
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.DeleteGenerallistItems(
2025-07-14 20:39:12 +05:30
:P_HEADERID, :P_ITEMNO, :P_USERID, :P_CURSOR
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
2025-07-14 20:39:12 +05:30
P_ITEMNO: { val: body.P_ITEMNO, type: oracledb.DB_TYPE_NUMBER },
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' },
// P_GLTABLE: { val: GLTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
// P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Deleted Successfully", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async AddCountries(body: AddCountriesDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const COUNTRYTABLE_INSTANCE = await this.oracleService.get_COUNTRY_TABLE_INSTANCE(body);
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.AddCountries(
:P_HEADERID, :P_USSETS, :P_COUNTRYTABLE, :P_USERID, :P_CURSOR
2025-02-24 10:32:41 +05:30
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_USSETS: { val: body.P_USSETS, type: oracledb.DB_TYPE_NUMBER },
P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT, typeName: 'CARNETCOUNTRYTABLE' },
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: 'CARNETSYS.GLTABLE' },
// P_COUNTRYTABLE: { val: COUNTRYTABLE_INSTANCE, type: oracledb.DB_TYPE_OBJECT },
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
// P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
2025-02-24 10:32:41 +05:30
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
2025-02-24 10:32:41 +05:30
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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Added Successfully", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateShippingDetails(body: UpdateShippingDetailsDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.UpdateShippingDetails(
2025-07-15 16:26:26 +05:30
:P_HEADERID,
:P_SHIPTOTYPE,:P_SHIPCONTACTID,:P_SHIPNAME,
:P_ADDRESS1,:P_ADDRESS2,:P_CITY,:P_STATE,:P_ZIP,:P_COUNTRY,
:P_FIRSTNAME,:P_LASTNAME,:P_TITLE,:P_PHONENO,:P_MOBILENO,:P_FAXNO,:P_EMAILADDRESS,:P_MIDDLEINITIAL,
:P_FORMOFSECURITY,:P_INSPROTECTION,:P_LDIPROTECTION,
:P_DELIVERYTYPE,:P_DELIVERYMETHOD,:P_PAYMENTMETHOD,
:P_CUSTCOURIERNO,:P_REFNO,:P_NOTES,:P_USERID,
:P_CURSOR
2025-02-24 10:32:41 +05:30
);
END;`,
{
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_SHIPTOTYPE: { val: body.P_SHIPTOTYPE, type: oracledb.DB_TYPE_NVARCHAR },
2025-07-15 16:26:26 +05:30
P_SHIPCONTACTID: { val: body.P_SHIPCONTACTID, type: oracledb.DB_TYPE_NUMBER },
P_SHIPNAME: { val: body.P_SHIPNAME, type: oracledb.DB_TYPE_NVARCHAR },
P_ADDRESS1: { val: body.P_ADDRESS1, type: oracledb.DB_TYPE_NVARCHAR },
P_ADDRESS2: { val: body.P_ADDRESS2, type: oracledb.DB_TYPE_NVARCHAR },
P_CITY: { val: body.P_CITY, type: oracledb.DB_TYPE_NVARCHAR },
P_STATE: { val: body.P_STATE, type: oracledb.DB_TYPE_NVARCHAR },
P_ZIP: { val: body.P_ZIP, type: oracledb.DB_TYPE_NVARCHAR },
P_COUNTRY: { val: body.P_COUNTRY, type: oracledb.DB_TYPE_NVARCHAR },
P_FIRSTNAME: { val: body.P_FIRSTNAME, type: oracledb.DB_TYPE_NVARCHAR },
P_LASTNAME: { val: body.P_LASTNAME, type: oracledb.DB_TYPE_NVARCHAR },
P_TITLE: { val: body.P_TITLE, type: oracledb.DB_TYPE_NVARCHAR },
P_PHONENO: { val: body.P_PHONENO, type: oracledb.DB_TYPE_NVARCHAR },
P_MOBILENO: { val: body.P_MOBILENO, type: oracledb.DB_TYPE_NVARCHAR },
P_FAXNO: { val: body.P_FAXNO, type: oracledb.DB_TYPE_NVARCHAR },
P_EMAILADDRESS: { val: body.P_EMAILADDRESS, type: oracledb.DB_TYPE_NVARCHAR },
P_MIDDLEINITIAL: { val: body.P_MIDDLEINITIAL, type: oracledb.DB_TYPE_NVARCHAR },
2025-02-24 10:32:41 +05:30
P_FORMOFSECURITY: { val: body.P_FORMOFSECURITY, type: oracledb.DB_TYPE_NVARCHAR },
P_INSPROTECTION: { val: body.P_INSPROTECTION, type: oracledb.DB_TYPE_NVARCHAR },
P_LDIPROTECTION: { val: body.P_LDIPROTECTION, type: oracledb.DB_TYPE_NVARCHAR },
P_DELIVERYTYPE: { val: body.P_DELIVERYTYPE, type: oracledb.DB_TYPE_NVARCHAR },
P_DELIVERYMETHOD: { val: body.P_DELIVERYMETHOD, type: oracledb.DB_TYPE_NVARCHAR },
P_PAYMENTMETHOD: { val: body.P_PAYMENTMETHOD, type: oracledb.DB_TYPE_NVARCHAR },
P_CUSTCOURIERNO: { val: body.P_CUSTCOURIERNO, type: oracledb.DB_TYPE_NVARCHAR },
P_REFNO: { val: body.P_REFNO, type: oracledb.DB_TYPE_NVARCHAR },
P_NOTES: { val: body.P_NOTES, 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 }
2025-02-24 10:32:41 +05:30
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CURSOR) {
2025-02-24 10:32:41 +05:30
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, CarnetApplicationService.name);
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", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async EstimatedFees(body: GetCarnetControlCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.EstimatedFees(
: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 }
);
const outBinds = 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, CarnetApplicationService.name);
return fres.length > 0 ? fres[0] : [];
} catch (error) {
handleError(error, CarnetApplicationService.name);
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name);
}
}
2025-02-24 10:32:41 +05:30
// processing [ PROCESSINGCENTER_PKG ]
async ProcessCarnet(body: CarnetProcessingCenterDTO) {
2025-02-24 10:32:41 +05:30
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.ProcessCarnet(
2025-08-05 14:32:54 +05:30
:P_USERID, :P_HEADERID, :P_CURSOR
2025-02-24 10:32:41 +05:30
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
2025-02-24 10:32:41 +05:30
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Processed Successfully", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdatePrintCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.UpdatePrintCarnet(
2025-08-05 14:32:54 +05:30
:P_USERID, :P_HEADERID, :P_CURSOR
2025-02-24 10:32:41 +05:30
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
2025-02-24 10:32:41 +05:30
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
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", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async VoidCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.VoidCarnet(
2025-08-05 14:32:54 +05:30
:P_USERID, :P_HEADERID, :P_CURSOR
2025-02-24 10:32:41 +05:30
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
2025-02-24 10:32:41 +05:30
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Voided Successfully", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
2025-08-13 11:51:24 +05:30
async CopyCarnet(body: CopyCarnetDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.CopyCarnet(
:P_USERID, :P_HEADERID, :P_APPLICATIONNAME, :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_APPLICATIONNAME: { val: body.P_APPLICATIONNAME, type: oracledb.DB_TYPE_NVARCHAR },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Copied Successfully", ...fres[0] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async DuplicateCarnet(body: CarnetProcessingCenterDTO2) {
2025-02-24 10:32:41 +05:30
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.DuplicateCarnet(
:P_USERID, :P_CARNETNO, :P_CURSOR
2025-02-24 10:32:41 +05:30
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CARNETNO: { val: body.P_CARNETNO, type: oracledb.DB_TYPE_NVARCHAR },
2025-02-24 10:32:41 +05:30
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Duplicated Successfully", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async AddlSets(body: CarnetProcessingCenterDTO2) {
2025-08-13 11:51:24 +05:30
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.AddlSets(
:P_USERID, :P_CARNETNO, :P_CURSOR
2025-08-13 11:51:24 +05:30
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CARNETNO: { val: body.P_CARNETNO, type: oracledb.DB_TYPE_NVARCHAR },
2025-08-13 11:51:24 +05:30
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Additional sets completed", ...fres[0] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async ExtendCarnet(body: CarnetProcessingCenterDTO2) {
2025-08-13 11:51:24 +05:30
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.ExtendCarnet(
:P_USERID, :P_CARNETNO, :P_CURSOR
2025-08-13 11:51:24 +05:30
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_CARNETNO: { val: body.P_CARNETNO, type: oracledb.DB_TYPE_NVARCHAR },
2025-08-13 11:51:24 +05:30
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Extended successfully", ...fres[0] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async GetExtendedSection(body: GetExtendedSectionDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.GetExtendedSection(
:P_SPID, :P_HEADERID, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
// return { statusCode: 200, message: "Extended successfully", ...fres[0] };
return fres;
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async SaveExtensionApplication(body: SaveExtensionApplicationDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.SaveExtensionApplication(
:P_USERID, :P_SPID, :P_HEADERID, :P_GOODSPORT, :P_GOODSCOUNTRY, :P_REASONCODE, :P_EXTENSIONPERIOD, :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_GOODSPORT: { val: body.P_GOODSPORT, type: oracledb.DB_TYPE_NVARCHAR },
P_GOODSCOUNTRY: { val: body.P_GOODSCOUNTRY, type: oracledb.DB_TYPE_NVARCHAR },
P_REASONCODE: { val: body.P_REASONCODE, type: oracledb.DB_TYPE_NVARCHAR },
P_EXTENSIONPERIOD: { val: body.P_EXTENSIONPERIOD, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Saved successfully", ...fres[0] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
2025-02-24 10:32:41 +05:30
async CloseCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.CloseCarnet(
2025-08-05 14:32:54 +05:30
:P_USERID, :P_HEADERID, :P_CURSOR
2025-02-24 10:32:41 +05:30
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
2025-02-24 10:32:41 +05:30
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Closed Successfully", ...fres[0] };
2025-02-24 10:32:41 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
2025-08-05 14:32:54 +05:30
}
}
async ResetCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.ResetCarnet(
:P_USERID, :P_HEADERID, :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
2025-08-05 14:32:54 +05:30
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Reset Successfull", ...fres[0] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async DeleteCarnet(body: CarnetProcessingCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PROCESSINGCENTER_PKG.DeleteCarnet(
:P_USERID, :P_HEADERID, :P_CURSOR
);
END;`,
{
P_USERID: { val: body.P_USERID, type: oracledb.DB_TYPE_NVARCHAR },
2025-08-05 14:32:54 +05:30
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = 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, CarnetApplicationService.name);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: "Deleted Successfully", ...fres[0] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
2025-02-24 10:32:41 +05:30
}
}
2025-07-03 16:57:37 +05:30
// [ CARNETCONTROLCENTER_PKG ]
async GetHolderstoEdit(body: GetCarnetControlCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETCONTROLCENTER_PKG.GetHolderstoEdit(
: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 }
);
const outBinds = 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.");
}
2025-07-22 20:43:57 +05:30
const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
return fres.length > 0 ? fres[0] : [];
2025-07-03 16:57:37 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async GetGoodsDetailstoEdit(body: GetCarnetControlCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETCONTROLCENTER_PKG.GetGoodsDetailstoEdit(
: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 }
);
const outBinds = 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.");
}
2025-07-22 20:43:57 +05:30
const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
// if (fres.length > 0 && fres[0].ERRORMESG) {
// this.logger.warn(fres[0].ERRORMESG);
// throw new BadRequestException(fres[0].ERRORMESG)
// }
return fres.length > 0 ? fres[0] : [];
2025-07-03 16:57:37 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async GetCountryDetailstoEdit(body: GetCarnetControlCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETCONTROLCENTER_PKG.GetCountryDetailstoEdit(
: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 }
);
const outBinds = 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.");
}
2025-07-22 20:43:57 +05:30
const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
return fres.length > 0 ?
{
NOOFUSSETS: fres[0].NOOFUSSETS,
P_COUNTRYTABLE: fres.map(({ NOOFUSSETS, ...rest }) => rest)
}
: {};
2025-07-03 16:57:37 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async GetShipPaymentDetailstoEdit(body: GetCarnetControlCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETCONTROLCENTER_PKG.GetShipPaymentDetailstoEdit(
: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 }
);
const outBinds = 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.");
}
2025-07-22 20:43:57 +05:30
const fres: any = await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
return fres.length > 0 ? fres[0] : [];
2025-07-03 16:57:37 +05:30
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async GetGoodsItemstoEdit(body: GetCarnetControlCenterDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
CARNETCONTROLCENTER_PKG.GetGoodsItemstoEdit(
: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 }
);
const outBinds = 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 await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
// [PRINT_PKG]
2025-08-12 15:27:32 +05:30
async getPrintingData(body: PrintCarnetDTO) {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
PRINT_PKG.PrintCarnet(
:P_SPID, :P_HEADERID, :P_PRINTGL, :P_CARNETDATACURSOR, :P_GLDATACURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_HEADERID: { val: body.P_HEADERID, type: oracledb.DB_TYPE_NUMBER },
P_PRINTGL: { val: body.P_PRINTGL === 'Y' ? 'YES' : 'NO', type: oracledb.DB_TYPE_NVARCHAR },
P_CARNETDATACURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
P_GLDATACURSOR: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_CARNETDATACURSOR || !outBinds?.P_GLDATACURSOR) {
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_CARNETDATACURSOR, CarnetApplicationService.name);
const fres1: any = await fetchCursor(outBinds.P_GLDATACURSOR, CarnetApplicationService.name);
2025-08-12 15:27:32 +05:30
if (fres.length === 0 || fres1.length === 0) {
throw new BadRequestException("Print failed please check the submitted details");
}
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
2025-08-13 11:51:24 +05:30
// console.log(fres, "\n", "--------------------", fres1.length > 0 ? fres[0] : []);
2025-08-12 15:27:32 +05:30
return { fres: fres, fres1: fres1 }
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
2025-08-12 15:27:32 +05:30
async PrintCarnet(body: PrintCarnetDTO) {
try {
const { fres, fres1 }: any = await this.getPrintingData(body);
2025-08-13 11:51:24 +05:30
if (body.P_PRINTGL === 'Y') {
if (fres.length === 0 || !fres[0].CARNETNO || fres1.length === 0) {
throw new BadRequestException("Print failed please check the submitted details");
}
}
else {
if (fres.length === 0 || !fres[0].CARNETNO) {
throw new BadRequestException("Print failed please check the submitted details");
}
2025-08-12 15:27:32 +05:30
}
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
try {
2025-08-13 11:51:24 +05:30
const glData: pdfGLData[] = fres1.map((x: any) => {
2025-08-12 15:27:32 +05:30
return {
itemNo: x.ITEMNO,
description: x.ITEMDESCRIPTION,
noOfPieces: x.NOOFPIECES,
weight: x.WEIGHT,
itemValue: x.ITEMVALUE,
countryOfOrigin: x.GOODSORIGINCOUNTRY
};
});
const carnetData: pdfCarnetData = {
2025-08-13 11:51:24 +05:30
carnetNo: fres[0].CARNETNO ?? "",
ISSUEDBY: fres[0].ISSUEDBY ?? "",
ISSUEDATE: fres[0].ISSUEDATE ?? "",
EXPDATE: fres[0].EXPDATE ?? "",
AUTHREP: fres[0].AUTHREP ?? "",
NOOFUSSETS: fres[0].NOOFUSSETS ?? 0,
NOOFFOREIGNSETS: fres[0].NOOFFOREIGNSETS ?? 0,
NOOFTRANSITSETS: fres[0].NOOFTRANSITSETS ?? 0,
PRINTGOODSTOBEEXPORTED: fres[0].PRINTGOODSTOBEEXPORTED ?? "",
HOLDERDATATOPRINT: fres[0].HOLDERDATATOPRINT ?? "",
CONTINUATIONSHEETS: fres[0].CONTINUATIONSHEETS ?? 0,
NEXTUSCFNO: fres[0].NEXTUSCFNO ?? 0,
NEXTFOREIGNCFNO: fres[0].NEXTFOREIGNCFNO ?? 0,
NEXTTRANSITCFNO: fres[0].NEXTTRANSITCFNO ?? 0,
2025-08-12 15:27:32 +05:30
contPageNo: 0
}
const p1Status = await generateGreenCoverPDF(carnetData);
let p2Status: any = "";
if (body.P_PRINTGL === 'Y') {
2025-08-13 11:51:24 +05:30
p2Status = await generateGL(glData, carnetData, body);
2025-08-12 15:27:32 +05:30
// console.log("-------- p2 --------", p2Status);
// console.log(typeof p2Status.batch, p2Status.batch);
if (p2Status.batch % 2 === 0) {
await generateFinalPDF([...p2Status.fileArray, '2GeneralListVOID.pdf'], `${replaceSlashWithDash(carnetData.carnetNo)}p2.pdf`)
await deleteFilesAsync([...p2Status.fileArray])
}
else {
await generateFinalPDF([...p2Status.fileArray], `${replaceSlashWithDash(carnetData.carnetNo)}p2.pdf`)
await deleteFilesAsync([...p2Status.fileArray])
}
} else {
p2Status = await generateGL1(carnetData);
if (p2Status === 'p2 done') {
await generateFinalPDF([`${replaceSlashWithDash(carnetData.carnetNo)}p2.pdf`, '2GeneralListVOID.pdf'], `${replaceSlashWithDash(carnetData.carnetNo)}p2.pdf`)
}
}
const p3Status = await usCounterFoil(carnetData);
const p4Status = await fnCounterFoil(carnetData);
const p5Status = await tsCounterFoil(carnetData);
const p6Status = await fnVochers(carnetData, body);
const p7Status = await tnVochers(carnetData, body);
const finalArray = [
...p3Status,
...p4Status,
...p5Status,
...p6Status,
...p7Status
]
return { finalArray, carnetData }
} catch (error) {
throw new InternalServerException(error.message)
}
} catch (error) {
handleError(error, CarnetApplicationService.name)
}
}
async PrintGL(body: PrintGLDTO) {
let newBody: PrintCarnetDTO = { ...body, P_PRINTGL: YON.YES }
try {
const { fres, fres1 }: any = await this.getPrintingData(newBody);
if (fres.length === 0 || fres1.length === 0) {
throw new BadRequestException("Print failed please check the submitted details");
}
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
try {
const glData: pdfGLData[] = fres1.map(x => {
return {
itemNo: x.ITEMNO,
description: x.ITEMDESCRIPTION,
noOfPieces: x.NOOFPIECES,
weight: x.WEIGHT,
itemValue: x.ITEMVALUE,
countryOfOrigin: x.GOODSORIGINCOUNTRY
};
});
const carnetData: pdfCarnetData = {
2025-08-13 11:51:24 +05:30
carnetNo: fres[0].CARNETNO ?? "",
ISSUEDBY: fres[0].ISSUEDBY ?? "",
ISSUEDATE: fres[0].ISSUEDATE ?? "",
EXPDATE: fres[0].EXPDATE ?? "",
AUTHREP: fres[0].AUTHREP ?? "",
NOOFUSSETS: fres[0].NOOFUSSETS ?? 0,
NOOFFOREIGNSETS: fres[0].NOOFFOREIGNSETS ?? 0,
NOOFTRANSITSETS: fres[0].NOOFTRANSITSETS ?? 0,
PRINTGOODSTOBEEXPORTED: fres[0].PRINTGOODSTOBEEXPORTED ?? "",
HOLDERDATATOPRINT: fres[0].HOLDERDATATOPRINT ?? "",
CONTINUATIONSHEETS: fres[0].CONTINUATIONSHEETS ?? 0,
NEXTUSCFNO: fres[0].NEXTUSCFNO ?? 0,
NEXTFOREIGNCFNO: fres[0].NEXTFOREIGNCFNO ?? 0,
NEXTTRANSITCFNO: fres[0].NEXTTRANSITCFNO ?? 0,
2025-08-12 15:27:32 +05:30
contPageNo: 0
}
// const p1Status = await generateGreenCoverPDF(carnetData);
let p2Status: any = "";
2025-08-13 11:51:24 +05:30
p2Status = await generateGL(glData, carnetData, body);
2025-08-12 15:27:32 +05:30
// console.log("-------- p2 --------", p2Status);
// console.log(typeof p2Status.batch, p2Status.batch);
if (p2Status.batch % 2 === 0) {
2025-08-13 11:51:24 +05:30
await generateFinalPDF([...p2Status.fileArray, '2GeneralListVOID.pdf'], `${body.P_HEADERID}p2.pdf`)
2025-08-12 15:27:32 +05:30
await deleteFilesAsync([...p2Status.fileArray])
}
else {
2025-08-13 11:51:24 +05:30
await generateFinalPDF([...p2Status.fileArray], `${body.P_HEADERID}p2.pdf`)
2025-08-12 15:27:32 +05:30
await deleteFilesAsync([...p2Status.fileArray])
}
// const p3Status = await usCounterFoil(carnetData);
// const p4Status = await fnCounterFoil(carnetData);
// const p5Status = await tsCounterFoil(carnetData);
// const p6Status = await fnVochers(carnetData);
// const p7Status = await tnVochers(carnetData);
const finalArray = [
// ...p3Status,
// ...p4Status,
// ...p5Status,
// ...p6Status,
// ...p7Status
]
return { finalArray, carnetData }
} catch (error) {
throw new InternalServerException(error.message)
}
} catch (error) {
handleError(error, CarnetApplicationService.name)
}
}
2025-08-18 20:34:44 +05:30
// [payment]
async InitiatePayment() {
try {
const accessToken = await this.payPalService.generateAccessToken();
// return { accessToken, orderid: "1abc" }
const response = await axios({
url: process.env.PAYPAL_BASE_URL + '/v2/checkout/orders',
method: 'post',
headers: {
'Content-Type': 'application/json',
Authorization: 'Bearer ' + accessToken
},
data: JSON.stringify({
intent: 'CAPTURE',
purchase_units: [
{
items: [
{
name: 'carnet',
description: 'carnet',
quantity: 1,
unit_amount: {
currency_code: 'USD',
value: '100.00'
}
}
],
amount: {
currency_code: 'USD',
value: '100.00',
breakdown: {
item_total: {
currency_code: 'USD',
value: '100.00'
}
}
}
}
],
application_context: {
return_url: process.env.BASE_URL + '/complete-order',
cancel_url: process.env.BASE_URL + '/cancel-order',
shipping_preference: 'NO_SHIPPING',
user_action: 'PAY_NOW',
brand_name: 'test sample',
disable_funding: "card"
}
})
});
// console.log('PayPal create order response headers:', response.headers);
// console.log('PayPal create order response data:', response.data);
return {
id: response.data.id, href: response?.data?.links?.find(obj => obj.rel === 'approve')?.href
};
// return { id: response.data.id };
} catch (error) {
console.error('Error creating PayPal order:', error.response?.data || error.message || error);
// Return a structured error object or throw to be handled by caller
throw new InternalServerException();
// return {
// error: true,
// message: 'Failed to create PayPal order',
// details: error.response?.data || error.message || error
// };
}
}
async CapturePayment(body: CapturePaymentDTO) {
try {
const accessToken = await this.payPalService.generateAccessToken();
const response = await axios({
url: `${process.env.PAYPAL_BASE_URL}/v2/checkout/orders/${body.P_ORDERID}/capture`,
method: 'post',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`,
},
});
const capture = response?.data?.purchase_units?.[0]?.payments?.captures?.[0];
return {
statusCode: 200,
message: "Payment successful",
amount: `${capture?.amount?.value} ${capture?.amount?.currency_code}`,
};
} catch (error: any) {
const status = error.response?.status || 500;
const message = error.response?.data?.message || "Payment failed due to an unexpected error.";
// Optional: log full error for debugging
console.error("PayPal Capture Error:", {
status,
message,
details: error.response?.data,
});
if (status === 404) {
throw new NotFoundException(error.response?.data?.message || error?.message || "Resource Not Found")
}
throw new InternalServerException();
}
}
2025-02-24 10:32:41 +05:30
}