import {
  Column,
  DataType,
  Table,
  Model,
  ForeignKey,
  BelongsTo,
  CreatedAt,
  UpdatedAt,
} from 'sequelize-typescript';
import { AgreementModel } from './agreement.entity';
import { IAgreementSignatureAttr } from '../interfaces/agreemeent-signature-attr.interface';
import { AgreementSignatureStatusEnum } from '../enum/agreement-signature-status.enum';
import { AgreementSignatureVerificationMethodEnum } from '../enum/agreement-signature-verification-method.enum';

@Table({
  tableName: 'rental_AgreementSignature',
})
export class AgreementSignatureModel
  extends Model
  implements IAgreementSignatureAttr
{
  @Column({
    primaryKey: true,
    allowNull: false,
    type: DataType.STRING(30),
  })
  SignatureId: string;

  @ForeignKey(() => AgreementModel)
  @Column({
    allowNull: false,
    type: DataType.STRING(30),
  })
  AgreementNo: string;

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

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

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

  @Column({
    allowNull: false,
    type: DataType.STRING(10),
  })
  SignatureStatus: AgreementSignatureStatusEnum;

  @Column({
    allowNull: true,
    type: DataType.DATE,
  })
  SignedAt: Date;

  @Column({
    allowNull: false,
    type: DataType.STRING(30),
  })
  VerificationMethod: AgreementSignatureVerificationMethodEnum;

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

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

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

  @CreatedAt
  CreatedAt: Date;

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

  @UpdatedAt
  UpdatedAt: Date;

  @BelongsTo(() => AgreementModel)
  Agreement: AgreementModel;
}
