Browse Source

Task/remove isDraft of activity (#7577)

* Remove deprecated isDraft attribute of activity

* Update changelog
pull/7604/head
Thomas Kaul 6 days ago
committed by GitHub
parent
commit
7ded5e4340
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 6
      CHANGELOG.md
  2. 22
      apps/api/src/app/activities/activities.service.ts
  3. 3
      apps/api/src/app/import/import.service.ts
  4. 1
      apps/api/src/app/portfolio/calculator/portfolio-calculator-test-utils.ts
  5. 1
      libs/common/src/lib/interfaces/responses/export-response.interface.ts
  6. 5
      libs/ui/src/lib/activities-table/activities-table.component.stories.ts
  7. 5
      prisma/migrations/20260812120000_removed_is_draft_from_order/migration.sql
  8. 3
      prisma/schema.prisma

6
CHANGELOG.md

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## Unreleased
### Changed
- Removed the deprecated `isDraft` attribute of the activity in favor of the _Draft_ tag
## 3.48.1 - 2026-08-11 ## 3.48.1 - 2026-08-11
### Added ### Added

22
apps/api/src/app/activities/activities.service.ts

@ -146,16 +146,12 @@ export class ActivitiesService {
activities.map((activity) => { activities.map((activity) => {
// The set operation replaces all existing connections with the provided // The set operation replaces all existing connections with the provided
// ones, hence the "Draft" tag of an individual activity is carried over // ones, hence the "Draft" tag of an individual activity is carried over
const isDraft = isDraftActivity(activity); const tagsToSet = isDraftActivity(activity)
const tagsToSet = isDraft
? [...tagsToAssign, { id: TAG_ID_DRAFT }] ? [...tagsToAssign, { id: TAG_ID_DRAFT }]
: tagsToAssign; : tagsToAssign;
return this.prismaService.order.update({ return this.prismaService.order.update({
data: { data: {
// @deprecated Mirrors the "Draft" tag until the attribute is removed
isDraft,
tags: { tags: {
set: tagsToSet set: tagsToSet
} }
@ -292,8 +288,6 @@ export class ActivitiesService {
data: { data: {
...orderData, ...orderData,
account, account,
// @deprecated Mirrors the "Draft" tag until the attribute is removed
isDraft: isDraftActivity({ tags: tagsToConnect }),
tags: { tags: {
connect: tagsToConnect connect: tagsToConnect
} }
@ -542,7 +536,6 @@ export class ActivitiesService {
feeInAssetProfileCurrency: 0, feeInAssetProfileCurrency: 0,
feeInBaseCurrency: 0, feeInBaseCurrency: 0,
id: balanceItem.id, id: balanceItem.id,
isDraft: false,
quantity: 1, quantity: 1,
symbolProfileId: account.currency, symbolProfileId: account.currency,
type: ActivityType.BUY, type: ActivityType.BUY,
@ -1044,20 +1037,18 @@ export class ActivitiesService {
// Leave the tags untouched if the request does not provide them, so that a // Leave the tags untouched if the request does not provide them, so that a
// partial update cannot drop the "Draft" tag // partial update cannot drop the "Draft" tag
let isDraft: boolean;
let tagsToUpdate: Prisma.OrderUpdateInput['tags']; let tagsToUpdate: Prisma.OrderUpdateInput['tags'];
if (areTagsProvided) { if (areTagsProvided) {
const tagsToSet = getTagsWithDraftTag({ tagsToUpdate = {
set: getTagsWithDraftTag({
originalDate, originalDate,
tags, tags,
date: data.date as Date, date: data.date as Date,
draftTag: { id: TAG_ID_DRAFT }, draftTag: { id: TAG_ID_DRAFT },
type: data.type type: data.type
}); })
};
isDraft = isDraftActivity({ tags: tagsToSet });
tagsToUpdate = { set: tagsToSet };
} else if ( } else if (
isDraftTagToBeAssigned({ isDraftTagToBeAssigned({
originalDate, originalDate,
@ -1065,7 +1056,6 @@ export class ActivitiesService {
type: data.type type: data.type
}) })
) { ) {
isDraft = true;
tagsToUpdate = { connect: { id: TAG_ID_DRAFT } }; tagsToUpdate = { connect: { id: TAG_ID_DRAFT } };
} }
@ -1073,8 +1063,6 @@ export class ActivitiesService {
where, where,
data: { data: {
...data, ...data,
// @deprecated Mirrors the "Draft" tag until the attribute is removed
isDraft,
tags: tagsToUpdate tags: tagsToUpdate
} }
}); });

3
apps/api/src/app/import/import.service.ts

@ -24,7 +24,6 @@ import {
} from '@ghostfolio/common/dtos'; } from '@ghostfolio/common/dtos';
import { import {
getAssetProfileIdentifier, getAssetProfileIdentifier,
isDraftActivity,
isValidCustomAssetProfileSymbol, isValidCustomAssetProfileSymbol,
parseDate parseDate
} from '@ghostfolio/common/helper'; } from '@ghostfolio/common/helper';
@ -168,7 +167,6 @@ export class ImportService {
feeInAssetProfileCurrency: 0, feeInAssetProfileCurrency: 0,
feeInBaseCurrency: 0, feeInBaseCurrency: 0,
id: assetProfile.id, id: assetProfile.id,
isDraft: false,
symbolProfileId: assetProfile.id, symbolProfileId: assetProfile.id,
type: 'DIVIDEND', type: 'DIVIDEND',
unitPrice: marketPrice, unitPrice: marketPrice,
@ -803,7 +801,6 @@ export class ImportService {
accountUserId: undefined, accountUserId: undefined,
createdAt: new Date(), createdAt: new Date(),
id: randomUUID(), id: randomUUID(),
isDraft: isDraftActivity({ tags: previewTags }),
SymbolProfile: { SymbolProfile: {
assetClass, assetClass,
assetSubClass, assetSubClass,

1
apps/api/src/app/portfolio/calculator/portfolio-calculator-test-utils.ts

@ -12,7 +12,6 @@ export const activityDummyData = {
feeInAssetProfileCurrency: undefined, feeInAssetProfileCurrency: undefined,
feeInBaseCurrency: undefined, feeInBaseCurrency: undefined,
id: undefined, id: undefined,
isDraft: false,
symbolProfileId: undefined, symbolProfileId: undefined,
unitPrice: undefined, unitPrice: undefined,
unitPriceInAssetProfileCurrency: undefined, unitPriceInAssetProfileCurrency: undefined,

1
libs/common/src/lib/interfaces/responses/export-response.interface.ts

@ -15,7 +15,6 @@ export interface ExportResponse {
| 'accountUserId' | 'accountUserId'
| 'createdAt' | 'createdAt'
| 'date' | 'date'
| 'isDraft'
| 'symbolProfileId' | 'symbolProfileId'
| 'updatedAt' | 'updatedAt'
| 'userId' | 'userId'

5
libs/ui/src/lib/activities-table/activities-table.component.stories.ts

@ -31,7 +31,6 @@ const activities: Activity[] = [
date: new Date('2025-04-09T13:45:45.504Z'), date: new Date('2025-04-09T13:45:45.504Z'),
fee: 1, fee: 1,
id: 'a76968ff-80a4-4453-81ed-c3627dea3919', id: 'a76968ff-80a4-4453-81ed-c3627dea3919',
isDraft: false,
quantity: 115, quantity: 115,
symbolProfileId: '21746431-d612-4298-911c-3099b2a43003', symbolProfileId: '21746431-d612-4298-911c-3099b2a43003',
type: 'BUY', type: 'BUY',
@ -96,7 +95,6 @@ const activities: Activity[] = [
date: new Date('2024-08-07T13:38:06.289Z'), date: new Date('2024-08-07T13:38:06.289Z'),
fee: 2.97, fee: 2.97,
id: '0c2f4fbf-6edc-4adc-8f83-abf8148500ec', id: '0c2f4fbf-6edc-4adc-8f83-abf8148500ec',
isDraft: false,
quantity: 105, quantity: 105,
symbolProfileId: '21746431-d612-4298-911c-3099b2a43003', symbolProfileId: '21746431-d612-4298-911c-3099b2a43003',
type: 'BUY', type: 'BUY',
@ -161,7 +159,6 @@ const activities: Activity[] = [
date: new Date('2024-03-12T15:14:38.597Z'), date: new Date('2024-03-12T15:14:38.597Z'),
fee: 45.29, fee: 45.29,
id: 'bfc92677-faf4-4d4f-9762-e0ec056525c2', id: 'bfc92677-faf4-4d4f-9762-e0ec056525c2',
isDraft: false,
quantity: 167, quantity: 167,
symbolProfileId: '888d4123-db9a-42f3-9775-01b1ae6f9092', symbolProfileId: '888d4123-db9a-42f3-9775-01b1ae6f9092',
type: 'BUY', type: 'BUY',
@ -226,7 +223,6 @@ const activities: Activity[] = [
date: new Date('2024-02-23T15:53:15.745Z'), date: new Date('2024-02-23T15:53:15.745Z'),
fee: 3, fee: 3,
id: '7c9ceb54-acb1-4850-bfb1-adb41c29fd6a', id: '7c9ceb54-acb1-4850-bfb1-adb41c29fd6a',
isDraft: false,
quantity: 81, quantity: 81,
symbolProfileId: '36effe43-7cb4-4e8b-b7ac-03ff65702cb9', symbolProfileId: '36effe43-7cb4-4e8b-b7ac-03ff65702cb9',
type: 'BUY', type: 'BUY',
@ -291,7 +287,6 @@ const activities: Activity[] = [
date: new Date('2023-01-11T14:34:55.174Z'), date: new Date('2023-01-11T14:34:55.174Z'),
fee: 7.38, fee: 7.38,
id: '3fe87b3f-78de-407a-bc02-4189b221051f', id: '3fe87b3f-78de-407a-bc02-4189b221051f',
isDraft: false,
quantity: 55, quantity: 55,
symbolProfileId: '21746431-d612-4298-911c-3099b2a43003', symbolProfileId: '21746431-d612-4298-911c-3099b2a43003',
type: 'BUY', type: 'BUY',

5
prisma/migrations/20260812120000_removed_is_draft_from_order/migration.sql

@ -0,0 +1,5 @@
-- DropIndex
DROP INDEX "Order_isDraft_idx";
-- AlterTable
ALTER TABLE "Order" DROP COLUMN "isDraft";

3
prisma/schema.prisma

@ -183,8 +183,6 @@ model Order {
date DateTime date DateTime
fee Float fee Float
id String @id @default(uuid()) id String @id @default(uuid())
/// @deprecated Use the "Draft" tag (`TAG_ID_DRAFT`) instead
isDraft Boolean @default(false)
quantity Float quantity Float
symbolProfileId String symbolProfileId String
tags Tag[] tags Tag[]
@ -197,7 +195,6 @@ model Order {
@@index([accountId]) @@index([accountId])
@@index([date]) @@index([date])
@@index([isDraft])
@@index([type]) @@index([type])
@@index([userId]) @@index([userId])
} }

Loading…
Cancel
Save