diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cdd9430f..fdd2cbea7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Added + +- Supported a note for accounts + ### Changed - Improved the language localization for French (`fr`) diff --git a/apps/api/src/app/account/create-account.dto.ts b/apps/api/src/app/account/create-account.dto.ts index 6495fa518..c700e7fa9 100644 --- a/apps/api/src/app/account/create-account.dto.ts +++ b/apps/api/src/app/account/create-account.dto.ts @@ -1,4 +1,5 @@ import { AccountType } from '@prisma/client'; +import { Transform, TransformFnParams } from 'class-transformer'; import { IsBoolean, IsNumber, @@ -6,6 +7,7 @@ import { IsString, ValidateIf } from 'class-validator'; +import { isString } from 'lodash'; export class CreateAccountDto { @IsString() @@ -14,6 +16,13 @@ export class CreateAccountDto { @IsNumber() balance: number; + @IsOptional() + @IsString() + @Transform(({ value }: TransformFnParams) => + isString(value) ? value.trim() : value + ) + comment?: string; + @IsString() currency: string; diff --git a/apps/api/src/app/account/update-account.dto.ts b/apps/api/src/app/account/update-account.dto.ts index 0b5737607..d8c62aff7 100644 --- a/apps/api/src/app/account/update-account.dto.ts +++ b/apps/api/src/app/account/update-account.dto.ts @@ -1,4 +1,5 @@ import { AccountType } from '@prisma/client'; +import { Transform, TransformFnParams } from 'class-transformer'; import { IsBoolean, IsNumber, @@ -6,6 +7,7 @@ import { IsString, ValidateIf } from 'class-validator'; +import { isString } from 'lodash'; export class UpdateAccountDto { @IsString() @@ -14,6 +16,13 @@ export class UpdateAccountDto { @IsNumber() balance: number; + @IsOptional() + @IsString() + @Transform(({ value }: TransformFnParams) => + isString(value) ? value.trim() : value + ) + comment?: string; + @IsString() currency: string; diff --git a/apps/api/src/app/export/export.service.ts b/apps/api/src/app/export/export.service.ts index c8bd651a6..eaeea0f07 100644 --- a/apps/api/src/app/export/export.service.ts +++ b/apps/api/src/app/export/export.service.ts @@ -21,6 +21,7 @@ export class ExportService { select: { accountType: true, balance: true, + comment: true, currency: true, id: true, isExcluded: true, diff --git a/apps/client/src/app/components/accounts-table/accounts-table.component.html b/apps/client/src/app/components/accounts-table/accounts-table.component.html index 0ab9ea9af..0b859321f 100644 --- a/apps/client/src/app/components/accounts-table/accounts-table.component.html +++ b/apps/client/src/app/components/accounts-table/accounts-table.component.html @@ -207,6 +207,30 @@ + + + + + + + + diff --git a/apps/client/src/app/components/accounts-table/accounts-table.component.ts b/apps/client/src/app/components/accounts-table/accounts-table.component.ts index 8ec0f86fb..77b7b4d0f 100644 --- a/apps/client/src/app/components/accounts-table/accounts-table.component.ts +++ b/apps/client/src/app/components/accounts-table/accounts-table.component.ts @@ -58,7 +58,8 @@ export class AccountsTableComponent implements OnChanges, OnDestroy, OnInit { 'balance', 'value', 'currency', - 'valueInBaseCurrency' + 'valueInBaseCurrency', + 'comment' ]; if (this.showActions) { @@ -92,6 +93,10 @@ export class AccountsTableComponent implements OnChanges, OnDestroy, OnInit { }); } + public onOpenComment(aComment: string) { + alert(aComment); + } + public onUpdateAccount(aAccount: AccountModel) { this.accountToUpdate.emit(aAccount); } diff --git a/apps/client/src/app/pages/accounts/accounts-page.component.ts b/apps/client/src/app/pages/accounts/accounts-page.component.ts index dc1fa590e..96bd06816 100644 --- a/apps/client/src/app/pages/accounts/accounts-page.component.ts +++ b/apps/client/src/app/pages/accounts/accounts-page.component.ts @@ -153,6 +153,7 @@ export class AccountsPageComponent implements OnDestroy, OnInit { public openUpdateAccountDialog({ accountType, balance, + comment, currency, id, isExcluded, @@ -164,6 +165,7 @@ export class AccountsPageComponent implements OnDestroy, OnInit { account: { accountType, balance, + comment, currency, id, isExcluded, @@ -232,6 +234,7 @@ export class AccountsPageComponent implements OnDestroy, OnInit { account: { accountType: AccountType.SECURITIES, balance: 0, + comment: null, currency: this.user?.settings?.baseCurrency, isExcluded: false, name: null, diff --git a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html index fca606d27..5413d08b3 100644 --- a/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html +++ b/apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html @@ -50,6 +50,19 @@ +
+ + Note + + +