new api in carnet application and modification

This commit is contained in:
Kallesh B S 2025-07-09 15:53:49 +05:30
parent 2259d306b1
commit aaf2764a7e
8 changed files with 244 additions and 41 deletions

View File

@ -708,7 +708,7 @@ export class AuthService {
template: 'a',
context: {
to: body.P_TO,
url: `https://client.alphaomegainfosys.com/register/${token}`
url: `https://client.alphaomegainfosys.com/register`
}
}
case MailTypeDTO.FORGOT_PASSWORD:
@ -847,8 +847,6 @@ export class AuthService {
token = await this.generateToken({ P_TO: body.P_TO, uuid: uuid })
const mailTemplate: MailTemplateDTO | null = await this.getMailTemplate(body, token, ROLE);
if (!mailTemplate) {

View File

@ -120,6 +120,10 @@ export class GetClientDTO extends IntersectionType(
CLIENTID_DTO
) { }
export class GetClientContactByLacationIdDTO extends IntersectionType(
SPID_DTO, LOCATIONID_DTO
){}
export class ClientContactControlsDTO extends IntersectionType(
SPID_DTO,
CLIENT_CONTACTID_DTO,

View File

@ -17,28 +17,32 @@ import { HandlebarsAdapter } from '@nestjs-modules/mailer/dist/adapters/handleba
MailerModule.forRootAsync({
imports: [ConfigModule],
useFactory: (configService: ConfigService) => ({
transport: {
host: 'smtp.gmail.com',
port: 587,
// ignoreTLS: true,
secure: false,
auth: {
user: configService.get<string>('MAIL_USER'),
pass: configService.get<string>('MAIL_PASS'),
useFactory: (configService: ConfigService) => {
const templatePath = join(__dirname, '../../..', 'public', 'mail-templates');
console.log('Resolved mail template path:', templatePath);
return {
transport: {
host: 'smtp.gmail.com',
port: 587,
secure: false,
auth: {
user: configService.get<string>('MAIL_USER'),
pass: configService.get<string>('MAIL_PASS'),
},
},
},
defaults: {
from: `"Carnet APP" <${configService.get<string>('MAIL_USER')}>`,
},
template: {
dir: join(__dirname, '../../..', 'public', 'mail-templates'),
adapter: new HandlebarsAdapter(), // import from '@nestjs-modules/mailer/dist/adapters/handlebars.adapter'
options: {
strict: true,
defaults: {
from: `"Carnet APP" <${configService.get<string>('MAIL_USER')}>`,
},
},
}),
template: {
dir: templatePath,
adapter: new HandlebarsAdapter(),
options: {
strict: true,
},
},
};
},
inject: [ConfigService],
}),
],

View File

@ -1,4 +1,4 @@
import { Body, Controller, Get, Param, Patch, Post, Put, UseGuards } from '@nestjs/common';
import { Body, Controller, Delete, Get, Param, Patch, Post, Put, UseGuards } from '@nestjs/common';
import { CarnetApplicationService } from './carnet-application.service';
import { ApiTags } from '@nestjs/swagger';
@ -63,6 +63,16 @@ export class CarnetApplicationController {
return this.carnetApplicationService.AddCountries(body);
}
@Put('EditGenerallistItems')
EditGenerallistItems(@Body() body: AddGenerallistItemsDTO) {
return this.carnetApplicationService.EditGenerallistItems(body);
}
@Delete('DeleteGenerallistItems')
DeleteGenerallistItems() {
return this.carnetApplicationService.DeleteGenerallistItems();
}
@Patch('UpdateShippingDetails')
UpdateShippingDetails(@Body() body: UpdateShippingDetailsDTO) {
return this.carnetApplicationService.UpdateShippingDetails(body);
@ -110,11 +120,19 @@ export class CarnetApplicationController {
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);

View File

@ -219,7 +219,14 @@ export class CarnetApplicationService {
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
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 {
@ -256,7 +263,14 @@ export class CarnetApplicationService {
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_CURSOR, CarnetApplicationService.name);
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] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
@ -340,7 +354,15 @@ export class CarnetApplicationService {
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
// 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] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
@ -383,7 +405,14 @@ export class CarnetApplicationService {
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] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
@ -423,7 +452,15 @@ export class CarnetApplicationService {
throw new InternalServerException("Incomplete data received from the database.");
}
return await fetchCursor(outBinds.P_ERRORMESG, CarnetApplicationService.name);
// 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 {
@ -431,6 +468,55 @@ export class CarnetApplicationService {
}
}
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)
}
}
async DeleteGenerallistItems() { }
async AddCountries(body: AddCountriesDTO) {
let connection;
try {
@ -441,7 +527,7 @@ export class CarnetApplicationService {
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.AddCountries(
:P_HEADERID, :P_USSETS, :P_COUNTRYTABLE, :P_USERID, :P_ERRORMESG
:P_HEADERID, :P_USSETS, :P_COUNTRYTABLE, :P_USERID, :P_CURSOR
);
END;`,
{
@ -451,8 +537,8 @@ export class CarnetApplicationService {
// 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 }
// P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
@ -460,12 +546,19 @@ export class CarnetApplicationService {
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
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_ERRORMESG, CarnetApplicationService.name);
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] };
} catch (error) {
handleError(error, CarnetApplicationService.name)
} finally {
@ -480,10 +573,10 @@ export class CarnetApplicationService {
const result = await connection.execute(
`BEGIN
CARNETAPPLICATION_PKG.UpdateHolder(
CARNETAPPLICATION_PKG.UpdateShippingDetails(
:P_HEADERID, :P_SHIPTOTYPE, :P_SHIPADDRID, :P_FORMOFSECURITY, :P_INSPROTECTION,
:P_LDIPROTECTION, :P_DELIVERYTYPE, :P_DELIVERYMETHOD, :P_PAYMENTMETHOD,
:P_CUSTCOURIERNO, :P_REFNO, :P_NOTES, :P_USERID, :P_ERRORMESG
:P_CUSTCOURIERNO, :P_REFNO, :P_NOTES, :P_USERID, :P_CURSOR
);
END;`,
{
@ -500,8 +593,8 @@ export class CarnetApplicationService {
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_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
// P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
// P_ERRORMESG: { dir: oracledb.BIND_OUT, type: oracledb.CURSOR },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{ outFormat: oracledb.OUT_FORMAT_OBJECT }
);
@ -509,12 +602,19 @@ export class CarnetApplicationService {
await connection.commit();
const outBinds = result.outBinds;
if (!outBinds?.P_ERRORMESG) {
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_ERRORMESG, CarnetApplicationService.name);
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 {
@ -840,4 +940,39 @@ export class CarnetApplicationService {
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)
}
}
}

View File

@ -6,6 +6,7 @@ import {
ClientContactControlsDTO,
CreateClientContactsDTO, CreateClientDataDTO,
CreateClientLocationsDTO,
GetClientContactByLacationIdDTO,
GetClientDTO,
GetPreparersParamDTO, GetPreparersQueryDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO
} from 'src/dto/property.dto';
@ -81,6 +82,11 @@ export class ManageClientsController {
return this.manageClientsService.GetPreparerContactsByClientid(body);
}
@Get('GetPreparerContactsbyClientLocationID/:P_SPID/:P_LOCATIONID')
GetPreparerContactsbyClientLocationID(@Param() body: GetClientContactByLacationIdDTO) {
return this.manageClientsService.GetPreparerContactsbyClientLocationID(body);
}
@Get('GetPreparerLocByClientid/:P_SPID/:P_CLIENTID')
GetPreparerLocByClientid(@Param() body: GetClientDTO) {
return this.manageClientsService.GetPreparerLocByClientid(body);

View File

@ -10,6 +10,7 @@ import {
ClientContactControlsDTO,
CreateClientContactsDTO, CreateClientDataDTO,
CreateClientLocationsDTO,
GetClientContactByLacationIdDTO,
GetClientDTO,
GetPreparersDTO, UpdateClientContactsDTO, UpdateClientDTO, UpdateClientLocationsDTO,
} from 'src/dto/property.dto';
@ -718,6 +719,43 @@ export class ManageClientsService {
}
};
GetPreparerContactsbyClientLocationID = async (body: GetClientContactByLacationIdDTO) => {
let connection;
try {
connection = await this.oracleDBService.getConnection();
const result = await connection.execute(
`BEGIN
MANAGEPREPARER_PKG.GetPreparerContactsByClientid(
:P_SPID, :P_LOCATIONID, :P_CURSOR
);
END;`,
{
P_SPID: { val: body.P_SPID, type: oracledb.DB_TYPE_NUMBER },
P_LOCATIONID: { val: body.P_LOCATIONID, type: oracledb.DB_TYPE_NUMBER },
P_CURSOR: { type: oracledb.CURSOR, dir: oracledb.BIND_OUT }
},
{
outFormat: oracledb.OUT_FORMAT_OBJECT,
},
);
const outBinds: any = 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, ManageClientsService.name);
} catch (error) {
handleError(error, ManageClientsService.name)
} finally {
await closeOracleDbConnection(connection, ManageClientsService.name)
}
}
GetPreparerLocByClientid = async (body: GetClientDTO) => {
let connection;

View File

@ -485,7 +485,7 @@ export class ManageHoldersService {
throw new BadRequestException(fres[0].ERRORMESG)
}
return { statusCode: 200, message: 'Reactivated holder successfully' };
return { statusCode: 200, message: 'Inactivated holder successfully' };
} catch (error) {
handleError(error, ManageHoldersService.name)
} finally {