Feature/add comment to activity (#1097)
* Add comment to activity * Update changelog
This commit is contained in:
parent
678f1f0051
commit
81217b35ef
10
CHANGELOG.md
10
CHANGELOG.md
@ -5,6 +5,16 @@ 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
|
||||||
|
|
||||||
|
### Added
|
||||||
|
|
||||||
|
- Support a note for activities
|
||||||
|
|
||||||
|
### Todo
|
||||||
|
|
||||||
|
- Apply data migration (`yarn database:migrate`)
|
||||||
|
|
||||||
## 1.173.0 - 23.07.2022
|
## 1.173.0 - 23.07.2022
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
@ -18,6 +18,7 @@ export class ExportService {
|
|||||||
orderBy: { date: 'desc' },
|
orderBy: { date: 'desc' },
|
||||||
select: {
|
select: {
|
||||||
accountId: true,
|
accountId: true,
|
||||||
|
comment: true,
|
||||||
date: true,
|
date: true,
|
||||||
fee: true,
|
fee: true,
|
||||||
id: true,
|
id: true,
|
||||||
@ -40,6 +41,7 @@ export class ExportService {
|
|||||||
activities: activities.map(
|
activities: activities.map(
|
||||||
({
|
({
|
||||||
accountId,
|
accountId,
|
||||||
|
comment,
|
||||||
date,
|
date,
|
||||||
fee,
|
fee,
|
||||||
id,
|
id,
|
||||||
@ -50,6 +52,7 @@ export class ExportService {
|
|||||||
}) => {
|
}) => {
|
||||||
return {
|
return {
|
||||||
accountId,
|
accountId,
|
||||||
|
comment,
|
||||||
fee,
|
fee,
|
||||||
id,
|
id,
|
||||||
quantity,
|
quantity,
|
||||||
|
@ -48,6 +48,7 @@ export class ImportService {
|
|||||||
|
|
||||||
for (const {
|
for (const {
|
||||||
accountId,
|
accountId,
|
||||||
|
comment,
|
||||||
currency,
|
currency,
|
||||||
dataSource,
|
dataSource,
|
||||||
date,
|
date,
|
||||||
@ -58,6 +59,7 @@ export class ImportService {
|
|||||||
unitPrice
|
unitPrice
|
||||||
} of activities) {
|
} of activities) {
|
||||||
await this.orderService.createOrder({
|
await this.orderService.createOrder({
|
||||||
|
comment,
|
||||||
fee,
|
fee,
|
||||||
quantity,
|
quantity,
|
||||||
type,
|
type,
|
||||||
|
@ -5,6 +5,7 @@ import {
|
|||||||
Tag,
|
Tag,
|
||||||
Type
|
Type
|
||||||
} from '@prisma/client';
|
} from '@prisma/client';
|
||||||
|
import { Transform, TransformFnParams } from 'class-transformer';
|
||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
IsEnum,
|
IsEnum,
|
||||||
@ -13,25 +14,33 @@ import {
|
|||||||
IsOptional,
|
IsOptional,
|
||||||
IsString
|
IsString
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
|
import { isString } from 'lodash';
|
||||||
|
|
||||||
export class CreateOrderDto {
|
export class CreateOrderDto {
|
||||||
@IsString()
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
accountId?: string;
|
accountId?: string;
|
||||||
|
|
||||||
@IsEnum(AssetClass, { each: true })
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
|
@IsEnum(AssetClass, { each: true })
|
||||||
assetClass?: AssetClass;
|
assetClass?: AssetClass;
|
||||||
|
|
||||||
@IsEnum(AssetSubClass, { each: true })
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
|
@IsEnum(AssetSubClass, { each: true })
|
||||||
assetSubClass?: AssetSubClass;
|
assetSubClass?: AssetSubClass;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
@Transform(({ value }: TransformFnParams) =>
|
||||||
|
isString(value) ? value.trim() : value
|
||||||
|
)
|
||||||
|
comment?: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
currency: string;
|
currency: string;
|
||||||
|
|
||||||
@IsEnum(DataSource, { each: true })
|
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
|
@IsEnum(DataSource, { each: true })
|
||||||
dataSource?: DataSource;
|
dataSource?: DataSource;
|
||||||
|
|
||||||
@IsISO8601()
|
@IsISO8601()
|
||||||
|
@ -21,7 +21,7 @@ import {
|
|||||||
} from '@prisma/client';
|
} from '@prisma/client';
|
||||||
import Big from 'big.js';
|
import Big from 'big.js';
|
||||||
import { endOfToday, isAfter } from 'date-fns';
|
import { endOfToday, isAfter } from 'date-fns';
|
||||||
import { groupBy } from 'lodash';
|
import { groupBy, isString } from 'lodash';
|
||||||
import { v4 as uuidv4 } from 'uuid';
|
import { v4 as uuidv4 } from 'uuid';
|
||||||
|
|
||||||
import { Activity } from './interfaces/activities.interface';
|
import { Activity } from './interfaces/activities.interface';
|
||||||
@ -143,6 +143,11 @@ export class OrderService {
|
|||||||
delete data.accountId;
|
delete data.accountId;
|
||||||
delete data.assetClass;
|
delete data.assetClass;
|
||||||
delete data.assetSubClass;
|
delete data.assetSubClass;
|
||||||
|
|
||||||
|
if (!data.comment) {
|
||||||
|
delete data.comment;
|
||||||
|
}
|
||||||
|
|
||||||
delete data.currency;
|
delete data.currency;
|
||||||
delete data.dataSource;
|
delete data.dataSource;
|
||||||
delete data.symbol;
|
delete data.symbol;
|
||||||
@ -316,6 +321,10 @@ export class OrderService {
|
|||||||
delete data.Account;
|
delete data.Account;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!data.comment) {
|
||||||
|
data.comment = null;
|
||||||
|
}
|
||||||
|
|
||||||
const tags = data.tags ?? [];
|
const tags = data.tags ?? [];
|
||||||
|
|
||||||
let isDraft = false;
|
let isDraft = false;
|
||||||
|
@ -5,6 +5,7 @@ import {
|
|||||||
Tag,
|
Tag,
|
||||||
Type
|
Type
|
||||||
} from '@prisma/client';
|
} from '@prisma/client';
|
||||||
|
import { Transform, TransformFnParams } from 'class-transformer';
|
||||||
import {
|
import {
|
||||||
IsArray,
|
IsArray,
|
||||||
IsEnum,
|
IsEnum,
|
||||||
@ -13,6 +14,7 @@ import {
|
|||||||
IsOptional,
|
IsOptional,
|
||||||
IsString
|
IsString
|
||||||
} from 'class-validator';
|
} from 'class-validator';
|
||||||
|
import { isString } from 'lodash';
|
||||||
|
|
||||||
export class UpdateOrderDto {
|
export class UpdateOrderDto {
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@ -27,6 +29,13 @@ export class UpdateOrderDto {
|
|||||||
@IsOptional()
|
@IsOptional()
|
||||||
assetSubClass?: AssetSubClass;
|
assetSubClass?: AssetSubClass;
|
||||||
|
|
||||||
|
@IsOptional()
|
||||||
|
@IsString()
|
||||||
|
@Transform(({ value }: TransformFnParams) =>
|
||||||
|
isString(value) ? value.trim() : value
|
||||||
|
)
|
||||||
|
comment?: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
currency: string;
|
currency: string;
|
||||||
|
|
||||||
|
@ -76,6 +76,7 @@ export class CreateOrUpdateTransactionDialog implements OnDestroy {
|
|||||||
accountId: [this.data.activity?.accountId, Validators.required],
|
accountId: [this.data.activity?.accountId, Validators.required],
|
||||||
assetClass: [this.data.activity?.SymbolProfile?.assetClass],
|
assetClass: [this.data.activity?.SymbolProfile?.assetClass],
|
||||||
assetSubClass: [this.data.activity?.SymbolProfile?.assetSubClass],
|
assetSubClass: [this.data.activity?.SymbolProfile?.assetSubClass],
|
||||||
|
comment: [this.data.activity?.comment],
|
||||||
currency: [
|
currency: [
|
||||||
this.data.activity?.SymbolProfile?.currency,
|
this.data.activity?.SymbolProfile?.currency,
|
||||||
Validators.required
|
Validators.required
|
||||||
@ -245,6 +246,7 @@ export class CreateOrUpdateTransactionDialog implements OnDestroy {
|
|||||||
accountId: this.activityForm.controls['accountId'].value,
|
accountId: this.activityForm.controls['accountId'].value,
|
||||||
assetClass: this.activityForm.controls['assetClass'].value,
|
assetClass: this.activityForm.controls['assetClass'].value,
|
||||||
assetSubClass: this.activityForm.controls['assetSubClass'].value,
|
assetSubClass: this.activityForm.controls['assetSubClass'].value,
|
||||||
|
comment: this.activityForm.controls['comment'].value,
|
||||||
currency: this.activityForm.controls['currency'].value,
|
currency: this.activityForm.controls['currency'].value,
|
||||||
date: this.activityForm.controls['date'].value,
|
date: this.activityForm.controls['date'].value,
|
||||||
dataSource: this.activityForm.controls['dataSource'].value,
|
dataSource: this.activityForm.controls['dataSource'].value,
|
||||||
|
@ -135,6 +135,18 @@
|
|||||||
>
|
>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<mat-form-field appearance="outline" class="w-100">
|
||||||
|
<mat-label i18n>Note</mat-label>
|
||||||
|
<textarea
|
||||||
|
cdkAutosizeMinRows="2"
|
||||||
|
cdkTextareaAutosize
|
||||||
|
formControlName="comment"
|
||||||
|
matInput
|
||||||
|
(keyup.enter)="$event.stopPropagation()"
|
||||||
|
></textarea>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
[ngClass]="{ 'd-none': activityForm.controls['type']?.value !== 'ITEM' }"
|
[ngClass]="{ 'd-none': activityForm.controls['type']?.value !== 'ITEM' }"
|
||||||
>
|
>
|
||||||
|
@ -347,6 +347,15 @@
|
|||||||
</mat-menu>
|
</mat-menu>
|
||||||
</th>
|
</th>
|
||||||
<td *matCellDef="let element" class="px-1 text-center" mat-cell>
|
<td *matCellDef="let element" class="px-1 text-center" mat-cell>
|
||||||
|
<button
|
||||||
|
*ngIf="element.comment && !this.showActions"
|
||||||
|
class="mx-1 no-min-width px-2"
|
||||||
|
mat-button
|
||||||
|
title="Note"
|
||||||
|
(click)="onOpenComment(element.comment)"
|
||||||
|
>
|
||||||
|
<ion-icon name="document-text-outline"></ion-icon>
|
||||||
|
</button>
|
||||||
<button
|
<button
|
||||||
*ngIf="this.showActions"
|
*ngIf="this.showActions"
|
||||||
class="mx-1 no-min-width px-2"
|
class="mx-1 no-min-width px-2"
|
||||||
|
@ -171,6 +171,10 @@ export class ActivitiesTableComponent implements OnChanges, OnDestroy {
|
|||||||
this.import.emit();
|
this.import.emit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public onOpenComment(aComment: string) {
|
||||||
|
alert(aComment);
|
||||||
|
}
|
||||||
|
|
||||||
public onOpenPositionDialog({ dataSource, symbol }: UniqueAsset): void {
|
public onOpenPositionDialog({ dataSource, symbol }: UniqueAsset): void {
|
||||||
this.router.navigate([], {
|
this.router.navigate([], {
|
||||||
queryParams: { dataSource, symbol, positionDetailDialog: true }
|
queryParams: { dataSource, symbol, positionDetailDialog: true }
|
||||||
|
@ -0,0 +1,2 @@
|
|||||||
|
-- AlterTable
|
||||||
|
ALTER TABLE "Order" ADD COLUMN "comment" TEXT;
|
@ -71,6 +71,7 @@ model Order {
|
|||||||
Account Account? @relation(fields: [accountId, accountUserId], references: [id, userId])
|
Account Account? @relation(fields: [accountId, accountUserId], references: [id, userId])
|
||||||
accountId String?
|
accountId String?
|
||||||
accountUserId String?
|
accountUserId String?
|
||||||
|
comment String?
|
||||||
createdAt DateTime @default(now())
|
createdAt DateTime @default(now())
|
||||||
date DateTime
|
date DateTime
|
||||||
fee Float
|
fee Float
|
||||||
|
Loading…
x
Reference in New Issue
Block a user