47 lines
1.9 KiB
TypeScript
47 lines
1.9 KiB
TypeScript
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<LFAPaymentInfo> {
|
|
return this.apiService.httpGet<LFAPaymentInfo>('/lfa/getPaymentInfo');
|
|
}
|
|
|
|
downloadTemplate(): Observable<Blob> {
|
|
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<LFAPaymentReadResult> {
|
|
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<LFAPaymentReadResult> {
|
|
return this.apiService.httpPost<LFAPaymentReadResult>('/lfa/calculatePayment', request);
|
|
}
|
|
|
|
/** Saves the rows as a new batch, all or nothing. The server calculates every row again. */
|
|
processPayment(request: LFAPaymentRequest): Observable<LFAPaymentProcessResult> {
|
|
return this.apiService.httpPost<LFAPaymentProcessResult>('/lfa/processPayment', request);
|
|
}
|
|
|
|
/** Dates as yyyy-MM-dd. */
|
|
getPaymentHistory(fromDate: string, toDate: string): Observable<LFAPaymentHistory[]> {
|
|
return this.apiService.httpGet<LFAPaymentHistory[]>('/lfa/getPaymentHistory/' + fromDate + '/' + toDate);
|
|
}
|
|
}
|