From 61a72c5df6f11637b1f4e1b7f068e9dcf45e3d30 Mon Sep 17 00:00:00 2001 From: Kallesh B S Date: Sat, 10 May 2025 16:22:30 +0530 Subject: [PATCH] added cargo rate --- ormconfig.ts | 18 ++--- src/mssql/manage-fee/manage-fee.controller.ts | 22 ++++++- src/mssql/manage-fee/manage-fee.service.ts | 66 ++++++++++++++++++- 3 files changed, 93 insertions(+), 13 deletions(-) diff --git a/ormconfig.ts b/ormconfig.ts index 1095c53..ce8b36c 100644 --- a/ormconfig.ts +++ b/ormconfig.ts @@ -15,17 +15,17 @@ export const OracleConfig: any = { export const MssqlConfig: any = { // type: 'mssql', - // server: 'localhost', - // user: 'mssql1433', - // password: 'root', - // database: 'CarnetDB', - - server: '172.31.18.76', - port: 1433, - user: 'Carnetsys', - password: 'Carnet1234', + server: 'localhost', + user: 'mssql1433', + password: 'root', database: 'CarnetDB', + // server: '172.31.18.76', + // port: 1433, + // user: 'Carnetsys', + // password: 'Carnet1234', + // database: 'CarnetDB', + // entities: [__dirname + '/**/*.entity{.ts,.js}'], // synchronize: true, diff --git a/src/mssql/manage-fee/manage-fee.controller.ts b/src/mssql/manage-fee/manage-fee.controller.ts index 4801d8c..6e44a52 100644 --- a/src/mssql/manage-fee/manage-fee.controller.ts +++ b/src/mssql/manage-fee/manage-fee.controller.ts @@ -1,6 +1,6 @@ import { Body, Controller, Get, Patch, Post, Query } from '@nestjs/common'; import { ManageFeeService } from './manage-fee.service'; -import { CreateBasicFeeDTO, CreateBondRateDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO } from 'src/oracle/manage-fee/manage-fee.dto'; +import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO } from 'src/oracle/manage-fee/manage-fee.dto'; import { ApiTags } from '@nestjs/swagger'; @Controller('mssql') @@ -43,4 +43,24 @@ export class ManageFeeController { UpdateBondRate(@Body() body: UpdateBondRateDTO) { return this.manageFeeService.UPDATEBONDRATE(body); } + + // Cargo Rate + + // @ApiTags('Manage Fee - Mssql') + // @Get('/GetCargoRates') + GetCargoRates(@Query() body: GetFeeGeneralDTO) { + return this.manageFeeService.GETCARGORATES(body); + } + + // @ApiTags('Manage Fee - Mssql') + // @Post('/CreateCargoRate') + CreateCargoRate(@Body() body: CreateCargoRateDTO) { + return this.manageFeeService.CREATECARGORATE(body); + } + + // @ApiTags('Manage Fee - Mssql') + // @Patch('/UpdateCargoRate') + UpdateCargoRate(@Body() body: UpdateCargoRateDTO) { + return this.manageFeeService.UPDATECARGORATE(body); + } } diff --git a/src/mssql/manage-fee/manage-fee.service.ts b/src/mssql/manage-fee/manage-fee.service.ts index 1e9a29f..349220e 100644 --- a/src/mssql/manage-fee/manage-fee.service.ts +++ b/src/mssql/manage-fee/manage-fee.service.ts @@ -1,7 +1,7 @@ import { Injectable, Logger } from '@nestjs/common'; import { MssqlDBService, OracleDBService } from 'src/db/db.service'; import { InternalServerException } from 'src/exceptions/internalServerError.exception'; -import { CreateBasicFeeDTO, CreateBondRateDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO } from 'src/oracle/manage-fee/manage-fee.dto'; +import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO } from 'src/oracle/manage-fee/manage-fee.dto'; import * as oracledb from 'oracledb'; import { BadRequestException } from 'src/exceptions/badRequest.exception'; import { Connection, Request } from 'mssql'; @@ -76,10 +76,11 @@ export class ManageFeeService { request.input('p_active_inactive', mssql.VarChar(8), body.P_ACTIVE_INACTIVE); const result = await request.execute('carnetsys.GetBondRates'); return result.recordset; + } catch (error) { console.log(error); - - throw new InternalServerException(); + + throw new InternalServerException(); } } @@ -124,4 +125,63 @@ export class ManageFeeService { } } + + // CArgo Rate + + async GETCARGORATES(body: GetFeeGeneralDTO): Promise { + let connection: Connection; + try { + connection = await this.mssqlDBService.getConnection(); + const request = new Request(connection); + request.input('p_spid', mssql.Int, body.P_SPID); + request.input('p_active_inactive', mssql.VarChar(8), body.P_ACTIVE_INACTIVE); + const result = await request.execute('carnetsys.GetCargoRates'); + if (result.recordset) { + return result.recordset; + } + throw new BadRequestException(); + } catch (error) { + if (error instanceof BadRequestException) { + throw error + } + throw new InternalServerException(); + } + } + + async CREATECARGORATE(body: CreateCargoRateDTO) { + let connection: Connection; + try { + connection = await this.mssqlDBService.getConnection(); + const request = new Request(connection); + request.input('P_SPID', mssql.Int, body.P_SPID); + request.input('P_CARNETTYPE', mssql.VarChar(20), body.P_CARNETTYPE); + request.input('P_STARTSETS', mssql.Int, body.P_STARTSETS); + request.input('P_ENDSETS', mssql.Int, body.P_ENDSETS); + request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE); + request.input('P_RATE', mssql.Float, body.P_RATE); + request.input('P_USERID', mssql.VarChar(100), body.P_USERID); + const result = await request.execute('carnetsys.CreateCargoRate'); + return result.recordset; + } catch (error) { + console.log(error); + throw new InternalServerException(); + } + } + + async UPDATECARGORATE(body: UpdateCargoRateDTO) { + let connection: Connection; + try { + connection = await this.mssqlDBService.getConnection(); + const request = new Request(connection); + request.input('P_CARGORATESETUPID', mssql.Int, body.P_CARGORATESETUPID); + request.input('P_RATE', mssql.Float, body.P_RATE); + request.input('P_EFFDATE', mssql.VarChar(100), body.P_EFFDATE); + request.input('P_USERID', mssql.VarChar(100), body.P_USERID); + const result = await request.execute('carnetsys.UpdateCargoRate'); + return result.recordset; + } catch (error) { + console.log(error); + throw new InternalServerException(); + } + } }