adding carnet module
This commit is contained in:
parent
3c27de26b9
commit
19115d50fe
302
src/pg/carnet-application/carnet-application.controller.ts
Normal file
302
src/pg/carnet-application/carnet-application.controller.ts
Normal file
@ -0,0 +1,302 @@
|
|||||||
|
import { Body, Controller, Delete, Get, HttpCode, Param, Patch, Post, Put, Res, StreamableFile, UseGuards } from '@nestjs/common';
|
||||||
|
import { CarnetApplicationService } from './carnet-application.service';
|
||||||
|
|
||||||
|
import {
|
||||||
|
AddCountriesDTO,
|
||||||
|
AddGenerallistItemsDTO,
|
||||||
|
CA_UpdateHolderDTO,
|
||||||
|
CapturePaymentDTO,
|
||||||
|
CarnetProcessingCenterDTO, CarnetProcessingCenterDTO2, CopyCarnetDTO, CreateApplicationDTO, DeleteGenerallistItemsDTO, EditGenerallistItemsDTO, GetCarnetControlCenterDTO, GetExtendedSectionDTO, GetOrderDetailsDTO, GetPaymentHistoryDTO, InitiatePaymentDTO, PrintCarnetDTO, PrintGLDTO, SaveCarnetApplicationDTO, SaveExtensionApplicationDTO, SaveHistoryDTO, TransmitApplicationtoProcessDTO,
|
||||||
|
UpdateExpGoodsAuthRepDTO,
|
||||||
|
UpdateShippingDetailsDTO
|
||||||
|
} from 'src/dto/property.dto';
|
||||||
|
import { Roles } from 'src/decorators/roles.decorator';
|
||||||
|
import { deleteFilesAsync, generateFinalPDF, replaceSlashWithDash } from 'src/utils/helper';
|
||||||
|
import { Response } from 'express';
|
||||||
|
import { join } from 'path';
|
||||||
|
import { InternalServerException } from 'src/exceptions/internalServerError.exception';
|
||||||
|
import { BadRequestException } from 'src/exceptions/badRequest.exception';
|
||||||
|
import { createReadStream } from 'fs';
|
||||||
|
import { BadRequestException as BR } from 'src/exceptions/badRequest.exception';
|
||||||
|
import { JwtAuthGuard } from 'src/guards/jwt-auth.guard';
|
||||||
|
import { RolesGuard } from 'src/guards/roles.guard';
|
||||||
|
import { ApiExcludeController, ApiTags } from '@nestjs/swagger';
|
||||||
|
|
||||||
|
@ApiTags('Carnet Application - PG')
|
||||||
|
// @UseGuards(JwtAuthGuard, RolesGuard)
|
||||||
|
@Roles('ca', 'sa')
|
||||||
|
@Controller('2')
|
||||||
|
export class CarnetApplicationController {
|
||||||
|
constructor(private readonly carnetApplicationService: CarnetApplicationService) { }
|
||||||
|
|
||||||
|
// [ CARNETAPPLICATION_PKG ]
|
||||||
|
|
||||||
|
// @Post('SaveCarnetApplication')
|
||||||
|
// async CreateClientData(@Body() body: SaveCarnetApplicationDTO) {
|
||||||
|
// return this.carnetApplicationService.SaveCarnetApplication(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Post('TransmitApplicationtoProcess')
|
||||||
|
@Roles('ca')
|
||||||
|
TransmitApplicationtoProcess(@Body() body: TransmitApplicationtoProcessDTO) {
|
||||||
|
return this.carnetApplicationService.TransmitApplicationtoProcess(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Post('CreateApplication')
|
||||||
|
@Roles('ca')
|
||||||
|
CreateApplication(@Body() body: CreateApplicationDTO) {
|
||||||
|
return this.carnetApplicationService.CreateApplication(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Patch('update-holder')
|
||||||
|
UpdateHolder(@Body() body: CA_UpdateHolderDTO) {
|
||||||
|
return this.carnetApplicationService.UpdateHolder(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Patch('UpdateExpGoodsAuthRep')
|
||||||
|
// UpdateExpGoodsAuthRep(@Body() body: UpdateExpGoodsAuthRepDTO) {
|
||||||
|
// return this.carnetApplicationService.UpdateExpGoodsAuthRep(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Post('AddGenerallistItems')
|
||||||
|
// AddGenerallistItems(@Body() body: AddGenerallistItemsDTO) {
|
||||||
|
// return this.carnetApplicationService.AddGenerallistItems(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Post('AddCountries')
|
||||||
|
// AddCountries(@Body() body: AddCountriesDTO) {
|
||||||
|
// return this.carnetApplicationService.AddCountries(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Put('EditGenerallistItems')
|
||||||
|
// EditGenerallistItems(@Body() body: EditGenerallistItemsDTO) {
|
||||||
|
// return this.carnetApplicationService.EditGenerallistItems(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Delete('DeleteGenerallistItems')
|
||||||
|
// DeleteGenerallistItems(@Body() body: DeleteGenerallistItemsDTO) {
|
||||||
|
// return this.carnetApplicationService.DeleteGenerallistItems(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Patch('UpdateShippingDetails')
|
||||||
|
// UpdateShippingDetails(@Body() body: UpdateShippingDetailsDTO) {
|
||||||
|
// return this.carnetApplicationService.UpdateShippingDetails(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Get('EstimatedFees/:P_SPID/:P_USERID/:P_HEADERID')
|
||||||
|
// EstimatedFees(@Param() body: GetCarnetControlCenterDTO) {
|
||||||
|
// return this.carnetApplicationService.EstimatedFees(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // processing [ PROCESSINGCENTER_PKG ]
|
||||||
|
|
||||||
|
// @Patch('ProcessCarnet')
|
||||||
|
// ProcessOriginalCarnet(@Body() body: CarnetProcessingCenterDTO) {
|
||||||
|
// return this.carnetApplicationService.ProcessCarnet(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Patch('UpdatePrintCarnet')
|
||||||
|
// UpdatePrintCarnet(@Body() body: CarnetProcessingCenterDTO) {
|
||||||
|
// return this.carnetApplicationService.UpdatePrintCarnet(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Patch('VoidCarnet')
|
||||||
|
// @Roles('sa')
|
||||||
|
// VoidCarnet(@Body() body: CarnetProcessingCenterDTO) {
|
||||||
|
// return this.carnetApplicationService.VoidCarnet(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// @Patch('CopyCarnet')
|
||||||
|
// CopyCarnet(@Body() body: CopyCarnetDTO) {
|
||||||
|
// return this.carnetApplicationService.CopyCarnet(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Patch('DuplicateCarnet')
|
||||||
|
// DuplicateCarnet(@Body() body: CarnetProcessingCenterDTO2) {
|
||||||
|
// return this.carnetApplicationService.DuplicateCarnet(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Patch('AddlSets')
|
||||||
|
// AddlSets(@Body() body: CarnetProcessingCenterDTO2) {
|
||||||
|
// return this.carnetApplicationService.AddlSets(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Patch('ExtendCarnet')
|
||||||
|
// ExtendCarnet(@Body() body: CarnetProcessingCenterDTO2) {
|
||||||
|
// return this.carnetApplicationService.ExtendCarnet(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Get('GetExtendedSection/:P_SPID/:P_HEADERID')
|
||||||
|
// GetExtendedSection(@Param() body: GetExtendedSectionDTO) {
|
||||||
|
// return this.carnetApplicationService.GetExtendedSection(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Post('SaveExtensionApplication')
|
||||||
|
// @HttpCode(200)
|
||||||
|
// SaveExtensionApplication(@Body() body: SaveExtensionApplicationDTO) {
|
||||||
|
// return this.carnetApplicationService.SaveExtensionApplication(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Patch('CloseCarnet')
|
||||||
|
// @Roles('sa')
|
||||||
|
// CloseCarnet(@Body() body: CarnetProcessingCenterDTO) {
|
||||||
|
// return this.carnetApplicationService.CloseCarnet(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Patch('ResetCarnet')
|
||||||
|
// @Roles('sa')
|
||||||
|
// ResetCarnet(@Body() body: CarnetProcessingCenterDTO) {
|
||||||
|
// return this.carnetApplicationService.ResetCarnet(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Delete('DeleteCarnet')
|
||||||
|
// DeleteCarnet(@Body() body: CarnetProcessingCenterDTO) {
|
||||||
|
// return this.carnetApplicationService.DeleteCarnet(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// [ CARNETCONTROLCENTER_PKG ]
|
||||||
|
|
||||||
|
@Get('GetHolderstoEdit/:P_SPID/:P_USERID/:P_HEADERID')
|
||||||
|
GetHolderstoEdit(@Param() body: GetCarnetControlCenterDTO) {
|
||||||
|
return this.carnetApplicationService.GetHolderstoEdit(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('GetGoodsDetailstoEdit/:P_SPID/:P_USERID/:P_HEADERID')
|
||||||
|
GetGoodsDetailstoEdit(@Param() body: GetCarnetControlCenterDTO) {
|
||||||
|
return this.carnetApplicationService.GetGoodsDetailstoEdit(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('GetGoodsItemstoEdit/:P_SPID/:P_USERID/:P_HEADERID')
|
||||||
|
GetGoodsItemstoEdit(@Param() body: GetCarnetControlCenterDTO) {
|
||||||
|
return this.carnetApplicationService.GetGoodsItemstoEdit(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('GetCountryDetailstoEdit/:P_SPID/:P_USERID/:P_HEADERID')
|
||||||
|
GetCountryDetailstoEdit(@Param() body: GetCarnetControlCenterDTO) {
|
||||||
|
return this.carnetApplicationService.GetCountryDetailstoEdit(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Get('GetShipPaymentDetailstoEdit/:P_SPID/:P_USERID/:P_HEADERID')
|
||||||
|
GetShipPaymentDetailstoEdit(@Param() body: GetCarnetControlCenterDTO) {
|
||||||
|
return this.carnetApplicationService.GetShipPaymentDetailstoEdit(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
// [PRINT_PKG]
|
||||||
|
// @Post('PrintCarnet')
|
||||||
|
// @HttpCode(200)
|
||||||
|
// async PrintCarnet(@Body() body: PrintCarnetDTO, @Res({ passthrough: true }) res: Response) {
|
||||||
|
|
||||||
|
// try {
|
||||||
|
// const { finalArray, carnetData }: any = await this.carnetApplicationService.PrintCarnet(body);
|
||||||
|
// // const filterCarnetData = finalArray.filter(item => item !== '2GeneralList.pdf')
|
||||||
|
|
||||||
|
// let filesArray = [`${replaceSlashWithDash(carnetData.carnetNo)}p1.pdf`, `${replaceSlashWithDash(carnetData.carnetNo)}p2.pdf`];
|
||||||
|
// // await generateFinalPDF([...filesArray, '2GeneralList.pdf', ...carnetData], 'carnet.pdf');
|
||||||
|
// await generateFinalPDF([...filesArray, ...finalArray, '13LastSheetP3.pdf', '13LastSheetP4.pdf'], `${replaceSlashWithDash(carnetData.carnetNo)}carnet.pdf`);
|
||||||
|
|
||||||
|
// const fileName = `${replaceSlashWithDash(carnetData.carnetNo)}carnet.pdf`;
|
||||||
|
|
||||||
|
// res.set({
|
||||||
|
// 'Content-Type': 'application/pdf',
|
||||||
|
// 'Content-Disposition': `attachment; filename="${fileName}"`,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const filePath = join(process.cwd(), 'dist/public/carnet-pdf', fileName); //server
|
||||||
|
// // const filePath = join(process.cwd(), 'public/carnet-pdf', fileName); //local
|
||||||
|
|
||||||
|
// console.log(filePath);
|
||||||
|
|
||||||
|
|
||||||
|
// // console.log(filePath);
|
||||||
|
|
||||||
|
// const stream = createReadStream(filePath);
|
||||||
|
|
||||||
|
// // Clean up files after response finishes streaming
|
||||||
|
// res.on('finish', async () => {
|
||||||
|
// await deleteFilesAsync([...filesArray, ...finalArray.filter(x => x !== `${replaceSlashWithDash(carnetData.carnetNo)}p2.pdf`), fileName]);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// return new StreamableFile(stream);
|
||||||
|
// } catch (error) {
|
||||||
|
// if (error instanceof BadRequestException || error instanceof BR) {
|
||||||
|
// throw new BadRequestException("Download failed please check the details")
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// throw new InternalServerException("Error while downloading");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Post('PrintGL')
|
||||||
|
// @HttpCode(200)
|
||||||
|
// async PrintGL(@Body() body: PrintGLDTO, @Res({ passthrough: true }) res: Response) {
|
||||||
|
// try {
|
||||||
|
// const { finalArray, carnetData }: any = await this.carnetApplicationService.PrintGL(body);
|
||||||
|
|
||||||
|
// let filesArray = [`${body.P_HEADERID}p2.pdf`];
|
||||||
|
// // await generateFinalPDF([...filesArray, '2GeneralList.pdf', ...carnetData], 'carnet.pdf');
|
||||||
|
// await generateFinalPDF([...filesArray, ...finalArray], `${body.P_HEADERID}-GL.pdf`);
|
||||||
|
|
||||||
|
// const fileName = `${body.P_HEADERID}-GL.pdf`;
|
||||||
|
|
||||||
|
// res.set({
|
||||||
|
// 'Content-Type': 'application/pdf',
|
||||||
|
// 'Content-Disposition': `attachment; filename="${fileName}"`,
|
||||||
|
// });
|
||||||
|
|
||||||
|
// const filePath = join(process.cwd(), 'dist/public/carnet-pdf', fileName); //server
|
||||||
|
// // const filePath = join(process.cwd(), 'public/carnet-pdf', fileName); //local
|
||||||
|
|
||||||
|
// // console.log(filePath);
|
||||||
|
|
||||||
|
|
||||||
|
// // console.log(filePath);
|
||||||
|
|
||||||
|
// const stream = createReadStream(filePath);
|
||||||
|
|
||||||
|
// // Clean up files after response finishes streaming
|
||||||
|
// res.on('finish', async () => {
|
||||||
|
// await deleteFilesAsync([...filesArray, ...finalArray, fileName]);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// return new StreamableFile(stream);
|
||||||
|
// } catch (error) {
|
||||||
|
// if (error instanceof BadRequestException || error instanceof BR) {
|
||||||
|
// throw new BadRequestException("Download failed please check the details")
|
||||||
|
// }
|
||||||
|
// else {
|
||||||
|
// throw new InternalServerException("Error while downloading");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
//[payment]
|
||||||
|
|
||||||
|
// @Post('InitiatePayment')
|
||||||
|
// async InitiatePayment(@Body() body: InitiatePaymentDTO) {
|
||||||
|
// return this.carnetApplicationService.InitiatePayment(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Post('CompletePayment')
|
||||||
|
// @HttpCode(200)
|
||||||
|
// async CapturePayment(@Body() body: CapturePaymentDTO) {
|
||||||
|
// return this.carnetApplicationService.CapturePayment(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Get('OrderDetails/:P_ORDERID')
|
||||||
|
async OrderDetails(@Param() body: GetOrderDetailsDTO) {
|
||||||
|
return this.carnetApplicationService.OrderDetails(body);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @Get('GetPaymentHistory/:P_APPLICATIONNAME/:P_USERID')
|
||||||
|
// async GetPaymentHistory(@Param() body: GetPaymentHistoryDTO) {
|
||||||
|
// return this.carnetApplicationService.GetPaymentHistory(body);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// @Post('SaveHistory')
|
||||||
|
// @HttpCode(200)
|
||||||
|
// async SaveHistory(@Body() body: SaveHistoryDTO) {
|
||||||
|
// return this.carnetApplicationService.SaveHistory(body);
|
||||||
|
// }
|
||||||
|
}
|
||||||
9
src/pg/carnet-application/carnet-application.module.ts
Normal file
9
src/pg/carnet-application/carnet-application.module.ts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
import { Module } from '@nestjs/common';
|
||||||
|
import { CarnetApplicationController } from './carnet-application.controller';
|
||||||
|
import { CarnetApplicationService } from './carnet-application.service';
|
||||||
|
|
||||||
|
@Module({
|
||||||
|
controllers: [CarnetApplicationController],
|
||||||
|
providers: [CarnetApplicationService]
|
||||||
|
})
|
||||||
|
export class CarnetApplicationModule {}
|
||||||
371
src/pg/carnet-application/carnet-application.service.ts
Normal file
371
src/pg/carnet-application/carnet-application.service.ts
Normal file
@ -0,0 +1,371 @@
|
|||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
|
||||||
|
import {
|
||||||
|
CarnetProcessingCenterDTO, SaveCarnetApplicationDTO, TransmitApplicationtoProcessDTO,
|
||||||
|
CreateApplicationDTO,
|
||||||
|
UpdateExpGoodsAuthRepDTO,
|
||||||
|
AddGenerallistItemsDTO,
|
||||||
|
AddCountriesDTO,
|
||||||
|
UpdateShippingDetailsDTO,
|
||||||
|
CA_UpdateHolderDTO,
|
||||||
|
GetCarnetControlCenterDTO,
|
||||||
|
DeleteGenerallistItemsDTO,
|
||||||
|
PrintCarnetDTO,
|
||||||
|
PrintGLDTO,
|
||||||
|
YON,
|
||||||
|
CopyCarnetDTO,
|
||||||
|
GetExtendedSectionDTO,
|
||||||
|
SaveExtensionApplicationDTO,
|
||||||
|
CarnetProcessingCenterDTO2,
|
||||||
|
CapturePaymentDTO,
|
||||||
|
InitiatePaymentDTO,
|
||||||
|
GetOrderDetailsDTO,
|
||||||
|
GetPaymentHistoryDTO,
|
||||||
|
SaveHistoryDTO
|
||||||
|
} from 'src/dto/property.dto';
|
||||||
|
import { BadRequestException } from 'src/exceptions/badRequest.exception';
|
||||||
|
import { PoolClient } from 'pg';
|
||||||
|
import { PgDBService } from 'src/db/db.service';
|
||||||
|
import { checkPgUserDefinedErrors, handlePgError, releasePgClient, ResponseStatus } from 'src/utils/helper';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class CarnetApplicationService {
|
||||||
|
|
||||||
|
constructor(private readonly pgDBService: PgDBService) { }
|
||||||
|
|
||||||
|
// [ CARNETAPPLICATION_PKG ]
|
||||||
|
|
||||||
|
// async SaveCarnetApplication(body: SaveCarnetApplicationDTO) { }
|
||||||
|
async TransmitApplicationtoProcess(body: TransmitApplicationtoProcessDTO) {
|
||||||
|
let client: PoolClient | null = null;
|
||||||
|
|
||||||
|
const cursorName = 'p_cursor';
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await this.pgDBService.getConnection();
|
||||||
|
|
||||||
|
await client.query('BEGIN');
|
||||||
|
|
||||||
|
const callProcQuery = `
|
||||||
|
CALL "CARNETSYS".carnetapplication_pkg_transmitapplicationtoprocess($1, $2, $3, $4)
|
||||||
|
`;
|
||||||
|
await client.query(callProcQuery, [body.P_SPID, body.P_USERID, body.P_HEADERID, cursorName]);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in FETCH
|
||||||
|
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in CLOSE
|
||||||
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
|
await client.query('COMMIT');
|
||||||
|
|
||||||
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
message: ResponseStatus.transmitted,
|
||||||
|
...fetchResult?.rows?.[0] || {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (client) await client.query('ROLLBACK');
|
||||||
|
handlePgError(error, CarnetApplicationService.name)
|
||||||
|
} finally {
|
||||||
|
releasePgClient(client)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async CreateApplication(body: CreateApplicationDTO) {
|
||||||
|
let client: PoolClient | null = null;
|
||||||
|
|
||||||
|
const cursorName = 'p_cursor';
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await this.pgDBService.getConnection();
|
||||||
|
|
||||||
|
await client.query('BEGIN');
|
||||||
|
|
||||||
|
const callProcQuery = `
|
||||||
|
CALL "CARNETSYS".carnetapplication_pkg_createapplication($1, $2, $3, $4, $5, $6, $7)
|
||||||
|
`;
|
||||||
|
await client.query(callProcQuery, [body.P_SPID, body.P_CLIENTID, body.P_LOCATIONID, body.P_USERID, body.P_APPLICATIONNAME, body.P_ORDERTYPE, cursorName]);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in FETCH
|
||||||
|
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in CLOSE
|
||||||
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
|
await client.query('COMMIT');
|
||||||
|
|
||||||
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
|
return {
|
||||||
|
statusCode: 201,
|
||||||
|
message: ResponseStatus.created,
|
||||||
|
...fetchResult?.rows?.[0] || {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (client) await client.query('ROLLBACK');
|
||||||
|
handlePgError(error, CarnetApplicationService.name)
|
||||||
|
} finally {
|
||||||
|
releasePgClient(client)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async UpdateHolder(body: CA_UpdateHolderDTO) {
|
||||||
|
let client: PoolClient | null = null;
|
||||||
|
|
||||||
|
const cursorName = 'p_cursor';
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await this.pgDBService.getConnection();
|
||||||
|
|
||||||
|
await client.query('BEGIN');
|
||||||
|
|
||||||
|
const callProcQuery = `
|
||||||
|
CALL "CARNETSYS".carnetapplication_pkg_createapplication($1, $2, $3)
|
||||||
|
`;
|
||||||
|
await client.query(callProcQuery, [body.P_HEADERID, body.P_HOLDERID, cursorName]);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in FETCH
|
||||||
|
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in CLOSE
|
||||||
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
|
await client.query('COMMIT');
|
||||||
|
|
||||||
|
checkPgUserDefinedErrors(fetchResult);
|
||||||
|
|
||||||
|
return {
|
||||||
|
statusCode: 200,
|
||||||
|
message: ResponseStatus.updated,
|
||||||
|
...fetchResult?.rows?.[0] || {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (client) await client.query('ROLLBACK');
|
||||||
|
handlePgError(error, CarnetApplicationService.name)
|
||||||
|
} finally {
|
||||||
|
releasePgClient(client)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async UpdateExpGoodsAuthRep(body: UpdateExpGoodsAuthRepDTO) { }
|
||||||
|
async AddGenerallistItems(body: AddGenerallistItemsDTO) { }
|
||||||
|
async EditGenerallistItems(body: AddGenerallistItemsDTO) { }
|
||||||
|
async DeleteGenerallistItems(body: DeleteGenerallistItemsDTO) { }
|
||||||
|
async AddCountries(body: AddCountriesDTO) { }
|
||||||
|
async UpdateShippingDetails(body: UpdateShippingDetailsDTO) { }
|
||||||
|
async EstimatedFees(body: GetCarnetControlCenterDTO) { }
|
||||||
|
|
||||||
|
// processing [ PROCESSINGCENTER_PKG ]
|
||||||
|
|
||||||
|
async ProcessCarnet(body: CarnetProcessingCenterDTO) { }
|
||||||
|
async UpdatePrintCarnet(body: CarnetProcessingCenterDTO) { }
|
||||||
|
async VoidCarnet(body: CarnetProcessingCenterDTO) { }
|
||||||
|
|
||||||
|
async CopyCarnet(body: CopyCarnetDTO) { }
|
||||||
|
async DuplicateCarnet(body: CarnetProcessingCenterDTO2) { }
|
||||||
|
async AddlSets(body: CarnetProcessingCenterDTO2) { }
|
||||||
|
async ExtendCarnet(body: CarnetProcessingCenterDTO2) { }
|
||||||
|
async GetExtendedSection(body: GetExtendedSectionDTO) { }
|
||||||
|
async SaveExtensionApplication(body: SaveExtensionApplicationDTO) { }
|
||||||
|
|
||||||
|
async CloseCarnet(body: CarnetProcessingCenterDTO) { }
|
||||||
|
async ResetCarnet(body: CarnetProcessingCenterDTO) { }
|
||||||
|
async DeleteCarnet(body: CarnetProcessingCenterDTO) { }
|
||||||
|
|
||||||
|
// [ CARNETCONTROLCENTER_PKG ]
|
||||||
|
|
||||||
|
async GetHolderstoEdit(body: GetCarnetControlCenterDTO) {
|
||||||
|
let client: PoolClient | null = null;
|
||||||
|
|
||||||
|
const cursorName = 'p_cursor';
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await this.pgDBService.getConnection();
|
||||||
|
|
||||||
|
await client.query('BEGIN');
|
||||||
|
|
||||||
|
const callProcQuery = `
|
||||||
|
CALL "CARNETSYS".carnetcontrolcenter_pkg_getholderstoedit($1, $2, $3, $4)
|
||||||
|
`;
|
||||||
|
await client.query(callProcQuery, [body.P_SPID, body.P_USERID, body.P_HEADERID, cursorName]);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in FETCH
|
||||||
|
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in CLOSE
|
||||||
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
|
await client.query('COMMIT');
|
||||||
|
|
||||||
|
return fetchResult.rows;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (client) await client.query('ROLLBACK');
|
||||||
|
handlePgError(error, CarnetApplicationService.name)
|
||||||
|
} finally {
|
||||||
|
releasePgClient(client)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async GetGoodsDetailstoEdit(body: GetCarnetControlCenterDTO) {
|
||||||
|
let client: PoolClient | null = null;
|
||||||
|
|
||||||
|
const cursorName = 'p_cursor';
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await this.pgDBService.getConnection();
|
||||||
|
|
||||||
|
await client.query('BEGIN');
|
||||||
|
|
||||||
|
const callProcQuery = `
|
||||||
|
CALL "CARNETSYS".carnetcontrolcenter_pkg_getgoodsdetailstoedit($1, $2, $3, $4)
|
||||||
|
`;
|
||||||
|
await client.query(callProcQuery, [body.P_SPID, body.P_USERID, body.P_HEADERID, cursorName]);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in FETCH
|
||||||
|
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in CLOSE
|
||||||
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
|
await client.query('COMMIT');
|
||||||
|
|
||||||
|
return fetchResult.rows;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (client) await client.query('ROLLBACK');
|
||||||
|
handlePgError(error, CarnetApplicationService.name)
|
||||||
|
} finally {
|
||||||
|
releasePgClient(client)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async GetCountryDetailstoEdit(body: GetCarnetControlCenterDTO) {
|
||||||
|
let client: PoolClient | null = null;
|
||||||
|
|
||||||
|
const cursorName = 'p_cursor';
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await this.pgDBService.getConnection();
|
||||||
|
|
||||||
|
await client.query('BEGIN');
|
||||||
|
|
||||||
|
const callProcQuery = `
|
||||||
|
CALL "CARNETSYS".carnetcontrolcenter_pkg_getcountrydetailstoedit($1, $2, $3, $4)
|
||||||
|
`;
|
||||||
|
await client.query(callProcQuery, [body.P_SPID, body.P_USERID, body.P_HEADERID, cursorName]);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in FETCH
|
||||||
|
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in CLOSE
|
||||||
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
|
await client.query('COMMIT');
|
||||||
|
|
||||||
|
return fetchResult.rows;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (client) await client.query('ROLLBACK');
|
||||||
|
handlePgError(error, CarnetApplicationService.name)
|
||||||
|
} finally {
|
||||||
|
releasePgClient(client)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async GetShipPaymentDetailstoEdit(body: GetCarnetControlCenterDTO) {
|
||||||
|
let client: PoolClient | null = null;
|
||||||
|
|
||||||
|
const cursorName = 'p_cursor';
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await this.pgDBService.getConnection();
|
||||||
|
|
||||||
|
await client.query('BEGIN');
|
||||||
|
|
||||||
|
const callProcQuery = `
|
||||||
|
CALL "CARNETSYS".carnetcontrolcenter_pkg_getshippaymentdetailstoedit($1, $2, $3, $4)
|
||||||
|
`;
|
||||||
|
await client.query(callProcQuery, [body.P_SPID, body.P_USERID, body.P_HEADERID, cursorName]);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in FETCH
|
||||||
|
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in CLOSE
|
||||||
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
|
await client.query('COMMIT');
|
||||||
|
|
||||||
|
return fetchResult.rows;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (client) await client.query('ROLLBACK');
|
||||||
|
handlePgError(error, CarnetApplicationService.name)
|
||||||
|
} finally {
|
||||||
|
releasePgClient(client)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async GetGoodsItemstoEdit(body: GetCarnetControlCenterDTO) {
|
||||||
|
let client: PoolClient | null = null;
|
||||||
|
|
||||||
|
const cursorName = 'p_cursor';
|
||||||
|
|
||||||
|
try {
|
||||||
|
client = await this.pgDBService.getConnection();
|
||||||
|
|
||||||
|
await client.query('BEGIN');
|
||||||
|
|
||||||
|
const callProcQuery = `
|
||||||
|
CALL "CARNETSYS".carnetcontrolcenter_pkg_getgoodsitemstoedit($1, $2, $3, $4)
|
||||||
|
`;
|
||||||
|
await client.query(callProcQuery, [body.P_SPID, body.P_USERID, body.P_HEADERID, cursorName]);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in FETCH
|
||||||
|
const fetchResult = await client.query(`FETCH ALL FROM ${cursorName}`);
|
||||||
|
|
||||||
|
// 🚫 DON'T quote the cursor name in CLOSE
|
||||||
|
await client.query(`CLOSE ${cursorName}`);
|
||||||
|
await client.query('COMMIT');
|
||||||
|
|
||||||
|
return fetchResult.rows;
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
if (client) await client.query('ROLLBACK');
|
||||||
|
handlePgError(error, CarnetApplicationService.name)
|
||||||
|
} finally {
|
||||||
|
releasePgClient(client)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// [PRINT_PKG]
|
||||||
|
|
||||||
|
async getPrintingData(body: PrintCarnetDTO) { }
|
||||||
|
|
||||||
|
async PrintCarnet(body: PrintCarnetDTO) { }
|
||||||
|
|
||||||
|
async PrintGL(body: PrintGLDTO) { }
|
||||||
|
|
||||||
|
// [payment]
|
||||||
|
|
||||||
|
async formatAmount(amount) {
|
||||||
|
if (typeof amount !== 'number' || isNaN(amount)) {
|
||||||
|
throw new Error('Amount must be a valid number');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (amount < 0) {
|
||||||
|
throw new BadRequestException('Amount must be non-negative');
|
||||||
|
}
|
||||||
|
|
||||||
|
return amount.toFixed(2); // Always returns a string with 2 decimal places
|
||||||
|
}
|
||||||
|
|
||||||
|
async InitiatePayment(body: InitiatePaymentDTO) { }
|
||||||
|
|
||||||
|
async CapturePayment(body: CapturePaymentDTO) { }
|
||||||
|
|
||||||
|
async OrderDetails(body: GetOrderDetailsDTO) { }
|
||||||
|
|
||||||
|
async GetPaymentHistory(body: GetPaymentHistoryDTO) { }
|
||||||
|
|
||||||
|
async SaveHistory(body: SaveHistoryDTO) { }
|
||||||
|
}
|
||||||
@ -6,10 +6,11 @@ import { UserMaintenanceModule } from './user-maintenance/user-maintenance.modul
|
|||||||
import { ManageFeeModule } from './manage-fee/manage-fee.module';
|
import { ManageFeeModule } from './manage-fee/manage-fee.module';
|
||||||
import { ManageHolderModule } from './manage-holder/manage-holder.module';
|
import { ManageHolderModule } from './manage-holder/manage-holder.module';
|
||||||
import { ManageClientsModule } from './manage-clients/manage-clients.module';
|
import { ManageClientsModule } from './manage-clients/manage-clients.module';
|
||||||
|
import { CarnetApplicationModule } from './carnet-application/carnet-application.module';
|
||||||
|
|
||||||
@Global()
|
@Global()
|
||||||
@Module({
|
@Module({
|
||||||
imports: [DbModule, ParamTableModule, UscibManagedSpModule, UserMaintenanceModule, ManageFeeModule, ManageHolderModule, ManageClientsModule],
|
imports: [DbModule, ParamTableModule, UscibManagedSpModule, UserMaintenanceModule, ManageFeeModule, ManageHolderModule, ManageClientsModule, CarnetApplicationModule],
|
||||||
providers: [],
|
providers: [],
|
||||||
exports: [UserMaintenanceModule]
|
exports: [UserMaintenanceModule]
|
||||||
})
|
})
|
||||||
|
|||||||
@ -24,7 +24,8 @@ export enum ResponseStatus {
|
|||||||
inActivate = 'Inactivated Successfully',
|
inActivate = 'Inactivated Successfully',
|
||||||
reActivate = 'Reactivated Successfully',
|
reActivate = 'Reactivated Successfully',
|
||||||
clientRegistrationDone = 'Client registration initiated successfully',
|
clientRegistrationDone = 'Client registration initiated successfully',
|
||||||
lockedUserDone = 'Locked Successfully'
|
lockedUserDone = 'Locked Successfully',
|
||||||
|
transmitted = 'Transmitted Successfully'
|
||||||
}
|
}
|
||||||
|
|
||||||
export const handleError = (error: any, context: string = 'UnknownService'): never => {
|
export const handleError = (error: any, context: string = 'UnknownService'): never => {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user