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/),
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
### Added

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

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

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

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

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

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

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

@ -15,7 +15,6 @@ export interface ExportResponse {
| 'accountUserId'
| 'createdAt'
| 'date'
| 'isDraft'
| 'symbolProfileId'
| 'updatedAt'
| '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'),
fee: 1,
id: 'a76968ff-80a4-4453-81ed-c3627dea3919',
isDraft: false,
quantity: 115,
symbolProfileId: '21746431-d612-4298-911c-3099b2a43003',
type: 'BUY',
@ -96,7 +95,6 @@ const activities: Activity[] = [
date: new Date('2024-08-07T13:38:06.289Z'),
fee: 2.97,
id: '0c2f4fbf-6edc-4adc-8f83-abf8148500ec',
isDraft: false,
quantity: 105,
symbolProfileId: '21746431-d612-4298-911c-3099b2a43003',
type: 'BUY',
@ -161,7 +159,6 @@ const activities: Activity[] = [
date: new Date('2024-03-12T15:14:38.597Z'),
fee: 45.29,
id: 'bfc92677-faf4-4d4f-9762-e0ec056525c2',
isDraft: false,
quantity: 167,
symbolProfileId: '888d4123-db9a-42f3-9775-01b1ae6f9092',
type: 'BUY',
@ -226,7 +223,6 @@ const activities: Activity[] = [
date: new Date('2024-02-23T15:53:15.745Z'),
fee: 3,
id: '7c9ceb54-acb1-4850-bfb1-adb41c29fd6a',
isDraft: false,
quantity: 81,
symbolProfileId: '36effe43-7cb4-4e8b-b7ac-03ff65702cb9',
type: 'BUY',
@ -291,7 +287,6 @@ const activities: Activity[] = [
date: new Date('2023-01-11T14:34:55.174Z'),
fee: 7.38,
id: '3fe87b3f-78de-407a-bc02-4189b221051f',
isDraft: false,
quantity: 55,
symbolProfileId: '21746431-d612-4298-911c-3099b2a43003',
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
fee Float
id String @id @default(uuid())
/// @deprecated Use the "Draft" tag (`TAG_ID_DRAFT`) instead
isDraft Boolean @default(false)
quantity Float
symbolProfileId String
tags Tag[]
@ -197,7 +195,6 @@ model Order {
@@index([accountId])
@@index([date])
@@index([isDraft])
@@index([type])
@@index([userId])
}

Loading…
Cancel
Save