Skip to content
This repository has been archived by the owner on Feb 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #381 from kmcwebdev/development
Browse files Browse the repository at this point in the history
Fix CreateReimbursementReqeustSchema validation and prevent HRBP from…
  • Loading branch information
csulit authored Oct 16, 2023
2 parents 5f9b1f9 + 8b6687a commit 6a2c130
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/finance/common/dto/create-reimbursement-request.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const CreateReimbursementReqeustSchema = z
.email({
message: 'Approvers must be a valid email',
}),
{},
)
.optional(),
remarks: z
Expand Down
14 changes: 12 additions & 2 deletions src/finance/services/reimbursement.create.service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Injectable, Logger } from '@nestjs/common';
import { HttpException, HttpStatus, Injectable, Logger } from '@nestjs/common';
import { EventEmitter2 } from '@nestjs/event-emitter';
import { InjectKysely } from 'nestjs-kysely';
import { RequestUser } from 'src/auth/common/interface/propelauthUser.interface';
Expand All @@ -17,11 +17,21 @@ export class ReimbursementCreateService {
) {}

async create(user: RequestUser, data: CreateReimbursementRequestType) {
const { original_user_id } = user;
const { original_user_id, hrbp_approver_email } = user;

const newReimbursementRequest = await this.pgsql
.transaction()
.execute(async (trx) => {
if (data?.approvers.length >= 1) {
const approver = data.approvers[0];
if (hrbp_approver_email === approver) {
throw new HttpException(
"Your hrbp can't be your approver manager",
HttpStatus.BAD_REQUEST,
);
}
}

const newReferenceNo = await trx
.insertInto('finance_reimbursement_reference_numbers')
.values({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class LacLexisnexisDownloadService implements OnModuleInit {
stationName: 'erp.lac.lexisnexis-download',
consumerName: 'erp.lac.lexisnexis-download.consumer-name',
consumerGroup: 'erp.lac.lexisnexis-download.consumer-group',
pullIntervalMs: 5000,
});

this.consumer.on('message', async (message: Message) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ export class LacLexisnexisSearchService implements OnModuleInit {
stationName: 'erp.lac.lexisnexis-search',
consumerName: 'erp.lac.lexisnexis-search.consumer-name',
consumerGroup: 'erp.lac.lexisnexis-search.consumer-group',
pullIntervalMs: 5000,
});

this.consumer.on('message', async (message: Message) => {
Expand Down

0 comments on commit 6a2c130

Please sign in to comment.