diff --git a/src/mssql/manage-fee/manage-fee.controller.ts b/src/mssql/manage-fee/manage-fee.controller.ts index 6e44a52..eec7c94 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, CreateCargoRateDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO } from 'src/oracle/manage-fee/manage-fee.dto'; +import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO } from 'src/oracle/manage-fee/manage-fee.dto'; import { ApiTags } from '@nestjs/swagger'; @Controller('mssql') @@ -63,4 +63,84 @@ export class ManageFeeController { UpdateCargoRate(@Body() body: UpdateCargoRateDTO) { return this.manageFeeService.UPDATECARGORATE(body); } + + // Counter Foil + + // @ApiTags('Manage Fee - Mssql') + // @Get('/GetCfFeeRates') + GetCfFeeRates(@Query() body: GetFeeGeneralDTO) { + return this.manageFeeService.GETCFFEERATES(body); + } + + // @ApiTags('Manage Fee - Mssql') + // @Post('/CreateCfFee') + CreateCfFee(@Body() body: CreateCfFeeDTO) { + return this.manageFeeService.CREATECFFEE(body); + } + + // @ApiTags('Manage Fee - Mssql') + // @Patch('/UpdateCfFee') + UpdateCfFee(@Body() body: UpdateCfFeeDTO) { + return this.manageFeeService.UPDATECFFEE(body); + } + + // Continuation sheet + + // @ApiTags('Manage Fee - Mssql') + // @Get('/GetCsFeeRates') + GetCsFeeRates(@Query() body: GetFeeGeneralDTO) { + return this.manageFeeService.GETCSFEERATES(body); + } + + // @ApiTags('Manage Fee - Mssql') + // @Post('/CreateCsFee') + CreateCsFee(@Body() body: CreateCsFeeDTO) { + return this.manageFeeService.CREATECSFEE(body); + } + + // @ApiTags('Manage Fee - Mssql') + // @Patch('/UpdateCsFee') + UpdateCsFee(@Body() body: UpdateCsFeeDTO) { + return this.manageFeeService.UPDATECSFEE(body); + } + + // Expedited Fee + + // @ApiTags('Manage Fee - Oracle') + // @Get('/GetEfFeeRates') + // GetEfFeeRates(@Query() body: GetFeeGeneralDTO) { + // return this.manageFeeService.GETEFFEERATES(body); + // } + + // @ApiTags('Manage Fee - Oracle') + // @Post('/CreateEfFee') + // CreateEeFee(@Body() body: CreateEfFeeDTO) { + // return this.manageFeeService.CREATEEFFEE(body); + // } + + // @ApiTags('Manage Fee - Oracle') + // @Patch('/UpdateEfFee') + // UpdateEfFee(@Body() body: UpdateEfFeeDTO) { + // return this.manageFeeService.UPDATEEFFEE(body); + // } + + // Fee Comm + + // @ApiTags('Manage Fee - Oracle') + // @Get('/GetFeeComm') + // GetFeeComm(@Query() body: GetFeeGeneralDTO) { + // return this.manageFeeService.GETFEECOMM(body); + // } + + // @ApiTags('Manage Fee - Oracle') + // @Post('/CreateFeeComm') + // CreateFeeComm(@Body() body: CreateFeeCommDTO) { + // return this.manageFeeService.CREATEFEECOMM(body); + // } + + // @ApiTags('Manage Fee - Oracle') + // @Patch('/UpdateFeeComm') + // UpdateFeeComm(@Body() body: UpdateFeeCommDTO) { + // return this.manageFeeService.UPDATEFEECOMM(body); + // } } diff --git a/src/mssql/manage-fee/manage-fee.service.ts b/src/mssql/manage-fee/manage-fee.service.ts index 349220e..37003cb 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, CreateCargoRateDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO } from 'src/oracle/manage-fee/manage-fee.dto'; +import { CreateBasicFeeDTO, CreateBondRateDTO, CreateCargoRateDTO, CreateCfFeeDTO, CreateCsFeeDTO, GetFeeGeneralDTO, UpdateBasicFeeDTO, UpdateBondRateDTO, UpdateCargoRateDTO, UpdateCfFeeDTO, UpdateCsFeeDTO } 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'; @@ -184,4 +184,128 @@ export class ManageFeeService { throw new InternalServerException(); } } + + // Counter Foil + + async GETCFFEERATES(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.GetCFFeeRates'); + if (result.recordset) { + return result.recordset; + } + throw new BadRequestException(); + } catch (error) { + if (error instanceof BadRequestException) { + throw error + } + throw new InternalServerException(); + } + } + + async CREATECFFEE(body: CreateCfFeeDTO) { + + 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_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_CUSTOMERTYPE', mssql.VarChar(20), body.P_CUSTOMERTYPE); + request.input('P_CARNETTYPE', mssql.VarChar(20), body.P_CARNETTYPE); + 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.CreateCFFee'); + return result.recordset; + } catch (error) { + console.log(error); + throw new InternalServerException(); + } + + } + + async UPDATECFFEE(body: UpdateCfFeeDTO) { + + let connection: Connection; + try { + connection = await this.mssqlDBService.getConnection(); + const request = new Request(connection); + request.input('P_CFFEESETUPID', mssql.Int, body.P_CFFEESETUPID); + 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.UpdateCFFee'); + return result.recordset; + } catch (error) { + console.log(error); + throw new InternalServerException(); + } + } + + // Continuation sheet + + async GETCSFEERATES(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.GetCSFeeRates'); + if (result.recordset) { + return result.recordset; + } + throw new BadRequestException(); + } catch (error) { + if (error instanceof BadRequestException) { + throw error + } + throw new InternalServerException(); + } + + } + + async CREATECSFEE(body: CreateCsFeeDTO) { + 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_CUSTOMERTYPE', mssql.VarChar(20), body.P_CUSTOMERTYPE); + request.input('P_CARNETTYPE', mssql.VarChar(20), body.P_CARNETTYPE); + 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.CreateCSFee'); + return result.recordset; + } catch (error) { + console.log(error); + throw new InternalServerException(); + } + + } + + async UPDATECSFEE(body: UpdateCsFeeDTO) { + let connection: Connection; + try { + connection = await this.mssqlDBService.getConnection(); + const request = new Request(connection); + request.input('P_CSFEESETUPID', mssql.Int, body.P_CSFEESETUPID); + 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.UpdateCSFee'); + return result.recordset; + } catch (error) { + console.log(error); + throw new InternalServerException(); + } + } }