using custom.BLL.Model; using System; namespace custom.BLL.Rules { public class CalculateMealsWaived : BasePayrollRule, IPayrollRule { public WeekClass Calculate(WeekClass TheWeek) { foreach (DayClass DayItem in TheWeek.DayList) { if ((DayItem.Start == null) && (DayItem.Regular > 0)) { string dayOfWeek = Helper.FormattedDayOfTheWeek(DayItem.TRAN_DATE); } if (DayItem.Regular <= HoursWorkedForFirstMealBreak) continue; DayItem.IsMealBreakAllowed = true; // TODO - need new meal credit logic // when I checked the checkbox, the status true doesnt appear, //If dayItem brings checkbox value, query to find out which date asking for wave timesheet meal break //Currently Im hardcoding to display on the dashboard and calculations. // If I uncheck, no deduction of meal break instead meal_credit 1 hr will be paid. If I check checkbox, total hours automatically deduct 1 hr as per DeductMeal shown below if (DayItem.TRAN_DATE == DateTime.Parse("4/6/2022 12:00:00 AM")) { DayItem.IsMealBreakWaived = true; } if (DayItem.TRAN_DATE == DateTime.Parse("4/7/2022 12:00:00 AM")) { DayItem.IsMealBreakWaived = true; } if ((DayItem.Regular > HoursWorkedForFirstMealBreak) && (DayItem.Meal_Credit > 0) && (DayItem.IsMealBreakWaived)) { DeductMeal(DayItem); } return TheWeek; } private void DeductMeal(DayClass DayItem) { if(DayItem.Meal_Credit > 0) { DayItem.Meal_Credit--; DayItem.Total_Payroll--; } } } }