| 1 | // This file contains type definitions for the data.
|
|---|
| 2 | // It describes the shape of the data, and what data type each property should accept.
|
|---|
| 3 |
|
|---|
| 4 | export type User = {
|
|---|
| 5 | user_id: number;
|
|---|
| 6 | user_name: string;
|
|---|
| 7 | email: string;
|
|---|
| 8 | password: string; // hashed
|
|---|
| 9 | };
|
|---|
| 10 |
|
|---|
| 11 | export type TransactionAccount = {
|
|---|
| 12 | transaction_account_id: number;
|
|---|
| 13 | account_name: string | null;
|
|---|
| 14 | balance: string; // DECIMAL comes back as string with `postgres` driver
|
|---|
| 15 | user_id: number | null;
|
|---|
| 16 | };
|
|---|
| 17 |
|
|---|
| 18 | export type Transaction = {
|
|---|
| 19 | transaction_id: number;
|
|---|
| 20 | transaction_name: string | null;
|
|---|
| 21 | amount: string; // DECIMAL -> string
|
|---|
| 22 | net_amount: string | null; // DECIMAL -> string
|
|---|
| 23 | date: string; // TIMESTAMPTZ -> ISO string
|
|---|
| 24 | };
|
|---|
| 25 |
|
|---|
| 26 | export type Tag = {
|
|---|
| 27 | tag_id: number;
|
|---|
| 28 | tag_name: string;
|
|---|
| 29 | };
|
|---|
| 30 |
|
|---|
| 31 | export type TagAssignedToTransaction = {
|
|---|
| 32 | tag_assigned_to_transaction_id: number;
|
|---|
| 33 | transaction_id: number;
|
|---|
| 34 | tag_id: number;
|
|---|
| 35 | };
|
|---|
| 36 |
|
|---|
| 37 | export type TransactionBreakdown = {
|
|---|
| 38 | transaction_breakdown_id: number;
|
|---|
| 39 | transaction_id: number | null;
|
|---|
| 40 | transaction_account_id: number | null;
|
|---|
| 41 | spent_amount: string | null; // DECIMAL -> string
|
|---|
| 42 | earned_amount: string | null; // DECIMAL -> string
|
|---|
| 43 | };
|
|---|
| 44 |
|
|---|
| 45 | /**
|
|---|
| 46 | * Useful “joined/view” shapes (not tables).
|
|---|
| 47 | * These make UI and API code nicer.
|
|---|
| 48 | */
|
|---|
| 49 |
|
|---|
| 50 | export type TransactionWithTags = Transaction & {
|
|---|
| 51 | tags: Tag[];
|
|---|
| 52 | };
|
|---|
| 53 |
|
|---|
| 54 | export type TransactionAccountWithBreakdowns = TransactionAccount & {
|
|---|
| 55 | breakdowns: TransactionBreakdown[];
|
|---|
| 56 | };
|
|---|
| 57 |
|
|---|
| 58 | export type TransactionBreakdownResolved = TransactionBreakdown & {
|
|---|
| 59 | transaction?: Transaction;
|
|---|
| 60 | transaction_account?: TransactionAccount;
|
|---|
| 61 | };
|
|---|