HRM-10/HRM.UI/ClientApp/src/app/_services/payroll/lfa.service.ts
Mohaimen Hasan 908a6d28ff Done
2026-11-29 10:06:33 +06:00

110 lines
4.7 KiB
TypeScript

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { ApiService } from '../../app.api.service';
import {
LFAApprovalInfo, LFAApprovalRequest, LFAApprovalResult, LFAApproverActionRequest, LFAApproverBatch,
LFAPaymentBatch, LFAPaymentBatchEmployee, LFAPaymentHistory, LFAPaymentInfo, LFAPaymentProcessResult,
LFAPaymentReadResult, LFAPaymentRequest, LFAPaymentUndoRequest, LFAPaymentUndoResult
} from '../../_models/Payroll/lfaPayment';
import { WFFlowHistory } from '../../_models/Work-Flow/wFMovementNext';
@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);
}
// ── LFA Payment Undo ──
getUndoBatches(): Observable<LFAPaymentBatch[]> {
return this.apiService.httpGet<LFAPaymentBatch[]>('/lfa/getUndoBatches');
}
getBatchEmployees(lfaPaymentID: number): Observable<LFAPaymentBatchEmployee[]> {
return this.apiService.httpGet<LFAPaymentBatchEmployee[]>('/lfa/getBatchEmployees/' + lfaPaymentID);
}
/** The whole batch (no detailIDs) or the selected employees of it. The server checks everything again. */
undoPayment(request: LFAPaymentUndoRequest): Observable<LFAPaymentUndoResult> {
return this.apiService.httpPost<LFAPaymentUndoResult>('/lfa/undoPayment', request);
}
// ── LFA Bank Advice (report viewer, /payroll-lfa/lfa-bank-advice) ──
/** The approved batches of the payroll type. */
getBankAdviceBatches(): Observable<LFAPaymentBatch[]> {
return this.apiService.httpGet<LFAPaymentBatch[]>('/lfa/getBankAdviceBatches');
}
// ── LFA Payment Approval (as Salary Approve) ──
getApprovalInfo(): Observable<LFAApprovalInfo> {
return this.apiService.httpGet<LFAApprovalInfo>('/lfa/getApprovalInfo');
}
getApprovalBatches(): Observable<LFAPaymentBatch[]> {
return this.apiService.httpGet<LFAPaymentBatch[]>('/lfa/getApprovalBatches');
}
getFlowHistory(lfaPaymentID: number): Observable<WFFlowHistory[]> {
return this.apiService.httpGet<WFFlowHistory[]>('/lfa/getFlowHistory/' + lfaPaymentID);
}
/** Workflow off: approve at once. */
approveDirect(request: LFAApprovalRequest): Observable<LFAApprovalResult> {
return this.apiService.httpPost<LFAApprovalResult>('/lfa/approveDirect', request);
}
/** Workflow on: submit (or submit again after a revert). */
submitForApproval(request: LFAApprovalRequest): Observable<LFAApprovalResult> {
return this.apiService.httpPost<LFAApprovalResult>('/lfa/submitForApproval', request);
}
// the approver's side (/payment-approval/lfa)
getApproverBatch(wfMovementTranID: number): Observable<LFAApproverBatch> {
return this.apiService.httpGet<LFAApproverBatch>('/lfa/getApproverBatch/' + wfMovementTranID);
}
approveFromApprover(request: LFAApproverActionRequest): Observable<LFAApprovalResult> {
return this.apiService.httpPost<LFAApprovalResult>('/lfa/approveFromApprover', request);
}
revertFromApprover(request: LFAApproverActionRequest): Observable<LFAApprovalResult> {
return this.apiService.httpPost<LFAApprovalResult>('/lfa/revertFromApprover', request);
}
}