import { Injectable } from '@angular/core';
import { ConnectorService } from '../../hmg-common/services/connector/connector.service';
import { AuthenticationService } from '../../hmg-common/services/authentication/authentication.service';
import { Observable } from 'rxjs';


@Injectable({
  providedIn: 'root'
})
export class PayslipService {
  public static getPayslip ="Services/ERP.svc/REST/GET_PAYSLIP";
  public static getSummaryOFPayment ="Services/ERP.svc/REST/GET_SUMMARY_OF_PAYMENT";
  public static getPaymentInfo ="Services/ERP.svc/REST/GET_PAYMENT_INFORMATION";
  public static getEarnings ="Services/ERP.svc/REST/GET_EARNINGS";
  public static getDeduction ="Services/ERP.svc/REST/GET_DEDUCTIONS";

  constructor(
    public api: ConnectorService,
    public authService: AuthenticationService,
    ) { }


public getPayslip(PayslipRequest: any , onError?: any,errorLabel?: string): Observable<any> {
  const request = PayslipRequest;
  this.authService.authenticateRequest(request);
  request.P_SELECTED_EMPLOYEE_NUMBER = request.UserName;
  return this.api.post(PayslipService.getPayslip, request, onError, errorLabel);
}
public getSummeryOFPayment(PayslipRequest: any, onError?: any,errorLabel?: string): Observable<any> {
  const request = PayslipRequest;
  this.authService.authenticateRequest(request);
  return this.api.post(PayslipService.getSummaryOFPayment,request,onError,errorLabel);
}

public getPaymentInfo(PayslipRequest: any, onError?: any,errorLabel?: string): Observable<any> {
  const request = PayslipRequest;
  this.authService.authenticateRequest(request);
  return this.api.post(PayslipService.getPaymentInfo,request,onError,errorLabel);
}
public getEarings(PayslipRequest: any, onError?: any,errorLabel?: string): Observable<any> {
  const request = PayslipRequest;
  this.authService.authenticateRequest(request);
  return this.api.post(PayslipService.getEarnings,request,onError,errorLabel);
}

public getDeduction(PayslipRequest: any, onError?: any,errorLabel?: string): Observable<any> {
  const request = PayslipRequest;
  this.authService.authenticateRequest(request);
  return this.api.post(PayslipService.getDeduction,request,onError,errorLabel);
}



}


