From ea95229c0c41fbc1dd838fe75bd3137014197672 Mon Sep 17 00:00:00 2001 From: Frank Date: Tue, 12 Mar 2024 12:31:20 +0100 Subject: [PATCH] feat: added delete operations for spvs, service provider and accounts --- api/src/modules/real-world-assets/listener.ts | 38 +++++++++++++++++-- 1 file changed, 35 insertions(+), 3 deletions(-) diff --git a/api/src/modules/real-world-assets/listener.ts b/api/src/modules/real-world-assets/listener.ts index d89a8afe..d14ab0cb 100644 --- a/api/src/modules/real-world-assets/listener.ts +++ b/api/src/modules/real-world-assets/listener.ts @@ -1,9 +1,8 @@ import { Prisma, RWAPortfolio } from "@prisma/client"; import { InternalTransmitterUpdate, OperationUpdate } from "document-drive"; -import { AddFileInput, DeleteNodeInput, DocumentDriveDocument, DocumentDriveState, ListenerFilter, actions } from "document-model-libs/document-drive"; -import { AddFeeTransactionsToGroupTransactionInput, CashGroupTransactionType, CreateAccountInput, CreateAssetPurchaseGroupTransactionInput, CreateAssetSaleGroupTransactionInput, CreateCashAssetInput, CreateFeesPaymentGroupTransactionInput, CreateFixedIncomeAssetInput, CreateFixedIncomeTypeInput, CreateInterestReturnGroupTransactionInput, CreatePrincipalDrawGroupTransactionInput, CreatePrincipalReturnGroupTransactionInput, CreateServiceProviderInput, CreateSpvInput, DeleteGroupTransactionInput, EditAccountInput, EditAssetPurchaseGroupTransactionInput, EditAssetSaleGroupTransactionInput, EditCashAssetInput, EditFeeTransactionInput, EditFixedIncomeAssetInput, EditFixedIncomeTypeInput, EditGroupTransactionTypeInput, EditInterestDrawGroupTransactionInput, EditInterestReturnGroupTransactionInput, EditPrincipalDrawGroupTransactionInput, EditPrincipalReturnGroupTransactionInput, EditServiceProviderInput, EditSpvInput, RealWorldAssetsDocument, RealWorldAssetsState, RemoveFeeTransactionFromGroupTransactionInput, utils } from "document-model-libs/real-world-assets" +import { AddFileInput, DeleteNodeInput, DocumentDriveDocument, DocumentDriveState, ListenerFilter } from "document-model-libs/document-drive"; +import { AddFeeTransactionsToGroupTransactionInput, CashGroupTransactionType, CreateAccountInput, CreateAssetPurchaseGroupTransactionInput, CreateAssetSaleGroupTransactionInput, CreateCashAssetInput, CreateFeesPaymentGroupTransactionInput, CreateFixedIncomeAssetInput, CreateFixedIncomeTypeInput, CreateInterestReturnGroupTransactionInput, CreatePrincipalDrawGroupTransactionInput, CreatePrincipalReturnGroupTransactionInput, CreateServiceProviderInput, CreateSpvInput, DeleteAccountInput, DeleteGroupTransactionInput, DeleteServiceProviderInput, DeleteSpvInput, EditAccountInput, EditAssetPurchaseGroupTransactionInput, EditAssetSaleGroupTransactionInput, EditCashAssetInput, EditFeeTransactionInput, EditFixedIncomeAssetInput, EditFixedIncomeTypeInput, EditGroupTransactionTypeInput, EditInterestDrawGroupTransactionInput, EditInterestReturnGroupTransactionInput, EditPrincipalDrawGroupTransactionInput, EditPrincipalReturnGroupTransactionInput, EditServiceProviderInput, EditSpvInput, RealWorldAssetsDocument, RealWorldAssetsState, RemoveFeeTransactionFromGroupTransactionInput, utils } from "document-model-libs/real-world-assets" import { getChildLogger } from "../../logger"; -import { Action } from "document-model/document"; const logger = getChildLogger({ msgPrefix: 'RWA Internal Listener' }, { moduleName: "RWA Internal Listener" }); @@ -258,6 +257,17 @@ const surgicalOperations: Record { + logger.debug({ msg: "Deleting SPV", input }); + await prisma.rWAPortfolioSpv.delete({ + where: { + id_portfolioId: { + id: input.id, + portfolioId: portfolio.id + } + } + }); + }, "CREATE_SERVICE_PROVIDER": async (input: CreateServiceProviderInput, portfolio: RWAPortfolio, prisma: Prisma.TransactionClient) => { logger.debug({ msg: "Creating service provider", input }); await prisma.rWAPortfolioServiceProvider.create({ @@ -284,6 +294,17 @@ const surgicalOperations: Record { + logger.debug({ msg: "Deleting service provider", input }); + await prisma.rWAPortfolioServiceProvider.delete({ + where: { + id_portfolioId: { + id: input.id, + portfolioId: portfolio.id + } + } + }); + }, "CREATE_ACCOUNT": async (input: CreateAccountInput, portfolio: RWAPortfolio, prisma: Prisma.TransactionClient) => { logger.debug({ msg: "Creating account", input }); await prisma.rWAPortfolioAccount.create({ @@ -308,6 +329,17 @@ const surgicalOperations: Record { + logger.debug({ msg: "Deleting account", input }); + await prisma.rWAPortfolioAccount.delete({ + where: { + id_portfolioId: { + id: input.id, + portfolioId: portfolio.id + } + } + }); + }, "CREATE_FIXED_INCOME_TYPE": async (input: CreateFixedIncomeTypeInput, portfolio: RWAPortfolio, prisma: Prisma.TransactionClient) => { logger.debug({ msg: "Creating fixed income type", input }); await prisma.rWAPortfolioFixedIncomeType.create({