mirror of
https://github.com/HamzaSha1/zod-backend.git
synced 2025-11-26 16:44:54 +00:00
feat: add transaction, card , and account entities
This commit is contained in:
62
src/card/entities/transaction.entity.ts
Normal file
62
src/card/entities/transaction.entity.ts
Normal file
@ -0,0 +1,62 @@
|
||||
import { Column, CreateDateColumn, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
|
||||
import { TransactionType } from '../enums';
|
||||
import { Account } from './account.entity';
|
||||
import { Card } from './card.entity';
|
||||
|
||||
@Entity('transactions')
|
||||
export class Transaction {
|
||||
@PrimaryGeneratedColumn('uuid')
|
||||
id!: string;
|
||||
|
||||
@Column({ name: 'card_reference', nullable: true, type: 'varchar' })
|
||||
cardReference!: string;
|
||||
|
||||
@Column({ name: 'transaction_type', type: 'varchar', default: TransactionType.EXTERNAL })
|
||||
transactionType!: TransactionType;
|
||||
|
||||
@Column({ name: 'account_reference', nullable: true, type: 'varchar' })
|
||||
accountReference!: string;
|
||||
|
||||
@Column({ name: 'transaction_id', unique: true, nullable: true, type: 'varchar' })
|
||||
transactionId!: string;
|
||||
|
||||
@Column({ name: 'card_masked_number', nullable: true, type: 'varchar' })
|
||||
cardMaskedNumber!: string;
|
||||
|
||||
@Column({ type: 'timestamp with time zone', name: 'transaction_date', nullable: true })
|
||||
transactionDate!: Date;
|
||||
|
||||
@Column({ name: 'rrn', nullable: true, type: 'varchar' })
|
||||
rrn!: string;
|
||||
|
||||
@Column({ type: 'decimal', precision: 12, scale: 2, name: 'transaction_amount' })
|
||||
transactionAmount!: number;
|
||||
|
||||
@Column({ type: 'varchar', name: 'transaction_currency' })
|
||||
transactionCurrency!: string;
|
||||
|
||||
@Column({ type: 'decimal', name: 'billing_amount', precision: 12, scale: 2 })
|
||||
billingAmount!: number;
|
||||
|
||||
@Column({ type: 'decimal', name: 'settlement_amount', precision: 12, scale: 2 })
|
||||
settlementAmount!: number;
|
||||
|
||||
@Column({ type: 'decimal', name: 'fees', precision: 12, scale: 2 })
|
||||
fees!: number;
|
||||
|
||||
@Column({ name: 'card_id', type: 'uuid', nullable: true })
|
||||
cardId!: string;
|
||||
|
||||
@Column({ name: 'account_id', type: 'uuid', nullable: true })
|
||||
accountId!: string;
|
||||
|
||||
@ManyToOne(() => Card, (card) => card.transactions, { onDelete: 'CASCADE', nullable: true })
|
||||
@JoinColumn({ name: 'card_id' })
|
||||
card!: Card;
|
||||
|
||||
@ManyToOne(() => Account, (account) => account.transactions, { onDelete: 'CASCADE', nullable: true })
|
||||
@JoinColumn({ name: 'account_id' })
|
||||
account!: Account;
|
||||
@CreateDateColumn({ name: 'created_at', type: 'timestamp with time zone' })
|
||||
createdAt!: Date;
|
||||
}
|
||||
Reference in New Issue
Block a user