import { Injectable } from '@angular/core'; import { Observable } from 'rxjs'; import { ApiService } from '../../app.api.service'; import { LFAPaymentHistory, LFAPaymentInfo, LFAPaymentProcessResult, LFAPaymentReadResult, LFAPaymentRequest } from '../../_models/Payroll/lfaPayment'; @Injectable({ providedIn: 'root' }) export class LFAService { constructor(public apiService: ApiService) { } /** The current salary month and the next batch number. */ getPaymentInfo(): Observable { return this.apiService.httpGet('/lfa/getPaymentInfo'); } downloadTemplate(): Observable { return this.apiService.httpGetBlob('/dataUpload/lfa-payment-upload-template'); } /** Reads a filled template on the server and returns the calculated employees. Nothing is saved. */ readUpload(file: File, paymentDate: string): Observable { const formData = new FormData(); formData.append('excelfile', file, file.name); formData.append('paymentDate', paymentDate); return this.apiService.httpPostBlob('/dataUpload/lfa-payment-upload-read', formData); } calculatePayment(request: LFAPaymentRequest): Observable { return this.apiService.httpPost('/lfa/calculatePayment', request); } /** Saves the rows as a new batch, all or nothing. The server calculates every row again. */ processPayment(request: LFAPaymentRequest): Observable { return this.apiService.httpPost('/lfa/processPayment', request); } /** Dates as yyyy-MM-dd. */ getPaymentHistory(fromDate: string, toDate: string): Observable { return this.apiService.httpGet('/lfa/getPaymentHistory/' + fromDate + '/' + toDate); } }