import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
import { Column, Entity, JoinColumn, ManyToOne } from 'typeorm';
import { TransactionTaxEntity } from '../../domain/entities/transaction-tax.entity';
import { BaseCoreModel } from 'src/core/modules/data/model/base-core.model';
import { TransactionModel } from './transaction.model';

@Entity(TABLE_NAME.TRANSACTION_TAX)
export class TransactionTaxModel
  extends BaseCoreModel<TransactionTaxEntity>
  implements TransactionTaxEntity
{
  @Column('varchar', { name: 'tax_id', nullable: true })
  tax_id: string;

  @Column('varchar', { name: 'tax_name', nullable: true })
  tax_name: string;

  @Column('decimal', { name: 'taxt_value', nullable: true })
  taxt_value: number;

  @Column('decimal', { name: 'tax_total_value', nullable: true })
  tax_total_value: number;

  @Column('varchar', { name: 'transaction_id', nullable: true })
  transaction_id: string;
  @ManyToOne(() => TransactionModel, (model) => model.taxes, {
    onDelete: 'CASCADE',
    onUpdate: 'CASCADE',
  })
  @JoinColumn({ name: 'transaction_id' })
  transaction: TransactionModel;
}
