import {PayInModel} from '../models/pay-in.model';

export abstract class PayInLenderIncomeModel {
  public matchedPayIn?: PayInModel | -1;
  abstract convertToPayIn(): PayInModel;
  abstract isMatch(pi: PayInModel): boolean;
  protected constructor(protected AgencyName: string, payload: Partial<PayInLenderIncomeModel>){
    this.matchedPayIn = payload.matchedPayIn || -1;
  }


  public asPayIn(): PayInModel {
    if (this.matchedPayIn !== undefined && this.matchedPayIn !== -1) {
      return this.matchedPayIn;
    }
    return this.convertToPayIn();
  }
}
