import { Column, Entity, JoinColumn, ManyToOne, PrimaryGeneratedColumn } from 'typeorm';
import { BankTransactionEntity } from './bank-transaction.entity';

@Entity('payday_rewards')
export class PaydayRewardEntity {
    @PrimaryGeneratedColumn() id: number;
    @Column({ type: 'varchar', length: 128 }) source_name: string;
    @Column() source_bank_account_id: number;
    @Column({ type: 'varchar', length: 128 }) target_name: string;
    @Column() target_bank_account_id: number;
    @Column({ type: 'int', nullable: true }) target_character_id: number | null;
    @Column() amount: number;
    @Column({ type: 'varchar', length: 128 }) reason: string;
    @Column({ type: 'varchar', length: 256 }) description: string;
    @Column({ type: 'datetime', default: () => 'CURRENT_TIMESTAMP' }) created: Date;
    @Column({ type: 'datetime', nullable: true }) paid: Date;
    @Column({ type: 'int', nullable: true }) income_tax_paid: number | null;
    @Column({ type: 'tinyint' }) check_balance: boolean;
    @Column({ type: 'varchar', nullable: true, length: 64 }) bank_transaction_ref: string | null;

    @ManyToOne(() => BankTransactionEntity, (bte) => bte.paydayRewards)
    @JoinColumn({ name: 'bank_transaction_ref', referencedColumnName: 'ref' })
    bankTransaction?: BankTransactionEntity;
}
