diff --git a/src/entity/trx_customer_accounts.ts b/src/entity/trx_customer_accounts.ts new file mode 100644 index 0000000..8ad1556 --- /dev/null +++ b/src/entity/trx_customer_accounts.ts @@ -0,0 +1,67 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, JoinColumn, ManyToOne, JoinTable } from "typeorm"; + +import { Status } from "../types/status"; +import { TrxPartner } from "./trx_partners"; +import { TrxCif } from "./trx_cifs"; +import { TrxCustomer } from "./trx_customers"; +import { Branch } from "./branchs"; + +@Entity("trx_customer_accounts", { schema: "trx" }) +export class TrxCustomerAccount { + @PrimaryGeneratedColumn("uuid") + id: string; + + @ManyToOne(() => TrxCustomer, { onDelete: "RESTRICT" }) + @JoinColumn() + customer: TrxCustomer; + + @ManyToOne(() => Branch, { onDelete: "NO ACTION" }) + @JoinColumn() + branch: Branch; + + @Column({ + nullable: false, + length: 256, + }) + cif_number: string; + + @Column({ + nullable: false, + length: 256, + }) + account_number: string; + + @Column({ + nullable: false, + length: 256, + }) + name: string; + + @Column({ + nullable: true, + length: 4096, + }) + address: string; + + @Column({ + type: "float8", + }) + balance: number; + + @Column({ + nullable: false, + }) + balance_at: Date; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} diff --git a/src/entity/trx_customers.ts b/src/entity/trx_customers.ts new file mode 100644 index 0000000..b30a09a --- /dev/null +++ b/src/entity/trx_customers.ts @@ -0,0 +1,88 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { Status } from "../types/status"; +import { TrxCustomerType } from "../types/trx"; + +@Entity("trx_customers", { schema: "trx" }) +export class TrxCustomer { + @PrimaryGeneratedColumn("uuid") + id: string; + + @Column({ + nullable: false, + length: 4096, + }) + type: TrxCustomerType; + + @Column({ + nullable: false, + unique: true, + length: 256, + }) + code: string; + + @Column({ + nullable: false, + unique: true, + length: 256, + }) + name: string; + + @Column({ + nullable: false, + length: 4096, + }) + address: string; + + @Column({ + nullable: false, + length: 256, + }) + pic_name: string; + + @Column({ + nullable: false, + unique: true, + length: 256, + }) + pic_phone: string; + + @Column({ + nullable: false, + unique: true, + length: 256, + }) + pic_email: string; + + @Column({ + nullable: false, + length: 256, + }) + desclimer: string; + + @Column({ + nullable: false, + length: 64, + }) + status: Status; + + @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 7d1d2e0..9832459 100644 --- a/src/schema/trx.ts +++ b/src/schema/trx.ts @@ -42,4 +42,7 @@ export * from "../entity/trx_partner_accounts"; export * from "../entity/trx_partner_user_activities"; export * from "../entity/trx_partner_user_refresh_tokens"; export * from "../entity/trx_partner_users"; + +export * from "../entity/trx_customers"; +export * from "../entity/trx_customer_accounts"; export * from "../types/trx"; diff --git a/src/types/trx.ts b/src/types/trx.ts index 7d98131..507b76d 100644 --- a/src/types/trx.ts +++ b/src/types/trx.ts @@ -1,3 +1,8 @@ +export enum TrxCustomerType { + "personal" = "personal", + "business" = "business", +} + export enum TrxTransactionStatus { "verify" = "verify", "open" = "open",