public async Task Update(SalaryBalanceBll elementToUpdate)
        {
            salaryBalance salaryBalance = Mapper.Map <SalaryBalanceBll, salaryBalance>(elementToUpdate);

            _unitOfWork.SalaruBalanceUnitOfWork.Update(salaryBalance);
            await _unitOfWork.Save();
        }
        public async Task Insert(SalaryBalanceBll element)
        {
            salaryBalance salaryBalance = Mapper.Map <SalaryBalanceBll, salaryBalance>(element);

            _unitOfWork.SalaruBalanceUnitOfWork.Insert(salaryBalance);
            await _unitOfWork.Save();
        }
        // ВНИМАНИЕЕ !!!!!!!!!
        // Изменить в соответствии с новой логикой Расходов
        private async Task PayrollExpenses(SalaryBalanceBll salaryBalance, int idPaymentState)
        {
            ExpensesBll expenses = new ExpensesBll();

            expenses.Amount            = salaryBalance.payoutAmount;
            expenses.dateExpenses      = salaryBalance.dateOfPayment;
            expenses.expenseCategoryId = 1;
            expenses.paymentType       = idPaymentState;
            // expenses.expenseCategoryId = 70;
            expenses.note = $"Выплачена через сервис ({salaryBalance.CarWashWorkersId})";

            int id = await _expenses.InsertId(expenses);

            SalaryExpensesBll salaryExpenses = new SalaryExpensesBll();

            salaryExpenses.idCarWashWorkers = salaryBalance.CarWashWorkersId;
            salaryExpenses.expenseId        = id;

            await _salaryExpenses.Insert(salaryExpenses);
        }
        public async Task PaymentOfPartOfTheSalary(int?employeeId, double payoutAmount, double totalPayable, double SalaryCurrentMonth, double Prize, double BalancLastMonth, double PaidMonth, int idPaymentState)
        {
            var lostMonthBalance = await _salaryBalance.LastMonthBalance(employeeId);

            SalaryBalanceBll salaryBalanceBll = new SalaryBalanceBll();

            if (BalancLastMonth != 0)
            {
            }

            double balance = 0;

            if (lostMonthBalance != null)
            {
                balance = lostMonthBalance.accountBalance.Value - lostMonthBalance.payoutAmount.Value;

                if (payoutAmount >= lostMonthBalance.payoutAmount)
                {
                    lostMonthBalance.accountBalance = 0;
                    await _salaryBalance.Update(lostMonthBalance);
                }
                else if (balance < 0)
                {
                    if (Math.Sign(balance) == -1)
                    {
                        balance = balance * -1;
                    }
                }
            }

            salaryBalanceBll.CarWashWorkersId = employeeId;
            salaryBalanceBll.dateOfPayment    = DateTime.Now;
            salaryBalanceBll.payoutAmount     = payoutAmount;
            salaryBalanceBll.accountBalance   = totalPayable;

            await _salaryBalance.Insert(salaryBalanceBll);

            await PayrollExpenses(salaryBalanceBll, idPaymentState);
        }