Пример #1
0
        public double?TotalPayroll(int idCarWash)
        {
            var viewResult    = Task.Run(() => _wagesForDays.MonthOrderResult(idCarWash, DateTime.Now.Month, DateTime.Now.Year)).Result;
            var payouts       = Task.Run(() => _salaryBalance.SelectIdToDate(idCarWash, DateTime.Now)).Result;
            var salaryBalance = Task.Run(() => _salaryBalance.LastMonthBalance(idCarWash)).Result;
            var bonusSalary   = Task.Run(() => _bonusToSalary.WhereMontsBonusToSalary(idCarWash)).Result;
            var salaryArchive = Task.Run(() => _salaryArchive.LastMonth(idCarWash)).Result;
            var employeeRate  = Task.Run(() => _employeeRate.WherySumRate(idCarWash)).Result;

            double monthlySalary = viewResult.Sum(s => s.payroll).Value;
            double paidPerMonth  = payouts.Sum(s => s.payoutAmount).Value;
            double bonus         = bonusSalary.Sum(s => s.amount).Value;
            double rate          = employeeRate.Sum(s => s.wage).Value;

            double lastMonthBalance    = 0;
            double resultSalaryArchive = 0;

            if (salaryArchive != null)
            {
                resultSalaryArchive = salaryArchive.balanceAtTheEndOfTheMonth.Value;
            }

            if (salaryBalance != null)
            {
                lastMonthBalance = salaryBalance.accountBalance.Value - salaryBalance.payoutAmount.Value;
            }

            return(Math.Round(monthlySalary - paidPerMonth + lastMonthBalance + resultSalaryArchive + bonus + rate, 3));
        }
Пример #2
0
        public async Task <ActionResult> PaymentForSpecificDays(int?idCarWash, bool message = true, bool messageClose = true)
        {
            if (idCarWash != null)
            {
                await _totalMonthlySalary.CheckMonthlyPaymentsEmployee(idCarWash);

                var viewResult           = Mapper.Map <IEnumerable <WagesForDaysWorkedView> >(await _wagesForDays.MonthOrderResult(idCarWash, DateTime.Now.Month, DateTime.Now.Year)).OrderByDescending(x => x.carWashWorkersId);
                var remainingUnpaidWages = Mapper.Map <SalaryArchiveView>(await _salaryArchive.SelectId(idCarWash));
                var payouts       = Mapper.Map <IEnumerable <SalaryBalanceView> >(await _salaryBalance.SelectIdToDate(idCarWash, DateTime.Now.Month, DateTime.Now.Year));
                var salaryBalance = Mapper.Map <SalaryBalanceView>(await _salaryBalance.LastMonthBalance(idCarWash));
                var bonusToSalary = Mapper.Map <IEnumerable <BonusToSalaryView> >(await _bonusToSalary.WhereMontsBonusToSalary(idCarWash.Value));
                var employeeRate  = Mapper.Map <IEnumerable <EmployeeRateView> >(await _employeeRate.WherySumRate(idCarWash.Value));

                ViewBag.EmployeeRate      = employeeRate;
                ViewBag.BonusToSalaryList = bonusToSalary;
                ViewBag.SalaryBalance     = salaryBalance;


                var salaryArxiv = Mapper.Map <SalaryArchiveView>(await _salaryArchive.LastMonth(idCarWash.Value));

                double monthlySalary    = viewResult.Sum(s => s.payroll).Value;
                double paidPerMonth     = payouts.Sum(s => s.payoutAmount).Value;
                double bonusToSalarySum = bonusToSalary.Sum(s => s.amount).Value;
                double rate             = employeeRate.Sum(s => s.wage).Value;
                double lastMonth        = 0;

                if (salaryArxiv != null)
                {
                    lastMonth             = salaryArxiv.balanceAtTheEndOfTheMonth.Value;
                    ViewBag.LastMonthList = salaryArxiv;
                }

                ViewBag.Rate          = rate;
                ViewBag.IdCarWash     = idCarWash;
                ViewBag.MonthlySalary = monthlySalary;
                ViewBag.PaidPerMonth  = paidPerMonth;
                ViewBag.LastMonth     = lastMonth;
                ViewBag.BonusToSalary = bonusToSalarySum;
                ViewBag.TotalPayable  = Math.Round(monthlySalary - paidPerMonth + lastMonth + bonusToSalarySum + rate, 3);
                ViewBag.Employee      = Mapper.Map <CarWashWorkersView>(await _carWashWorkers.CarWashWorkersId(idCarWash));
                ViewBag.Payouts       = payouts;

                if (message == false)
                {
                    ViewBag.Message = "Данная запись не соответствует типу double";
                }

                if (messageClose == false)
                {
                    ViewBag.MessageClose = "Данная запись не соответствует типу double";
                }

                return(View(viewResult));
            }

            return(RedirectToAction("ShiftInformation"));
        }