diff --git a/src/entity/trx_config_banks.ts b/src/entity/trx_config_banks.ts new file mode 100644 index 0000000..90c3970 --- /dev/null +++ b/src/entity/trx_config_banks.ts @@ -0,0 +1,74 @@ +import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, DeleteDateColumn } from "typeorm"; +import { Status } from "../types/status"; +import { TrxConfigBankType } from "../types/trx"; + +@Entity("trx_config_banks", { schema: "trx" }) +export class TrxConfigBank { + @PrimaryGeneratedColumn("uuid") + id: string; + + @Column({ + nullable: true, + unique: true, + length: 256, + }) + code: string; + + @Column({ + nullable: true, + length: 256, + }) + name: string; + + @Column({ + nullable: false, + default: "indonesia", + length: 256, + }) + type: TrxConfigBankType; + + @Column({ + nullable: true, + length: 256, + }) + fullname: string; + + @Column({ + nullable: true, + length: 256, + }) + formerly: string; + + @Column({ + nullable: true, + length: 4096, + }) + logo: string; + + @Column({ + nullable: true, + 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/entity/trx_transaction_recepients.ts b/src/entity/trx_recepient_domestic.ts similarity index 69% rename from src/entity/trx_transaction_recepients.ts rename to src/entity/trx_recepient_domestic.ts index 7ea88f8..0c8c576 100644 --- a/src/entity/trx_transaction_recepients.ts +++ b/src/entity/trx_recepient_domestic.ts @@ -1,19 +1,16 @@ import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; -import { TrxCompany } from "./trx_companies"; import { Status } from "../types/status"; -import { TrxCif } from "./trx_cifs"; import { TrxConfigNationality } from "./trx_config_nationalities"; -import { TrxTransaction } from "./trx_transactions"; -import { TrxConfigSourceIncome } from "./trx_config_source_incomes"; -import { TrxTransactionType, TrxTransactionCorrespondentFees } from "./../types/trx"; +import { TrxTransactionDomestic } from "./trx_transaction_domestic"; +import { TrxConfigBank } from "./trx_config_banks"; -@Entity("trx_transaction_recepients", { schema: "trx" }) -export class TrxTransactionRecepient { +@Entity("trx_recepient_domestics", { schema: "trx" }) +export class TrxRecepientDomestic { @PrimaryGeneratedColumn("uuid") id: string; - @OneToOne(() => TrxTransaction, (transaction) => transaction.recepient, { onDelete: "CASCADE" }) - transaction: TrxTransaction; + @OneToOne(() => TrxTransactionDomestic, (transaction_domestic) => transaction_domestic.recepient_domestic, { onDelete: "CASCADE" }) + transaction_domestic: TrxTransactionDomestic; @Column({ nullable: false, @@ -27,11 +24,9 @@ export class TrxTransactionRecepient { }) phone: string; - @Column({ - nullable: false, - length: 256, - }) - bank: string; + @ManyToOne(() => TrxConfigBank, { onDelete: "NO ACTION", nullable: false }) + @JoinColumn() + recepient_bank: TrxConfigBank; @Column({ nullable: false, @@ -39,6 +34,13 @@ export class TrxTransactionRecepient { }) account_number: string; + @Column({ + nullable: false, + length: 256, + unique: true, + }) + iban: string; + @Column({ nullable: true, length: 4096, diff --git a/src/entity/trx_recepient_remittance.ts b/src/entity/trx_recepient_remittance.ts new file mode 100644 index 0000000..791e1e2 --- /dev/null +++ b/src/entity/trx_recepient_remittance.ts @@ -0,0 +1,80 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { Status } from "../types/status"; +import { TrxConfigNationality } from "./trx_config_nationalities"; +import { TrxTransactionRemittance } from "./trx_transaction_remittance"; +import { TrxConfigBank } from "./trx_config_banks"; + +@Entity("trx_recepient_remittances", { schema: "trx" }) +export class TrxRecepientRemittance { + @PrimaryGeneratedColumn("uuid") + id: string; + + @OneToOne(() => TrxTransactionRemittance, (transaction_remittance) => transaction_remittance.recepient_remittance, { onDelete: "CASCADE" }) + transaction_remittance: TrxTransactionRemittance; + + @Column({ + nullable: false, + length: 256, + }) + name: string; + + @Column({ + nullable: false, + length: 256, + unique: true, + }) + iban: string; + + @Column({ + nullable: false, + length: 256, + }) + phone: string; + + @ManyToOne(() => TrxConfigBank, { onDelete: "NO ACTION", nullable: false }) + @JoinColumn() + recepient_bank: TrxConfigBank; + + @Column({ + nullable: false, + length: 256, + }) + account_number: string; + + @Column({ + nullable: true, + length: 4096, + }) + address: string; + + @ManyToOne(() => TrxConfigNationality, { onDelete: "NO ACTION", nullable: true }) + @JoinColumn() + nationality: TrxConfigNationality; + + @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/entity/trx_transaction_senders.ts b/src/entity/trx_sender_domestic.ts similarity index 72% rename from src/entity/trx_transaction_senders.ts rename to src/entity/trx_sender_domestic.ts index 5f3433f..66e09b4 100644 --- a/src/entity/trx_transaction_senders.ts +++ b/src/entity/trx_sender_domestic.ts @@ -2,15 +2,16 @@ import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToO import { Status } from "../types/status"; import { TrxConfigNationality } from "./trx_config_nationalities"; import { TrxCompanyAccount } from "./trx_company_accounts"; -import { TrxTransaction } from "./trx_transactions"; +import { TrxTransactionDomestic } from "./trx_transaction_domestic"; +import { TrxConfigBank } from "./trx_config_banks"; -@Entity("trx_transaction_senders", { schema: "trx" }) -export class TrxTransactionSender { +@Entity("trx_sender_domestics", { schema: "trx" }) +export class TrxSenderDomestic { @PrimaryGeneratedColumn("uuid") id: string; - @OneToOne(() => TrxTransaction, (transaction) => transaction.sender, { onDelete: "CASCADE" }) - transaction: TrxTransaction; + @OneToOne(() => TrxTransactionDomestic, (transaction) => transaction.sender_domestic, { onDelete: "CASCADE" }) + transaction_domestic: TrxTransactionDomestic; @Column({ nullable: false, @@ -24,12 +25,6 @@ export class TrxTransactionSender { }) phone: string; - @Column({ - nullable: false, - length: 256, - }) - bank: string; - @Column({ nullable: true, length: 4096, @@ -44,6 +39,10 @@ export class TrxTransactionSender { @JoinColumn() company_account: TrxCompanyAccount; + @ManyToOne(() => TrxConfigBank, { onDelete: "NO ACTION", nullable: false }) + @JoinColumn() + sender_bank: TrxConfigBank; + @Column({ nullable: false, length: 64, diff --git a/src/entity/trx_sender_remittance.ts b/src/entity/trx_sender_remittance.ts new file mode 100644 index 0000000..c518366 --- /dev/null +++ b/src/entity/trx_sender_remittance.ts @@ -0,0 +1,72 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { Status } from "../types/status"; +import { TrxConfigNationality } from "./trx_config_nationalities"; +import { TrxCompanyAccount } from "./trx_company_accounts"; +import { TrxTransactionRemittance } from "./trx_transaction_remittance"; +import { TrxConfigBank } from "./trx_config_banks"; + +@Entity("trx_sender_remittances", { schema: "trx" }) +export class TrxSenderRemittance { + @PrimaryGeneratedColumn("uuid") + id: string; + + @OneToOne(() => TrxTransactionRemittance, (transaction) => transaction.sender_remittance, { onDelete: "CASCADE" }) + transaction_remittance: TrxTransactionRemittance; + + @Column({ + nullable: false, + length: 256, + }) + name: string; + + @Column({ + nullable: false, + length: 256, + }) + phone: string; + + @Column({ + nullable: true, + length: 4096, + }) + address: string; + + @ManyToOne(() => TrxConfigNationality, { onDelete: "NO ACTION", nullable: true }) + @JoinColumn() + nationality: TrxConfigNationality; + + @ManyToOne(() => TrxCompanyAccount, { onDelete: "NO ACTION", nullable: true }) + @JoinColumn() + company_account: TrxCompanyAccount; + + @ManyToOne(() => TrxConfigBank, { onDelete: "NO ACTION", nullable: false }) + @JoinColumn() + sender_bank: TrxConfigBank; + + @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/entity/trx_transaction_domestic.ts b/src/entity/trx_transaction_domestic.ts new file mode 100644 index 0000000..9429285 --- /dev/null +++ b/src/entity/trx_transaction_domestic.ts @@ -0,0 +1,82 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { TrxCompany } from "./trx_companies"; +import { TrxConfigSourceIncome } from "./trx_config_source_incomes"; +import { TrxSenderDomestic } from "./trx_sender_domestic"; +import { TrxRecepientDomestic } from "./trx_recepient_domestic"; +import { TrxTransaction } from "./trx_transactions"; +import { TrxTransactionTypeStatus, TrxTransactionCorrespondentFees, TrxTransactionStatus } from "./../types/trx"; + +@Entity("trx_transaction_domestics", { schema: "trx" }) +export class TrxTransactionDomestic { + @PrimaryGeneratedColumn("uuid") + id: string; + + @Column({ + nullable: false, + length: 256, + }) + type_transaction: TrxTransactionTypeStatus; + + @Column({ + nullable: true, + length: 256, + }) + correspondent_fees: string; + + @Column({ type: "float8" }) + amount_overbooking: number; + + @Column({ type: "float8", nullable: true }) + transfer_amount: number; + + @Column({ type: "float8", nullable: true }) + transfer_total: number; + + @Column({ type: "float8", nullable: true }) + commission: number; + + @Column({ type: "float8", nullable: true }) + cost_of_sender: number; + + @Column({ type: "float8", nullable: true }) + sub_total: number; + + @Column({ type: "float8", nullable: false, default: 0 }) + rate_idr: number; + + @OneToOne(() => TrxTransaction, (transaction) => transaction.transaction_domestic, { onDelete: "CASCADE" }) + transaction: TrxTransaction; + + @ManyToOne(() => TrxConfigSourceIncome, { onDelete: "NO ACTION", nullable: true }) + @JoinColumn() + source_income: TrxConfigSourceIncome; + + @OneToOne(() => TrxSenderDomestic, (sender) => sender.transaction_domestic, { cascade: true }) + @JoinColumn() + sender_domestic: TrxSenderDomestic; + + @OneToOne(() => TrxRecepientDomestic, (recepient) => recepient.transaction_domestic, { cascade: true }) + @JoinColumn() + recepient_domestic: TrxRecepientDomestic; + + @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_transaction_remittance.ts b/src/entity/trx_transaction_remittance.ts new file mode 100644 index 0000000..546577d --- /dev/null +++ b/src/entity/trx_transaction_remittance.ts @@ -0,0 +1,82 @@ +import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; +import { TrxCompany } from "./trx_companies"; +import { TrxConfigSourceIncome } from "./trx_config_source_incomes"; +import { TrxSenderRemittance } from "./trx_sender_remittance"; +import { TrxRecepientRemittance } from "./trx_recepient_remittance"; +import { TrxTransaction } from "./trx_transactions"; +import { TrxTransactionTypeStatus, TrxTransactionCorrespondentFees, TrxTransactionStatus } from "./../types/trx"; + +@Entity("trx_transaction_remittances", { schema: "trx" }) +export class TrxTransactionRemittance { + @PrimaryGeneratedColumn("uuid") + id: string; + + @Column({ + nullable: false, + length: 256, + }) + type_transaction: TrxTransactionTypeStatus; + + @Column({ + nullable: true, + length: 256, + }) + correspondent_fees: string; + + @Column({ type: "float8" }) + amount_overbooking: number; + + @Column({ type: "float8", nullable: true }) + transfer_amount: number; + + @Column({ type: "float8", nullable: true }) + transfer_total: number; + + @Column({ type: "float8", nullable: true }) + commission: number; + + @Column({ type: "float8", nullable: true }) + cost_of_sender: number; + + @Column({ type: "float8", nullable: true }) + sub_total: number; + + @Column({ type: "float8", nullable: false, default: 0 }) + rate_idr: number; + + @OneToOne(() => TrxTransaction, (transaction) => transaction.transaction_remittance, { onDelete: "CASCADE" }) + transaction: TrxTransaction; + + @ManyToOne(() => TrxConfigSourceIncome, { onDelete: "NO ACTION", nullable: true }) + @JoinColumn() + source_income: TrxConfigSourceIncome; + + @OneToOne(() => TrxSenderRemittance, (sender) => sender.transaction_remittance, { cascade: true }) + @JoinColumn() + sender_remittance: TrxSenderRemittance; + + @OneToOne(() => TrxRecepientRemittance, (recepient) => recepient.transaction_remittance, { cascade: true }) + @JoinColumn() + recepient_remittance: TrxRecepientRemittance; + + @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 index 26a262c..2fe5710 100644 --- a/src/entity/trx_transactions.ts +++ b/src/entity/trx_transactions.ts @@ -1,15 +1,26 @@ import { Column, CreateDateColumn, DeleteDateColumn, Entity, JoinColumn, ManyToOne, OneToOne, PrimaryGeneratedColumn, UpdateDateColumn } from "typeorm"; import { TrxCompany } from "./trx_companies"; -import { TrxConfigSourceIncome } from "./trx_config_source_incomes"; -import { TrxTransactionSender } from "./trx_transaction_senders"; -import { TrxTransactionRecepient } from "./trx_transaction_recepients"; -import { TrxTransactionType, TrxTransactionCorrespondentFees, TrxTransactionStatusType } from "./../types/trx"; +import { TrxTransactionDomestic } from "./trx_transaction_domestic"; +import { TrxTransactionTransferStatus, TrxTransactionStatus } from "./../types/trx"; +import { TrxTransactionRemittance } from "./trx_transaction_remittance"; @Entity("trx_transactions", { schema: "trx" }) export class TrxTransaction { @PrimaryGeneratedColumn("uuid") id: string; + @ManyToOne(() => TrxCompany, { onDelete: "NO ACTION", nullable: false }) + @JoinColumn() + company: TrxCompany; + + @OneToOne(() => TrxTransactionDomestic, (transaction_domestic) => transaction_domestic.transaction, { cascade: true }) + @JoinColumn() + transaction_domestic: TrxTransactionDomestic; + + @OneToOne(() => TrxTransactionRemittance, (transaction_remittance) => transaction_remittance.transaction, { cascade: true }) + @JoinColumn() + transaction_remittance: TrxTransactionRemittance; + @Column({ nullable: false, length: 256, @@ -21,34 +32,7 @@ export class TrxTransaction { nullable: false, length: 256, }) - type: TrxTransactionType; - - @Column({ - nullable: true, - length: 256, - }) - correspondent_fees: string; - - @Column({ type: "float8" }) - amount_overbooking: number; - - @Column({ type: "float8", nullable: true }) - transfer_amount: number; - - @Column({ type: "float8", nullable: true }) - transfer_total: number; - - @Column({ type: "float8", nullable: true }) - commission: number; - - @Column({ type: "float8", nullable: true }) - cost_of_sender: number; - - @Column({ type: "float8", nullable: true }) - sub_total: number; - - @Column({ type: "float8", nullable: false, default: 0 }) - rate_idr: number; + type_transfer: TrxTransactionTransferStatus; @Column({ nullable: true, @@ -92,27 +76,14 @@ export class TrxTransaction { }) spv_signatures: String; - @ManyToOne(() => TrxConfigSourceIncome, { onDelete: "NO ACTION", nullable: true }) - @JoinColumn() - source_income: TrxConfigSourceIncome; - - @OneToOne(() => TrxTransactionSender, (sender) => sender.transaction, { cascade: true }) - @JoinColumn() - sender: TrxTransactionSender; - - @OneToOne(() => TrxTransactionRecepient, (recepient) => recepient.transaction, { cascade: true }) - @JoinColumn() - recepient: TrxTransactionRecepient; - - @ManyToOne(() => TrxCompany, { onDelete: "NO ACTION", nullable: false }) - @JoinColumn() - company: TrxCompany; + @Column({ type: "varchar", length: 4096, nullable: true }) + remark: string; @Column({ nullable: false, length: 64, }) - status: TrxTransactionStatusType; + status: TrxTransactionStatus; @Column({ nullable: true }) transaction_at: Date; diff --git a/src/schema/trx.ts b/src/schema/trx.ts index 2544247..6ab37b1 100644 --- a/src/schema/trx.ts +++ b/src/schema/trx.ts @@ -13,6 +13,7 @@ export * from "../entity/trx_config_channels"; export * from "../entity/trx_config_educations"; export * from "../entity/trx_config_identity_types"; export * from "../entity/trx_config_munisipos"; +export * from "../entity/trx_config_banks"; export * from "../entity/trx_config_nationalities"; export * from "../entity/trx_config_levels"; export * from "../entity/trx_config_occupations"; @@ -27,7 +28,11 @@ export * from "../entity/trx_region_administrativus"; export * from "../entity/trx_region_aldeias"; export * from "../entity/trx_region_sucos"; export * from "../entity/trx_registration"; -export * from "../entity/trx_transaction_senders"; -export * from "../entity/trx_transaction_recepients"; +export * from "../entity/trx_sender_remittance"; +export * from "../entity/trx_recepient_remittance"; +export * from "../entity/trx_sender_domestic"; +export * from "../entity/trx_recepient_domestic"; +export * from "../entity/trx_transaction_domestic"; +export * from "../entity/trx_transaction_remittance"; export * from "../entity/trx_transactions"; export * from "../types/trx"; diff --git a/src/types/trx.ts b/src/types/trx.ts index 478cd11..62f59d3 100644 --- a/src/types/trx.ts +++ b/src/types/trx.ts @@ -1,4 +1,4 @@ -export enum TrxTransactionStatusType { +export enum TrxTransactionStatus { "verify" = "verify", "open" = "open", "progress" = "progress", @@ -7,15 +7,26 @@ export enum TrxTransactionStatusType { "approved" = "approved", } -export enum TrxTransactionType { +export enum TrxTransactionTypeStatus { "deposit" = "deposit", "transfer" = "transfer", "clearing" = "clearing", "rtgs" = "rtgs", } +export enum TrxTransactionTransferStatus { + "remittance" = "remittance", + "swift" = "swift", + "domestic" = "domestic", +} + export enum TrxTransactionCorrespondentFees { "sender" = "sender", "recepient" = "recepient", "other" = "other", } + +export enum TrxConfigBankType { + "indonesia" = "indonesia", + "domestic" = "domestic", +}