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 ## Unreleased
### Added
- Supported a note for accounts
### Changed ### Changed
- Improved the language localization for French (`fr`) - 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 { AccountType } from '@prisma/client';
import { Transform, TransformFnParams } from 'class-transformer';
import { import {
IsBoolean, IsBoolean,
IsNumber, IsNumber,
@ -6,6 +7,7 @@ import {
IsString, IsString,
ValidateIf ValidateIf
} from 'class-validator'; } from 'class-validator';
import { isString } from 'lodash';
export class CreateAccountDto { export class CreateAccountDto {
@IsString() @IsString()
@ -14,6 +16,13 @@ export class CreateAccountDto {
@IsNumber() @IsNumber()
balance: number; balance: number;
@IsOptional()
@IsString()
@Transform(({ value }: TransformFnParams) =>
isString(value) ? value.trim() : value
)
comment?: string;
@IsString() @IsString()
currency: string; currency: string;

9
apps/api/src/app/account/update-account.dto.ts

@ -1,4 +1,5 @@
import { AccountType } from '@prisma/client'; import { AccountType } from '@prisma/client';
import { Transform, TransformFnParams } from 'class-transformer';
import { import {
IsBoolean, IsBoolean,
IsNumber, IsNumber,
@ -6,6 +7,7 @@ import {
IsString, IsString,
ValidateIf ValidateIf
} from 'class-validator'; } from 'class-validator';
import { isString } from 'lodash';
export class UpdateAccountDto { export class UpdateAccountDto {
@IsString() @IsString()
@ -14,6 +16,13 @@ export class UpdateAccountDto {
@IsNumber() @IsNumber()
balance: number; balance: number;
@IsOptional()
@IsString()
@Transform(({ value }: TransformFnParams) =>
isString(value) ? value.trim() : value
)
comment?: string;
@IsString() @IsString()
currency: string; currency: string;

1
apps/api/src/app/export/export.service.ts

@ -21,6 +21,7 @@ export class ExportService {
select: { select: {
accountType: true, accountType: true,
balance: true, balance: true,
comment: true,
currency: true, currency: true,
id: true, id: true,
isExcluded: true, isExcluded: true,

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

@ -207,6 +207,30 @@
</td> </td>
</ng-container> </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"> <ng-container matColumnDef="actions">
<th *matHeaderCellDef class="px-1 text-center" i18n mat-header-cell></th> <th *matHeaderCellDef class="px-1 text-center" i18n mat-header-cell></th>
<td *matCellDef="let element" class="px-1 text-center" mat-cell> <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', 'balance',
'value', 'value',
'currency', 'currency',
'valueInBaseCurrency' 'valueInBaseCurrency',
'comment'
]; ];
if (this.showActions) { if (this.showActions) {
@ -92,6 +93,10 @@ export class AccountsTableComponent implements OnChanges, OnDestroy, OnInit {
}); });
} }
public onOpenComment(aComment: string) {
alert(aComment);
}
public onUpdateAccount(aAccount: AccountModel) { public onUpdateAccount(aAccount: AccountModel) {
this.accountToUpdate.emit(aAccount); 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({ public openUpdateAccountDialog({
accountType, accountType,
balance, balance,
comment,
currency, currency,
id, id,
isExcluded, isExcluded,
@ -164,6 +165,7 @@ export class AccountsPageComponent implements OnDestroy, OnInit {
account: { account: {
accountType, accountType,
balance, balance,
comment,
currency, currency,
id, id,
isExcluded, isExcluded,
@ -232,6 +234,7 @@ export class AccountsPageComponent implements OnDestroy, OnInit {
account: { account: {
accountType: AccountType.SECURITIES, accountType: AccountType.SECURITIES,
balance: 0, balance: 0,
comment: null,
currency: this.user?.settings?.baseCurrency, currency: this.user?.settings?.baseCurrency,
isExcluded: false, isExcluded: false,
name: null, 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-select>
</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
matInput
name="comment"
[(ngModel)]="data.account.comment"
(keyup.enter)="$event.stopPropagation()"
></textarea>
</mat-form-field>
</div>
<div class="mb-3 px-2"> <div class="mb-3 px-2">
<mat-checkbox <mat-checkbox
color="primary" 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 { model Account {
accountType AccountType @default(SECURITIES) accountType AccountType @default(SECURITIES)
balance Float @default(0) balance Float @default(0)
comment String?
createdAt DateTime @default(now()) createdAt DateTime @default(now())
currency String? currency String?
id String @default(uuid()) id String @default(uuid())

Loading…
Cancel
Save