This commit is contained in:
Mohaimen Hasan 2026-11-09 12:39:38 +06:00
parent b11141a57c
commit 78747c0674
4 changed files with 0 additions and 113 deletions

View File

@ -522,7 +522,6 @@ namespace HRM.BO
List<Employee> GetAllEmps();
void UpdateLM2(List<Employee> emps);
List<Employee> GetWithDiscontinue(int payrollTypeID);
List<Employee> GetDiscontinuedInRange(DateTime fromDate, DateTime toDate, int payrollTypeID);
List<Employee> GetSubordinates(int employeeID);
//List<Employee> GetAllSubordinates(int nodeID);
List<Employee> GetByDeptShiftGFType(string deptIDs, int shiftID, string GFType, int payrollTypeID);

View File

@ -663,18 +663,6 @@ namespace HRM.DA
return tc.ExecuteReader(sql);
}
// Discontinue Employee Details report: employees discontinued (Status = Discontinued)
// whose discontinue date (ENDOFCONTRACTDATE) falls inside the date range.
internal static IDataReader GetDiscontinuedInRange(TransactionContext tc, DateTime fromDate, DateTime toDate,
int payrollTypeID)
{
string sql = SQLParser.MakeSQL(
"SELECT * FROM Employee WHERE STATUS = %n AND ENDOFCONTRACTDATE IS NOT NULL "
+ "AND CAST(ENDOFCONTRACTDATE AS DATE) BETWEEN %d AND %d AND PAYROLLTYPEID = %n order by EmployeeNo",
(int)EnumEmployeeStatus.Discontinued, fromDate, toDate, payrollTypeID);
return tc.ExecuteReader(sql);
}
internal static IDataReader GetAllSubordinatesNew(TransactionContext tc, int employeeID)
{
//For Oracle

View File

@ -1482,37 +1482,6 @@ namespace HRM.DA
return employees;
}
public List<Employee> GetDiscontinuedInRange(DateTime fromDate, DateTime toDate, int payrollTypeID)
{
List<Employee> employees = new List<Employee>();
TransactionContext tc = null;
try
{
tc = TransactionContext.Begin();
DataReader dr = new DataReader(EmployeeDA.GetDiscontinuedInRange(tc, fromDate, toDate, payrollTypeID));
employees = this.CreateObjects<Employee>(dr);
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 employees;
}
public List<Employee> GetWithDiscontinue(int payrollTypeID)
{
List<Employee> employees = new List<Employee>();

View File

@ -2213,75 +2213,6 @@ namespace HRM.UI.Controllers
return Ok(items);
}
public class DiscontinueEmpDetailRequest
{
public string FromDate { get; set; } // yyyy-MM-dd
public string ToDate { get; set; } // yyyy-MM-dd
}
/// <summary>
/// Discontinue Employee Details report: the same columns as Employee Details (getEmpDetailInfo),
/// but only for employees discontinued between FromDate and ToDate (by discontinue date),
/// in the current payroll type, plus their Discontinue Date. Reuses GetEmpDetailInfo unchanged.
/// </summary>
[HttpPost("getDiscontinueEmpDetailInfo")]
public ActionResult GetDiscontinueEmpDetailInfo(DiscontinueEmpDetailRequest request)
{
DateTime fromDate, toDate;
if (request == null
|| !DateTime.TryParseExact(request.FromDate, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture,
System.Globalization.DateTimeStyles.None, out fromDate)
|| !DateTime.TryParseExact(request.ToDate, "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture,
System.Globalization.DateTimeStyles.None, out toDate))
return BadRequest("Please select a valid From Date and To Date.");
if (fromDate > toDate)
return BadRequest("From Date cannot be after To Date.");
List<Employee> discontinued;
try
{
CurrentUser currentUser = CurrentUser.GetCurrentUser(HttpContext.User);
discontinued = _EmployeeService.GetDiscontinuedInRange(fromDate, toDate, (int)currentUser.PayrollTypeID);
}
catch (Exception e)
{
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
}
if (discontinued.Count == 0)
return Ok(new List<Newtonsoft.Json.Linq.JObject>());
// Built here rather than with Employee.getSearchEmp, which casts DepartmentID for
// LocationID/GradeID and throws when an employee has no department.
List<SearchEmployee> selected = discontinued
.Select(x => new SearchEmployee { ID = x.ID, EmployeeID = x.ID, EmployeeNo = x.EmployeeNo, Name = x.Name })
.ToList();
ActionResult detailResult = GetEmpDetailInfo(selected);
if (!(detailResult is OkObjectResult ok) || !(ok.Value is List<EmployeeDetailInfo> details))
return detailResult;
var serializer = JsonSerializer.Create(new JsonSerializerSettings
{
ContractResolver = new Newtonsoft.Json.Serialization.CamelCasePropertyNamesContractResolver()
});
var discontinueDates = discontinued
.GroupBy(x => x.EmployeeNo)
.ToDictionary(g => g.Key, g => g.First().EndOfContractDate);
var rows = new List<Newtonsoft.Json.Linq.JObject>();
foreach (EmployeeDetailInfo item in details)
{
var row = Newtonsoft.Json.Linq.JObject.FromObject(item, serializer);
DateTime? discontinueDate = null;
if (item.EmployeeNo != null && discontinueDates.TryGetValue(item.EmployeeNo, out DateTime? d))
discontinueDate = d;
row["discontinueDate"] = discontinueDate;
rows.Add(row);
}
return Ok(rows);
}
//[HttpPost("getEmpApiResponse")]
//[AllowAnonymous]