import {PeopleModel} from './people.model';
import {UserExtraModel} from './user-extra.model';

export class BrokerModel extends PeopleModel {
  public Login: string;
  public BSB: string;
  public ACC: string;
  public License: string;
  public Organization: string;
  constructor( payload?: Partial<BrokerModel>) {
    super(payload);
    if (! payload ) { payload = {} ; }
    this.Login = payload.Login || '';
    this.BSB = payload.BSB || '';
    this.ACC = payload.ACC || '';
    this.License = payload.License || '';
    this.Organization = payload.Organization || '';
  }



  public static EmptyNew(): BrokerModel {
    return new BrokerModel({});
  }

  public static getFromUserAndExtra(u: PeopleModel, ex: UserExtraModel): BrokerModel {
    const ret =  new BrokerModel({});
    ret.Id = u.Id;
    ret.First = u.First;
    ret.Last = u.Last;
    ret.Middle =  u.Middle;
    ret.Title = u.Title;
    ret.Display = u.Display;
    ret.Nick = u.Nick;
    ret.Login = ex.Login;
    ret.Enabled = u.Enabled;
    ret.BSB = ex.BSB;
    ret.ACC = ex.ACC;
    ret.License = ex.License;
    ret.Organization = ex.Organization;
    return ret;
  }

  // public toPeopleModel(): PeopleModel{
  //   const ret = new PeopleModel( {} );
  //   ret.Id = this.Id;
  //   ret.First = this.First;
  //   ret.Last = this.Last;
  //   ret.Middle = this.Middle;
  //   ret.Title = this.Title;
  //   ret.Display = this.Display;
  //   ret.Nick = this.Nick;
  //   ret.Enabled = this.Enabled;
  //   return ret;
  // }
}
