This commit is contained in:
Mohaimen Hasan 2026-11-29 09:56:57 +06:00
parent fa8c19b209
commit 4be77e5433
16 changed files with 41 additions and 137 deletions

View File

@ -4,18 +4,6 @@ using System.IO;
namespace HRM.BO
{
#region Enums
/// <summary>LFAPaymentDetail.PaymentStatus.</summary>
public enum EnumLFAPaymentStatus
{
Pending = 1,
Paid = 2,
Failed = 3
}
#endregion
#region LFAPayment
/// <summary>One Leave Fare Assistance payment batch (dbo.LFAPayment), as SalaryProcess is for the salary.</summary>
@ -76,11 +64,6 @@ namespace HRM.BO
/// <summary>One employee of a batch (dbo.LFAPaymentDetail): a snapshot of the employee and of the calculation.</summary>
public class LFAPaymentDetail : AuditTrailBase
{
public LFAPaymentDetail()
{
PaymentStatus = EnumLFAPaymentStatus.Pending;
}
public int LFAPaymentID { get; set; }
public int EmployeeID { get; set; }
public DateTime LFAYear { get; set; }
@ -109,7 +92,6 @@ namespace HRM.BO
public double Amount { get; set; }
public string Remarks { get; set; }
public EnumLFAPaymentStatus PaymentStatus { get; set; }
}
#endregion

View File

@ -17,7 +17,6 @@ namespace HRM.BO
public enumwfStatus? WFStatus { get; set; }
public bool IsTaxUpdated { get; set; }
public int HeadCount { get; set; }
public int PaidCount { get; set; }
public double TotalAmount { get; set; }
public string CreatedByName { get; set; }
public DateTime CreationDate { get; set; }
@ -51,7 +50,6 @@ namespace HRM.BO
public DateTime JoiningDate { get; set; }
public double BasicSalary { get; set; }
public double Amount { get; set; }
public EnumLFAPaymentStatus PaymentStatus { get; set; }
}
/// <summary>What to undo: the whole batch (no DetailIDs) or only these employees of it.</summary>

View File

@ -143,7 +143,6 @@ namespace HRM.BO
public DateTime JoiningDate { get; set; }
public double BasicSalary { get; set; }
public double Amount { get; set; }
public EnumLFAPaymentStatus PaymentStatus { get; set; }
}
#endregion

View File

@ -106,7 +106,7 @@ namespace HRM.DA
@"SELECT p.LFAPaymentID, p.BatchNumber, p.SalaryMonth, p.LFAYear, p.PaymentDate, p.Remarks, p.WFStatus,
p.IsTaxUpdated, p.CreationDate, ISNULL(u.UserName, u.LoginID) AS CreatedByName,
p.ApprovedDate, ISNULL(ua.UserName, ua.LoginID) AS ApprovedByName,
ISNULL(s.HeadCount, 0) AS HeadCount, ISNULL(s.PaidCount, 0) AS PaidCount,
ISNULL(s.HeadCount, 0) AS HeadCount,
ISNULL(s.TotalAmount, 0) AS TotalAmount,
lt.WFMOVEMENTTRANID AS WFMovementTranID, lt.UNIQUENUMBER AS UniqueNumber,
CASE WHEN EXISTS (SELECT 1 FROM WFMOVEMENTNEXT n
@ -117,8 +117,7 @@ namespace HRM.DA
WHERE n.WFMOVEMENTTRANID = lt.WFMOVEMENTTRANID AND n.STATUS = %n
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 2, '') AS PendingWith
FROM LFAPayment p
LEFT JOIN (SELECT dt.LFAPaymentID, COUNT(*) AS HeadCount, SUM(dt.Amount) AS TotalAmount,
SUM(CASE WHEN dt.PaymentStatus = %n THEN 1 ELSE 0 END) AS PaidCount
LEFT JOIN (SELECT dt.LFAPaymentID, COUNT(*) AS HeadCount, SUM(dt.Amount) AS TotalAmount
FROM LFAPaymentDetail dt GROUP BY dt.LFAPaymentID) s ON s.LFAPaymentID = p.LFAPaymentID
LEFT JOIN Users u ON u.UserID = p.CreatedBy
LEFT JOIN Users ua ON ua.UserID = p.ApprovedBy
@ -129,7 +128,7 @@ namespace HRM.DA
WHERE f.UNIQUENUMBER = lt.UNIQUENUMBER ORDER BY f.WFMOVEMENTTRANID) it
WHERE p.PayrollTypeID=%n
ORDER BY p.PaymentDate DESC, p.LFAPaymentID DESC",
(int)EnumwfStatus.Received, (int)EnumwfStatus.Received, (int)EnumLFAPaymentStatus.Paid,
(int)EnumwfStatus.Received, (int)EnumwfStatus.Received,
LFAPaymentApproval.WFTypeID, payrollTypeID);
}
@ -265,12 +264,12 @@ namespace HRM.DA
effectdate);
}
/// <summary>Payment History tab: every paid employee of the payment date range.</summary>
/// <summary>Payment History tab: every employee of the batches of the payment date range.</summary>
internal static IDataReader GetHistory(TransactionContext tc, DateTime fromDate, DateTime toDate, int payrollTypeID)
{
return tc.ExecuteReader(
@"SELECT dt.LFAPaymentDetailID, p.BatchNumber, p.PaymentDate, e.EMPLOYEENO, e.NAME, ds.NAME AS DesignationName,
d.DESCRIPTION AS DepartmentName, dt.JoiningDate, dt.BasicSalary, dt.Amount, dt.PaymentStatus
d.DESCRIPTION AS DepartmentName, dt.JoiningDate, dt.BasicSalary, dt.Amount
FROM LFAPayment p
INNER JOIN LFAPaymentDetail dt ON dt.LFAPaymentID = p.LFAPaymentID
INNER JOIN EMPLOYEE e ON e.EMPLOYEEID = dt.EmployeeID

View File

@ -50,7 +50,6 @@ namespace HRM.DA
table.Columns.Add("CalculatedAmount", typeof(decimal));
table.Columns.Add("Amount", typeof(decimal));
table.Columns.Add("Remarks", typeof(string));
table.Columns.Add("PaymentStatus", typeof(byte));
table.Columns.Add("CreatedBy", typeof(int));
table.Columns.Add("CreationDate", typeof(DateTime));
@ -60,7 +59,7 @@ namespace HRM.DA
Null(item.ConfirmationDate), Null(item.GradeID), Null(item.DesignationID), Null(item.DepartmentID),
Null(item.CostCenterID), Null(item.BranchID), Null(item.AccountNo), Null(Money(item.JoiningBasic)),
Null(Money(item.LastDecBasic)), Money(item.BasicSalary), Money(item.CalculatedAmount),
Money(item.Amount), Null(item.Remarks), (byte)item.PaymentStatus, item.CreatedBy, item.CreatedDate);
Money(item.Amount), Null(item.Remarks), item.CreatedBy, item.CreatedDate);
}
using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection, SqlBulkCopyOptions.CheckConstraints,
@ -99,7 +98,7 @@ namespace HRM.DA
{
return tc.ExecuteReader(
@"SELECT dt.LFAPaymentDetailID, dt.EmployeeID, e.EMPLOYEENO, e.NAME, ds.NAME AS DesignationName,
d.DESCRIPTION AS DepartmentName, dt.JoiningDate, dt.BasicSalary, dt.Amount, dt.PaymentStatus
d.DESCRIPTION AS DepartmentName, dt.JoiningDate, dt.BasicSalary, dt.Amount
FROM LFAPaymentDetail dt
INNER JOIN EMPLOYEE e ON e.EMPLOYEEID = dt.EmployeeID
LEFT JOIN DESIGNATION ds ON ds.DESIGNATIONID = dt.DesignationID

View File

@ -65,7 +65,6 @@ namespace HRM.DA
oDetail.CalculatedAmount = oReader.GetDouble("CalculatedAmount").Value;
oDetail.Amount = oReader.GetDouble("Amount").Value;
oDetail.Remarks = oReader.GetString("Remarks");
oDetail.PaymentStatus = (EnumLFAPaymentStatus)oReader.GetInt32("PaymentStatus").Value;
oDetail.CreatedBy = oReader.GetInt32("CreatedBy").Value;
oDetail.CreatedDate = oReader.GetDateTime("CreationDate").Value;
oDetail.ModifiedBy = oReader.GetInt32("ModifiedBy");
@ -113,7 +112,6 @@ namespace HRM.DA
history.JoiningDate = oReader.GetDateTime("JoiningDate").Value;
history.BasicSalary = oReader.GetDouble("BasicSalary").Value;
history.Amount = oReader.GetDouble("Amount").Value;
history.PaymentStatus = (EnumLFAPaymentStatus)oReader.GetInt32("PaymentStatus").Value;
return history;
}
@ -131,7 +129,6 @@ namespace HRM.DA
batch.CreationDate = oReader.GetDateTime("CreationDate").Value;
batch.CreatedByName = oReader.GetString("CreatedByName");
batch.HeadCount = oReader.GetInt32("HeadCount").Value;
batch.PaidCount = oReader.GetInt32("PaidCount").Value;
batch.TotalAmount = oReader.GetDouble("TotalAmount").Value;
batch.ApprovedDate = oReader.GetDateTime("ApprovedDate");
batch.ApprovedByName = oReader.GetString("ApprovedByName");
@ -141,7 +138,7 @@ namespace HRM.DA
batch.PendingWith = oReader.GetString("PendingWith");
batch.StatusText = StatusText(batch.WFStatus, batch.IsAtInitiator);
batch.UndoBlockedReason = UndoBlockedReason(batch.WFStatus, batch.IsTaxUpdated, batch.PaidCount, batch.IsAtInitiator);
batch.UndoBlockedReason = UndoBlockedReason(batch.WFStatus, batch.IsTaxUpdated, batch.IsAtInitiator);
batch.CanUndo = batch.UndoBlockedReason == null;
return batch;
}
@ -158,7 +155,6 @@ namespace HRM.DA
employee.JoiningDate = oReader.GetDateTime("JoiningDate").Value;
employee.BasicSalary = oReader.GetDouble("BasicSalary").Value;
employee.Amount = oReader.GetDouble("Amount").Value;
employee.PaymentStatus = (EnumLFAPaymentStatus)oReader.GetInt32("PaymentStatus").Value;
return employee;
}
@ -651,8 +647,8 @@ namespace HRM.DA
/// <summary>
/// Undoes the whole batch (request.DetailIDs empty) or only those employees of it, in ONE transaction.
/// Everything is checked again here with the batch locked: a batch submitted for approval, approved,
/// already in the tax data or with a paid employee is not undone. When the last employee goes, the
/// Everything is checked again here with the batch locked: a batch submitted for approval, approved
/// or already in the tax data is not undone. When the last employee goes, the
/// batch goes too. The undone employees can then be paid again in another batch.
/// </summary>
public LFAPaymentUndoResult Undo(LFAPaymentUndoRequest request, int payrollTypeID, int userID)
@ -695,8 +691,7 @@ namespace HRM.DA
List<LFAPaymentDetail> selected = wholeBatch ? details : details.Where(x => detailIDs.Contains(x.ID)).ToList();
bool isAtInitiator = GetIsAtInitiator(tc, oPayment.ID);
string blocked = UndoBlockedReason(oPayment.WFStatus, oPayment.IsTaxUpdated,
selected.Count(x => x.PaymentStatus == EnumLFAPaymentStatus.Paid), isAtInitiator);
string blocked = UndoBlockedReason(oPayment.WFStatus, oPayment.IsTaxUpdated, isAtInitiator);
if (blocked != null)
{
result.Message = blocked;
@ -745,7 +740,7 @@ namespace HRM.DA
/// Why a batch cannot be undone; null when it can. As Salary Undo: allowed before the batch is
/// submitted for approval, and when an approver has reverted it back to the person who submitted it.
/// </summary>
private static string UndoBlockedReason(enumwfStatus? wfStatus, bool isTaxUpdated, int paidCount, bool isAtInitiator)
private static string UndoBlockedReason(enumwfStatus? wfStatus, bool isTaxUpdated, bool isAtInitiator)
{
if (wfStatus == enumwfStatus.Approve)
return "The batch is already approved.";
@ -754,8 +749,6 @@ namespace HRM.DA
return "The batch is submitted and pending for approval.";
if (isTaxUpdated)
return "The batch is already in the income tax data.";
if (paidCount > 0)
return paidCount + " employee(s) of the batch are already paid.";
return null;
}

View File

@ -1,11 +1,5 @@
// LFA Payment (HRM.BO/LFA)
export enum EnumLFAPaymentStatus {
Pending = 1,
Paid = 2,
Failed = 3
}
/** One uploaded row: what the user gives. Every amount is worked out by the server. */
export class LFAPaymentInput {
rowNo: number;
@ -76,9 +70,6 @@ export class LFAPaymentHistory {
joiningDate: Date;
basicSalary: number;
amount: number;
paymentStatus: EnumLFAPaymentStatus;
// filled on the page
statusText: string;
}
// ── LFA Payment Undo ──
@ -94,7 +85,6 @@ export class LFAPaymentBatch {
wfStatus: number;
isTaxUpdated: boolean;
headCount: number;
paidCount: number;
totalAmount: number;
createdByName: string;
creationDate: Date;
@ -121,9 +111,6 @@ export class LFAPaymentBatchEmployee {
joiningDate: Date;
basicSalary: number;
amount: number;
paymentStatus: EnumLFAPaymentStatus;
// filled on the page
statusText: string;
}
/** detailIDs empty = the whole batch. */

View File

@ -8,7 +8,7 @@ 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
LFAApprovalResult, LFAApproverBatch, LFAPaymentBatchEmployee
} from 'src/app/_models/Payroll/lfaPayment';
/**
@ -58,8 +58,7 @@ export class LfaApprovalComponent implements OnInit {
this.data = resp;
this.employees = (resp && resp.employees || []).map(x => ({
...x,
joiningDate: this.toDate(x.joiningDate),
statusText: this.paymentStatusText(x.paymentStatus)
joiningDate: this.toDate(x.joiningDate)
}));
if (resp && resp.batch) {
resp.batch.paymentDate = this.toDate(resp.batch.paymentDate);
@ -138,14 +137,6 @@ export class LfaApprovalComponent implements OnInit {
}
}
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;

View File

@ -84,7 +84,6 @@
<kendo-grid-column field="joiningDate" title="Joining Date" [width]="125" format="dd-MMM-yyyy"></kendo-grid-column>
<kendo-grid-column field="basicSalary" title="Basic Salary" [width]="135" format="n2" [style]="{ 'text-align': 'right' }" [headerStyle]="{ 'text-align': 'right', 'justify-content': 'flex-end' }"></kendo-grid-column>
<kendo-grid-column field="amount" title="LFA Amount" [width]="135" format="n2" [style]="{ 'text-align': 'right', 'font-weight': '600' }" [headerStyle]="{ 'text-align': 'right', 'justify-content': 'flex-end' }"></kendo-grid-column>
<kendo-grid-column field="statusText" title="Payment Status" [width]="130"></kendo-grid-column>
<ng-template kendoGridNoRecordsTemplate>No employee in this batch.</ng-template>
<kendo-grid-excel fileName="LFA-Batch-Employees.xlsx" [fetchData]="allEmployees"></kendo-grid-excel>
</kendo-grid>

View File

@ -6,7 +6,7 @@ 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
LFAApprovalInfo, LFAApprovalResult, LFAPaymentBatch, LFAPaymentBatchEmployee
} from '../../_models/Payroll/lfaPayment';
/**
@ -93,8 +93,7 @@ export class LfaPaymentApprovalComponent implements OnInit {
next: (resp) => {
this.employees = (resp || []).map(x => ({
...x,
joiningDate: this.toDate(x.joiningDate),
statusText: this.paymentStatusText(x.paymentStatus)
joiningDate: this.toDate(x.joiningDate)
}));
if (!batch.wfMovementTranID) {
this.stop();
@ -213,14 +212,6 @@ export class LfaPaymentApprovalComponent implements OnInit {
// ── 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;

View File

@ -67,7 +67,6 @@
<kendo-grid-column field="joiningDate" title="Joining Date" [width]="125" format="dd-MMM-yyyy"></kendo-grid-column>
<kendo-grid-column field="basicSalary" title="Basic Salary" [width]="135" format="n2" [style]="{ 'text-align': 'right' }" [headerStyle]="{ 'text-align': 'right', 'justify-content': 'flex-end' }"></kendo-grid-column>
<kendo-grid-column field="amount" title="LFA Amount" [width]="135" format="n2" [style]="{ 'text-align': 'right', 'font-weight': '600' }" [headerStyle]="{ 'text-align': 'right', 'justify-content': 'flex-end' }"></kendo-grid-column>
<kendo-grid-column field="statusText" title="Payment Status" [width]="130"></kendo-grid-column>
<ng-template kendoGridNoRecordsTemplate>No employee in this batch.</ng-template>
<kendo-grid-excel fileName="LFA-Batch-Employees.xlsx" [fetchData]="allEmployees"></kendo-grid-excel>
</kendo-grid>

View File

@ -5,7 +5,7 @@ import { HRMNotificationService } from '../../app.notification.service';
import { loadingPanelService } from '../../hrm-loding panel/loding.panel.service';
import { LFAService } from '../../_services/payroll/lfa.service';
import {
EnumLFAPaymentStatus, LFAPaymentBatch, LFAPaymentBatchEmployee, LFAPaymentUndoRequest, LFAPaymentUndoResult
LFAPaymentBatch, LFAPaymentBatchEmployee, LFAPaymentUndoRequest, LFAPaymentUndoResult
} from '../../_models/Payroll/lfaPayment';
/**
@ -77,8 +77,7 @@ export class LfaPaymentUndoComponent implements OnInit {
this.stop();
this.employees = (resp || []).map(x => ({
...x,
joiningDate: this.toDate(x.joiningDate),
statusText: this.paymentStatusText(x.paymentStatus)
joiningDate: this.toDate(x.joiningDate)
}));
},
error: (err) => this.fail(err, 'Could not load the employees of the batch.')
@ -171,14 +170,6 @@ export class LfaPaymentUndoComponent implements OnInit {
// ── 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;

View File

@ -141,10 +141,6 @@
<label>End Date <span class="lfa-required">*</span></label>
<kendo-datepicker [format]="'dd-MMM-yyyy'" [(ngModel)]="historyTo"></kendo-datepicker>
</div>
<div class="lfa-field">
<label>Status</label>
<kendo-dropdownlist [data]="historyStatuses" [(ngModel)]="historyStatus" (valueChange)="historyStatus = $event; filterHistory()"></kendo-dropdownlist>
</div>
<div class="lfa-field">
<label>Department</label>
<kendo-dropdownlist [data]="historyDepartments" [(ngModel)]="historyDepartment" (valueChange)="historyDepartment = $event; filterHistory()"></kendo-dropdownlist>
@ -176,12 +172,6 @@
<kendo-grid-column field="amount" title="LFA Amount" [width]="130" format="n2" [style]="{ 'text-align': 'right', 'font-weight': '600' }" [headerStyle]="{ 'text-align': 'right', 'justify-content': 'flex-end' }">
<ng-template kendoGridFooterTemplate><div class="lfa-right">{{ historyTotalAmount | number: '1.2-2' }}</div></ng-template>
</kendo-grid-column>
<kendo-grid-column field="statusText" title="Payment Status" [width]="130">
<ng-template kendoGridCellTemplate let-dataItem>
<span class="lfa-badge" [class.lfa-badge--paid]="dataItem.statusText === 'Paid'"
[class.lfa-badge--failed]="dataItem.statusText === 'Failed'">{{ dataItem.statusText }}</span>
</ng-template>
</kendo-grid-column>
<ng-template kendoGridNoRecordsTemplate>No records found.</ng-template>
<kendo-grid-excel fileName="LFA-Payment-History.xlsx" [fetchData]="allHistoryRows"></kendo-grid-excel>
</kendo-grid>

View File

@ -104,26 +104,6 @@
text-align: right;
}
.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--paid {
color: var(--gh-ok);
background: color-mix(in srgb, var(--gh-ok) 15%, transparent);
}
.lfa-badge--failed {
color: var(--gh-dn);
background: color-mix(in srgb, var(--gh-dn) 15%, transparent);
}
.lfa-confirm {
width: 100%;

View File

@ -7,7 +7,7 @@ import { HRMNotificationService } from '../../app.notification.service';
import { loadingPanelService } from '../../hrm-loding panel/loding.panel.service';
import { LFAService } from '../../_services/payroll/lfa.service';
import {
EnumLFAPaymentStatus, LFAPaymentHistory, LFAPaymentInfo, LFAPaymentInput, LFAPaymentIssue,
LFAPaymentHistory, LFAPaymentInfo, LFAPaymentInput, LFAPaymentIssue,
LFAPaymentProcessResult, LFAPaymentReadResult, LFAPaymentRequest, LFAPaymentRow
} from '../../_models/Payroll/lfaPayment';
@ -28,7 +28,6 @@ export class LfaPaymentComponent implements OnInit {
readonly maxFileSizeMB = 10;
readonly allDepartments = 'All departments';
readonly allStatuses = 'All statuses';
selectedTab = 0;
info: LFAPaymentInfo = null;
@ -59,9 +58,7 @@ export class LfaPaymentComponent implements OnInit {
historyFrom: Date = new Date(new Date().getFullYear(), 0, 1);
historyTo: Date = this.today();
historySearch = '';
historyStatus = this.allStatuses;
historyDepartment = this.allDepartments;
historyStatuses = [this.allStatuses, 'Pending', 'Paid', 'Failed'];
historyDepartments = [this.allDepartments];
history: LFAPaymentHistory[] = [];
historyRows: LFAPaymentHistory[] = [];
@ -313,8 +310,7 @@ export class LfaPaymentComponent implements OnInit {
this.history = (resp || []).map(x => ({
...x,
paymentDate: this.toDate(x.paymentDate),
joiningDate: this.toDate(x.joiningDate),
statusText: EnumLFAPaymentStatus[x.paymentStatus]
joiningDate: this.toDate(x.joiningDate)
}));
this.historyDepartments = [this.allDepartments].concat(
Array.from(new Set(this.history.map(x => x.departmentName).filter(x => !!x))).sort());
@ -330,16 +326,13 @@ export class LfaPaymentComponent implements OnInit {
filterHistory() {
const search = (this.historySearch || '').trim().toLowerCase();
this.historyRows = this.history.filter(x =>
(this.historyStatus === this.allStatuses || x.statusText === this.historyStatus)
&& (this.historyDepartment === this.allDepartments || x.departmentName === this.historyDepartment)
(this.historyDepartment === this.allDepartments || x.departmentName === this.historyDepartment)
&& (!search || [x.batchNumber, x.employeeNo, x.name, x.designationName, x.departmentName]
.some(v => (v || '').toLowerCase().indexOf(search) >= 0)));
this.historyTotalBasic = this.sum(this.historyRows, x => x.basicSalary);
this.historyTotalAmount = this.sum(this.historyRows, x => x.amount);
const count = (status: EnumLFAPaymentStatus) => this.historyRows.filter(x => x.paymentStatus === status).length;
this.historySummary = 'Total ' + this.historyRows.length + ' records · '
+ new Set(this.historyRows.map(x => x.batchNumber)).size + ' batch(es) · Paid ' + count(EnumLFAPaymentStatus.Paid)
+ ' · Pending ' + count(EnumLFAPaymentStatus.Pending) + ' · Failed ' + count(EnumLFAPaymentStatus.Failed);
+ new Set(this.historyRows.map(x => x.batchNumber)).size + ' batch(es)';
}
allHistoryRows = (): ExcelExportData => ({ data: this.historyRows });
@ -357,13 +350,12 @@ export class LfaPaymentComponent implements OnInit {
const money = (n: number) => this.money(n);
const cells = (values: any[], tag: string) => values.map(v => '<' + tag + '>' + this.escape(v) + '</' + tag + '>').join('');
const body = this.historyRows.map(x => '<tr>' + cells([x.batchNumber, this.displayDate(x.paymentDate), x.employeeNo, x.name,
x.designationName, x.departmentName, this.displayDate(x.joiningDate), money(x.basicSalary), money(x.amount),
x.statusText], 'td') + '</tr>').join('');
x.designationName, x.departmentName, this.displayDate(x.joiningDate), money(x.basicSalary), money(x.amount)], 'td') + '</tr>').join('');
w.document.write('<html><head><title>LFA Payment History</title><style>body{font-family:Arial;font-size:12px}'
+ 'table{border-collapse:collapse;width:100%}th,td{border:1px solid #999;padding:4px;text-align:left}</style></head><body>'
+ '<h3>LFA Payment History (' + this.displayDate(this.historyFrom) + ' - ' + this.displayDate(this.historyTo) + ')</h3><table><thead><tr>'
+ cells(['Batch ID', 'Payment Date', 'Employee ID', 'Name', 'Designation', 'Department', 'Joining Date', 'Basic Salary',
'LFA Amount', 'Payment Status'], 'th')
'LFA Amount'], 'th')
+ '</tr></thead><tbody>' + body + '</tbody></table><p>' + this.escape(this.historySummary) + ' · LFA Amount '
+ money(this.historyTotalAmount) + '</p></body></html>');
w.document.close();

View File

@ -125,7 +125,6 @@ CREATE TABLE dbo.LFAPaymentDetail (
Amount MONEY NOT NULL CONSTRAINT DF_LFAPayDtl_Amount DEFAULT (0), -- LFA amount to pay
Remarks NVARCHAR(500) NULL,
PaymentStatus TINYINT NOT NULL CONSTRAINT DF_LFAPayDtl_PaymentStatus DEFAULT (1), -- 1 Pending, 2 Paid, 3 Failed
CreatedBy INT NOT NULL,
CreationDate DATETIME NOT NULL,
ModifiedBy INT NULL,
@ -133,8 +132,7 @@ CREATE TABLE dbo.LFAPaymentDetail (
CONSTRAINT PK_LFAPaymentDetail PRIMARY KEY (LFAPaymentDetailID),
CONSTRAINT FK_LFAPayDtl_Payment FOREIGN KEY (LFAPaymentID) REFERENCES dbo.LFAPayment (LFAPaymentID),
CONSTRAINT CK_LFAPayDtl_Amount CHECK (Amount >= 0),
CONSTRAINT CK_LFAPayDtl_PaymentStatus CHECK (PaymentStatus IN (1, 2, 3))
CONSTRAINT CK_LFAPayDtl_Amount CHECK (Amount >= 0)
);
GO
/* policy: LFA once in a calendar year (Undo deletes the rows, which frees the employee again) */
@ -146,3 +144,19 @@ GO
SET NOEXEC OFF;
GO
/* ---------- 4. Drop LFAPaymentDetail.PaymentStatus (no longer used) ----------
Runs even when Part 0 refused (the tables hold data): a database that already
has the column loses it, with its default and check constraints. Re-runnable. */
IF OBJECT_ID(N'dbo.CK_LFAPayDtl_PaymentStatus', N'C') IS NOT NULL
ALTER TABLE dbo.LFAPaymentDetail DROP CONSTRAINT CK_LFAPayDtl_PaymentStatus;
GO
IF OBJECT_ID(N'dbo.DF_LFAPayDtl_PaymentStatus', N'D') IS NOT NULL
ALTER TABLE dbo.LFAPaymentDetail DROP CONSTRAINT DF_LFAPayDtl_PaymentStatus;
GO
IF COL_LENGTH(N'dbo.LFAPaymentDetail', N'PaymentStatus') IS NOT NULL
BEGIN
ALTER TABLE dbo.LFAPaymentDetail DROP COLUMN PaymentStatus;
PRINT 'LFAPaymentDetail.PaymentStatus dropped.';
END
GO