This commit is contained in:
fro1991
2025-10-20 23:51:46 +07:00
parent 63ff039e77
commit 94df863f97
5 changed files with 172 additions and 1 deletions

View File

@ -1,11 +1,17 @@
import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm";
import { TrxCurrency } from "./trx_currencies"; import { TrxCurrency } from "./trx_currencies";
import { TrxCurrencyRateType } from "../types/trx";
@Entity("trx_currency_rates", { schema: "trx" }) @Entity("trx_currency_rates", { schema: "trx" })
export class TrxCurrencyRates { export class TrxCurrencyRate {
@PrimaryGeneratedColumn("uuid") @PrimaryGeneratedColumn("uuid")
id: string; id: string;
@Column({
length: 256,
})
type: TrxCurrencyRateType;
@ManyToOne(() => TrxCurrency, { onDelete: "NO ACTION" }) @ManyToOne(() => TrxCurrency, { onDelete: "NO ACTION" })
@JoinColumn() @JoinColumn()
base: TrxCurrency; base: TrxCurrency;
@ -19,6 +25,12 @@ export class TrxCurrencyRates {
}) })
rate: number; rate: number;
@Column({
nullable: true,
length: 256,
})
deal_code: string;
@Column() @Column()
@CreateDateColumn() @CreateDateColumn()
created_at: Date; created_at: Date;

View File

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

View File

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

View File

@ -10,4 +10,5 @@ export * from "../entity/trx_currencies";
export * from "../entity/trx_currency_rates"; export * from "../entity/trx_currency_rates";
export * from "../entity/trx_banks"; export * from "../entity/trx_banks";
export * from "../entity/trx_bank_swifts"; export * from "../entity/trx_bank_swifts";
export * from "../entity/trx_receivers";
export * from "../types/trx"; export * from "../types/trx";

View File

@ -38,6 +38,13 @@ export enum TrxCostType {
"percentage" = "percentage", "percentage" = "percentage",
} }
export enum TrxCurrencyRateType {
"reguler" = "reguler",
"deal" = "deal",
}
////
export enum TrxTransactionStatus { export enum TrxTransactionStatus {
"verify" = "verify", "verify" = "verify",
"open" = "open", "open" = "open",