From c17b52ad895d52d5bde2805acef7ee644cdb9a8e Mon Sep 17 00:00:00 2001
From: Thomas <4159106+dtslvr@users.noreply.github.com>
Date: Sun, 17 Sep 2023 09:21:04 +0200
Subject: [PATCH] Add business logic for fees
---
apps/api/src/app/order/order.service.ts | 20 ++-
.../portfolio-summary.component.html | 14 +-
...ate-or-update-activity-dialog.component.ts | 24 +++-
.../create-or-update-activity-dialog.html | 127 ++++++++++--------
.../activities-table.component.html | 6 +
.../activities-table.component.scss | 4 +
.../activities-table.component.ts | 3 +-
libs/ui/src/lib/i18n.ts | 1 +
.../migration.sql | 0
9 files changed, 135 insertions(+), 64 deletions(-)
rename prisma/migrations/{20230509124205_added_fee_to_order_type => 20230917074305_added_fee_to_order_type}/migration.sql (100%)
diff --git a/apps/api/src/app/order/order.service.ts b/apps/api/src/app/order/order.service.ts
index 0f7da5da3..13709fad1 100644
--- a/apps/api/src/app/order/order.service.ts
+++ b/apps/api/src/app/order/order.service.ts
@@ -97,7 +97,11 @@ export class OrderService {
const updateAccountBalance = data.updateAccountBalance ?? false;
const userId = data.userId;
- if (data.type === 'ITEM' || data.type === 'LIABILITY') {
+ if (
+ data.type === 'FEE' ||
+ data.type === 'ITEM' ||
+ data.type === 'LIABILITY'
+ ) {
const assetClass = data.assetClass;
const assetSubClass = data.assetSubClass;
currency = data.SymbolProfile.connectOrCreate.create.currency;
@@ -151,7 +155,7 @@ export class OrderService {
const orderData: Prisma.OrderCreateInput = data;
const isDraft =
- data.type === 'LIABILITY'
+ data.type === 'FEE' || data.type === 'ITEM' || data.type === 'LIABILITY'
? false
: isAfter(data.date as Date, endOfToday());
@@ -197,7 +201,11 @@ export class OrderService {
where
});
- if (order.type === 'ITEM' || order.type === 'LIABILITY') {
+ if (
+ order.type === 'FEE' ||
+ order.type === 'ITEM' ||
+ order.type === 'LIABILITY'
+ ) {
await this.symbolProfileService.deleteById(order.symbolProfileId);
}
@@ -368,7 +376,11 @@ export class OrderService {
let isDraft = false;
- if (data.type === 'ITEM' || data.type === 'LIABILITY') {
+ if (
+ data.type === 'FEE' ||
+ data.type === 'ITEM' ||
+ data.type === 'LIABILITY'
+ ) {
delete data.SymbolProfile.connect;
} else {
delete data.SymbolProfile.update;
diff --git a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html
index 81c25bf75..a84fbebaf 100644
--- a/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html
+++ b/apps/client/src/app/components/portfolio-summary/portfolio-summary.component.html
@@ -5,6 +5,15 @@