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
parent
commit
9116443305
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 9
      apps/api/src/app/account/create-account.dto.ts
  3. 9
      apps/api/src/app/account/update-account.dto.ts
  4. 1
      apps/api/src/app/export/export.service.ts
  5. 24
      apps/client/src/app/components/accounts-table/accounts-table.component.html
  6. 7
      apps/client/src/app/components/accounts-table/accounts-table.component.ts
  7. 3
      apps/client/src/app/pages/accounts/accounts-page.component.ts
  8. 13
      apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html
  9. 2
      prisma/migrations/20230610083653_added_comment_to_account/migration.sql
  10. 1
      prisma/schema.prisma

4
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`)

9
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;

9
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;

1
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,

24
apps/client/src/app/components/accounts-table/accounts-table.component.html

@ -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>

7
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);
}

3
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,

13
apps/client/src/app/pages/accounts/create-or-update-account-dialog/create-or-update-account-dialog.html

@ -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"

2
prisma/migrations/20230610083653_added_comment_to_account/migration.sql

@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Account" ADD COLUMN "comment" TEXT;

1
prisma/schema.prisma

@ -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())

Loading…
Cancel
Save