Bonus Process by Religion Done
This commit is contained in:
parent
46de19578e
commit
f3ff0cd16a
|
|
@ -211,6 +211,7 @@ namespace HRM.BO
|
|||
DataSet GetCCWiseBonusSummary(DateTime bMonthDate, string bonus);
|
||||
DataSet GetCCWiseBonus(DateTime bMonthDate, string bonus);
|
||||
List<Religion> GetReligions(int bonusID);
|
||||
List<int> GetReligionEmployeeIDs(int bonusID, int payrollTypeID);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -141,6 +141,15 @@ namespace HRM.DA
|
|||
" WHERE br.BonusID=%n ORDER BY r.SequenceNo, r.Name", bonusID);
|
||||
}
|
||||
|
||||
// Live employees of the payroll type whose religion is one of the bonus's religions
|
||||
internal static IDataReader GetReligionEmployeeIDs(TransactionContext tc, int bonusID, int payrollTypeID)
|
||||
{
|
||||
return tc.ExecuteReader(
|
||||
"SELECT e.EmployeeID FROM Employee e WHERE e.Status=%n AND e.PayrollTypeID=%n" +
|
||||
" AND e.ReligionID IN (SELECT br.ReligionID FROM BonusReligion br WHERE br.BonusID=%n) ORDER BY e.EmployeeNo",
|
||||
(int)EnumEmployeeStatus.Live, payrollTypeID, bonusID);
|
||||
}
|
||||
|
||||
internal static IDataReader GetReligionsByPayrollType(TransactionContext tc, int payrollTypeID)
|
||||
{
|
||||
return tc.ExecuteReader(
|
||||
|
|
|
|||
|
|
@ -716,7 +716,9 @@ AND BP.PayrollTypeID=%n", emps, FromDate, ToDate, payrollTypeID);
|
|||
internal static DataTable GetUnApprovedBonuses(TransactionContext tc, DateTime dMonthDate, int payrollTypeID)
|
||||
{
|
||||
return tc.ExecuteDataTable("SELECT *, b.name, (SELECT Count(*) FROM bonusProcessDetail bdetail WHERE bdetail.bonusProcessid = bp.bonusProcessid) Count, " +
|
||||
"(CASE WHEN EXISTS (SELECT 1 FROM SalaryApprovalAttachment saa WHERE saa.ReferenceID = bp.bonusProcessid) THEN 1 ELSE 0 END) IsAttachment " +
|
||||
"(CASE WHEN EXISTS (SELECT 1 FROM SalaryApprovalAttachment saa WHERE saa.ReferenceID = bp.bonusProcessid) THEN 1 ELSE 0 END) IsAttachment, " +
|
||||
"(SELECT STRING_AGG(r.Name, ', ') WITHIN GROUP (ORDER BY r.SequenceNo, r.Name) FROM BonusReligion br " +
|
||||
"INNER JOIN Religion r ON r.ReligionID = br.ReligionID WHERE br.BonusID = bp.bonusid) ReligionNames " +
|
||||
"FROM bonusProcess bp, bonus b WHERE b.bonusid = bp.bonusid AND bp.IsApprove = %b AND bp.BonusMonth = %d AND bp.PayrollTypeID = %n",
|
||||
false, dMonthDate, payrollTypeID);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -921,11 +921,24 @@ namespace HRM.DA
|
|||
throw new ServiceException("Nothing to process.");
|
||||
if (request.BonusID <= 0)
|
||||
throw new ServiceException("Please select a bonus.");
|
||||
if (request.EmployeeIDs == null || request.EmployeeIDs.Count == 0)
|
||||
throw new ServiceException("Please select employee for the proces");
|
||||
if (request.CurrProcess <= 0)
|
||||
throw new ServiceException("Currently Process For Basic must be greater than zero.");
|
||||
|
||||
// No employee selected: a bonus with Religion(s) set (Bonus master) is processed for every Live
|
||||
// employee of the current payroll type with one of those religions; without a Religion the
|
||||
// employees must be selected, as before.
|
||||
bool byReligion = false;
|
||||
if (request.EmployeeIDs == null || request.EmployeeIDs.Count == 0)
|
||||
{
|
||||
BonusService bonusService = new BonusService();
|
||||
if (bonusService.GetReligions(request.BonusID).Count == 0)
|
||||
throw new ServiceException("Please select employee for the process");
|
||||
request.EmployeeIDs = bonusService.GetReligionEmployeeIDs(request.BonusID, payrolltypeid);
|
||||
if (request.EmployeeIDs.Count == 0)
|
||||
throw new ServiceException("Employee not found of this bonus's religion(s).");
|
||||
byReligion = true;
|
||||
}
|
||||
|
||||
PayrollType payrollType = new PayrollTypeService().Get(payrolltypeid);
|
||||
if (payrollType == null)
|
||||
throw new ServiceException("Payroll type not found.");
|
||||
|
|
@ -947,7 +960,9 @@ namespace HRM.DA
|
|||
else empIDs.Add(id);
|
||||
}
|
||||
if (empIDs.Count == 0)
|
||||
throw new ServiceException("The selected bonus is already processed for all the selected employees.");
|
||||
throw new ServiceException(byReligion
|
||||
? "The selected bonus is already processed for all the employees of its religion(s)."
|
||||
: "The selected bonus is already processed for all the selected employees.");
|
||||
|
||||
List<Employee> employees = new EmployeeService().GetByEmpIDList(empIDs, payrolltypeid);
|
||||
if (employees.Count == 0)
|
||||
|
|
|
|||
|
|
@ -402,6 +402,34 @@ namespace HRM.DA
|
|||
return religions;
|
||||
}
|
||||
|
||||
// Live employees of the payroll type whose religion is set on the bonus (BonusReligion)
|
||||
public List<int> GetReligionEmployeeIDs(int bonusID, int payrollTypeID)
|
||||
{
|
||||
List<int> employeeIDs = new List<int>();
|
||||
TransactionContext tc = null;
|
||||
try
|
||||
{
|
||||
tc = TransactionContext.Begin();
|
||||
DataReader dr = new DataReader(BonusDA.GetReligionEmployeeIDs(tc, bonusID, payrollTypeID));
|
||||
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 DataSet GetCCWiseBonusSummary(DateTime bMonthDate, string bonus)
|
||||
{
|
||||
DataSet obonus = new DataSet();
|
||||
|
|
|
|||
|
|
@ -235,7 +235,16 @@ export class BonusProcessComponent implements OnInit {
|
|||
search() {
|
||||
}
|
||||
process() {
|
||||
if (this.bonusProcess == undefined || this.bonusProcess.bonusProcessDetails.length == 0) {
|
||||
if (this.selectedbonusID == undefined || this.selectedbonusID == null || this.selectedbonusID <= 0) {
|
||||
this.notificationService.showWarning('Please select a Bonus Type first.');
|
||||
return;
|
||||
}
|
||||
const hasEmployees = this.bonusProcess != undefined && this.bonusProcess.bonusProcessDetails != undefined
|
||||
&& this.bonusProcess.bonusProcessDetails.length > 0;
|
||||
// no employee selected: allowed only when the bonus has Religion(s) set — the server then processes
|
||||
// every live employee of the current payroll type with one of those religions
|
||||
const byReligion = !hasEmployees && this.bonusReligions != undefined && this.bonusReligions.length > 0;
|
||||
if (!hasEmployees && !byReligion) {
|
||||
this.notificationService.showWarning('Please select employee for the proces');
|
||||
return;
|
||||
}
|
||||
|
|
@ -244,7 +253,10 @@ export class BonusProcessComponent implements OnInit {
|
|||
const option = this.disburseWithSalary ? 'with Disburse With Salary'
|
||||
: this.isTaxProcess ? 'with Calculate Tax'
|
||||
: 'without Disburse With Salary and Calculate Tax';
|
||||
this.notificationService.showActiveConfirm('Confirmation', 'Are you sure you want to process the bonus ' + option + '?').then((isConfirmed) => {
|
||||
const whom = byReligion
|
||||
? ' for all live employees of ' + this.bonusReligions.map(r => r.name).join(', ')
|
||||
: '';
|
||||
this.notificationService.showActiveConfirm('Confirmation', 'Are you sure you want to process the bonus' + whom + ' ' + option + '?').then((isConfirmed) => {
|
||||
if (isConfirmed)
|
||||
{
|
||||
this.processConfirmed();
|
||||
|
|
@ -281,7 +293,8 @@ export class BonusProcessComponent implements OnInit {
|
|||
currProcess: this.processFor,
|
||||
isDisburseWithSalary: this.disburseWithSalary,
|
||||
isTaxProcess: this.isTaxProcess,
|
||||
employeeIDs: this.bonusProcess.bonusProcessDetails.map(x => x.employeeID),
|
||||
// empty = no employee selected: the server takes the bonus's religion employees
|
||||
employeeIDs: (this.bonusProcess?.bonusProcessDetails ?? []).map(x => x.employeeID),
|
||||
};
|
||||
var result: BonusProcessAndSaveResult;
|
||||
this.errorOrSucessList = [];
|
||||
|
|
|
|||
|
|
@ -25,6 +25,9 @@
|
|||
</kendo-grid-column>
|
||||
<kendo-grid-column field="count" title="Head-Count">
|
||||
</kendo-grid-column>
|
||||
<!-- religions set on the bonus (Bonus master), comma separated -->
|
||||
<kendo-grid-column field="religionNames" title="Religion">
|
||||
</kendo-grid-column>
|
||||
<kendo-grid-command-column title="Action" [width]="220">
|
||||
<ng-template kendoGridCellTemplate let-dataItem let-rowIndex="rowIndex">
|
||||
<button kendoButton (click)="UndoProcessByID(rowIndex)" class="kt-delete" [svgIcon]="apiService.KendoSVGIcon['delete']"></button>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user