Browse Source
Feature/support note in accounts (#2063)
* Add support for a note in accounts
* Update changelog
pull/2065/head
Thomas Kaul
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with
72 additions and
1 deletions
-
CHANGELOG.md
-
apps/api/src/app/account/create-account.dto.ts
-
apps/api/src/app/account/update-account.dto.ts
-
apps/api/src/app/export/export.service.ts
-
apps/client/src/app/components/accounts-table/accounts-table.component.html
-
apps/client/src/app/components/accounts-table/accounts-table.component.ts
-
apps/client/src/app/pages/accounts/accounts-page.component.ts
-
apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html
-
prisma/migrations/20230610083653_added_comment_to_account/migration.sql
-
prisma/schema.prisma
|
|
@ -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`) |
|
|
|
|
|
@ -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; |
|
|
|
|
|
|
|
|
|
@ -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; |
|
|
|
|
|
|
|
|
|
@ -21,6 +21,7 @@ export class ExportService { |
|
|
|
select: { |
|
|
|
accountType: true, |
|
|
|
balance: true, |
|
|
|
comment: true, |
|
|
|
currency: true, |
|
|
|
id: true, |
|
|
|
isExcluded: true, |
|
|
|
|
|
@ -207,6 +207,30 @@ |
|
|
|
</td> |
|
|
|
</ng-container> |
|
|
|
|
|
|
|
<ng-container matColumnDef="comment"> |
|
|
|
<th |
|
|
|
*matHeaderCellDef |
|
|
|
class="d-none d-lg-table-cell px-1" |
|
|
|
mat-header-cell |
|
|
|
></th> |
|
|
|
<td *matCellDef="let element" class="d-none d-lg-table-cell px-1" mat-cell> |
|
|
|
<button |
|
|
|
*ngIf="element.comment" |
|
|
|
class="mx-1 no-min-width px-2" |
|
|
|
mat-button |
|
|
|
title="Note" |
|
|
|
(click)="onOpenComment(element.comment); $event.stopPropagation()" |
|
|
|
> |
|
|
|
<ion-icon name="document-text-outline"></ion-icon> |
|
|
|
</button> |
|
|
|
</td> |
|
|
|
<td |
|
|
|
*matFooterCellDef |
|
|
|
class="d-none d-lg-table-cell px-1" |
|
|
|
mat-footer-cell |
|
|
|
></td> |
|
|
|
</ng-container> |
|
|
|
|
|
|
|
<ng-container matColumnDef="actions"> |
|
|
|
<th *matHeaderCellDef class="px-1 text-center" i18n mat-header-cell></th> |
|
|
|
<td *matCellDef="let element" class="px-1 text-center" mat-cell> |
|
|
|
|
|
@ -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); |
|
|
|
} |
|
|
|
|
|
@ -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, |
|
|
|
|
|
@ -50,6 +50,19 @@ |
|
|
|
</mat-select> |
|
|
|
</mat-form-field> |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
<mat-form-field appearance="outline" class="w-100"> |
|
|
|
<mat-label i18n>Note</mat-label> |
|
|
|
<textarea |
|
|
|
cdkAutosizeMinRows="2" |
|
|
|
cdkTextareaAutosize |
|
|
|
matInput |
|
|
|
name="comment" |
|
|
|
[(ngModel)]="data.account.comment" |
|
|
|
(keyup.enter)="$event.stopPropagation()" |
|
|
|
></textarea> |
|
|
|
</mat-form-field> |
|
|
|
</div> |
|
|
|
<div class="mb-3 px-2"> |
|
|
|
<mat-checkbox |
|
|
|
color="primary" |
|
|
|
|
|
@ -0,0 +1,2 @@ |
|
|
|
-- AlterTable |
|
|
|
ALTER TABLE "Account" ADD COLUMN "comment" TEXT; |
|
|
@ -23,6 +23,7 @@ model Access { |
|
|
|
model Account { |
|
|
|
accountType AccountType @default(SECURITIES) |
|
|
|
balance Float @default(0) |
|
|
|
comment String? |
|
|
|
createdAt DateTime @default(now()) |
|
|
|
currency String? |
|
|
|
id String @default(uuid()) |
|
|
|