public decimal GetWeeklyAmount(decimal stopAmount, ServiceDetail sd) { decimal empAmount = 0; if (sd.Service.ExcludeEmpPay) { return(0); } if (PayPerc > 0) { empAmount = stopAmount * PayPerc / 100; } if (sd.Service.QtyFlatPayAmt > 0 && sd.Qty > 0) { var qtyAmount = Invoice.GetWeeklyAmount(sd.Service.Freq, sd.Service.QtyFlatPayAmt, sd.Qty); empAmount = qtyAmount == 0 ? empAmount : qtyAmount; } if (sd.Service.FlatEmpPayAmt > 0) { var flatAmount = Invoice.GetWeeklyAmount(sd.Service.Freq, sd.Service.FlatEmpPayAmt); empAmount = flatAmount == 0 ? empAmount : flatAmount; } return(empAmount); }
public static bool RouteQualifies(DateTime weekStart, Service service, ServiceDetail serviceDetail, Customer cust) { DateTime?nextRouteDate = weekStart.AddDays(serviceDetail.ServiceDay.Day); DateTime?lastRouteDate = serviceDetail.LastRouteDate; if (!lastRouteDate.HasValue) { return(false); } return(RouteQualifies(weekStart, service, serviceDetail, cust, lastRouteDate.Value, nextRouteDate.Value)); }
public static bool RouteQualifies(DateTime weekStart, Service service, ServiceDetail serviceDetail, Customer cust, DateTime nextRouteDate, DateTime lastRouteDate) { //int CountDown, int Freq, DateTime NextRouteDate, DateTime LastRouteDate, DateTime CustStartDate, DateTime CustPauseDate, DateTime CustReStartDate, DateTime CustFinalDate) int lastRouteDays = 0; lastRouteDays = (int)((nextRouteDate - (lastRouteDate > DateTime.Today ? DateTime.Today : lastRouteDate)).TotalDays); //customer is done. if (serviceDetail.CountDown <= 0) { return(false); } //before Start date if ((cust.RouteStartDate ?? DateTime.MinValue) > nextRouteDate) { return(false); } //During pause timeframe var futurePauses = cust.Pauses.Where(x => x.PauseDate > DateTime.Now || x.RestartDate > DateTime.Now); foreach (var pause in futurePauses) { if (nextRouteDate > pause.PauseDate && nextRouteDate < pause.RestartDate) { return(false); } } //after final date if (cust.FinalServiceDate.HasValue && cust.FinalServiceDate.Value < nextRouteDate) { return(false); } // Freq Values // Weekly = 1 // Every Other Week = 2 // Monthly = 3 // One Time = 4 if (service.Freq == 4 || (service.Freq == 1 && lastRouteDays < 7) || (service.Freq == 2 && lastRouteDays < 14) || (service.Freq == 3 && lastRouteDays < 28)) { return(false); } return(true); }
public static Route GenerateCustomerRoute(Customer c, ServiceDetail sd, DateTime weekStart) { var stopAmount = sd.GetStopAmout(); var employee = sd.ServiceDay.Crew.Employees.Single(); var route = new Route { CustomerID = c.Id, ServiceId = sd.ServiceId, Date = weekStart.AddDays(sd.ServiceDay.Day), EmployeeId = employee.Id, Status = "A", Discount = sd.Discount, EmpPerc = employee.PayPerc, EmpAmount = employee.GetWeeklyAmount(stopAmount, sd), ServiceDetailId = sd.Id }; return(route); }
public static bool IsRouteValid(Route route, Customer customer, IQueryable <Pause> pauses, ServiceDetail serviceDetail) { if (pauses.Any(x => x.CustomerId == route.CustomerID && x.PauseDate <= route.Date && x.RestartDate > route.Date)) { return(false); } if (customer.FinalServiceDate < route.Date) { return(false); } if (serviceDetail.CountDown <= 0) { return(false); } if (customer.StartDate > route.Date) { return(false); } return(serviceDetail.Service.Frequency.IsValidFrequency(route.Date, serviceDetail.LastRouteDate)); }