public ProfitReportsController(IAdditionalCostsManager additionalCostsManager, IEmployeeRateRspManager employeeRateRspManager, IEmployeesManager employeeManager, IOrdersManager orderManager, IForeignProductsManager foreignProductsManager, IMaterialDeliveryRspManager materialDeliveryRspManager, ISocialTaxesManager socialTaxesManager, IInstrumentsManager instrumentsManager, IOwnProductsManager ownProductsManager, ITermPositionsManager termPositionsManager, IPositionsManager positionsManager, ITermCostsManager termCostsManager, ITaxesManager taxesManager, IInvoicesManager invoicesManager, IInterestsManager interestsManager, ITermsManager termsManager) { this.additionalCostsManager = additionalCostsManager; this.employeeRateRspManager = employeeRateRspManager; this.employeeManager = employeeManager; this.orderManager = orderManager; this.foreignProductsManager = foreignProductsManager; this.ownProductsManager = ownProductsManager; this.materialDeliveryRspManager = materialDeliveryRspManager; this.socialTaxesManager = socialTaxesManager; this.instrumentsManager = instrumentsManager; this.interestsManager = interestsManager; this.termPositionsManager = termPositionsManager; this.positionsManager = positionsManager; this.termCostsManager = termCostsManager; this.taxesManager = taxesManager; this.invoicesManager = invoicesManager; this.termsManager = termsManager; }
public static IEnumerable<SalaryModel> GetSalary(ITermsManager termsManager, IEmployeeRateRspManager employeeRateRspManager, IEmployeesManager employeeManager, DateTime fromDate, DateTime toDate) { var result = new List<SalaryModel>(); var rates = employeeRateRspManager.GetEntities(o => o.SalaryTypes == SalaryTypes.Monthly).ToList(); //TODO delete check ? var employees = employeeManager.GetEntities().ToList(); foreach (var employee in employees) { double amount = 0; for (var date = fromDate; date < toDate; date = date.AddMonths(1)) { var rate = rates.Where(o => o.EmployeeId == employee.Id && o.FromDate <= date && date <= o.ToDate).FirstOrDefault(); if(rate != null) { amount += rate.Salary; } } result.Add(new SalaryModel() { Id = employee.Id, employeeName = employee.Name, amountString = amount.ToString("N2") + " EUR", amount = amount, }); } var workHours = WorkHoursHelper.GetWorkHours(termsManager, employeeRateRspManager, employeeManager, fromDate, toDate, null); foreach (var group in workHours.GroupBy(o => o.employeeId)) { var model = result.FirstOrDefault(o => o.Id == group.Key); var amount = group.Sum(o => o.amount); if (model == null) { model = new SalaryModel() { Id = group.Key, employeeName = employees.FirstOrDefault(o => o.Id == group.Key).Name, amountString = amount.ToString("N2") + " EUR", amount = amount, }; result.Add(model); } else { model.amount += amount; model.amountString = model.amount.ToString("N2") + " EUR"; } } return result; }
public WorkHoursController(ITermsManager termsManager, IEmployeeRateRspManager employeeRateRspManager, IEmployeesManager employeeManager) { this.termsManager = termsManager; this.employeeRateRspManager = employeeRateRspManager; this.employeeManager = employeeManager; }
public static IEnumerable <SalaryModel> GetSalary(ITermsManager termsManager, IEmployeeRateRspManager employeeRateRspManager, IEmployeesManager employeeManager, DateTime fromDate, DateTime toDate) { var result = new List <SalaryModel>(); var rates = employeeRateRspManager.GetEntities(o => o.SalaryTypes == SalaryTypes.Monthly).ToList(); //TODO delete check ? var employees = employeeManager.GetEntities().ToList(); foreach (var employee in employees) { double amount = 0; for (var date = fromDate; date < toDate; date = date.AddMonths(1)) { var rate = rates.Where(o => o.EmployeeId == employee.Id && o.FromDate <= date && date <= o.ToDate).FirstOrDefault(); if (rate != null) { amount += rate.Salary; } } result.Add(new SalaryModel() { Id = employee.Id, employeeName = employee.Name, amountString = amount.ToString("N2") + " EUR", amount = amount, }); } var workHours = WorkHoursHelper.GetWorkHours(termsManager, employeeRateRspManager, employeeManager, fromDate, toDate, null); foreach (var group in workHours.GroupBy(o => o.employeeId)) { var model = result.FirstOrDefault(o => o.Id == group.Key); var amount = group.Sum(o => o.amount); if (model == null) { model = new SalaryModel() { Id = group.Key, employeeName = employees.FirstOrDefault(o => o.Id == group.Key).Name, amountString = amount.ToString("N2") + " EUR", amount = amount, }; result.Add(model); } else { model.amount += amount; model.amountString = model.amount.ToString("N2") + " EUR"; } } return(result); }
public SalaryController(IEmployeeRateRspManager employeeRateRspManager, IEmployeesManager employeeManager, ITermsManager termsManager) { this.employeeRateRspManager = employeeRateRspManager; this.employeeManager = employeeManager; this.termsManager = termsManager; }
public static IEnumerable<WorkHoursModel> GetWorkHours(ITermsManager termsManager, IEmployeeRateRspManager employeeRateRspManager, IEmployeesManager employeeManager, DateTime fromDate, DateTime toDate, int? employeeId) { var result = new List<WorkHoursModel>(); var rates = employeeRateRspManager.GetEntities(o => o.SalaryTypes == SalaryTypes.Hour).ToList(); var employees = employeeManager.GetEntities().ToList(); var terms = termsManager.GetEntities(o => o.Date >= fromDate && o.Date <= toDate).ToList(); foreach (var term in terms) { var termEmployees = term.TermEmployees.Where(o => !o.DeleteDate.HasValue); if (employeeId.HasValue) { termEmployees = termEmployees.Where(o => o.EmployeeId == employeeId.Value); } foreach (var termEmployee in termEmployees.ToList()) { var rate = rates.Where(o => o.EmployeeId == termEmployee.EmployeeId && o.FromDate <= term.Date && term.Date <= o.ToDate).FirstOrDefault(); double amount = 0; var startTime = term.Date; var endTime = term.Date.AddMinutes(term.Duration); if (term.BeginTrip.HasValue) { startTime = term.BeginTrip.Value; } if(term.EndReturnTrip.HasValue) { endTime = term.EndReturnTrip.Value; } else if(term.EndWork.HasValue) { endTime = term.EndWork.Value; } var duration = Math.Round((endTime - startTime).TotalMinutes); if(rate != null) { amount = (rate.Salary / (double)60) * duration; } result.Add(new WorkHoursModel() { Id = termEmployee.Id, employeeId = termEmployee.EmployeeId, employeeName = termEmployee.Employees.Name, amountString = amount.ToString("N2") + " EUR", amount = amount, duration = String.Format("{0} Min.", duration), date = term.Date, }); } } return result; }
public static IEnumerable <WorkHoursModel> GetWorkHours(ITermsManager termsManager, IEmployeeRateRspManager employeeRateRspManager, IEmployeesManager employeeManager, DateTime fromDate, DateTime toDate, int?employeeId) { var result = new List <WorkHoursModel>(); var rates = employeeRateRspManager.GetEntities(o => o.SalaryTypes == SalaryTypes.Hour).ToList(); var employees = employeeManager.GetEntities().ToList(); var terms = termsManager.GetEntities(o => o.Date >= fromDate && o.Date <= toDate).ToList(); foreach (var term in terms) { var termEmployees = term.TermEmployees.Where(o => !o.DeleteDate.HasValue); if (employeeId.HasValue) { termEmployees = termEmployees.Where(o => o.EmployeeId == employeeId.Value); } foreach (var termEmployee in termEmployees.ToList()) { var rate = rates.Where(o => o.EmployeeId == termEmployee.EmployeeId && o.FromDate <= term.Date && term.Date <= o.ToDate).FirstOrDefault(); double amount = 0; var startTime = term.Date; var endTime = term.Date.AddMinutes(term.Duration); if (term.BeginTrip.HasValue) { startTime = term.BeginTrip.Value; } if (term.EndReturnTrip.HasValue) { endTime = term.EndReturnTrip.Value; } else if (term.EndWork.HasValue) { endTime = term.EndWork.Value; } var duration = Math.Round((endTime - startTime).TotalMinutes); if (rate != null) { amount = (rate.Salary / (double)60) * duration; } result.Add(new WorkHoursModel() { Id = termEmployee.Id, employeeId = termEmployee.EmployeeId, employeeName = termEmployee.Employees.Name, amountString = amount.ToString("N2") + " EUR", amount = amount, duration = String.Format("{0} Min.", duration), date = term.Date, }); } } return(result); }