Beispiel #1
0
        public static async Task <PayrollViewModel> ReBuildAsync(PayrollViewModel model, IPayrollService services)
        {
            model.From            = DateTime.Today.AddMonths(-1);
            model.To              = DateTime.Today;
            model.EmployeeOptions = await services.GetAccountingEmployeeOptions();

            return(model);
        }
Beispiel #2
0
        public static async Task <PayrollViewModel> CreateAsync(
            DateTime from,
            DateTime to,
            string employeeId,
            IPayrollService services,
            IMapper mapper)
        {
            var model = await PayrollViewModel.CreateAsync(services);

            var employees = await services.GetEmployeesWihtPayrolls(employeeId);

            var employeessWithFilteredPaycheks = services.FilterEmployeesPaycheksByDate(from, to, employees);

            model.Employees               = mapper.Map <IEnumerable <Employee>, IEnumerable <EmployeeViewModel> >(employeessWithFilteredPaycheks);
            model.From                    = from;
            model.To                      = to;
            model.TotalPaycheksSum        = employees.Sum(e => e.Paycheks.Select(p => p.Total).Sum());
            model.TotalPaymentsSum        = employees.Sum(e => e.Paycheks.Select(p => p.GetPaidAmount()).Sum());
            model.TotalDiffrenceToBePayed = model.TotalPaycheksSum - model.TotalPaymentsSum;

            return(model);
        }