import {
  Table,
  Model,
  Column,
  DataType,
  ForeignKey,
  BelongsTo,
  HasMany,
} from 'sequelize-typescript';
import { CustomerBaseModel } from './customer-base.entity';
import { BusinessContactModel } from './business-contact.entity';

@Table({ tableName: 'customer_Business', createdAt: false, updatedAt: false })
export class CustomerBusinessModel extends Model {
  @ForeignKey(() => CustomerBaseModel)
  @Column({ primaryKey: true, allowNull: false, type: DataType.STRING(30) })
  CustomerId: string;

  @Column({ allowNull: false, type: DataType.STRING(200) })
  CompanyName: string;

  @Column({ type: DataType.STRING(20) })
  RegistrationNo: string;

  @Column({ type: DataType.STRING(20) })
  TaxIdentificationNo: string;

  @BelongsTo(() => CustomerBaseModel)
  CustomerBase: CustomerBaseModel;

  @HasMany(() => BusinessContactModel)
  BusinessContact: BusinessContactModel[];
}
