Compare commits
No commits in common. "90e3dbc8387687542ed83f5a7b18011fbd1a94ef" and "3ecd3cf01da4f414a4c6ba301066edbc9f8f70ed" have entirely different histories.
90e3dbc838
...
3ecd3cf01d
|
|
@ -1,7 +1,6 @@
|
||||||
using Ease.Core.DataAccess;
|
using Ease.Core.DataAccess;
|
||||||
using HRM.BO;
|
|
||||||
using Microsoft.Data.SqlClient;
|
|
||||||
using System;
|
using System;
|
||||||
|
using HRM.BO;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
@ -781,63 +780,5 @@ namespace HRM.DA
|
||||||
}
|
}
|
||||||
return monthlyDetail;
|
return monthlyDetail;
|
||||||
}
|
}
|
||||||
internal static DataSet GetMonthlyKPIDetail(TransactionContext tc, DateTime fromDate, DateTime toDate, List<int> empIds, List<Leave> leaves, string connectionString)
|
|
||||||
{
|
|
||||||
DataSet ds = new DataSet();
|
|
||||||
|
|
||||||
// Convert Employee IDs to DataTable
|
|
||||||
DataTable dtEmp = new DataTable();
|
|
||||||
dtEmp.Columns.Add("ID", typeof(int));
|
|
||||||
|
|
||||||
foreach (var id in empIds)
|
|
||||||
dtEmp.Rows.Add(id);
|
|
||||||
|
|
||||||
// Convert Leaves to DataTable
|
|
||||||
DataTable dtLeave = new DataTable();
|
|
||||||
dtLeave.Columns.Add("ID", typeof(int));
|
|
||||||
dtLeave.Columns.Add("Code", typeof(string));
|
|
||||||
|
|
||||||
foreach (var lv in leaves)
|
|
||||||
dtLeave.Rows.Add(lv.ID, lv.Code);
|
|
||||||
|
|
||||||
using (SqlConnection connection = new SqlConnection(connectionString))
|
|
||||||
{
|
|
||||||
connection.Open();
|
|
||||||
|
|
||||||
using (SqlCommand cmd = new SqlCommand())
|
|
||||||
{
|
|
||||||
cmd.Connection = connection;
|
|
||||||
cmd.CommandText = "dbo.GetMonthlyKPIDetail";
|
|
||||||
cmd.CommandType = CommandType.StoredProcedure;
|
|
||||||
|
|
||||||
// Employee TVP
|
|
||||||
SqlParameter pEmp = cmd.Parameters.Add("@EmpIds", SqlDbType.Structured);
|
|
||||||
pEmp.Value = dtEmp;
|
|
||||||
pEmp.TypeName = "dbo.IntList";
|
|
||||||
|
|
||||||
// Leave TVP
|
|
||||||
SqlParameter pLeave = cmd.Parameters.Add("@Leaves", SqlDbType.Structured);
|
|
||||||
pLeave.Value = dtLeave;
|
|
||||||
pLeave.TypeName = "dbo.LeaveType";
|
|
||||||
|
|
||||||
// Dates
|
|
||||||
cmd.Parameters.Add("@FromDate", SqlDbType.DateTime).Value = fromDate;
|
|
||||||
cmd.Parameters.Add("@ToDate", SqlDbType.DateTime).Value = toDate;
|
|
||||||
|
|
||||||
// Execute
|
|
||||||
using (SqlDataAdapter adapter = new SqlDataAdapter(cmd))
|
|
||||||
{
|
|
||||||
adapter.Fill(ds);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
connection.Close();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ds.Tables.Count > 0)
|
|
||||||
ds.Tables[0].TableName = "MonthlyKPIDetail";
|
|
||||||
|
|
||||||
return ds;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -395,14 +395,14 @@ namespace HRM.DA
|
||||||
DataTable _dtRawData = null;
|
DataTable _dtRawData = null;
|
||||||
_dtRawData = new DataTable("AttnRawData");
|
_dtRawData = new DataTable("AttnRawData");
|
||||||
// _dtRawData.Columns.Add("ATTNRAWDATAID", typeof(int));
|
// _dtRawData.Columns.Add("ATTNRAWDATAID", typeof(int));
|
||||||
_dtRawData.Columns.Add("CardID", typeof(int));
|
_dtRawData.Columns.Add("CARDID", typeof(int));
|
||||||
_dtRawData.Columns.Add("EmployeeID", typeof(int));
|
_dtRawData.Columns.Add("EMPLOYEEID", typeof(int));
|
||||||
_dtRawData.Columns.Add("CardNo", typeof(string));
|
_dtRawData.Columns.Add("CARDNO", typeof(string));
|
||||||
_dtRawData.Columns.Add("PunchTime", typeof(DateTime));
|
_dtRawData.Columns.Add("PUNCHTIME", typeof(DateTime));
|
||||||
_dtRawData.Columns.Add("EntryMode", typeof(int));
|
_dtRawData.Columns.Add("ENTRYMODE", typeof(int));
|
||||||
_dtRawData.Columns.Add("DeviceIPAddress", typeof(string));
|
_dtRawData.Columns.Add("DEVICEIPADDRESS", typeof(string));
|
||||||
_dtRawData.Columns.Add("DeviceNo", typeof(string));
|
_dtRawData.Columns.Add("DEVICENO", typeof(string));
|
||||||
//_dtRawData.Columns.Add("PUNCHDATE", typeof(DateTime));
|
_dtRawData.Columns.Add("PUNCHDATE", typeof(DateTime));
|
||||||
|
|
||||||
foreach (AttnRawData item in attnRawDatas)
|
foreach (AttnRawData item in attnRawDatas)
|
||||||
{
|
{
|
||||||
|
|
@ -422,8 +422,8 @@ namespace HRM.DA
|
||||||
item.PunchTime,
|
item.PunchTime,
|
||||||
(int)item.EntryMode,
|
(int)item.EntryMode,
|
||||||
item.DeviceIPAddress,
|
item.DeviceIPAddress,
|
||||||
item.DeviceNo
|
item.DeviceNo,
|
||||||
);
|
item.PunchTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection,
|
using (SqlBulkCopy bulkCopy = new SqlBulkCopy((SqlConnection)tc.Connection,
|
||||||
|
|
@ -433,14 +433,14 @@ namespace HRM.DA
|
||||||
bulkCopy.BatchSize = 5000;
|
bulkCopy.BatchSize = 5000;
|
||||||
|
|
||||||
// bulkCopy.ColumnMappings.Add("ATTNRAWDATAID", "ATTNRAWDATAID");
|
// bulkCopy.ColumnMappings.Add("ATTNRAWDATAID", "ATTNRAWDATAID");
|
||||||
bulkCopy.ColumnMappings.Add("CardID", "CardID");
|
bulkCopy.ColumnMappings.Add("CARDID", "CARDID");
|
||||||
bulkCopy.ColumnMappings.Add("EmployeeID", "EmployeeID");
|
bulkCopy.ColumnMappings.Add("EMPLOYEEID", "EMPLOYEEID");
|
||||||
bulkCopy.ColumnMappings.Add("CardNo", "CardNo");
|
bulkCopy.ColumnMappings.Add("CARDNO", "CARDNO");
|
||||||
bulkCopy.ColumnMappings.Add("PunchTime", "PunchTime");
|
bulkCopy.ColumnMappings.Add("PUNCHTIME", "PUNCHTIME");
|
||||||
bulkCopy.ColumnMappings.Add("EntryMode", "EntryMode");
|
bulkCopy.ColumnMappings.Add("ENTRYMODE", "ENTRYMODE");
|
||||||
bulkCopy.ColumnMappings.Add("DeviceIPAddress", "DeviceIPAddress");
|
bulkCopy.ColumnMappings.Add("DEVICEIPADDRESS", "DEVICEIPADDRESS");
|
||||||
bulkCopy.ColumnMappings.Add("DeviceNo", "DeviceNo");
|
bulkCopy.ColumnMappings.Add("DEVICENO", "DEVICENO");
|
||||||
// bulkCopy.ColumnMappings.Add("PUNCHDATE", "PUNCHDATE");
|
bulkCopy.ColumnMappings.Add("PUNCHDATE", "PUNCHDATE");
|
||||||
|
|
||||||
bulkCopy.DestinationTableName = "AttnRawData";
|
bulkCopy.DestinationTableName = "AttnRawData";
|
||||||
bulkCopy.WriteToServer(_dtRawData);
|
bulkCopy.WriteToServer(_dtRawData);
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,6 @@ namespace HRM.Report
|
||||||
string tempEmpID = string.Empty;
|
string tempEmpID = string.Empty;
|
||||||
private int TotalEmp = 0;
|
private int TotalEmp = 0;
|
||||||
int count = 1;
|
int count = 1;
|
||||||
double _dExtraAllowanceHours = 0;
|
|
||||||
public rptEcho()
|
public rptEcho()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -2872,367 +2871,143 @@ namespace HRM.Report
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region MonthlyKPI
|
#region MonthlyKPI
|
||||||
//public byte[] ShowMonthlyKPI(DateTime dFromDate, DateTime dToDate, string sEmpID, string reportType, int payrollTypeID)
|
|
||||||
//{
|
|
||||||
// ReportProcessor reportProcessor = new ReportProcessor();
|
|
||||||
|
|
||||||
// DataSet oMonthlyKPIDetail = null;
|
|
||||||
// oMonthlyKPIDetail = new EchoTexExceptionReportService().GetMonthlyKPIDetail(dFromDate, dToDate, sEmpID);
|
|
||||||
|
|
||||||
// var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
|
|
||||||
// IConfiguration Configuration = builder.Build();
|
|
||||||
|
|
||||||
// string sExtraAllowanceHour = Configuration.GetSection("Attendance")["ExtraAllowanceHour"];
|
|
||||||
// //double dExtraAllowanceHours = 0;
|
|
||||||
// if (!double.TryParse(sExtraAllowanceHour, out _dExtraAllowanceHours))
|
|
||||||
// {
|
|
||||||
// _dExtraAllowanceHours = 13.5; // Default if Hour not given
|
|
||||||
// }
|
|
||||||
|
|
||||||
// #region Extra
|
|
||||||
|
|
||||||
// oMonthlyKPIDetail.Tables[0].Columns.Add("ExtraAllowance", typeof(double));
|
|
||||||
|
|
||||||
// if (oMonthlyKPIDetail != null && oMonthlyKPIDetail.Tables.Count > 0)
|
|
||||||
// {
|
|
||||||
// List<DailyAttnProcess> dAttnProcessess = dAttnProcessess = new DailyAttnProcessService().Get(sEmpID, dFromDate, dToDate);
|
|
||||||
// //List<AttnNationalHoliday> oNationalHolidays = AttnNationalHoliday.GetByMonth(dFromDate.FirstDateOfYear(), dFromDate.LastDateOfYear());
|
|
||||||
// List<Shift> oShifts = new ShiftService().Get(EnumStatus.Regardless, payrollTypeID);
|
|
||||||
// List<Employee> oemps = new EmployeeService().GetByEmpIDs(sEmpID);
|
|
||||||
// List<ADParameter> oAdparameters = new ADParameterService().Get(EnumStatus.Active, EnumAllowOrDeduct.Allowance, payrollTypeID).Where(x => x.AllowDeductID == 4).ToList(); // AllowDeductID = 4 is Extra Allowance in ALLOWANCEDEDUCTION table
|
|
||||||
// List<Grade> ogrades = new GradeService().Get(EnumStatus.Regardless);
|
|
||||||
|
|
||||||
// int count = 0;
|
|
||||||
// foreach (DataRow monthlyRow in oMonthlyKPIDetail.Tables[0].Rows)
|
|
||||||
// {
|
|
||||||
// count++;
|
|
||||||
// Employee emp = oemps.Find(x => x.EmployeeNo.ToString() == monthlyRow["IDNo"].ToString());
|
|
||||||
// if (emp == null) continue;
|
|
||||||
// DateTime attnDate = Convert.ToDateTime(monthlyRow["AttnDate"]);
|
|
||||||
// List<DailyAttnProcess> dEmpAttn = dAttnProcessess.FindAll(x => x.EmployeeID == emp.ID && x.AttnDate.Date == attnDate.Date).ToList();
|
|
||||||
// DataTable oDataTable = GetEmpDailyAttnNewKPI(emp.ID, dEmpAttn, emp, oShifts, oAdparameters, ogrades);
|
|
||||||
// if (oDataTable != null && oDataTable.Rows.Count > 0)
|
|
||||||
// {
|
|
||||||
// monthlyRow["ExtraAllowance"] = oDataTable.Rows[0]["ExtraAllowance"];
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// monthlyRow["ExtraAllowance"] = 0;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
|
|
||||||
// DataTable oMnthlyKPIDtlSummary = new AttendenceDataSet.MnthlyKPIDtlSummaryDataTable();
|
|
||||||
|
|
||||||
// #region Summary Parts
|
|
||||||
|
|
||||||
|
|
||||||
// if (oMonthlyKPIDetail.Tables.Count > 0 && oMonthlyKPIDetail.Tables[0].Rows.Count > 0)
|
|
||||||
// {
|
|
||||||
// var groupedData = oMonthlyKPIDetail.Tables[0]
|
|
||||||
// .AsEnumerable()
|
|
||||||
// .GroupBy(x => x.Field<string>("IDNo"))
|
|
||||||
// .Select(g => new { EmployeeNo = g.Key, OTSum = g.Sum(x => Convert.ToDouble(x["OTHour"].ToString())), OTAvg = g.Sum(x => Convert.ToDouble(x["OTHour"].ToString())) / g.Count(), OTGreaterThan5 = g.Count(x => Convert.ToDouble(x["OTHour"].ToString()) > 5), WH = g.Sum(x => Convert.ToDouble(x["Minutes"].ToString())) })
|
|
||||||
// .ToList();
|
|
||||||
|
|
||||||
// DataRow dRow = oMnthlyKPIDtlSummary.NewRow();
|
|
||||||
// dRow["ManPower"] = groupedData.Count();
|
|
||||||
// dRow["PerAvgOTGreater2"] = groupedData.Count(x => x.OTAvg > 2);
|
|
||||||
// dRow["PerSumOTGreater75"] = groupedData.Count(x => x.OTSum > 75);
|
|
||||||
// dRow["PerSumOTGreater100"] = groupedData.Count(x => x.OTSum > 100);
|
|
||||||
// dRow["PerSumOTGreater52"] = groupedData.Count(x => x.OTSum > 52);
|
|
||||||
// dRow["PerOneOTGreater5"] = groupedData.Count(x => x.OTGreaterThan5 > 0);
|
|
||||||
// double wh = groupedData.Sum(c => c.WH);
|
|
||||||
// oMnthlyKPIDtlSummary.Rows.Add(dRow);
|
|
||||||
|
|
||||||
// }
|
|
||||||
// #endregion
|
|
||||||
|
|
||||||
// oMnthlyKPIDtlSummary.TableName = "MnthlyKPIDtlSummary";
|
|
||||||
// oMonthlyKPIDetail.Tables.Add(oMnthlyKPIDtlSummary);
|
|
||||||
|
|
||||||
// string RDLC = "rptMonthlyKPI.rdlc";
|
|
||||||
|
|
||||||
// List<ReportParameter> _parameters = new List<ReportParameter>();
|
|
||||||
// ReportParameter rParam = new ReportParameter("FromDate", dFromDate.ToString("dd MMM yyyy"));
|
|
||||||
// _parameters.Add(rParam);
|
|
||||||
// rParam = new ReportParameter("ToDate", dToDate.LastDateOfMonth().ToString("dd MMM yyyy"));
|
|
||||||
// _parameters.Add(rParam);
|
|
||||||
|
|
||||||
// return reportProcessor.AttendanceReportsView(null, oMonthlyKPIDetail, null, RDLC, _parameters, true, payrollTypeID, reportType);
|
|
||||||
//}
|
|
||||||
//public DataTable GetEmpDailyAttnNewKPI(int EmpID, List<DailyAttnProcess> dAttnProcessess, Employee emp, List<Shift> oShifts, List<ADParameter> oADPrams, List<Grade> ogrades)
|
|
||||||
//{
|
|
||||||
// AttendenceDataSet.EmpDailyAttnDataTable dTable = new AttendenceDataSet.EmpDailyAttnDataTable();
|
|
||||||
|
|
||||||
// DateTime startTime, endTime;
|
|
||||||
|
|
||||||
// if (!(dAttnProcessess == null || dAttnProcessess.Count <= 0))
|
|
||||||
// {
|
|
||||||
// foreach (DailyAttnProcess dAttnProcess in dAttnProcessess)
|
|
||||||
// {
|
|
||||||
// DataRow Rowbody = dTable.NewRow();
|
|
||||||
// Rowbody["ExtraAllowance"] = 0;
|
|
||||||
// if (oADPrams != null && emp != null)
|
|
||||||
// {
|
|
||||||
// foreach (ADParameter adparam in oADPrams)
|
|
||||||
// {
|
|
||||||
// foreach (ADParameter.ADParameterGrade grn in adparam.ADParameterGrades)
|
|
||||||
// {
|
|
||||||
// //Grade gr = ogrades.GetItem(grn.GradeID);
|
|
||||||
// Grade gr = ogrades.Find(delegate (Grade item) { return item.ID == grn.GradeID; });
|
|
||||||
// if (gr != null && gr.ID == emp.GradeID)
|
|
||||||
// {
|
|
||||||
// if (dAttnProcess.InTime != null && dAttnProcess.InTime != DateTime.MinValue)
|
|
||||||
// {
|
|
||||||
// Shift sft = oShifts.FirstOrDefault(x => x.ID == dAttnProcess.ShiftID);
|
|
||||||
// startTime = dAttnProcess.InTime.Value.Date.Add(sft.InTime.TimeOfDay);
|
|
||||||
|
|
||||||
// startTime = (DateTime)startTime.AddMinutes(-15) > (DateTime)dAttnProcess.InTime ? (DateTime)startTime.AddMinutes(-15) : (DateTime)dAttnProcess.InTime;
|
|
||||||
|
|
||||||
// endTime = dAttnProcess.OutTime != null ? (DateTime)dAttnProcess.OutTime : DateTime.MinValue;
|
|
||||||
// if (endTime != DateTime.MinValue)
|
|
||||||
// {
|
|
||||||
// if (endTime.Subtract(startTime).Add(TimeSpan.FromMinutes(1)).TotalHours >= _dExtraAllowanceHours)
|
|
||||||
// {
|
|
||||||
// Rowbody["ExtraAllowance"] = 1;// ncount++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// dTable.Rows.Add(Rowbody);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// return dTable;
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public byte[] ShowMonthlyKPI(DateTime dFromDate, DateTime dToDate, string sEmpID, string reportType, int payrollTypeID)
|
public byte[] ShowMonthlyKPI(DateTime dFromDate, DateTime dToDate, string sEmpID, string reportType, int payrollTypeID)
|
||||||
{
|
{
|
||||||
int count = 0;
|
ReportProcessor reportProcessor = new ReportProcessor();
|
||||||
try
|
|
||||||
|
DataSet oMonthlyKPIDetail = null;
|
||||||
|
oMonthlyKPIDetail = new EchoTexExceptionReportService().GetMonthlyKPIDetail(dFromDate, dToDate, sEmpID);
|
||||||
|
|
||||||
|
|
||||||
|
#region Extra
|
||||||
|
|
||||||
|
oMonthlyKPIDetail.Tables[0].Columns.Add("ExtraAllowance", typeof(double));
|
||||||
|
|
||||||
|
if (oMonthlyKPIDetail != null && oMonthlyKPIDetail.Tables.Count > 0)
|
||||||
{
|
{
|
||||||
ReportProcessor reportProcessor = new ReportProcessor();
|
List<DailyAttnProcess> dAttnProcessess = dAttnProcessess = new DailyAttnProcessService().Get(sEmpID, dFromDate, dToDate);
|
||||||
|
//List<AttnNationalHoliday> oNationalHolidays = AttnNationalHoliday.GetByMonth(dFromDate.FirstDateOfYear(), dFromDate.LastDateOfYear());
|
||||||
DataSet oMonthlyKPIDetail = null;
|
List<Shift> oShifts = new ShiftService().Get(EnumStatus.Active, payrollTypeID);
|
||||||
oMonthlyKPIDetail = new EchoTexExceptionReportService().GetMonthlyKPIDetail(dFromDate, dToDate, sEmpID);
|
List<Employee> oemps = new EmployeeService().GetByEmpIDs(sEmpID);
|
||||||
|
List<ADParameter> oAdparameters = new ADParameterService().Get(EnumStatus.Active, EnumAllowOrDeduct.Allowance, payrollTypeID).Where(x => x.AllowDeductID == 4).ToList(); // AllowDeductID = 4 is Extra Allowance in ALLOWANCEDEDUCTION table
|
||||||
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
|
List<Grade> ogrades = new GradeService().Get(EnumStatus.Regardless);
|
||||||
IConfiguration Configuration = builder.Build();
|
foreach (DataRow monthlyRow in oMonthlyKPIDetail.Tables[0].Rows)
|
||||||
|
|
||||||
string sExtraAllowanceHour = Configuration.GetSection("Attendance")["ExtraAllowanceHour"];
|
|
||||||
//double dExtraAllowanceHours = 0;
|
|
||||||
if (!double.TryParse(sExtraAllowanceHour, out _dExtraAllowanceHours))
|
|
||||||
{
|
{
|
||||||
_dExtraAllowanceHours = 13.5; // Default if Hour not given
|
Employee emp = oemps.Find(x => x.EmployeeNo.ToString() == monthlyRow["IDNo"].ToString());
|
||||||
}
|
if (emp == null) continue;
|
||||||
|
DateTime attnDate = Convert.ToDateTime(monthlyRow["AttnDate"]);
|
||||||
#region Extra
|
List<DailyAttnProcess> dEmpAttn = dAttnProcessess.FindAll(x => x.EmployeeID == emp.ID && x.AttnDate.Date == attnDate.Date).ToList();
|
||||||
|
DataTable oDataTable = new rptEcho().GetEmpDailyAttnNewKPI(emp.ID, dEmpAttn, emp, oShifts, oAdparameters, ogrades);
|
||||||
oMonthlyKPIDetail.Tables[0].Columns.Add("ExtraAllowance", typeof(double));
|
if (oDataTable != null && oDataTable.Rows.Count > 0)
|
||||||
|
|
||||||
if (oMonthlyKPIDetail != null && oMonthlyKPIDetail.Tables.Count > 0)
|
|
||||||
{
|
|
||||||
List<DailyAttnProcess> dAttnProcessess = dAttnProcessess = new DailyAttnProcessService().Get(sEmpID, dFromDate, dToDate);
|
|
||||||
//List<AttnNationalHoliday> oNationalHolidays = AttnNationalHoliday.GetByMonth(dFromDate.FirstDateOfYear(), dFromDate.LastDateOfYear());
|
|
||||||
List<Shift> oShifts = new ShiftService().Get(EnumStatus.Regardless, payrollTypeID);
|
|
||||||
List<Employee> oemps = new EmployeeService().GetByEmpIDs(sEmpID);
|
|
||||||
List<ADParameter> oAdparameters = new ADParameterService().Get(EnumStatus.Active, EnumAllowOrDeduct.Allowance, payrollTypeID).Where(x => x.AllowDeductID == 4).ToList(); // AllowDeductID = 4 is Extra Allowance in ALLOWANCEDEDUCTION table
|
|
||||||
List<Grade> ogrades = new GradeService().Get(EnumStatus.Regardless);
|
|
||||||
|
|
||||||
var empDict = oemps.ToDictionary(x => x.EmployeeNo.ToString(), x => x);
|
|
||||||
|
|
||||||
var attnLookup = dAttnProcessess
|
|
||||||
.GroupBy(x => new { x.EmployeeID, Date = x.AttnDate.Date })
|
|
||||||
.ToDictionary(g => (g.Key.EmployeeID, g.Key.Date), g => g.ToList());
|
|
||||||
|
|
||||||
var shiftDict = oShifts.ToDictionary(x => x.ID, x => x);
|
|
||||||
|
|
||||||
var gradeEligible = new HashSet<int>();
|
|
||||||
foreach (var ad in oAdparameters)
|
|
||||||
{
|
{
|
||||||
foreach (var gr in ad.ADParameterGrades)
|
monthlyRow["ExtraAllowance"] = oDataTable.Rows[0]["ExtraAllowance"];
|
||||||
{
|
|
||||||
gradeEligible.Add(gr.GradeID);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (DataRow monthlyRow in oMonthlyKPIDetail.Tables[0].Rows)
|
else
|
||||||
{
|
{
|
||||||
count++;
|
monthlyRow["ExtraAllowance"] = 0;
|
||||||
if(count == 341926)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
string empNo = monthlyRow["IDNo"].ToString();
|
|
||||||
|
|
||||||
if (!empDict.TryGetValue(empNo, out var emp))
|
|
||||||
{
|
|
||||||
monthlyRow["ExtraAllowance"] = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
DateTime attnDate = Convert.ToDateTime(monthlyRow["AttnDate"]).Date;
|
|
||||||
|
|
||||||
if (!attnLookup.TryGetValue((emp.ID, attnDate), out var dEmpAttn))
|
|
||||||
{
|
|
||||||
monthlyRow["ExtraAllowance"] = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 👇 SAME method name used
|
|
||||||
var dt = GetEmpDailyAttnNewKPI(
|
|
||||||
emp.ID,
|
|
||||||
dEmpAttn,
|
|
||||||
emp,
|
|
||||||
oShifts,
|
|
||||||
oAdparameters,
|
|
||||||
ogrades
|
|
||||||
);
|
|
||||||
|
|
||||||
monthlyRow["ExtraAllowance"] =
|
|
||||||
(dt != null && dt.Rows.Count > 0)
|
|
||||||
? dt.Rows[0]["ExtraAllowance"]
|
|
||||||
: 0;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
|
|
||||||
DataTable oMnthlyKPIDtlSummary = new AttendenceDataSet.MnthlyKPIDtlSummaryDataTable();
|
|
||||||
|
|
||||||
#region Summary Parts
|
|
||||||
|
|
||||||
|
|
||||||
if (oMonthlyKPIDetail.Tables.Count > 0 && oMonthlyKPIDetail.Tables[0].Rows.Count > 0)
|
|
||||||
{
|
|
||||||
var groupedData = oMonthlyKPIDetail.Tables[0]
|
|
||||||
.AsEnumerable()
|
|
||||||
.GroupBy(x => x.Field<string>("IDNo"))
|
|
||||||
.Select(g => new { EmployeeNo = g.Key, OTSum = g.Sum(x => Convert.ToDouble(x["OTHour"].ToString())), OTAvg = g.Sum(x => Convert.ToDouble(x["OTHour"].ToString())) / g.Count(), OTGreaterThan5 = g.Count(x => Convert.ToDouble(x["OTHour"].ToString()) > 5), WH = g.Sum(x => Convert.ToDouble(x["Minutes"].ToString())) })
|
|
||||||
.ToList();
|
|
||||||
|
|
||||||
DataRow dRow = oMnthlyKPIDtlSummary.NewRow();
|
|
||||||
dRow["ManPower"] = groupedData.Count();
|
|
||||||
dRow["PerAvgOTGreater2"] = groupedData.Count(x => x.OTAvg > 2);
|
|
||||||
dRow["PerSumOTGreater75"] = groupedData.Count(x => x.OTSum > 75);
|
|
||||||
dRow["PerSumOTGreater100"] = groupedData.Count(x => x.OTSum > 100);
|
|
||||||
dRow["PerSumOTGreater52"] = groupedData.Count(x => x.OTSum > 52);
|
|
||||||
dRow["PerOneOTGreater5"] = groupedData.Count(x => x.OTGreaterThan5 > 0);
|
|
||||||
double wh = groupedData.Sum(c => c.WH);
|
|
||||||
oMnthlyKPIDtlSummary.Rows.Add(dRow);
|
|
||||||
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
oMnthlyKPIDtlSummary.TableName = "MnthlyKPIDtlSummary";
|
|
||||||
oMonthlyKPIDetail.Tables.Add(oMnthlyKPIDtlSummary);
|
|
||||||
|
|
||||||
string RDLC = "rptMonthlyKPI.rdlc";
|
|
||||||
|
|
||||||
List<ReportParameter> _parameters = new List<ReportParameter>();
|
|
||||||
ReportParameter rParam = new ReportParameter("FromDate", dFromDate.ToString("dd MMM yyyy"));
|
|
||||||
_parameters.Add(rParam);
|
|
||||||
rParam = new ReportParameter("ToDate", dToDate.LastDateOfMonth().ToString("dd MMM yyyy"));
|
|
||||||
_parameters.Add(rParam);
|
|
||||||
|
|
||||||
return reportProcessor.AttendanceReportsView(null, oMonthlyKPIDetail, null, RDLC, _parameters, true, payrollTypeID, reportType);
|
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
DataTable oMnthlyKPIDtlSummary = new AttendenceDataSet.MnthlyKPIDtlSummaryDataTable();
|
||||||
|
|
||||||
|
#region Summary Parts
|
||||||
|
|
||||||
|
|
||||||
|
if (oMonthlyKPIDetail.Tables.Count > 0 && oMonthlyKPIDetail.Tables[0].Rows.Count > 0)
|
||||||
{
|
{
|
||||||
throw new ServiceException("Failed to Save Leave Year: " + e.Message, e);
|
var groupedData = oMonthlyKPIDetail.Tables[0]
|
||||||
var x = count;
|
.AsEnumerable()
|
||||||
|
.GroupBy(x => x.Field<string>("IDNo"))
|
||||||
|
.Select(g => new { EmployeeNo = g.Key, OTSum = g.Sum(x => Convert.ToDouble(x["OTHour"].ToString())), OTAvg = g.Sum(x => Convert.ToDouble(x["OTHour"].ToString())) / g.Count(), OTGreaterThan5 = g.Count(x => Convert.ToDouble(x["OTHour"].ToString()) > 5), WH = g.Sum(x => Convert.ToDouble(x["Minutes"].ToString())) })
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
DataRow dRow = oMnthlyKPIDtlSummary.NewRow();
|
||||||
|
dRow["ManPower"] = groupedData.Count();
|
||||||
|
dRow["PerAvgOTGreater2"] = groupedData.Count(x => x.OTAvg > 2);
|
||||||
|
dRow["PerSumOTGreater75"] = groupedData.Count(x => x.OTSum > 75);
|
||||||
|
dRow["PerSumOTGreater100"] = groupedData.Count(x => x.OTSum > 100);
|
||||||
|
dRow["PerSumOTGreater52"] = groupedData.Count(x => x.OTSum > 52);
|
||||||
|
dRow["PerOneOTGreater5"] = groupedData.Count(x => x.OTGreaterThan5 > 0);
|
||||||
|
double wh = groupedData.Sum(c => c.WH);
|
||||||
|
oMnthlyKPIDtlSummary.Rows.Add(dRow);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
oMnthlyKPIDtlSummary.TableName = "MnthlyKPIDtlSummary";
|
||||||
|
oMonthlyKPIDetail.Tables.Add(oMnthlyKPIDtlSummary);
|
||||||
|
|
||||||
|
string RDLC = "rptMonthlyKPI.rdlc";
|
||||||
|
|
||||||
|
List<ReportParameter> _parameters = new List<ReportParameter>();
|
||||||
|
ReportParameter rParam = new ReportParameter("FromDate", dFromDate.ToString("dd MMM yyyy"));
|
||||||
|
_parameters.Add(rParam);
|
||||||
|
rParam = new ReportParameter("ToDate", dToDate.LastDateOfMonth().ToString("dd MMM yyyy"));
|
||||||
|
_parameters.Add(rParam);
|
||||||
|
|
||||||
|
return reportProcessor.AttendanceReportsView(null, oMonthlyKPIDetail, null, RDLC, _parameters, true, payrollTypeID, reportType);
|
||||||
}
|
}
|
||||||
public DataTable GetEmpDailyAttnNewKPI(
|
public DataTable GetEmpDailyAttnNewKPI(int EmpID, List<DailyAttnProcess> dAttnProcessess, Employee emp, List<Shift> oShifts, List<ADParameter> oADPrams, List<Grade> ogrades)
|
||||||
int EmpID,
|
|
||||||
List<DailyAttnProcess> dAttnProcessess,
|
|
||||||
Employee emp,
|
|
||||||
List<Shift> oShifts,
|
|
||||||
List<ADParameter> oADPrams,
|
|
||||||
List<Grade> ogrades)
|
|
||||||
{
|
{
|
||||||
AttendenceDataSet.EmpDailyAttnDataTable dTable =
|
AttendenceDataSet.EmpDailyAttnDataTable dTable = new AttendenceDataSet.EmpDailyAttnDataTable();
|
||||||
new AttendenceDataSet.EmpDailyAttnDataTable();
|
|
||||||
|
|
||||||
DataRow row = dTable.NewRow();
|
var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json");
|
||||||
row["ExtraAllowance"] = 0;
|
IConfiguration Configuration = builder.Build();
|
||||||
|
|
||||||
if (emp == null || dAttnProcessess == null || dAttnProcessess.Count == 0)
|
string sExtraAllowanceHour = Configuration.GetSection("Attendance")["ExtraAllowanceHour"];
|
||||||
|
double dExtraAllowanceHours = 0;
|
||||||
|
if (!double.TryParse(sExtraAllowanceHour, out dExtraAllowanceHours))
|
||||||
{
|
{
|
||||||
dTable.Rows.Add(row);
|
dExtraAllowanceHours = 13.5; // Default if Hour not given
|
||||||
return dTable;
|
|
||||||
}
|
}
|
||||||
|
DateTime startTime, endTime;
|
||||||
|
|
||||||
// 🔥 Precompute shift dictionary
|
if (!(dAttnProcessess == null || dAttnProcessess.Count <= 0))
|
||||||
var shiftDict = oShifts.ToDictionary(x => x.ID, x => x);
|
|
||||||
|
|
||||||
// 🔥 Precompute eligible grades
|
|
||||||
var gradeEligible = new HashSet<int>();
|
|
||||||
foreach (var ad in oADPrams)
|
|
||||||
{
|
{
|
||||||
foreach (var gr in ad.ADParameterGrades)
|
foreach (DailyAttnProcess dAttnProcess in dAttnProcessess)
|
||||||
{
|
{
|
||||||
gradeEligible.Add(gr.GradeID);
|
DataRow Rowbody = dTable.NewRow();
|
||||||
|
Rowbody["ExtraAllowance"] = 0;
|
||||||
|
if (oADPrams != null && emp != null)
|
||||||
|
{
|
||||||
|
foreach (ADParameter adparam in oADPrams)
|
||||||
|
{
|
||||||
|
foreach (ADParameter.ADParameterGrade grn in adparam.ADParameterGrades)
|
||||||
|
{
|
||||||
|
//Grade gr = ogrades.GetItem(grn.GradeID);
|
||||||
|
Grade gr = ogrades.Find(delegate (Grade item) { return item.ID == grn.GradeID; });
|
||||||
|
if (gr != null && gr.ID == emp.GradeID)
|
||||||
|
{
|
||||||
|
if (dAttnProcess.InTime != null && dAttnProcess.InTime != DateTime.MinValue)
|
||||||
|
{
|
||||||
|
Shift sft = oShifts.FirstOrDefault(x => x.ID == dAttnProcess.ShiftID);
|
||||||
|
startTime = dAttnProcess.InTime.Value.Date.Add(sft.InTime.TimeOfDay);
|
||||||
|
|
||||||
|
startTime = (DateTime)startTime.AddMinutes(-15) > (DateTime)dAttnProcess.InTime ? (DateTime)startTime.AddMinutes(-15) : (DateTime)dAttnProcess.InTime;
|
||||||
|
|
||||||
|
endTime = dAttnProcess.OutTime != null ? (DateTime)dAttnProcess.OutTime : DateTime.MinValue;
|
||||||
|
if (endTime != DateTime.MinValue)
|
||||||
|
{
|
||||||
|
if (endTime.Subtract(startTime).Add(TimeSpan.FromMinutes(1)).TotalHours >= dExtraAllowanceHours)
|
||||||
|
{
|
||||||
|
Rowbody["ExtraAllowance"] = 1;// ncount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dTable.Rows.Add(Rowbody);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(emp.GradeID != null)
|
|
||||||
{
|
|
||||||
if (!gradeEligible.Contains((int)emp.GradeID))
|
|
||||||
{
|
|
||||||
dTable.Rows.Add(row);
|
|
||||||
return dTable;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
foreach (var dAttnProcess in dAttnProcessess)
|
|
||||||
{
|
|
||||||
if (dAttnProcess.InTime == null || dAttnProcess.InTime == DateTime.MinValue)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
if (!shiftDict.TryGetValue((int)dAttnProcess.ShiftID, out var shift))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
DateTime shiftStart = dAttnProcess.InTime.Value.Date.Add(shift.InTime.TimeOfDay);
|
|
||||||
DateTime adjustedStart = shiftStart.AddMinutes(-15);
|
|
||||||
|
|
||||||
DateTime startTime = adjustedStart > dAttnProcess.InTime
|
|
||||||
? adjustedStart
|
|
||||||
: dAttnProcess.InTime.Value;
|
|
||||||
|
|
||||||
if (dAttnProcess.OutTime == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
double workedHours = dAttnProcess.OutTime.Value
|
|
||||||
.Subtract(startTime)
|
|
||||||
.Add(TimeSpan.FromMinutes(1))
|
|
||||||
.TotalHours;
|
|
||||||
|
|
||||||
// 🚀 EARLY EXIT (biggest improvement)
|
|
||||||
if (workedHours >= _dExtraAllowanceHours)
|
|
||||||
{
|
|
||||||
row["ExtraAllowance"] = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dTable.Rows.Add(row);
|
|
||||||
return dTable;
|
return dTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ export class AttendanceManualEditForMultipleEmployeeComponent implements OnInit
|
||||||
{ value: 5, name: "Natural Calamity" },
|
{ value: 5, name: "Natural Calamity" },
|
||||||
{ value: 2, name: "Forget To Punch" },
|
{ value: 2, name: "Forget To Punch" },
|
||||||
{ value: 9, name: 'LOA' },
|
{ value: 9, name: 'LOA' },
|
||||||
{ value: 11, name: 'Other' },
|
//{ value: 11, name: 'Other' },
|
||||||
]
|
]
|
||||||
isOtherRemarks: boolean = false;
|
isOtherRemarks: boolean = false;
|
||||||
otherRemarks: string = "";
|
otherRemarks: string = "";
|
||||||
|
|
@ -207,7 +207,6 @@ export class AttendanceManualEditForMultipleEmployeeComponent implements OnInit
|
||||||
}
|
}
|
||||||
|
|
||||||
updateobject(type: number) {
|
updateobject(type: number) {
|
||||||
debugger;
|
|
||||||
if (this.selectedRemarks != undefined) {
|
if (this.selectedRemarks != undefined) {
|
||||||
if (this.remarksList.find(y => y.value == this.selectedRemarks).name == "Other") {
|
if (this.remarksList.find(y => y.value == this.selectedRemarks).name == "Other") {
|
||||||
this.isOtherRemarks = true;
|
this.isOtherRemarks = true;
|
||||||
|
|
|
||||||
|
|
@ -248,8 +248,8 @@ export class ReadAttendanceRawdataComponent {
|
||||||
item.employeeNo = x.employeeNo,
|
item.employeeNo = x.employeeNo,
|
||||||
item.entryMode = (x.entryMode == undefined || x.entryMode.length <= 0) ? 0 : this.entryModes.find(e => e.name.trim().toLowerCase() == x.entryMode.trim().toLowerCase()).value,
|
item.entryMode = (x.entryMode == undefined || x.entryMode.length <= 0) ? 0 : this.entryModes.find(e => e.name.trim().toLowerCase() == x.entryMode.trim().toLowerCase()).value,
|
||||||
item.cardNo = (x.cardNo !== undefined || x.cardNo !== "" || x.cardNo !== null) ? item.employeeNo : item.cardNo,
|
item.cardNo = (x.cardNo !== undefined || x.cardNo !== "" || x.cardNo !== null) ? item.employeeNo : item.cardNo,
|
||||||
item.deviceNo = (x.deviceNo !== undefined || x.deviceNo !== "" || x.deviceNo !== null) ? "" : item.deviceNo,
|
item.deviceNo = (x.deviceNo !== undefined || x.deviceNo !== "" || x.deviceNo !== null) ? null : item.deviceNo,
|
||||||
item.deviceIPAddress = (x.deviceIPAddress !== undefined || x.deviceIPAddress !== "" || x.deviceIPAddress !== null) ? "" : item.deviceIPAddress
|
item.deviceIPAddress = (x.deviceIPAddress !== undefined || x.deviceIPAddress !== "" || x.deviceIPAddress !== null) ? null : item.deviceIPAddress
|
||||||
this.attnRawDatas.push(item);
|
this.attnRawDatas.push(item);
|
||||||
});
|
});
|
||||||
//console.log(this.attnRawDatas);
|
//console.log(this.attnRawDatas);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user