public ReadResponse <DailyBankTransactionModel> GetReport(int bankId, int month, int year, int clientTimeZoneOffset)
        {
            IQueryable <DailyBankTransactionModel> Query = GetQuery(bankId, month, year, clientTimeZoneOffset);

            //var Test = Query.ToList();
            List <DailyBankTransactionModel> Result = Query.ToList();

            if (Query.ToArray().Count() > 0)
            {
                var BalanceByMonthAndYear = GetBalanceMonthAndYear(bankId, month, year, clientTimeZoneOffset);
                if (BalanceByMonthAndYear == null)
                {
                    BalanceByMonthAndYear = new BankTransactionMonthlyBalanceModel();
                }
                var beforeBalance = BalanceByMonthAndYear.InitialBalance;

                foreach (var item in Result)
                {
                    var afterBalance = beforeBalance + (item.Status.Equals("IN") ? (double)item.Nominal : (double)item.Nominal * -1);
                    item.BeforeNominal      = (decimal)beforeBalance;
                    item.BeforeNominalValas = (decimal)beforeBalance * item.CurrencyRate;
                    item.AfterNominal       = (decimal)afterBalance;
                    item.AfterNominalValas  = (decimal)afterBalance * item.CurrencyRate;
                    beforeBalance           = afterBalance;
                }
            }

            Dictionary <string, string> order = new Dictionary <string, string>();

            return(new ReadResponse <DailyBankTransactionModel>(Result, Result.Count, order, new List <string>()));
        }
        private void SetNewActualBalanceByMonth(int month, int year, DailyBankTransactionModel model, decimal nominal, decimal nominalValas, DateTimeOffset date)
        {
            var PreviousMonthBalance = GetPreviousMonthBalance(month, year, model.AccountBankId, date);
            var NextMonthBalance     = GetNextMonthBalance(month, year, model.AccountBankId, date);
            var NewMonthBalance      = new BankTransactionMonthlyBalanceModel
            {
                Month            = month,
                Year             = year,
                InitialBalance   = PreviousMonthBalance != null ? PreviousMonthBalance.RemainingBalance : 0,
                RemainingBalance = PreviousMonthBalance != null ? PreviousMonthBalance.RemainingBalance + (double)nominal : (double)nominal,
                AccountBankId    = model.AccountBankId
            };

            NewMonthBalance.InitialBalanceValas   = NewMonthBalance.InitialBalance * (double)model.CurrencyRate;
            NewMonthBalance.RemainingBalanceValas = NewMonthBalance.RemainingBalance * (double)model.CurrencyRate;

            EntityExtension.FlagForCreate(NewMonthBalance, _IdentityService.Username, _UserAgent);
            _DbMonthlyBalanceSet.Add(NewMonthBalance);

            if (NextMonthBalance != null)
            {
                NextMonthBalance.InitialBalance         = NewMonthBalance.RemainingBalance;
                NextMonthBalance.InitialBalanceValas    = NewMonthBalance.RemainingBalanceValas;
                NextMonthBalance.RemainingBalance      += (double)nominal;
                NextMonthBalance.RemainingBalanceValas += NextMonthBalance.RemainingBalance * (double)model.CurrencyRate;
                EntityExtension.FlagForUpdate(NextMonthBalance, _IdentityService.Username, _UserAgent);
                _DbMonthlyBalanceSet.Update(NextMonthBalance);
            }
        }