From 689132c19af4f8f8ec2f76a24a85d5e15d414112 Mon Sep 17 00:00:00 2001 From: fro1991 Date: Fri, 7 Feb 2025 01:01:02 +0700 Subject: [PATCH] upate briva --- src/entity/briva_accounts.ts | 68 ++++++++++++++++ src/entity/briva_companies.ts | 73 ++++++++++++++++++ .../briva_company_user_refresh_token.ts | 64 +++++++++++++++ src/entity/briva_company_users.ts | 77 +++++++++++++++++++ src/entity/briva_transactions.ts | 67 ++++++++++++++++ src/index.ts | 10 +++ 6 files changed, 359 insertions(+) create mode 100644 src/entity/briva_accounts.ts create mode 100644 src/entity/briva_companies.ts create mode 100644 src/entity/briva_company_user_refresh_token.ts create mode 100644 src/entity/briva_company_users.ts create mode 100644 src/entity/briva_transactions.ts diff --git a/src/entity/briva_accounts.ts b/src/entity/briva_accounts.ts new file mode 100644 index 0000000..53f95fd --- /dev/null +++ b/src/entity/briva_accounts.ts @@ -0,0 +1,68 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, JoinColumn, ManyToOne, JoinTable } from 'typeorm'; + +import { Status } from '../types/status'; +import { BrivaCompany } from './briva_companies'; + +@Entity('briva_accounts', { schema: 'brivas' }) +export class BrivaAccount { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + unique: true, + length: 256 + }) + code: string; + + @Column({ + nullable: true, + length: 256 + }) + name: string; + + @Column({ + nullable: false, + length: 256 + }) + account_number: string; + + @Column({ + nullable: false, + length: 256 + }) + account_holder: string; + + @ManyToOne(() => BrivaCompany, { onDelete: 'CASCADE', nullable: true }) + @JoinTable() + company: BrivaCompany + + @Column({ + nullable: true + }) + last_trans_at: Date; + + @Column({ + nullable: false, + length: 256 + }) + last_trans_ref_number: string; + + @Column({ + nullable: false, + type: 'float8' + }) + last_trans_amount: number; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} \ No newline at end of file diff --git a/src/entity/briva_companies.ts b/src/entity/briva_companies.ts new file mode 100644 index 0000000..fff232e --- /dev/null +++ b/src/entity/briva_companies.ts @@ -0,0 +1,73 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, JoinColumn, ManyToOne } from 'typeorm'; + +import { Status } from '../types/status'; + +@Entity('briva_companies', { schema: 'brivas' }) +export class BrivaCompany { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + unique: true, + length: 256 + }) + name: string; + + @Column({ + nullable: false, + unique: true, + length: 256 + }) + code: string; + + @Column({ + nullable: true, + length: 4096 + }) + description: string; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @Column({ + nullable: true, + length: 256 + }) + type: 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() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} \ No newline at end of file diff --git a/src/entity/briva_company_user_refresh_token.ts b/src/entity/briva_company_user_refresh_token.ts new file mode 100644 index 0000000..deb1a47 --- /dev/null +++ b/src/entity/briva_company_user_refresh_token.ts @@ -0,0 +1,64 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index } from 'typeorm'; + +@Entity('briva_company_user_refresh_tokens', { schema: 'brivas' }) +export class BrivaCompanyUserRefreshToken { + @PrimaryGeneratedColumn('uuid') + refresh_token: string; + + @Index() + @Column({ + type: 'uuid' + }) + id_user: string; + + @Column({ + nullable: false, + length: 4096, + }) + user_agent: string; + + @Column({ + nullable: true, + length: 128 + }) + os: string; + + @Column({ + nullable: true, + length: 256 + }) + device: string; + + @Column({ + nullable: true, + length: 64 + }) + platform: string; + + @Column({ + nullable: true, + length: 64 + }) + browser: string; + + @Column({ + nullable: true, + length: 32 + }) + remote_addr: string; + + @Column('timestamp') + expired_at: Date; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} \ No newline at end of file diff --git a/src/entity/briva_company_users.ts b/src/entity/briva_company_users.ts new file mode 100644 index 0000000..bd12703 --- /dev/null +++ b/src/entity/briva_company_users.ts @@ -0,0 +1,77 @@ +import bcrypt from 'bcryptjs'; +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, OneToOne, JoinColumn, ManyToOne, OneToMany, ManyToMany, JoinTable } from 'typeorm'; + +import { Status } from '../types/status'; +import { BrivaCompany } from './briva_companies'; + +@Entity('briva_company_users', { schema: 'brivas' }) +export class BrivaCompanyUser { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: false, + unique: false, + length: 64 + }) + email: string; + + @Column({ + nullable: false, + length: 64, + select: false + }) + password: string; + + @Column({ + nullable: false, + unique: false, + length: 64 + }) + username: string; + + @Column({ + nullable: true, + length: 64, + unique: false, + }) + name: string; + + @ManyToOne(() => BrivaCompany, { onDelete: 'CASCADE' }) + @JoinTable() + company: BrivaCompany + + @Index() + @Column({ + nullable: true, + type: 'uuid', + select: false + }) + reset_token: string; + + @Column({ + nullable: false, + length: 64 + }) + status: Status; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; + + hashPassword() { + this.password = bcrypt.hashSync(this.password, 8); + } + + checkIfPasswordMatch(unencryptedPassword: string) { + return bcrypt.compareSync(unencryptedPassword, this.password); + } +} \ No newline at end of file diff --git a/src/entity/briva_transactions.ts b/src/entity/briva_transactions.ts new file mode 100644 index 0000000..64b4d5b --- /dev/null +++ b/src/entity/briva_transactions.ts @@ -0,0 +1,67 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn, Index, JoinColumn, ManyToOne, JoinTable } from 'typeorm'; + +import { Status } from '../types/status'; +import { BrivaCompany } from './briva_companies'; +import { BrivaAccount } from './briva_accounts'; +import { Branch } from './branchs'; + +@Entity('briva_transactions', { schema: 'brivas' }) +export class BrivaTransaction { + @PrimaryGeneratedColumn('uuid') + id: string; + + @Column({ + nullable: true, + }) + position_datetime: Date; + + @Column({ + nullable: false, + length: 64 + }) + reference_number: string; + + @ManyToOne(() => Branch, { onDelete: "RESTRICT" }) + @JoinColumn() + branch: Branch + + @Column({ + nullable: true, + length: 10 + }) + teller_code: string; + + @ManyToOne(() => BrivaAccount, { onDelete: 'CASCADE' }) + @JoinTable() + account: BrivaAccount + + @Column({ + type: 'float8', + nullable: false, + }) + amount: number; + + @Column({ + length: 3, + nullable: true, + }) + currency: string; + + @Column({ + length: 64, + nullable: true, + }) + supervisor: string; + + @Column() + @CreateDateColumn() + created_at: Date; + + @Column({ nullable: true }) + @UpdateDateColumn() + updated_at: Date; + + @Column({ nullable: true }) + @DeleteDateColumn() + deleted_at: Date; +} \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 1414ee3..a81685a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -72,6 +72,11 @@ import { FinanceMemo } from "./entity/finance_memo"; import { TellerMutation } from "./entity/teller_mutation"; import { LogHikvision } from "./entity/log_hikvision"; import { CreditConfigs } from "./entity/credit_config"; +import { BrivaCompany } from "./entity/briva_companies" +import { BrivaCompanyUser } from "./entity/briva_company_users" +import { BrivaCompanyUserRefreshToken } from "./entity/briva_company_user_refresh_token" +import { BrivaAccount } from './entity/briva_accounts' +import { BrivaTransaction } from './entity/briva_transactions' export { User, // @@ -155,4 +160,9 @@ export { TellerMutation, LogHikvision, CreditConfigs, + BrivaCompany, + BrivaCompanyUser, + BrivaCompanyUserRefreshToken, + BrivaAccount, + BrivaTransaction };