Category Wise Salary Process

This commit is contained in:
Mohaimen Hasan 2026-11-29 18:51:10 +06:00
parent f3ff0cd16a
commit 16f6a635fd
9 changed files with 173 additions and 23 deletions

View File

@ -462,6 +462,7 @@ namespace HRM.BO
bool GetBySMonth(DateTime sMonth, int payrollTypeID);
List<SalaryProcessStatus> SalaryProcess(SalaryProcess item, List<Employee> employees);
List<int> GetCategoryEmployeeIDs(int categoryID, int payrollTypeID, DateTime salaryMonth);
int Save(SalaryProcess item);
void Delete(int id);

View File

@ -89,28 +89,38 @@ namespace HRM.BO
public EnumIncomeTaxItemGroup ItemGroup { get; set; }
public EnumIncomeTaxSide Side { get; set; }
//#region Service Factory IIncomeTaxService : IIncomeTaxService
//#region Service Factory IIncomeTaxService : IIncomeTaxService
//internal static IIncomeTaxService Service
//{
// get { return Services.Factory.CreateService<IIncomeTaxService>(typeof(IIncomeTaxService)); }
//}
//internal static IIncomeTaxService Service
//{
// get { return Services.Factory.CreateService<IIncomeTaxService>(typeof(IIncomeTaxService)); }
//}
//#endregion
//#endregion
#endregion
public string getEmpID(List<IncomeTax> items)
#endregion
//public string getEmpID(List<IncomeTax> items)
//{
// string str = "";
// items.ForEach(x =>
// {
// if (x != null)
// str = str + x.EmployeeID + ",";
// });
// if (str.Length > 0) str = str.Substring(0, str.Length - 1);
// return str;
//}
// Comma-separated employee IDs of the rows, for "employeeID IN (...)".
// Each employee once: income-tax data has many rows per employee, and building the string by
// repeated concatenation made Bonus Approve take minutes on a large payroll.
public string getEmpID(List<IncomeTax> items)
{
string str = "";
items.ForEach(x =>
{
if (x != null)
str = str + x.EmployeeID + ",";
});
if (str.Length > 0) str = str.Substring(0, str.Length - 1);
return str;
return string.Join(",", items.Where(x => x != null).Select(x => x.EmployeeID).Distinct());
}

View File

@ -21,6 +21,20 @@ namespace HRM.DA
#endregion
#region Category employees (Salary Process screen, no employee selected)
// Live employees of the payroll type in the category whose salary of the month is not processed yet
internal static IDataReader GetCategoryEmployeeIDs(TransactionContext tc, int categoryID, int payrollTypeID, DateTime salaryMonth)
{
return tc.ExecuteReader(
"SELECT e.EmployeeID FROM Employee e WHERE e.Status=%n AND e.PayrollTypeID=%n AND e.CategoryID=%n" +
" AND NOT EXISTS (SELECT 1 FROM SalaryMonthly sm WHERE sm.EmployeeID = e.EmployeeID AND sm.SalaryMonth=%d AND sm.PayrollTypeID=%n)" +
" ORDER BY e.EmployeeNo",
(int)EnumEmployeeStatus.Live, payrollTypeID, categoryID, salaryMonth, payrollTypeID);
}
#endregion
#region Insert function
internal static void Insert(TransactionContext tc, SalaryProcess item)

View File

@ -339,6 +339,35 @@ namespace HRM.DA
}
return errorList;
}
// Salary Process screen, no employee selected but a Category: the Live employees of the payroll type in
// that category whose salary of the month is not processed yet (the employee picker leaves those out too)
public List<int> GetCategoryEmployeeIDs(int categoryID, int payrollTypeID, DateTime salaryMonth)
{
List<int> employeeIDs = new List<int>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(SalaryProcessDA.GetCategoryEmployeeIDs(tc, categoryID, payrollTypeID, salaryMonth));
while (dr.Read())
{
employeeIDs.Add(dr.GetInt32("EmployeeID").Value);
}
dr.Close();
tc.End();
}
catch (Exception e)
{
#region Handle Exception
if (tc != null)
tc.HandleError();
ExceptionLog.Write(e);
throw new ServiceException(e.Message, e);
#endregion
}
return employeeIDs;
}
public List<SalaryProcessStatus> SalaryProcess(SalaryProcess item, List<Employee> employees)
{
try

View File

@ -207,6 +207,11 @@ export class SalaryService {
return this.apiService.httpPost<SalaryProcessStatus[]>('/salary/salaryValidation', params);
}
// Salary Process screen: employees of a category (payroll type wise, Live, salary not processed yet)
getCategoryEmployeeIDsForSalary(categoryID: number) {
return this.apiService.httpGet<number[]>('/salary/getCategoryEmployeeIDsForSalary/' + categoryID);
}
salaryProcess(params: any) {
return this.apiService.httpPost<SalaryProcessStatus[]>('/salary/SalaryProcess', params);
}

View File

@ -1,3 +1,5 @@
<!-- page-level spinner (Approve / Submit / attachments); the other loading panels are inside the pop-up windows -->
<app-loading-panel></app-loading-panel>
<div class="bm-head">
<span class="bm-head__icon"><i class="pi pi-calendar"></i></span>
<div class="bm-head__text">

View File

@ -33,6 +33,7 @@
</kendo-datepicker>
</div>
</div>
<!-- Euro Rate is not used any more (euroRate stays 0 and is still sent with the process request)
<div class="col-12 md:col-4">
<div class="col-12 padding-bottom-zero">
<label>Euro Rate</label>
@ -43,6 +44,24 @@
</kendo-numerictextbox>
</div>
</div>
-->
<div class="col-12 md:col-4">
<div class="col-12 padding-bottom-zero">
<label>Category</label>
</div>
<div class="col-12">
<!-- no employee selected + a Category: the salary of that category's employees is processed -->
<kendo-dropdownlist [(ngModel)]="selectedCategoryID"
[data]="categories"
[defaultItem]="{ name: 'Select Category', id: null }"
[textField]="'name'"
[valueField]="'id'"
[valuePrimitive]="true"
formControlName="category"
style="width:100%">
</kendo-dropdownlist>
</div>
</div>
</div>
<div class="grid">
<div class="col-12">
@ -143,7 +162,12 @@
<div class="grid">
<div class="col-12">
<kendo-grid [data]="errorOrSucessList">
<!-- virtual scrolling: only the rows in view are drawn, so a long error list does not slow the page -->
<kendo-grid [kendoGridBinding]="errorOrSucessList ?? []"
scrollable="virtual"
[rowHeight]="36"
[height]="450"
[pageSize]="50">
<kendo-grid-column field="employeeNo" title="EmployeeID">
</kendo-grid-column>
<kendo-grid-column field="name" title="Name">

View File

@ -6,6 +6,8 @@ import {DataTransferService} from '../../../data.transfer.service';
import {loadingPanelService} from '../../../hrm-loding panel/loding.panel.service';
import {PayrollType} from '../../../_models/Authentication/payrollType';
import {SearchEmployee} from '../../../_models/Employee/searchEmployee';
import {Category} from '../../../_models/Basic/category';
import {EnumStatus} from '../../../_models/enums';
import {SalaryProcessStatus, SalaryProcessSummaryItem} from '../../../_models/Payroll/salaryProcess';
import {AuthService} from '../../../_services/auth/auth.service';
import {BasicService} from '../../../_services/Basic/basic.service';
@ -42,6 +44,9 @@ export class SalaryProcessComponent implements OnInit {
returnMessage: string = '';
processRequest: { paymentDate: Date, remarks: string, empid: number, euroRate: number }[];
euroRate = 0;
// Category: when no employee is selected, the salary of this category's employees is processed
categories: Category[] = [];
selectedCategoryID: number = null;
// Salary summary panel (collapsed by default, loaded on first expand per salary month)
showSummary: boolean = false;
@ -75,6 +80,15 @@ export class SalaryProcessComponent implements OnInit {
this.pbuttonEnalble = true;
this.createFrom();
// categories of the current payroll type (the API filters by the login's payroll type)
this.basicDataService.getAllCategory(EnumStatus.Active).subscribe(
(resp: Category[]) => {
this.categories = resp || [];
},
(err: any) => {
this.notificationService.showError(err.error);
});
this.authservice.GetPayrollTypeByLoginID().subscribe(
(resp: any) => {
this.payrollType = resp;
@ -170,6 +184,7 @@ export class SalaryProcessComponent implements OnInit {
salaryMonth: ['', Validators.required],
processDate: ['', Validators.required],
euroRate: [0, Validators.required],
category: [null],
});
}
@ -182,16 +197,47 @@ export class SalaryProcessComponent implements OnInit {
}
process() {
if (this.selectedEmps == undefined || this.selectedEmps.length == 0) {
this.notificationService.showWarning('Please select employee for the proces');
if (this.selectedEmps != undefined && this.selectedEmps.length > 0) {
// employees selected: processed exactly as before (the Category is not used)
this.runSalaryProcess(this.selectedEmps.map(x => x.employeeID));
return;
}
if (this.selectedCategoryID == undefined || this.selectedCategoryID == null || this.selectedCategoryID <= 0) {
this.notificationService.showWarning('Please select employee or category for the proces');
return;
}
// no employee selected: the Live employees of the category (current payroll type) whose salary of
// this month is not processed yet, then the same process as for selected employees
let empIDs: number[] = [];
this.loadingPanelService.ShowLoadingPanel = true;
this.salaryservice.getCategoryEmployeeIDsForSalary(this.selectedCategoryID).subscribe(
(resp: number[]) => {
empIDs = resp || [];
},
(err: any) => {
this.loadingPanelService.ShowLoadingPanel = false;
this.notificationService.showError(err.error);
this.returnMessage = err.error;
},
() => {
this.loadingPanelService.ShowLoadingPanel = false;
if (empIDs.length == 0) {
this.notificationService.showWarning('Employee not found of this category.');
this.returnMessage = 'Employee not found of this category.';
return;
}
this.runSalaryProcess(empIDs);
});
}
// the salary process itself, unchanged: one request item per employee
private runSalaryProcess(empIDs: number[]) {
this.loadingPanelService.ShowLoadingPanel = true;
var returnID: number;
this.processRequest = [];
this.selectedEmps.forEach(x => {
this.processRequest.push({ 'paymentDate': this.paymentdate, 'remarks': this.remarks, 'empid': x.employeeID, 'euroRate': this.euroRate });
empIDs.forEach(empID => {
this.processRequest.push({ 'paymentDate': this.paymentdate, 'remarks': this.remarks, 'empid': empID, 'euroRate': this.euroRate });
});
this.errorOrSucessList = [];
this.salaryservice.salaryProcess(this.processRequest).subscribe(

View File

@ -1197,6 +1197,25 @@ namespace HRM.UI.Controllers.Payroll
}
// Salary Process screen: no employee selected but a Category -> the employees to process
[HttpGet("getCategoryEmployeeIDsForSalary/{categoryID}")]
public ActionResult GetCategoryEmployeeIDsForSalary(int categoryID)
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
List<int> employeeIDs = new List<int>();
try
{
employeeIDs = _salaryProcessService.GetCategoryEmployeeIDs(categoryID, (int)currentUser.PayrollTypeID,
(DateTime)currentUser.NextPayProcessDate);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
return Ok(employeeIDs);
}
[HttpPost]
[Route("undoSalaryProcessById")]
public ActionResult UndoSalaryProcessById(SalaryProcess item)