diff --git a/Payroll.BO/Salary/SalaryCalculator.cs b/Payroll.BO/Salary/SalaryCalculator.cs index 6c662ae..a8a908c 100644 --- a/Payroll.BO/Salary/SalaryCalculator.cs +++ b/Payroll.BO/Salary/SalaryCalculator.cs @@ -1437,6 +1437,11 @@ namespace Payroll.BO item.BasicCurrentDeduct = nTotalUnAuthorizedLeave - item.BasicPaidDays; item.BasicPaidDays += item.BasicCurrentDeduct; item.BasicUnpaidDays = 0; + + // Allowances set in the parameter are cut for the same days as Basic + item.OtherCurrentDeduct = nTotalUnAuthorizedLeave - item.OtherPaidDays; + item.OtherPaidDays += item.OtherCurrentDeduct; + item.OtherUnpaidDays = 0; } foreach (UnAuthorizeLeaveParamDetail detail in Param.Details) @@ -1497,13 +1502,51 @@ namespace Payroll.BO detail.Type == EnumSalaryComponent.Basic ? (int)EnumSalaryItemCode.Basic_Salary : detail.AllowanceID.Integer, salaryDetail.SupportID.Integer, salaryDetail.Description, GlobalFunctions.Round(nAmount)); - this.AddDetail(salary, EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Tot_UnauthLeave_Days, Param.UnAhuthorizeLeaveID.Integer, 0, "UnAuthorized Leave Days", nThisMonthUnAuthorizedLeave); //if(nUnpaidDays>0) //{ // } } + // Days deducted this month, added once (not per parameter item); used by salary sheet, payslip and arrear + if (Param.Details.Count > 0) + this.AddDetail(salary, EnumSalaryGroup.Miscellaneous, EnumSalaryItemCode.Tot_UnauthLeave_Days, Param.UnAhuthorizeLeaveID.Integer, 0, "UnAuthorized Leave Days", item.BasicCurrentDeduct); + + #region Deduct all allowances for unauthorized leave + // Same days and daily-rate formula as Basic; allowances already set in the parameter are skipped to avoid double deduction + if (item.BasicCurrentDeduct > 0) + { + List allowances = salary.Details.FindAll(delegate(SalaryMonthlyDetail dtl) + { + return dtl.itemGroupCode == EnumSalaryGroup.Gross && dtl.ItemCode == EnumSalaryItemCode.Allowance; + }); + + foreach (SalaryMonthlyDetail allowance in allowances) + { + bool isInParam = Param.Details.Exists(delegate(UnAuthorizeLeaveParamDetail pd) + { + return pd.Type == EnumSalaryComponent.Allowance && pd.AllowanceID.Integer == allowance.ItemID; + }); + if (isInParam) continue; + + nAmount = allowance.CalculatedAmount; + if (salary.Employee.JoiningDate > GlobalFunctions.FirstDateOfMonth(_processMonth)) + { + double ndays = Ease.CoreV35.Utility.Global.DateFunctions.DateDiff("d", salary.Employee.JoiningDate, _processMonth) + 1; + nAmount = nAmount / ndays; + nAmount = nAmount * _processMonth.Day; + } + + nAmount = GlobalFunctions.ConevrtToDlyRateofMonth(nAmount, _processMonth) * item.BasicCurrentDeduct; + nAmount = GlobalFunctions.Round(nAmount); + if (nAmount <= 0) continue; + + this.AddDetail(salary, EnumSalaryGroup.UnauthLeave, EnumSalaryItemCode.Allowance, + allowance.ItemID, allowance.SupportID.Integer, allowance.Description, nAmount); + } + } + #endregion + //} //item.currentDeduct = nUnpaidDays;