From 94df863f979a11c1ef035c2848adbe70805439ee Mon Sep 17 00:00:00 2001 From: fro1991 Date: Mon, 20 Oct 2025 23:51:46 +0700 Subject: [PATCH] update --- src/entity/trx_currency_rates.ts | 14 +++++- src/entity/trx_receivers.ts | 69 +++++++++++++++++++++++++++ src/entity/trx_transactions.ts | 82 ++++++++++++++++++++++++++++++++ src/schema/trx.ts | 1 + src/types/trx.ts | 7 +++ 5 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 src/entity/trx_receivers.ts create mode 100644 src/entity/trx_transactions.ts diff --git a/src/entity/trx_currency_rates.ts b/src/entity/trx_currency_rates.ts index f0e228b..1983532 100644 --- a/src/entity/trx_currency_rates.ts +++ b/src/entity/trx_currency_rates.ts @@ -1,11 +1,17 @@ import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; import { TrxCurrency } from "./trx_currencies"; +import { TrxCurrencyRateType } from "../types/trx"; @Entity("trx_currency_rates", { schema: "trx" }) -export class TrxCurrencyRates { +export class TrxCurrencyRate { @PrimaryGeneratedColumn("uuid") id: string; + @Column({ + length: 256, + }) + type: TrxCurrencyRateType; + @ManyToOne(() => TrxCurrency, { onDelete: "NO ACTION" }) @JoinColumn() base: TrxCurrency; @@ -19,6 +25,12 @@ export class TrxCurrencyRates { }) rate: number; + @Column({ + nullable: true, + length: 256, + }) + deal_code: string; + @Column() @CreateDateColumn() created_at: Date; diff --git a/src/entity/trx_receivers.ts b/src/entity/trx_receivers.ts new file mode 100644 index 0000000..6d7b5c4 --- /dev/null +++ b/src/entity/trx_receivers.ts @@ -0,0 +1,69 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { Status } from "../types/status"; +import { TrxCustomerType } from "../types/trx"; +import { TrxBank } from "./trx_banks"; +import { TrxBankSwift } from "./trx_bank_swifts"; + +@Entity("trx_receivers", { schema: "trx" }) +export class TrxReceiver { + @PrimaryGeneratedColumn("uuid") + id: string; + + @Column({ + length: 256, + }) + name: string; + + @Column({ + nullable: true, + length: 4096, + }) + address: string; + + @Column({ + nullable: true, + length: 256, + }) + phone: string; + + @Column({ + nullable: true, + length: 256, + }) + email: string; + + @ManyToOne(() => TrxBank, { onDelete: "NO ACTION" }) + @JoinColumn() + bank: TrxBank; + + @ManyToOne(() => TrxBankSwift, { onDelete: "NO ACTION", nullable: true }) + @JoinColumn() + bank_swift: TrxBankSwift; + + @Column({ + nullable: true, + length: 256, + }) + account_number: string; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true, length: 256 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true, length: 256 }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ nullable: true, length: 256 }) + deleted_by: string; +} diff --git a/src/entity/trx_transactions.ts b/src/entity/trx_transactions.ts new file mode 100644 index 0000000..0d93db4 --- /dev/null +++ b/src/entity/trx_transactions.ts @@ -0,0 +1,82 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { TrxCurrency } from "./trx_currencies"; +import { TrxCustomer } from "./trx_customers"; +import { TrxCustomerAccount } from "./trx_customer_accounts"; +import { TrxReceiver } from "./trx_receivers"; +import { TrxCurrencyRate } from "./trx_currency_rates"; +import { TrxCustomerCost } from "./trx_customer_costs"; + +@Entity("trx_transactions", { schema: "trx" }) +export class TrxTransactions { + @PrimaryGeneratedColumn("uuid") + id: string; + + @Column({ + length: 256, + }) + code: string; + + @ManyToOne(() => TrxCustomer, { onDelete: "NO ACTION" }) + @JoinColumn() + customer: TrxCustomer; + + @ManyToOne(() => TrxCustomerAccount, { onDelete: "NO ACTION" }) + @JoinColumn() + customer_account: TrxCustomerAccount; + + @ManyToOne(() => TrxReceiver, { onDelete: "NO ACTION" }) + @JoinColumn() + receiver: TrxReceiver; + + @ManyToOne(() => TrxCurrency, { onDelete: "NO ACTION" }) + @JoinColumn() + base: TrxCurrency; + + @Column({ + type: "float8", + }) + base_amount: number; + + @ManyToOne(() => TrxCurrency, { onDelete: "NO ACTION" }) + @JoinColumn() + target: TrxCurrency; + + @ManyToOne(() => TrxCurrencyRate, { onDelete: "NO ACTION" }) + @JoinColumn() + target_rate: TrxCurrency; + + @Column({ + type: "float8", + }) + target_amount: number; + + @ManyToOne(() => TrxCustomerCost, { onDelete: "NO ACTION" }) + @JoinColumn() + customer_cost: TrxCustomerCost; + + @Column({ + type: "float8", + }) + cost_amount: number; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true, length: 256 }) + created_by: string; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true, length: 256 }) + updated_by: string; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + @Column({ nullable: true, length: 256 }) + deleted_by: string; +} diff --git a/src/schema/trx.ts b/src/schema/trx.ts index 610b892..e275be9 100644 --- a/src/schema/trx.ts +++ b/src/schema/trx.ts @@ -10,4 +10,5 @@ export * from "../entity/trx_currencies"; export * from "../entity/trx_currency_rates"; export * from "../entity/trx_banks"; export * from "../entity/trx_bank_swifts"; +export * from "../entity/trx_receivers"; export * from "../types/trx"; diff --git a/src/types/trx.ts b/src/types/trx.ts index 5d9600e..7aedc37 100644 --- a/src/types/trx.ts +++ b/src/types/trx.ts @@ -38,6 +38,13 @@ export enum TrxCostType { "percentage" = "percentage", } +export enum TrxCurrencyRateType { + "reguler" = "reguler", + "deal" = "deal", +} + +//// + export enum TrxTransactionStatus { "verify" = "verify", "open" = "open",