From 6e407d19c593bb19b9fc14d54675846edbabd3c4 Mon Sep 17 00:00:00 2001 From: Lior Zamir Date: Sun, 10 Mar 2024 22:01:58 +0200 Subject: [PATCH 1/2] fix(alert.controller.external.ts): change property name from 'business' to 'counterparty' and add 'endUser' property to improve data consistency and completeness fix(alert.service.ts): remove unnecessary properties from 'data' parameter in createAlert method fix(get-transactions.dto.ts): remove unused 'businessId' property from GetTransactionsDto class fix(transaction.controller.external.ts): remove unused 'businessId' query parameter from getTransactions method fix(transaction.repository.ts): remove unused 'businessId' and 'endUserId' variables and related code in TransactionRepository class --- .../src/alert/alert.controller.external.ts | 6 ++++-- .../src/alert/alert.service.ts | 2 +- .../transaction/dtos/get-transactions.dto.ts | 4 ---- .../transaction.controller.external.ts | 20 ++++++++++++++++--- .../src/transaction/transaction.repository.ts | 19 ++---------------- 5 files changed, 24 insertions(+), 27 deletions(-) diff --git a/services/workflows-service/src/alert/alert.controller.external.ts b/services/workflows-service/src/alert/alert.controller.external.ts index b1bc88dd02..5c004798ad 100644 --- a/services/workflows-service/src/alert/alert.controller.external.ts +++ b/services/workflows-service/src/alert/alert.controller.external.ts @@ -63,14 +63,16 @@ export class AlertControllerExternal { lastName: true, }, }, - business: { + counterparty: { select: { id: true, - companyName: true, + business: true, + endUser: true, }, }, }, }); + const formattedAlerts = alerts.map(alert => { const { alertDefinition, assignee, business, state, ...alertWithoutDefinition } = alert as TAlertResponse; diff --git a/services/workflows-service/src/alert/alert.service.ts b/services/workflows-service/src/alert/alert.service.ts index 20159da964..3da37c9b35 100644 --- a/services/workflows-service/src/alert/alert.service.ts +++ b/services/workflows-service/src/alert/alert.service.ts @@ -208,7 +208,7 @@ export class AlertService { private createAlert( alertDef: AlertDefinition, - data: Pick, + data: Pick, ): Promise { return this.alertRepository.create({ data: { diff --git a/services/workflows-service/src/transaction/dtos/get-transactions.dto.ts b/services/workflows-service/src/transaction/dtos/get-transactions.dto.ts index a26df7b690..a9ea288c09 100644 --- a/services/workflows-service/src/transaction/dtos/get-transactions.dto.ts +++ b/services/workflows-service/src/transaction/dtos/get-transactions.dto.ts @@ -4,10 +4,6 @@ import { PaymentMethod } from '@prisma/client'; import { IsDateString, IsEnum, IsNumber, IsOptional, IsString } from 'class-validator'; export class GetTransactionsDto { - @IsOptional() - @IsString() - businessId?: string; - @IsOptional() @IsString() counterpartyId?: string; diff --git a/services/workflows-service/src/transaction/transaction.controller.external.ts b/services/workflows-service/src/transaction/transaction.controller.external.ts index bcd05caac3..1750887a46 100644 --- a/services/workflows-service/src/transaction/transaction.controller.external.ts +++ b/services/workflows-service/src/transaction/transaction.controller.external.ts @@ -61,7 +61,6 @@ export class TransactionControllerExternal { @Get() // @UseGuards(CustomerAuthGuard) @swagger.ApiOkResponse({ description: 'Returns an array of transactions.' }) - @swagger.ApiQuery({ name: 'businessId', description: 'Filter by business ID.', required: false }) @swagger.ApiQuery({ name: 'counterpartyId', description: 'Filter by counterparty ID.', @@ -104,13 +103,28 @@ export class TransactionControllerExternal { ) { return this.service.getTransactions(getTransactionsParameters, projectId, { include: { - business: { + counterpartyBeneficiary: { select: { - companyName: true, + business: { + select: { + companyName: true, + }, + }, + endUser: { + select: { + firstName: true, + lastName: true, + }, + }, }, }, counterpartyOriginator: { select: { + business: { + select: { + companyName: true, + }, + }, endUser: { select: { firstName: true, diff --git a/services/workflows-service/src/transaction/transaction.repository.ts b/services/workflows-service/src/transaction/transaction.repository.ts index 3239d11e9c..28f4fdfc35 100644 --- a/services/workflows-service/src/transaction/transaction.repository.ts +++ b/services/workflows-service/src/transaction/transaction.repository.ts @@ -19,8 +19,8 @@ export class TransactionRepository { args: Prisma.SelectSubset, ): Promise { createTranscationValidator.safeParse(args.data); - // #TODO: Fix this - const { projectId, businessId, endUserId, ...rest } = args.data; + + const { projectId, ...rest } = args.data; args = { ...args, @@ -32,17 +32,6 @@ export class TransactionRepository { }, } as any; - // if (businessId) { - // args.data.business = { - // connect: { id: businessId }, - // } as any; - // } - - // if (endUserId) { - // args.data.endUser = { - // connect: { id: endUserId }, - // } as any; - // } const res = await this.prisma.transactionRecord.create(args); return res; @@ -93,10 +82,6 @@ export class TransactionRepository { ): Prisma.TransactionRecordWhereInput { const whereClause: Prisma.TransactionRecordWhereInput = {}; - if (getTransactionsParameters.businessId) { - whereClause.businessId = getTransactionsParameters.businessId; - } - if (getTransactionsParameters.counterpartyId) { whereClause.OR = [ { counterpartyOriginatorId: getTransactionsParameters.counterpartyId }, From 09cbd4458bab824c0b9d00402b21f8c590e68abf Mon Sep 17 00:00:00 2001 From: Lior Zamir Date: Sun, 10 Mar 2024 22:01:58 +0200 Subject: [PATCH 2/2] fix(alert.controller.external.ts): change property name from 'business' to 'counterparty' and add 'endUser' property to improve data consistency and completeness fix(alert.service.ts): remove unnecessary properties from 'data' parameter in createAlert method fix(get-transactions.dto.ts): remove unused 'businessId' property from GetTransactionsDto class fix(transaction.controller.external.ts): remove unused 'businessId' query parameter from getTransactions method fix(transaction.repository.ts): remove unused 'businessId' and 'endUserId' variables and related code in TransactionRepository class