import { Injectable } from '@angular/core';
import { HttpRequestService } from '../http-request.service';
import { RequestInvoice } from '../../interfaces/acquisition-management/invoice.interface';
import { map } from 'rxjs';

@Injectable({
  providedIn: 'root'
})
export class InvoiceService {

  private _url: string;
  constructor( private _httpRequestService:HttpRequestService ) {
    this._url = 'acquisition-management/invoice';
  }

  public compareInvoice(requestInvoice: RequestInvoice) {
    return this._httpRequestService.postQuery(`${this._url}/compare-invoice`, requestInvoice).pipe(map((data:any) => data));
  }
  
  public getInvoicePayment(user: string, line: number) {
    return this._httpRequestService.getQuery(`${this._url}/get-invoice-payment/${user}/${line}`).pipe(map((data:any) => data));
  }

  public getInvoice(user: string, line: number) {
    return this._httpRequestService.getQuery(`${this._url}/get-compare-invoice/${user}/${line}`).pipe(map((data:any) => data));
  }
  
  public getBudgetManagement(user: string, line: number) {
    return this._httpRequestService.getQuery(`${this._url}/get-budget-management/${user}/${line}`).pipe(map((data:any) => data));
  }

  public getInvoiceById(id:string, user: string, line: number) {
    return this._httpRequestService.getQuery(`${this._url}/get-invoice-by-id/${id}/${user}/${line}`).pipe(map((data:any) => data));
  }
}
