Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,267 changes: 1,043 additions & 224 deletions server/.erd/erdiadb.json

Large diffs are not rendered by default.

3,200 changes: 2,411 additions & 789 deletions server/.erd/index.html

Large diffs are not rendered by default.

154 changes: 142 additions & 12 deletions server/.erd/mermaid.html
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,30 @@ <h3 class="title is-4">Diagram</h3>

erDiagram

"note(Note)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*varchar name
varchar(100) description
}



"note_transaction(NoteTransaction)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*uuid note_id FK
*varchar(100) description
*numeric total
*numeric pre_balance
*numeric post_balance
}


"note_transaction(NoteTransaction)" }o -- || "note(Note)": "note_id"

"user(User)" {
*uuid id PK
*timestamp created_at
Expand Down Expand Up @@ -273,19 +297,22 @@ <h3 class="title is-4">Diagram</h3>

"account(Account)" }o -- || "user(User)": "user_id"

"account_history(AccountHistory)" {
"note_item(NoteItem)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*uuid transaction_id FK
*uuid account_id FK
*varchar action
*varchar description
*numeric pre_balance
*numeric post_balance
*uuid user_id FK
*varchar(100) name
*numeric amount
*smallint is_over_budget
}


"account_history(AccountHistory)" }o -- || "account(Account)": "account_id"
"note_item(NoteItem)" }o -- || "note_transaction(NoteTransaction)": "transaction_id"
"note_item(NoteItem)" }o -- || "account(Account)": "account_id"
"note_item(NoteItem)" }o -- || "user(User)": "user_id"

"user_session(UserSession)" {
*uuid id PK
Expand All @@ -307,6 +334,44 @@ <h3 class="title is-4">Diagram</h3>

"user_session(UserSession)" }o -- || "user(User)": "user_id"

"account_history(AccountHistory)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*uuid account_id FK
*varchar action
*varchar description
*numeric pre_balance
*numeric post_balance
}


"account_history(AccountHistory)" }o -- || "account(Account)": "account_id"

"note_account(NoteAccount)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*uuid note_id FK
*uuid account_id FK
}


"note_account(NoteAccount)" }o -- || "note(Note)": "note_id"
"note_account(NoteAccount)" }o -- || "account(Account)": "account_id"

"note_member(NoteMember)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*uuid note_id FK
*uuid user_id FK
}


"note_member(NoteMember)" }o -- || "note(Note)": "note_id"
"note_member(NoteMember)" }o -- || "user(User)": "user_id"

</pre
>
</div>
Expand All @@ -330,6 +395,30 @@ <h2 id="entity-relationship-mermiad-source-code" class="title is-3">

erDiagram

"note(Note)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*varchar name
varchar(100) description
}



"note_transaction(NoteTransaction)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*uuid note_id FK
*varchar(100) description
*numeric total
*numeric pre_balance
*numeric post_balance
}


"note_transaction(NoteTransaction)" }o -- || "note(Note)": "note_id"

"user(User)" {
*uuid id PK
*timestamp created_at
Expand Down Expand Up @@ -361,19 +450,22 @@ <h2 id="entity-relationship-mermiad-source-code" class="title is-3">

"account(Account)" }o -- || "user(User)": "user_id"

"account_history(AccountHistory)" {
"note_item(NoteItem)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*uuid transaction_id FK
*uuid account_id FK
*varchar action
*varchar description
*numeric pre_balance
*numeric post_balance
*uuid user_id FK
*varchar(100) name
*numeric amount
*smallint is_over_budget
}


"account_history(AccountHistory)" }o -- || "account(Account)": "account_id"
"note_item(NoteItem)" }o -- || "note_transaction(NoteTransaction)": "transaction_id"
"note_item(NoteItem)" }o -- || "account(Account)": "account_id"
"note_item(NoteItem)" }o -- || "user(User)": "user_id"

"user_session(UserSession)" {
*uuid id PK
Expand All @@ -395,6 +487,44 @@ <h2 id="entity-relationship-mermiad-source-code" class="title is-3">

"user_session(UserSession)" }o -- || "user(User)": "user_id"

"account_history(AccountHistory)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*uuid account_id FK
*varchar action
*varchar description
*numeric pre_balance
*numeric post_balance
}


"account_history(AccountHistory)" }o -- || "account(Account)": "account_id"

"note_account(NoteAccount)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*uuid note_id FK
*uuid account_id FK
}


"note_account(NoteAccount)" }o -- || "note(Note)": "note_id"
"note_account(NoteAccount)" }o -- || "account(Account)": "account_id"

"note_member(NoteMember)" {
*uuid id PK
*timestamp created_at
*timestamp updated_at
*uuid note_id FK
*uuid user_id FK
}


"note_member(NoteMember)" }o -- || "note(Note)": "note_id"
"note_member(NoteMember)" }o -- || "user(User)": "user_id"

</textarea
>
</section>
Expand Down
21 changes: 21 additions & 0 deletions server/src/databases/entities/core/note-account.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import BaseEntity from '@db/entities/base/base';
import { CoreEntity } from '@db/entities/base/core';
import { ForeignColumn } from '@libs/typeorm/column-decorator.typeorm';
import { ManyToOne } from 'typeorm';
import { Note } from '@db/entities/core/note.entity';
import { Account } from '@db/entities/core/account.entity';

@CoreEntity()
export class NoteAccount extends BaseEntity {
@ForeignColumn()
note_id: string;

@ManyToOne(() => Note, { onDelete: 'CASCADE' })
note: Note;

@ForeignColumn()
account_id: string;

@ManyToOne(() => Account, { onDelete: 'SET NULL' })
account: Note;
}
38 changes: 38 additions & 0 deletions server/src/databases/entities/core/note-item.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import BaseEntity from '@db/entities/base/base';
import { CoreEntity } from '@db/entities/base/core';
import { AmountColumn, BooleanColumn, ForeignColumn, StringColumn } from '@libs/typeorm/column-decorator.typeorm';
import { ManyToOne } from 'typeorm';
import { NoteTransaction } from '@db/entities/core/note-transaction.entity';
import { Account } from '@db/entities/core/account.entity';
import { DecimalNumber } from '@libs/helpers/decimal.helper';
import { User } from '@db/entities/core/user.entity';

@CoreEntity()
export class NoteItem extends BaseEntity {
@ForeignColumn()
transaction_id: string;

@ManyToOne(() => NoteTransaction, { onDelete: 'CASCADE' })
transaction: NoteTransaction;

@ForeignColumn()
account_id: string;

@ManyToOne(() => Account, { onDelete: 'SET NULL' })
account: Account;

@ForeignColumn()
user_id: string;

@ManyToOne(() => User, { onDelete: 'SET NULL' })
user: User;

@StringColumn({ nullable: false, length: 100 })
name: string;

@AmountColumn({ nullable: false })
amount: DecimalNumber;

@BooleanColumn({ nullable: false, default: false })
is_over_budget: boolean;
}
21 changes: 21 additions & 0 deletions server/src/databases/entities/core/note-member.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import BaseEntity from '@db/entities/base/base';
import { CoreEntity } from '@db/entities/base/core';
import { ForeignColumn } from '@libs/typeorm/column-decorator.typeorm';
import { ManyToOne } from 'typeorm';
import { Note } from '@db/entities/core/note.entity';
import { User } from '@db/entities/core/user.entity';

@CoreEntity()
export class NoteMember extends BaseEntity {
@ForeignColumn()
note_id: string;

@ManyToOne(() => Note, { onDelete: 'CASCADE' })
note: Note;

@ForeignColumn()
user_id: string;

@ManyToOne(() => User, { onDelete: 'SET NULL' })
user: User;
}
27 changes: 27 additions & 0 deletions server/src/databases/entities/core/note-transaction.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import BaseEntity from '@db/entities/base/base';
import { CoreEntity } from '@db/entities/base/core';
import { AmountColumn, ForeignColumn, StringColumn } from '@libs/typeorm/column-decorator.typeorm';
import { ManyToOne } from 'typeorm';
import { Note } from '@db/entities/core/note.entity';
import { DecimalNumber } from '@libs/helpers/decimal.helper';

@CoreEntity()
export class NoteTransaction extends BaseEntity {
@ForeignColumn()
note_id: string;

@ManyToOne(() => Note, { onDelete: 'CASCADE' })
note: Note;

@StringColumn({ nullable: false, length: 100 })
description: string;

@AmountColumn({ nullable: false })
total: DecimalNumber;

@AmountColumn({ nullable: false })
pre_balance: DecimalNumber;

@AmountColumn({ nullable: false })
post_balance: DecimalNumber;
}
14 changes: 14 additions & 0 deletions server/src/databases/entities/core/note.entity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { CoreEntity } from '@db/entities/base/core';
import BaseEntity from '@db/entities/base/base';
import { StringColumn } from '@libs/typeorm/column-decorator.typeorm';
import { Index } from 'typeorm';

@CoreEntity()
export class Note extends BaseEntity {
@Index()
@StringColumn({ nullable: false })
name: string;

@StringColumn({ nullable: true, length: 100 })
description: string | null;
}
Loading