+
LFA Payment Approval
+
+ @if (data && data.batch) {
+
+
Batch ID
{{ data.batch.batchNumber }}
+
Payment Date
{{ data.batch.paymentDate | date: 'dd-MMM-yyyy' }}
+
LFA Year
{{ data.batch.lfaYear | date: 'yyyy' }}
+
Employees
{{ data.batch.headCount }}
+
Total LFA Amount (BDT)
{{ data.batch.totalAmount | number: '1.2-2' }}
+
+ @if (data.batch.remarks) {
+
Remarks of the batch: {{ data.batch.remarks }}
+ }
+
+
+ Employees
+
+ Export
+
+
+
+
+
+
+
+
+
+ No employee in this batch.
+
+
+ } @else if (data && data.message) {
+
{{ data.message }}
+ }
+
+ @if (flowHistory.length > 0) {
+
Approval History
+
+
+ {{ dataItem.employeeNo }} - {{ dataItem.employeeName }}
+
+
+ {{ dataItem.tranDate | date: 'dd-MMM-yyyy' }}
+
+
+ {{ flowStatusText(dataItem.status) }}
+
+
+ {{ dataItem.statusUpdateDate | date: 'dd-MMM-yyyy hh:mm a' }}
+
+
+
+ }
+
+ @if (data && data.batch) {
+ @if (canAct) {
+
+
+ Revert
+ Approve
+
+ } @else if (data.message) {
+
{{ data.message }}
+ }
+ }
+
diff --git a/HRM.UI/ClientApp/src/app/payment-approval/lfa-approval/lfa-approval.component.scss b/HRM.UI/ClientApp/src/app/payment-approval/lfa-approval/lfa-approval.component.scss
new file mode 100644
index 0000000..09bb364
--- /dev/null
+++ b/HRM.UI/ClientApp/src/app/payment-approval/lfa-approval/lfa-approval.component.scss
@@ -0,0 +1,88 @@
+/* Payment Approval › LFA: layout only; colours are the theme's --gh-* variables */
+.lfa-apv {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ padding: 8px 4px;
+}
+
+.lfa-apv__title {
+ font-size: 18px;
+ font-weight: 700;
+ color: var(--gh-lk);
+}
+
+.lfa-apv__sub {
+ font-size: 14px;
+ font-weight: 700;
+ color: var(--gh-lk);
+}
+
+.lfa-apv__head {
+ display: flex;
+ align-items: center;
+ gap: 10px;
+}
+
+.lfa-apv__spacer {
+ flex: 1 1 auto;
+}
+
+.lfa-apv__note {
+ font-size: 12px;
+ color: var(--gh-muted);
+}
+
+.lfa-apv__blocked {
+ padding: 8px 12px;
+ border-radius: 6px;
+ font-weight: 600;
+ color: var(--gh-dn);
+ background: color-mix(in srgb, var(--gh-dn) 10%, transparent);
+}
+
+.lfa-apv__action {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: flex-end;
+ gap: 12px;
+}
+
+.lfa-apv__remarks {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ width: 420px;
+ max-width: 100%;
+
+ label {
+ font-size: 12px;
+ font-weight: 600;
+ color: var(--gh-muted);
+ }
+}
+
+.lfa-summary {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
+ gap: 12px;
+}
+
+.lfa-stat {
+ padding: 12px 14px;
+ border: 1px solid var(--gh-bo);
+ border-radius: 6px;
+ background: var(--gh-tb);
+}
+
+.lfa-stat__key {
+ font-size: 12px;
+ color: var(--gh-muted);
+}
+
+.lfa-stat__value {
+ margin-top: 4px;
+ font-size: 18px;
+ font-weight: 700;
+ color: var(--gh-lk);
+}
diff --git a/HRM.UI/ClientApp/src/app/payment-approval/lfa-approval/lfa-approval.component.ts b/HRM.UI/ClientApp/src/app/payment-approval/lfa-approval/lfa-approval.component.ts
new file mode 100644
index 0000000..ff19259
--- /dev/null
+++ b/HRM.UI/ClientApp/src/app/payment-approval/lfa-approval/lfa-approval.component.ts
@@ -0,0 +1,168 @@
+import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
+import { ExcelExportData } from '@progress/kendo-angular-excel-export';
+import { ApiService } from 'src/app/app.api.service';
+import { HRMNotificationService } from 'src/app/app.notification.service';
+import { DataTransferService } from 'src/app/data.transfer.service';
+import { loadingPanelService } from 'src/app/hrm-loding panel/loding.panel.service';
+import { LFAService } from 'src/app/_services/payroll/lfa.service';
+import { WorkflowService } from 'src/app/_services/workflow/workflow.service';
+import { WFFlowHistory } from 'src/app/_models/Work-Flow/wFMovementNext';
+import {
+ EnumLFAPaymentStatus, LFAApprovalResult, LFAApproverBatch, LFAPaymentBatchEmployee
+} from 'src/app/_models/Payroll/lfaPayment';
+
+/**
+ * Payment Approval › LFA (/payment-approval/lfa): an approver opens the LFA batch they received from their
+ * pending list and approves it (to the next approver, or finally) or reverts it, as for the salary.
+ */
+@Component({
+ selector: 'app-lfa-approval',
+ templateUrl: './lfa-approval.component.html',
+ styleUrls: ['./lfa-approval.component.scss'],
+ changeDetection: ChangeDetectionStrategy.Eager,
+ standalone: false
+})
+export class LfaApprovalComponent implements OnInit {
+
+ wfMovementTranID = 0;
+ data: LFAApproverBatch = null;
+ employees: LFAPaymentBatchEmployee[] = [];
+ flowHistory: WFFlowHistory[] = [];
+ remarks = '';
+ isBusy = false;
+ acted = false;
+
+ constructor(public apiService: ApiService,
+ public notificationService: HRMNotificationService,
+ public loadingPanel: loadingPanelService,
+ private dataTransferService: DataTransferService,
+ private workflowService: WorkflowService,
+ private lfaService: LFAService) {
+ this.apiService.selectedMenuName = 'LFA Payment Approval';
+ }
+
+ ngOnInit() {
+ // the pending list puts the workflow step (WFMovementTranID) here before it opens the page
+ this.wfMovementTranID = Number(this.dataTransferService.getData()) || 0;
+ this.load();
+ }
+
+ load() {
+ if (!this.wfMovementTranID) {
+ this.notificationService.showWarning('Please open the LFA approval request from your pending list.');
+ return;
+ }
+ this.start();
+ this.lfaService.getApproverBatch(this.wfMovementTranID).subscribe({
+ next: (resp) => {
+ this.data = resp;
+ this.employees = (resp && resp.employees || []).map(x => ({
+ ...x,
+ joiningDate: this.toDate(x.joiningDate),
+ statusText: this.paymentStatusText(x.paymentStatus)
+ }));
+ if (resp && resp.batch) {
+ resp.batch.paymentDate = this.toDate(resp.batch.paymentDate);
+ resp.batch.lfaYear = this.toDate(resp.batch.lfaYear);
+ }
+ this.workflowService.getFlowHistorybyTranID(this.wfMovementTranID).subscribe({
+ next: (history: any) => {
+ this.stop();
+ this.flowHistory = history || [];
+ },
+ error: () => this.stop()
+ });
+ },
+ error: (err) => this.fail(err, 'Could not load the LFA approval request.')
+ });
+ }
+
+ get canAct(): boolean {
+ return !!this.data && this.data.canAct && !this.acted;
+ }
+
+ approve() {
+ if (!this.canAct || this.isBusy) {
+ return;
+ }
+ this.notificationService.showActiveConfirm('Confirmation', 'Are you sure to approve this LFA payment batch?').then((isConfirmed) => {
+ if (isConfirmed) {
+ this.send(this.lfaService.approveFromApprover({ wfMovementTranID: this.wfMovementTranID, remarks: this.remarks }));
+ }
+ });
+ }
+
+ revert() {
+ if (!this.canAct || this.isBusy) {
+ return;
+ }
+ if (!this.remarks || !this.remarks.trim()) {
+ this.notificationService.showWarning('Please write in Remarks why the batch is reverted.');
+ return;
+ }
+ this.notificationService.showActiveConfirm('Confirmation', 'Are you sure to revert this LFA payment batch?').then((isConfirmed) => {
+ if (isConfirmed) {
+ this.send(this.lfaService.revertFromApprover({ wfMovementTranID: this.wfMovementTranID, remarks: this.remarks }));
+ }
+ });
+ }
+
+ private send(call: any) {
+ this.start();
+ call.subscribe({
+ next: (resp: LFAApprovalResult) => {
+ this.stop();
+ if (resp.done) {
+ this.acted = true;
+ this.notificationService.showSuccess(resp.message);
+ } else {
+ this.notificationService.showError(resp.message);
+ }
+ this.load();
+ },
+ error: (err) => this.fail(err, 'Nothing was changed. Please try again.')
+ });
+ }
+
+ allEmployees = (): ExcelExportData => ({ data: this.employees });
+
+ flowStatusText(status: number): string {
+ switch (status) { // the workflow's EnumwfStatus
+ case 0: return 'Submitted';
+ case 1: return 'Received & Working';
+ case 2: return 'Reverted';
+ case 3: return 'Declined';
+ case 4: return 'Approved';
+ case 7: return 'Completed';
+ default: return '';
+ }
+ }
+
+ private paymentStatusText(status: EnumLFAPaymentStatus): string {
+ switch (status) {
+ case EnumLFAPaymentStatus.Paid: return 'Paid';
+ case EnumLFAPaymentStatus.Failed: return 'Failed';
+ default: return 'Pending';
+ }
+ }
+
+ private start() {
+ this.isBusy = true;
+ this.loadingPanel.ShowLoadingPanel = true;
+ }
+
+ private stop() {
+ this.isBusy = false;
+ this.loadingPanel.ShowLoadingPanel = false;
+ }
+
+ private fail(err: any, fallback: string) {
+ this.stop();
+ const text = typeof err === 'string' ? err : err && typeof err.error === 'string' ? err.error : '';
+ this.notificationService.showError(text || fallback);
+ }
+
+ private toDate(value: any): Date {
+ return value ? new Date(value) : null;
+ }
+}
diff --git a/HRM.UI/ClientApp/src/app/payment-approval/payment-approval-routing.module.ts b/HRM.UI/ClientApp/src/app/payment-approval/payment-approval-routing.module.ts
index aa70a6c..b96af42 100644
--- a/HRM.UI/ClientApp/src/app/payment-approval/payment-approval-routing.module.ts
+++ b/HRM.UI/ClientApp/src/app/payment-approval/payment-approval-routing.module.ts
@@ -3,12 +3,14 @@ import { RouterModule, Routes } from '@angular/router';
import { PaymentApprovalComponent } from './payment-approval/payment-approval.component';
import { AuthGuard } from '../_guards/auth.guard';
import { ApprovalHistoryComponent } from './approval-history/approval-history.component';
+import { LfaApprovalComponent } from './lfa-approval/lfa-approval.component';
export const routes: Routes = [
{ path: 'salary', component: PaymentApprovalComponent, canActivate: [AuthGuard] },
{ path: 'bonus', component: PaymentApprovalComponent, canActivate: [AuthGuard] },
{ path: 'leaveencashment', component: PaymentApprovalComponent, canActivate: [AuthGuard] },
{ path: 'opi', component: PaymentApprovalComponent, canActivate: [AuthGuard] },
+ { path: 'lfa', component: LfaApprovalComponent, canActivate: [AuthGuard] },
{ path: 'approval-history', component: ApprovalHistoryComponent, canActivate: [AuthGuard] },
];
diff --git a/HRM.UI/ClientApp/src/app/payment-approval/payment-approval.module.ts b/HRM.UI/ClientApp/src/app/payment-approval/payment-approval.module.ts
index d39a7cb..12df297 100644
--- a/HRM.UI/ClientApp/src/app/payment-approval/payment-approval.module.ts
+++ b/HRM.UI/ClientApp/src/app/payment-approval/payment-approval.module.ts
@@ -38,13 +38,15 @@ import { EmpLifeCycleServices } from '../_services/employee/empLifeCycle.service
import { PaymentApprovalRoutingModule } from './payment-approval-routing.module';
import { PaymentApprovalComponent } from './payment-approval/payment-approval.component';
import { ApprovalHistoryComponent } from './approval-history/approval-history.component';
+import { LfaApprovalComponent } from './lfa-approval/lfa-approval.component';
import { BackgroundCanvasModule } from '../BackgroundCanvas/BackgroundCanvas.module';
@NgModule({
declarations: [
PaymentApprovalComponent,
- ApprovalHistoryComponent
+ ApprovalHistoryComponent,
+ LfaApprovalComponent
],
imports: [
CommonModule,
diff --git a/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.html b/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.html
index cd96c1d..58eaa29 100644
--- a/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.html
+++ b/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.html
@@ -1,8 +1,149 @@
-
- LFA Payment Approval
-
-
-
+
+
+
+ @if (info) {
+
+ @if (isWorkflow) {
+
Approval Workflow is on. Submit a batch for approval; the approvers set up for LFA Payment in Work Flow Setup approve it one after another from the Payment Approval page.
+ @if (!info.hasWorkflowSetup) {
+
No approval workflow is set up for LFA Payment yet. Please set it up in Work Flow Setup.
+ }
+ @if (!info.hasEmployee) {
+
Your login is not linked with an employee, so you cannot submit a batch for approval.
+ }
+ } @else {
+
Direct Approve. The approval workflow is off; a batch is approved here at once.
+ }
+
+ }
+
+
+
+ LFA Batches
+
+ Show approved batches
+ Refresh
+
+
+
+
+
+
+ {{ dataItem.lfaYear | date: 'yyyy' }}
+
+
+
+
+
+ {{ dataItem.statusText }}
+
+
+
+ {{ dataItem.wfStatus === approvedStatus ? '' : dataItem.pendingWith }}
+
+
+
+
+
+ View
+
+
+ {{ showApproved ? 'No LFA batch found.' : 'No LFA batch is waiting for approval.' }}
+
+
+
+ @if (selectedBatch) {
+
+ Batch {{ selectedBatch.batchNumber }}
+ {{ selectedBatch.statusText }}
+
+ Export
+ Close
+
+
+
+
Payment Date
{{ selectedBatch.paymentDate | date: 'dd-MMM-yyyy' }}
+
Employees
{{ selectedBatch.headCount }}
+
Total LFA Amount (BDT)
{{ selectedBatch.totalAmount | number: '1.2-2' }}
+
+
{{ selectedBatch.wfStatus === approvedStatus ? 'Approved By' : 'Pending With' }}
+
{{ selectedBatch.wfStatus === approvedStatus ? (selectedBatch.approvedByName || '—') : (selectedBatch.pendingWith || '—') }}
+
+
+
+
+
+
+
+
+
+
+
+
+ No employee in this batch.
+
+
+
+ @if (flowHistory.length > 0) {
+
Approval History
+
+
+ {{ dataItem.employeeNo }} - {{ dataItem.employeeName }}
+
+
+ {{ dataItem.tranDate | date: 'dd-MMM-yyyy' }}
+
+
+ {{ flowStatusText(dataItem.status) }}
+
+
+ {{ dataItem.statusUpdateDate | date: 'dd-MMM-yyyy hh:mm a' }}
+
+
+
+ }
+
+ @if (selectedBatch.wfStatus !== approvedStatus) {
+
+
+ {{ actionLabel }}
+
+ @if (actionBlockedReason) {
+
{{ actionBlockedReason }}
+ }
+ }
+ }
+
+@if (showConfirm && selectedBatch) {
+
+
+ @if (isWorkflow) {
+ Batch {{ selectedBatch.batchNumber }} will be sent to the approvers of LFA Payment.
+ } @else {
+ Batch {{ selectedBatch.batchNumber }} will be approved. This cannot be reversed.
+ }
+
+
+ Batch ID {{ selectedBatch.batchNumber }}
+ Payment Date {{ selectedBatch.paymentDate | date: 'dd-MMM-yyyy' }}
+ Employees {{ selectedBatch.headCount }}
+ Total LFA Amount BDT {{ selectedBatch.totalAmount | number: '1.2-2' }}
+
+
+
+ Cancel
+ Confirm
+
+
+
+}
diff --git a/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.scss b/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.scss
index e69de29..e88e688 100644
--- a/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.scss
+++ b/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.scss
@@ -0,0 +1,145 @@
+/* LFA Payment Approval: layout only; colours are the theme's --gh-* variables */
+.lfa-appr {
+ display: flex;
+ flex-direction: column;
+ gap: 12px;
+ padding: 8px 4px;
+}
+
+.lfa-appr__mode {
+ padding: 10px 14px;
+ border-radius: 6px;
+ border: 1px solid var(--gh-bo);
+ background: var(--gh-tb);
+}
+
+.lfa-appr__mode--wf {
+ border-color: color-mix(in srgb, var(--gh-lk) 40%, transparent);
+}
+
+.lfa-appr__warn {
+ margin-top: 6px;
+ font-weight: 600;
+ color: var(--gh-dn);
+}
+
+.lfa-appr__head {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ gap: 10px;
+}
+
+.lfa-appr__title {
+ font-size: 16px;
+ font-weight: 700;
+ color: var(--gh-lk);
+}
+
+.lfa-appr__title--small {
+ font-size: 14px;
+}
+
+.lfa-appr__spacer {
+ flex: 1 1 auto;
+}
+
+.lfa-appr__check {
+ display: inline-flex;
+ align-items: center;
+ gap: 6px;
+ font-size: 13px;
+}
+
+.lfa-appr__action {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: flex-end;
+ gap: 12px;
+}
+
+.lfa-appr__remarks {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ width: 420px;
+ max-width: 100%;
+
+ label {
+ font-size: 12px;
+ font-weight: 600;
+ color: var(--gh-muted);
+ }
+}
+
+.lfa-appr__note {
+ font-size: 12px;
+ color: var(--gh-muted);
+}
+
+.lfa-selected {
+ border-color: var(--gh-lk);
+ color: var(--gh-lk);
+}
+
+.lfa-summary {
+ display: grid;
+ grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
+ gap: 12px;
+}
+
+.lfa-stat {
+ padding: 12px 14px;
+ border: 1px solid var(--gh-bo);
+ border-radius: 6px;
+ background: var(--gh-tb);
+}
+
+.lfa-stat__key {
+ font-size: 12px;
+ color: var(--gh-muted);
+}
+
+.lfa-stat__value {
+ margin-top: 4px;
+ font-size: 18px;
+ font-weight: 700;
+ color: var(--gh-lk);
+}
+
+.lfa-stat__value--small {
+ font-size: 14px;
+}
+
+.lfa-badge {
+ display: inline-block;
+ padding: 2px 10px;
+ border-radius: 999px;
+ font-size: 12px;
+ font-weight: 600;
+ color: var(--gh-warn);
+ background: color-mix(in srgb, var(--gh-warn) 15%, transparent);
+}
+
+.lfa-badge--ok {
+ color: var(--gh-ok);
+ background: color-mix(in srgb, var(--gh-ok) 15%, transparent);
+}
+
+.lfa-badge--back {
+ color: var(--gh-dn);
+ background: color-mix(in srgb, var(--gh-dn) 12%, transparent);
+}
+
+.lfa-confirm {
+ width: 100%;
+
+ td {
+ padding: 4px 0;
+ }
+
+ td:last-child {
+ text-align: right;
+ font-weight: 600;
+ }
+}
diff --git a/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.ts b/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.ts
index e2626dd..d9dd1d8 100644
--- a/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.ts
+++ b/HRM.UI/ClientApp/src/app/payroll-lfa/lfa-payment-approval/lfa-payment-approval.component.ts
@@ -1,6 +1,20 @@
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
+import { ExcelExportData } from '@progress/kendo-angular-excel-export';
import { ApiService } from '../../app.api.service';
+import { HRMNotificationService } from '../../app.notification.service';
+import { loadingPanelService } from '../../hrm-loding panel/loding.panel.service';
+import { LFAService } from '../../_services/payroll/lfa.service';
+import { WFFlowHistory } from '../../_models/Work-Flow/wFMovementNext';
+import {
+ EnumLFAPaymentStatus, LFAApprovalInfo, LFAApprovalResult, LFAPaymentBatch, LFAPaymentBatchEmployee
+} from '../../_models/Payroll/lfaPayment';
+/**
+ * LFA Payment Approval, as Salary Approve: the Logic key lfaapproval/workflow decides between Direct Approve
+ * ("No") and Submit for Approval ("Yes"). In the workflow the approvers set up for LFA Payment in Work Flow
+ * Setup act one after another from the Payment Approval page; a reverted batch comes back here to be
+ * submitted again. The server checks everything again.
+ */
@Component({
selector: 'app-lfa-payment-approval',
templateUrl: './lfa-payment-approval.component.html',
@@ -10,10 +24,220 @@ import { ApiService } from '../../app.api.service';
})
export class LfaPaymentApprovalComponent implements OnInit {
- constructor(public apiService: ApiService) {
+ readonly approvedStatus = 5; // enumwfStatus.Approve
+
+ info: LFAApprovalInfo = null;
+ batches: LFAPaymentBatch[] = [];
+ showApproved = false;
+ selectedBatch: LFAPaymentBatch = null;
+ employees: LFAPaymentBatchEmployee[] = [];
+ flowHistory: WFFlowHistory[] = [];
+ remarks = '';
+ isBusy = false;
+ showConfirm = false;
+
+ constructor(public apiService: ApiService,
+ public notificationService: HRMNotificationService,
+ public loadingPanel: loadingPanelService,
+ private lfaService: LFAService) {
this.apiService.selectedMenuName = 'LFA Payment Approval';
}
ngOnInit() {
+ this.start();
+ this.lfaService.getApprovalInfo().subscribe({
+ next: (resp) => {
+ this.info = resp;
+ this.loadBatches();
+ },
+ error: (err) => this.fail(err, 'Could not read the LFA approval settings.')
+ });
+ }
+
+ // ── Batches ─────────────────────────────────────────────────────
+
+ get visibleBatches(): LFAPaymentBatch[] {
+ return this.showApproved ? this.batches : this.batches.filter(x => x.wfStatus !== this.approvedStatus);
+ }
+
+ loadBatches(keepBatchID: number = 0) {
+ this.start();
+ this.lfaService.getApprovalBatches().subscribe({
+ next: (resp) => {
+ this.stop();
+ this.batches = (resp || []).map(x => ({
+ ...x,
+ paymentDate: this.toDate(x.paymentDate),
+ lfaYear: this.toDate(x.lfaYear),
+ creationDate: this.toDate(x.creationDate),
+ approvedDate: this.toDate(x.approvedDate)
+ }));
+ const keep = keepBatchID ? this.batches.find(x => x.lfaPaymentID === keepBatchID) : null;
+ if (keep) {
+ this.viewBatch(keep);
+ } else {
+ this.clearBatch();
+ }
+ },
+ error: (err) => this.fail(err, 'Could not load the LFA batches.')
+ });
+ }
+
+ viewBatch(batch: LFAPaymentBatch) {
+ this.selectedBatch = batch;
+ this.employees = [];
+ this.flowHistory = [];
+ this.remarks = '';
+ this.start();
+ this.lfaService.getBatchEmployees(batch.lfaPaymentID).subscribe({
+ next: (resp) => {
+ this.employees = (resp || []).map(x => ({
+ ...x,
+ joiningDate: this.toDate(x.joiningDate),
+ statusText: this.paymentStatusText(x.paymentStatus)
+ }));
+ if (!batch.wfMovementTranID) {
+ this.stop();
+ return;
+ }
+ this.lfaService.getFlowHistory(batch.lfaPaymentID).subscribe({
+ next: (history) => {
+ this.stop();
+ this.flowHistory = history || [];
+ },
+ error: (err) => this.fail(err, 'Could not load the approval history.')
+ });
+ },
+ error: (err) => this.fail(err, 'Could not load the employees of the batch.')
+ });
+ }
+
+ clearBatch() {
+ this.selectedBatch = null;
+ this.employees = [];
+ this.flowHistory = [];
+ this.remarks = '';
+ }
+
+ // ── What the selected batch allows ──────────────────────────────
+
+ get isWorkflow(): boolean {
+ return !!this.info && this.info.isWorkflowRequired;
+ }
+
+ /** The batch has not been approved or submitted yet. */
+ get isNew(): boolean {
+ const b = this.selectedBatch;
+ return !!b && (b.wfStatus === null || b.wfStatus === undefined || b.wfStatus === 8);
+ }
+
+ get actionLabel(): string {
+ if (!this.isWorkflow) {
+ return 'Approve';
+ }
+ return this.selectedBatch && this.selectedBatch.isAtInitiator ? 'Submit Again' : 'Submit for Approval';
+ }
+
+ /** Why the button is disabled; empty when it can be used. */
+ get actionBlockedReason(): string {
+ const b = this.selectedBatch;
+ if (!b || !this.info) {
+ return 'Please select a batch.';
+ }
+ if (b.wfStatus === this.approvedStatus) {
+ return 'This batch is already approved.';
+ }
+ if (b.headCount === 0) {
+ return 'This batch has no employee.';
+ }
+ if (!this.isWorkflow) {
+ return this.isNew ? '' : 'This batch is in the approval workflow; it is approved from the Payment Approval page.';
+ }
+ if (!this.info.hasEmployee) {
+ return 'Your login is not linked with an employee. The approval workflow needs an employee to submit the batch.';
+ }
+ if (this.isNew) {
+ return this.info.hasWorkflowSetup ? '' : 'No approval workflow is set up for LFA Payment. Please set it up in Work Flow Setup first.';
+ }
+ return b.isAtInitiator ? '' : 'This batch is submitted and pending for approval' + (b.pendingWith ? ' with ' + b.pendingWith : '') + '.';
+ }
+
+ confirmAction() {
+ const reason = this.actionBlockedReason;
+ if (reason) {
+ this.notificationService.showWarning(reason);
+ return;
+ }
+ this.showConfirm = true;
+ }
+
+ act() {
+ if (this.isBusy || !this.selectedBatch) {
+ return;
+ }
+ const batchID = this.selectedBatch.lfaPaymentID;
+ const request = { lfaPaymentID: batchID, remarks: this.remarks };
+ const call = this.isWorkflow ? this.lfaService.submitForApproval(request) : this.lfaService.approveDirect(request);
+ this.start();
+ call.subscribe({
+ next: (resp: LFAApprovalResult) => {
+ this.stop();
+ this.showConfirm = false;
+ if (resp.done) {
+ this.notificationService.showSuccess(resp.message);
+ } else {
+ this.notificationService.showError(resp.message);
+ }
+ this.loadBatches(batchID);
+ },
+ error: (err) => {
+ this.showConfirm = false;
+ this.fail(err, 'Nothing was changed. Please try again.');
+ }
+ });
+ }
+
+ allEmployees = (): ExcelExportData => ({ data: this.employees });
+
+ flowStatusText(status: number): string {
+ switch (status) { // the workflow's EnumwfStatus
+ case 0: return 'Submitted';
+ case 1: return 'Received & Working';
+ case 2: return 'Reverted';
+ case 3: return 'Declined';
+ case 4: return 'Approved';
+ case 7: return 'Completed';
+ default: return '';
+ }
+ }
+
+ // ── Helpers ─────────────────────────────────────────────────────
+
+ private paymentStatusText(status: EnumLFAPaymentStatus): string {
+ switch (status) {
+ case EnumLFAPaymentStatus.Paid: return 'Paid';
+ case EnumLFAPaymentStatus.Failed: return 'Failed';
+ default: return 'Pending';
+ }
+ }
+
+ private start() {
+ this.isBusy = true;
+ this.loadingPanel.ShowLoadingPanel = true;
+ }
+
+ private stop() {
+ this.isBusy = false;
+ this.loadingPanel.ShowLoadingPanel = false;
+ }
+
+ private fail(err: any, fallback: string) {
+ this.stop();
+ const text = typeof err === 'string' ? err : err && typeof err.error === 'string' ? err.error : '';
+ this.notificationService.showError(text || fallback);
+ }
+
+ private toDate(value: any): Date {
+ return value ? new Date(value) : null;
}
}
diff --git a/HRM.UI/Controllers/Payroll/LFAController.cs b/HRM.UI/Controllers/Payroll/LFAController.cs
index cf94821..468ee53 100644
--- a/HRM.UI/Controllers/Payroll/LFAController.cs
+++ b/HRM.UI/Controllers/Payroll/LFAController.cs
@@ -154,6 +154,147 @@ namespace HRM.UI.Controllers.Payroll
}
}
+ // ── LFA Payment Approval (as Salary Approve: Direct Approve or the approval workflow, Logic lfaapproval/workflow) ──
+
+ ///
Logic key, whether the login has an employee, and whether Work Flow Setup has LFA rules.
+ [HttpGet("getApprovalInfo")]
+ public ActionResult GetApprovalInfo()
+ {
+ CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
+ if (currentUser.UserType == EnumUserType.Employee)
+ {
+ return NotAllowed();
+ }
+ try
+ {
+ return Ok(this._lfaPaymentService.GetApprovalInfo(currentUser.EmployeeID));
+ }
+ catch (Exception ex)
+ {
+ return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
+ }
+ }
+
+ [HttpGet("getApprovalBatches")]
+ public ActionResult GetApprovalBatches()
+ {
+ CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
+ if (currentUser.UserType == EnumUserType.Employee)
+ {
+ return NotAllowed();
+ }
+ try
+ {
+ return Ok(this._lfaPaymentService.GetApprovalBatches(currentUser.PayrollTypeID.GetValueOrDefault()));
+ }
+ catch (Exception ex)
+ {
+ return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
+ }
+ }
+
+ [HttpGet("getFlowHistory/{lfaPaymentID}")]
+ public ActionResult GetFlowHistory(int lfaPaymentID)
+ {
+ CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
+ if (currentUser.UserType == EnumUserType.Employee)
+ {
+ return NotAllowed();
+ }
+ try
+ {
+ return Ok(this._lfaPaymentService.GetFlowHistory(lfaPaymentID, currentUser.PayrollTypeID.GetValueOrDefault()));
+ }
+ catch (Exception ex)
+ {
+ return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
+ }
+ }
+
+ ///
Direct Approve, when the workflow is off.
+ [HttpPost("approveDirect")]
+ public ActionResult ApproveDirect(LFAApprovalRequest request)
+ {
+ CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
+ if (currentUser.UserType == EnumUserType.Employee)
+ {
+ return NotAllowed();
+ }
+ try
+ {
+ return Ok(this._lfaPaymentService.ApproveDirect(request, currentUser.PayrollTypeID.GetValueOrDefault(), currentUser.UserID));
+ }
+ catch (Exception ex)
+ {
+ return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
+ }
+ }
+
+ ///
Submit for approval (or submit again after a revert), when the workflow is on.
+ [HttpPost("submitForApproval")]
+ public ActionResult SubmitForApproval(LFAApprovalRequest request)
+ {
+ CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
+ if (currentUser.UserType == EnumUserType.Employee)
+ {
+ return NotAllowed();
+ }
+ try
+ {
+ return Ok(this._lfaPaymentService.SubmitForApproval(request, currentUser.PayrollTypeID.GetValueOrDefault(),
+ currentUser.EmployeeID, currentUser.UserID));
+ }
+ catch (Exception ex)
+ {
+ return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
+ }
+ }
+
+ // The approver's side (/payment-approval/lfa). Approvers act as employees, as on Salary's Payment Approval
+ // page, so these are open to every login; the service checks that the step is pending with the login.
+
+ [HttpGet("getApproverBatch/{wfMovementTranID}")]
+ public ActionResult GetApproverBatch(int wfMovementTranID)
+ {
+ CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
+ try
+ {
+ return Ok(this._lfaPaymentService.GetApproverBatch(wfMovementTranID, currentUser.EmployeeID));
+ }
+ catch (Exception ex)
+ {
+ return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
+ }
+ }
+
+ [HttpPost("approveFromApprover")]
+ public ActionResult ApproveFromApprover(LFAApproverActionRequest request)
+ {
+ CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
+ try
+ {
+ return Ok(this._lfaPaymentService.ApproveFromApprover(request, currentUser.EmployeeID, currentUser.UserID));
+ }
+ catch (Exception ex)
+ {
+ return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
+ }
+ }
+
+ [HttpPost("revertFromApprover")]
+ public ActionResult RevertFromApprover(LFAApproverActionRequest request)
+ {
+ CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
+ try
+ {
+ return Ok(this._lfaPaymentService.RevertFromApprover(request, currentUser.EmployeeID));
+ }
+ catch (Exception ex)
+ {
+ return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
+ }
+ }
+
private ActionResult NotAllowed()
{
return StatusCode(StatusCodes.Status403Forbidden, "You are not allowed to process LFA payment.");