print carnet api

This commit is contained in:
Kallesh B S 2025-08-05 16:59:36 +05:30
parent 49e4f45073
commit 401981ec8c
4 changed files with 69 additions and 12 deletions

View File

@ -12,6 +12,16 @@ export enum YON {
NO = "N",
}
export class PRINTGL_DTO {
@ApiProperty({ required: true, enum: YON })
@Transform(({ value }) => typeof value === 'string' ? value.trim().toUpperCase() : value)
@IsEnum(YON, { message: 'P_PRINTGL must be either "Y" or "N"' })
@Length(1, 1, { message: 'P_PRINTGL must be 1 character' })
@IsString()
@IsDefined({ message: "Invalid Request" })
P_PRINTGL: YON;
}
export class CARNETSTATUS_DTO {
@ApiProperty({ required: true })
@Length(0, 20, {

View File

@ -5,6 +5,7 @@ import {
COUNTRYTABLE_DTO, CUSTCOURIERNO_DTO, DELIVERYMETHOD_DTO, DELIVERYTYPE_DTO,
EXIBITIONS_FAIR_FLAG_DTO, FORMOFSECURITY_DTO, GLTABLE_DTO, HEADERID_DTO,
HORSE_FLAG_DTO, INSPROTECTION_DTO, ITEMNO_DTO, LDIPROTECTION_DTO, ORDERTYPE_DTO, PAYMENTMETHOD_DTO,
PRINTGL_DTO,
PROF_EQUIPMENT_FLAG_DTO, REFNO_DTO, SHIPADDRID_DTO, SHIPCONTACTID_DTO, SHIPNAME_DTO, SHIPTOTYPE_DTO, USSETS_DTO
} from "./carnet-application-property.dto";
@ -54,6 +55,8 @@ export class TransmitApplicationtoProcessDTO extends IntersectionType(
export class CarnetProcessingCenterDTO extends (IntersectionType(USERID_DTO, HEADERID_DTO)) { }
export class PrintCarnetDTO extends (IntersectionType(SPID_DTO, HEADERID_DTO, PRINTGL_DTO)){}
export class CreateApplicationDTO extends IntersectionType(
SPID_DTO, CLIENTID_DTO, LOCATIONID_DTO, USERID_DTO, APPLICATIONNAME_DTO,
ORDERTYPE_DTO

View File

@ -7,7 +7,7 @@ import {
AddCountriesDTO,
AddGenerallistItemsDTO,
CA_UpdateHolderDTO,
CarnetProcessingCenterDTO, CreateApplicationDTO, DeleteGenerallistItemsDTO, GetCarnetControlCenterDTO, SaveCarnetApplicationDTO, TransmitApplicationtoProcessDTO,
CarnetProcessingCenterDTO, CreateApplicationDTO, DeleteGenerallistItemsDTO, GetCarnetControlCenterDTO, PrintCarnetDTO, SaveCarnetApplicationDTO, TransmitApplicationtoProcessDTO,
UpdateExpGoodsAuthRepDTO,
UpdateShippingDetailsDTO
} from 'src/dto/property.dto';
@ -150,4 +150,10 @@ export class CarnetApplicationController {
return this.carnetApplicationService.GetShipPaymentDetailstoEdit(body);
}
// [PRINT_PKG]
@Post('PrintCarnet')
PrintCarnet(@Body() body: PrintCarnetDTO) {
return this.carnetApplicationService.PrintCarnet(body);
}
}

View File

@ -13,7 +13,8 @@ import {
UpdateShippingDetailsDTO,
CA_UpdateHolderDTO,
GetCarnetControlCenterDTO,
DeleteGenerallistItemsDTO
DeleteGenerallistItemsDTO,
PrintCarnetDTO
} from 'src/dto/property.dto';
import { OracleService } from '../oracle.service';
import { BadRequestException } from 'src/exceptions/badRequest.exception';
@ -138,7 +139,6 @@ export class CarnetApplicationService {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
let connection;
try {
@ -181,7 +181,6 @@ export class CarnetApplicationService {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async CreateApplication(body: CreateApplicationDTO) {
let connection;
try {
@ -229,7 +228,6 @@ export class CarnetApplicationService {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateHolder(body: CA_UpdateHolderDTO) {
let connection;
try {
@ -273,7 +271,6 @@ export class CarnetApplicationService {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateExpGoodsAuthRep(body: UpdateExpGoodsAuthRepDTO) {
let connection;
try {
@ -323,7 +320,6 @@ export class CarnetApplicationService {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async AddGenerallistItems(body: AddGenerallistItemsDTO) {
let connection;
try {
@ -371,7 +367,6 @@ export class CarnetApplicationService {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async EditGenerallistItems(body: AddGenerallistItemsDTO) {
let connection;
try {
@ -418,7 +413,6 @@ export class CarnetApplicationService {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async DeleteGenerallistItems(body: DeleteGenerallistItemsDTO) {
let connection;
try {
@ -466,7 +460,6 @@ export class CarnetApplicationService {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async AddCountries(body: AddCountriesDTO) {
let connection;
try {
@ -515,7 +508,6 @@ export class CarnetApplicationService {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async UpdateShippingDetails(body: UpdateShippingDetailsDTO) {
let connection;
try {
@ -590,7 +582,6 @@ export class CarnetApplicationService {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
async EstimatedFees(body: GetCarnetControlCenterDTO) {
let connection;
@ -1122,4 +1113,51 @@ export class CarnetApplicationService {
}
}
// [PRINT_PKG]
async PrintCarnet(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);
if (fres.length > 0 && fres[0].ERRORMESG) {
this.logger.warn(fres[0].ERRORMESG);
throw new BadRequestException(fres[0].ERRORMESG)
}
return { P_CARNETDATACURSOR: fres, P_GLDATACURSOR: fres1 };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
await closeOracleDbConnection(connection, CarnetApplicationService.name)
}
}
}