import {SortDescriptor} from '@progress/kendo-data-query';

export class PayInListFilterModel {
  LoanIds: string[];
  UploadIds: string[];
  Take: number;
  Skip: number;
  TsFrom: Date;
  TsTo: Date;
  IdFrom: number;
  IdTo: number;
  TrailFrom: number;
  TrailTo: number;
  BalanceFrom: number;
  BalanceTo: number;
  AmountFrom: number;
  AmountTo: number;
  Sort?: SortDescriptor[];

  constructor(payload: Partial<PayInListFilterModel>) {
    this.LoanIds = [];
    if (payload.LoanIds !== undefined && payload.LoanIds.length > 0) {
      payload.LoanIds.forEach(v => { this.LoanIds.push(v); });
    }
    this.UploadIds = [];
    if (payload.UploadIds !== undefined && payload.UploadIds.length > 0 ) {
      payload.UploadIds.forEach(v => { this.UploadIds.push(v); });
    }

    const bigNumber = 9999999999;
    this.Take = payload.Take || 10;
    this.Skip = payload.Skip || 0;
    this.TsFrom = payload.TsFrom? new Date(payload.TsFrom) : new Date('1900-01-01');
    this.TsTo = payload.TsTo? new Date(payload.TsTo) : new Date('2038-01-01');
    this.IdFrom = payload.IdFrom || 0;
    this.IdTo = payload.IdTo || bigNumber;
    this.TrailFrom = payload.TrailFrom || 0;
    this.TrailTo = payload.TrailTo || bigNumber;
    this.BalanceFrom = payload.BalanceFrom || -1 ;
    this.BalanceTo = payload.BalanceTo || bigNumber;
    this.AmountFrom = payload.AmountFrom || 0;
    this.AmountTo = payload.AmountTo || bigNumber;
  }
}
