示例#1
0
        public TransactionsView()
        {
            InitializeComponent();
            DataContext = _viewModel = new TransactionsViewModel();

            Loaded += OnViewLoaded;
        }
示例#2
0
        /// <summary>
        /// Creates a new TransactionsViewModel.
        /// Initializes its DateTime, Month, Year, Accounts, Categories, Client, and Transactions.
        /// Transactions are queried with the month and year parameters.
        /// Returns the new TransactionsViewModel.
        /// </summary>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <returns> Returns the new TransactionsViewModel. </returns>
        private TransactionsViewModel CreateModel(int month, int year)
        {
            TransactionsViewModel model = new TransactionsViewModel();

            model.DateTime   = new DateTime(year, month, 1);
            model.Month      = month;
            model.Year       = year;
            model.Accounts   = this.GetAccounts();
            model.Categories = this.GetCategories();
            //model.Client = this.GetClient();
            model.Transactions = this.GetTransactions(month, year);
            return(model);
        }
示例#3
0
 public ActionResult Edit(int id, TransactionsViewModel model)
 {
     try
     {
         _transactionLogic.UpdateTransaction(id, model);
         _accountLogic.RefreshAccountBalance(model.AccountId);
         return(RedirectToAction("Index", "Transaction", new{ id = model.AccountId }));
     }
     catch
     {
         return(View("~/Views/Transaction/EditTransaction.cshtml", model));
     }
 }
        public IHttpActionResult GetTransactions(int id)
        {
            var transactions = hBHelper.GetTransactionOfAccount(id)
                               .ProjectTo <TransactionViewModel>(new { currentUserId = User.Identity.GetUserId() }).ToList();

            var transactionModel = new TransactionsViewModel
            {
                Transactions    = transactions,
                BankAccountName = hBHelper.GetBankAccountById(id).Name,
                HouseholdId     = hBHelper.GetBankAccountById(id).HouseholdId
            };

            return(Ok(transactionModel));
        }
        public async Task <ActionResult> WithdrawMoneyOperation(TransactionsViewModel model)
        {
            if (ModelState.IsValid)
            {
                accountService.WithdrawAccount(model.AccountNumber, model.Amount);
                var accEmail = GetAccountEmail(model.AccountNumber);
                await accountService.SendMail(accEmail, $"Withdraw {model.Amount} from your account.", "Withdraw money.");

                TempData["OperationSuccess"] = true;
                TempData["Message"]          = "Operation completed successfull!";
                return(RedirectToAction("AccountOperations"));
            }
            return(View());
        }
示例#6
0
        public async Task CallsCorrectServices_WhenParametersAreCorrect()
        {
            //Arrange
            var walletViewModel = new TransactionsViewModel(listOfTransactions.ToPagedList(), new Dictionary <string, decimal>());

            //Act
            var controller = new TransactionsController(transactionServiceMock.Object);

            var result = await controller.UpdateTable(walletViewModel) as PartialViewResult;

            //Assert
            transactionServiceMock.Verify(transaction => transaction.GetAllTransactions(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>()), Times.Once);
            transactionServiceMock.Verify(transaction => transaction.GetAllAmounts(It.IsAny <string>(), It.IsAny <string>()), Times.Once);
        }
        public async Task <IActionResult> MakePayment(Guid Id)
        {
            //var client = await this.accountServices.GetClientAsync(Id);
            var account = await this.accountServices.GetAccountByIdAsync(Id);

            var model = new TransactionsViewModel
            {
                PayerAccount    = account.AccountNumber,
                PayerAccountId  = account.Id,
                PayerClientName = account.ClientName
            };

            return(PartialView("_MakePayment", model));
        }
示例#8
0
        public async Task <IActionResult> Index()
        {
            var transactions = await this.transactionService.GetAllTransactions();

            var amounts = await this.transactionService.GetAllAmounts();

            var model = new TransactionsViewModel(transactions, amounts);

            ViewData["BaseCurrencySymbol"] = GlobalConstants.BaseCurrencySymbol;

            model.SortOrder = model.SortOrder ?? GlobalConstants.DefaultTransactionSorting;

            return(View(model));
        }
示例#9
0
        /// <summary>
        /// Called on initial page load.
        /// Creates new TransactionsViewModel with Transactions from current month and year.
        /// Returns the new TransactionsViewModel to the Index View.
        /// </summary>
        /// <returns> Returns the new TransactionsViewModel to the Index View. </returns>
        public ActionResult Index()
        {
            ActionResult result = checkUser();

            if (result != null)
            {
                return(result);
            }

            DateTime dateTime           = System.DateTime.Now;
            TransactionsViewModel model = this.CreateModel(dateTime.Month, dateTime.Year);

            return(View(model));
        }
示例#10
0
        public JsonResult UpdateTransactions(TransactionsViewModel transactionsViewModel)
        {
            var response = transactionsManager.TransactionMasterUpdate(transactionsViewModel, user.InstituteId, user.FinancialYearId, user.DepartmentID, Convert.ToInt32(user.UserName));

            if (response == "Transaction saved")
            {
                var cashBalance = transactionsManager.CashBalance(user.InstituteId, user.FinancialYearId);
                ViewBag.CashBalance = cashBalance;
                return(Json(new { result = true, message = response }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new { result = false, message = response }, JsonRequestBehavior.AllowGet));
            }
        }
        // Gets all the transactions for a user
        private TransactionsViewModel GetAllTransactionsList(int userId)
        {
            //Get accounts
            List <Account> accounts = getAccounts();

            //Get ALL transactions
            var query = from t in _context.Transaction.Include(t => t.TransactionType)
                        join au in _context.AccountUser
                        on t.AccountId equals au.AccountId
                        where au.UserId == userId
                        select new
            {
                t.TransactionId,
                t.TransactionTypeId,
                t.TransactionType,
                t.Amount,
                t.AccountId,
                t.Account,
                t.DateOfTransaction,
                t.Comments
            };

            List <Transaction> transactions = new List <Transaction>();

            foreach (var transaction in query)
            {
                transactions.Add(new Transaction
                {
                    TransactionId     = transaction.TransactionId,
                    TransactionTypeId = transaction.TransactionTypeId,
                    TransactionType   = transaction.TransactionType,
                    Amount            = transaction.Amount,
                    AccountId         = transaction.AccountId,
                    Account           = transaction.Account,
                    DateOfTransaction = transaction.DateOfTransaction,
                    Comments          = transaction.Comments
                });
            }

            var transactionViewModel = new TransactionsViewModel()
            {
                Transactions = transactions,
                Accounts     = accounts
            };

            return(transactionViewModel);
        }
        // GET: Transactions
        public ActionResult Index([Bind(Prefix = "id")] int dataSourceId)
        {
            var dataSource = _dataSourceManager.GetById(dataSourceId, Client);
            IEnumerable <Transaction> transactions = _transactionManager.Get(dataSource);

            var model = new TransactionsViewModel
            {
                DataSource =
                    string.IsNullOrWhiteSpace(dataSource.ClientName)
                        ? dataSource.BankAccount
                        : dataSource.ClientName + " - " + dataSource.BankAccount,
                Transactions = transactions,
                DataSourceId = dataSource.Id
            };

            return(View(model));
        }
示例#13
0
 public ActionResult DeleteScheduledTransaction(TransactionsViewModel model)
 {
     if ([email protected])
     {
         return(RedirectToAction("DeleteScheduledTransaction", "Transaction", new { id = model.TransactionId }));
     }
     try
     {
         _transactionLogic.RemoveScheduledTransaction(model.TransactionId);
         return(RedirectToAction("Index", "Transaction", new { id = model.AccountId }));
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(RedirectToAction("Index", "Transaction", new { id = model.AccountId })); throw;
     }
 }
        public IActionResult EditTransaction(Guid Id)
        {
            var transaction = this.accountServices.GetTransactionById(Id);
            var model       = new TransactionsViewModel
            {
                Id                 = Id,
                PayerAccount       = transaction.SenderAccount.AccountNumber,
                PayerAccountId     = transaction.SenderAccountId,
                PayerClientName    = transaction.SenderAccount.Client.Name,
                PayeeAccount       = transaction.RecieverAccount.AccountNumber,
                PayeeClientName    = transaction.RecieverAccount.Client.Name,
                PayeeAccountId     = transaction.RecieverAccountId,
                Ammount            = transaction.Amount,
                PaymentDescription = transaction.Description
            };

            return(PartialView("_EditTransaction", model));
        }
示例#15
0
        public async Task ReturnsCorrectViewModel_WhenModelIsNotValid()
        {
            //Arrange
            var walletViewModel = new TransactionsViewModel(listOfTransactions.ToPagedList(), new Dictionary <string, decimal>());

            //Act
            var controller = new TransactionsController(transactionServiceMock.Object);

            controller.ControllerContext = new ControllerContext()
            {
                HttpContext = mockContext.Object
            };
            controller.TempData = new Mock <ITempDataDictionary>().Object;
            controller.ModelState.AddModelError("error", "error");

            var result = await controller.UpdateTable(walletViewModel) as PartialViewResult;

            //Assert
            Assert.IsInstanceOfType(result.Model, typeof(TransactionsViewModel));
        }
示例#16
0
        public async Task CallsCorrectServices_WhenModelIsNotValid()
        {
            //Arrange
            var walletViewModel = new TransactionsViewModel(listOfTransactions.ToPagedList(), new Dictionary <string, decimal>());

            //Act
            var controller = new TransactionsController(transactionServiceMock.Object);

            controller.ControllerContext = new ControllerContext()
            {
                HttpContext = mockContext.Object
            };
            controller.TempData = new Mock <ITempDataDictionary>().Object;
            controller.ModelState.AddModelError("error", "error");

            var result = await controller.UpdateTable(walletViewModel);

            //Assert
            transactionServiceMock.Verify(transaction => transaction.GetAllTransactions(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>(), It.IsAny <string>()), Times.Once);
            transactionServiceMock.Verify(transaction => transaction.GetAllAmounts(It.IsAny <string>(), It.IsAny <string>()), Times.Once);
        }
示例#17
0
        public async Task <PartialViewResult> TransactionsTablePartialViewAsync(string address = "")
        {
            try
            {
                TransactionsViewModel transactionsViewModel = new TransactionsViewModel
                {
                    coinQuoteCol           = CoinQuoteResult.Current,
                    CoinbaseBtcQuoteResult = CoinbaseBtcQuote.Current,
                    DelegateResult         = DelegateResult.Current
                };

                if (address?.Length == 0)
                {
                    transactionsViewModel.TransactionsResult = TransactionsResult.Current;
                }
                else
                {
                    var account = DelegateResult.Current.Delegates.Where(x => x.Username.Contains(address.ToLower()) || x.Address == address).OrderBy(j => j.Username.Length).FirstOrDefault();

                    if (account != null)
                    {
                        transactionsViewModel.TransactionsResult = await TransactionsFetcher.FetchAllUserTransactions(account.Address);
                    }
                    else
                    {
                        transactionsViewModel.TransactionsResult = await TransactionsFetcher.FetchAllUserTransactions(address);
                    }
                }

                return(PartialView("_TransactionsTablePartial", transactionsViewModel));
            }
            catch (Exception ex)
            {
                var log = new Log();
                log.LogMessage(ex.Message + " " + ex.StackTrace + " " + ex.InnerException);
                _appdb.Logger.Add(log);
                _appdb.SaveChangesAsync().Wait();
                return(null);
            }
        }
示例#18
0
        /// <summary>
        /// Triggered by clicking on the Update button in the Index View.
        /// Creates a new TransactionsViewModel based on the month and year parameters.
        /// Filters the TransactionsViewModel by account number and category type.
        /// Also filters via searching by description.
        /// Returns the new TransactionsViewModel back to the Index View.
        /// </summary>
        /// <param name="searchString"></param>
        /// <param name="sortBy"></param>
        /// <param name="month"></param>
        /// <param name="year"></param>
        /// <param name="account"></param>
        /// <param name="category"></param>
        /// <returns></returns>
        public ActionResult Filter(string searchString, int?month, int?year, int?account, string category)
        {
            TransactionsViewModel model = this.CreateModel(month.Value, year.Value);

            if (account != null)
            {
                model.Transactions = this.FilterTransactionsByAccount(model.Transactions, account.Value);
                model.AccountNo    = account.Value;
            }
            if (!String.IsNullOrEmpty(category))
            {
                model.Transactions = this.FilterTransactionsByCategory(model.Transactions, category);
                model.BudgetGoals  = this.GetBudgetGoals(month.Value, year.Value, category);
                model.Category     = category;
            }
            if (!String.IsNullOrEmpty(searchString))
            {
                model.Transactions = this.SearchTransactions(model.Transactions, searchString);
            }

            return(View("Index", model));
        }
示例#19
0
        public async Task <IActionResult> UpdateTable(TransactionsViewModel model)
        {
            var username = userManager.GetUserName(HttpContext.User);

            if (username == null)
            {
                throw new ApplicationException($"Unable to load user with ID '{userManager.GetUserId(User)}'.");
            }

            if (!ModelState.IsValid)
            {
                ModelState.Clear();

                var oldTransactions = await this.transactionService.GetUserTransactions(username);

                var oldAmounts = await this.transactionService.GetAllAmounts(username, oldTransactions.Currency);

                var oldModel = new UserTransactionsViewModel(oldTransactions, oldAmounts);

                oldModel.SortOrder = model.SortOrder ?? GlobalConstants.DefaultTransactionSorting;

                ViewData["CurrencySymbol"] = oldTransactions.CurrencySymbol;

                return(PartialView("_TransactionHistoryTablePartial", oldModel));
            }

            var newTransactions = await this.transactionService.GetUserTransactions(username, model.PageNumber, model.PageSize, model.SortOrder);

            var newAmounts = await this.transactionService.GetAllAmounts(username, newTransactions.Currency);

            var newModel = new UserTransactionsViewModel(newTransactions, newAmounts);

            newModel.SortOrder = model.SortOrder;

            ViewData["CurrencySymbol"] = newTransactions.CurrencySymbol;

            return(PartialView("_TransactionHistoryTablePartial", newModel));
        }
示例#20
0
        public ActionResult EditTransaction(int ID)
        {
            transaction           trans  = ts.GetTransaction(ID);
            TransactionsViewModel acc_vm = new TransactionsViewModel();
            var mapper_trans             = new MapperConfiguration(cfg => cfg.CreateMap <transaction, TransactionsViewModel>()).CreateMapper();
            var trs = mapper_trans.Map <transaction, TransactionsViewModel>(trans);

            List <AccountDomainModel> accs_listDomain = accs.GetAccounts();
            List <AccountViewModel>   VM_accs_list    = new List <AccountViewModel>();
            var mapper_accs = new MapperConfiguration(cfg => cfg.CreateMap <AccountDomainModel, AccountViewModel>()).CreateMapper();
            var accounts    = mapper_accs.Map <IEnumerable <AccountDomainModel>, List <AccountViewModel> >(accs_listDomain);

            List <TypeDomainModel> t_listDomain = t.GetTypes();
            List <TypeViewModel>   VM_t_list    = new List <TypeViewModel>();
            var mapper_t = new MapperConfiguration(cfg => cfg.CreateMap <TypeDomainModel, TypeViewModel>()).CreateMapper();
            var types    = mapper_t.Map <IEnumerable <TypeDomainModel>, List <TypeViewModel> >(t_listDomain);
            List <TransactionDomainModel> ts_listDomain = ts.GetTransactions();

            ViewBag.Accounts = new SelectList(accounts, "ID", "Name");
            ViewBag.Types    = new SelectList(types, "ID", "Description");

            return(View(trs));
        }
        public IActionResult Index(int page = 1)
        {
            var viewModel         = new TransactionsViewModel();
            var totalTransactions = _repository.GetAllTransactions();
            var paging            = new Pager(totalTransactions.Count(), page, 50, 10);
            var skip = CalculateHowManyAccountsToSkip(page, 50);

            var transactions = totalTransactions.Skip(skip).Take(50).Select(transaction =>
                                                                            new TransactionViewModel()
            {
                AccountId = transaction.AccountId,
                Balance   = transaction.Balance,
                Amount    = transaction.Amount,
                Date      = transaction.Date
            });

            viewModel.Transactions   = transactions.ToList();
            viewModel.TotalPageCount = paging.TotalPages;
            viewModel.DisplayPages   = paging.Pages;
            viewModel.CurrentPage    = paging.CurrentPage;

            return(View(viewModel));
        }
示例#22
0
        public MainForm()
        {
            InitializeComponent();
            _accountViewModel = new AccountViewModel();
            ViewModel         = _accountViewModel;

            _sendTransactionViewModel      = new SendTransactionViewModel();
            transferUserControl1.ViewModel = _sendTransactionViewModel;
            _keyStoreLoaderViewModel       = new KeyStoreLoaderViewModel();
            keystoreAccountLoaderUserControl3.ViewModel = _keyStoreLoaderViewModel;
            _privateKeyLoaderViewModel = new PrivateKeyLoaderViewModel();
            privateKeyAccountLoaderUserControl1.ViewModel = _privateKeyLoaderViewModel;
            _hdWalletAccountLoaderViewModel             = new HdWalletAccountLoaderViewModel();
            hdWalletAccountLoaderUserControl1.ViewModel = _hdWalletAccountLoaderViewModel;

            _standardTokenBalanceOfViewModel             = new StandardTokenBalanceOfViewModel();
            standardTokenBalanceOfUserControl1.ViewModel = _standardTokenBalanceOfViewModel;

            _standardTokenContractAddressViewModel             = new StandardTokenContractAddressViewModel();
            standardTokenContractAddressUserControl1.ViewModel = _standardTokenContractAddressViewModel;

            _standardTokenTransferViewModel             = new StandardTokenTransferViewModel();
            standardTokenTransferUserControl1.ViewModel = _standardTokenTransferViewModel;

            _transactionsViewModel             = new TransactionsViewModel();
            transactionsUserControl1.ViewModel = _transactionsViewModel;

            this.Bind(ViewModel, x => x.Address, x => x.txtCurrentAccount.Text);
            this.Bind(ViewModel, x => x.PrivateKey, x => x.txtPrivateKey.Text);
            this.Bind(ViewModel, x => x.Balance, x => x.lblAccountBalance.Text);
            this.Bind(ViewModel, x => x.Url, x => x.cmbUrl.Text);
            this.BindCommand(ViewModel, x => x.RefreshBalanceCommand, x => x.btnRefreshBalance);

            ViewModel.Url = "https://ropsten.infura.io";

            //WatchEventRpc();
        }
示例#23
0
        public MainForm()
        {
            InitializeComponent();
            _accountViewModel = new AccountViewModel();
            ViewModel         = _accountViewModel;

            _sendTransactionViewModel      = new SendTransactionViewModel();
            transferUserControl1.ViewModel = _sendTransactionViewModel;
            _keyStoreLoaderViewModel       = new KeyStoreLoaderViewModel();
            keystoreAccountLoaderUserControl3.ViewModel = _keyStoreLoaderViewModel;
            _privateKeyLoaderViewModel = new PrivateKeyLoaderViewModel();
            privateKeyAccountLoaderUserControl1.ViewModel = _privateKeyLoaderViewModel;
            _hdWalletAccountLoaderViewModel             = new HdWalletAccountLoaderViewModel();
            hdWalletAccountLoaderUserControl1.ViewModel = _hdWalletAccountLoaderViewModel;

            _standardTokenBalanceOfViewModel             = new StandardTokenBalanceOfViewModel();
            standardTokenBalanceOfUserControl1.ViewModel = _standardTokenBalanceOfViewModel;

            _standardTokenContractAddressViewModel             = new StandardTokenContractAddressViewModel();
            standardTokenContractAddressUserControl1.ViewModel = _standardTokenContractAddressViewModel;

            _standardTokenTransferViewModel             = new StandardTokenTransferViewModel();
            standardTokenTransferUserControl1.ViewModel = _standardTokenTransferViewModel;

            _transactionsViewModel             = new TransactionsViewModel();
            transactionsUserControl1.ViewModel = _transactionsViewModel;

            this.Bind(ViewModel, x => x.Address, x => x.txtCurrentAccount.Text);
            this.Bind(ViewModel, x => x.PrivateKey, x => x.txtPrivateKey.Text);
            this.Bind(ViewModel, x => x.Balance, x => x.lblAccountBalance.Text);
            this.Bind(ViewModel, x => x.Url, x => x.cmbUrl.Text);
            this.BindCommand(ViewModel, x => x.RefreshBalanceCommand, x => x.btnRefreshBalance);

            // Note: in this sample, a special INFURA API key is used: `7238211010344719ad14a89db874158c`. If you wish to use this sample in your own project you’ll need to [sign up on INFURA](https://infura.io/register) and use your own key.
            ViewModel.Url = "https://mainnet.infura.io/v3/7238211010344719ad14a89db874158c";
        }
示例#24
0
        private void Add(object sender, RoutedEventArgs e)
        {
            if (AddViewModel.Price.HasValue == false || AddViewModel.Price <= 0 ||
                AddViewModel.Amount.HasValue == false || AddViewModel.Amount <= 0)
            {
                MessageBox.Show("Wrong values", "Wrong values");
                return;
            }

            var transaction = new Transaction()
            {
                Amount    = (int)AddViewModel.Amount,
                Commision = AddViewModel.Comission,
                Date      = AddViewModel.Date,
                FrontID   = frontID,
                Price     = (decimal)AddViewModel.Price,
                TypeID    = (int)AddViewModel.TransactionTypeEnum
            };

            var repo = Global.Kernel.Get <ITransactionRepository>();

            repo.Add(transaction);
            repo.SaveChanges();

            TransactionsViewModel.Add(new TransactionListItemViewModel()
            {
                Amount          = transaction.Amount,
                Commision       = transaction.Commision,
                Price           = transaction.Price,
                TransactionType = (TransactionTypeEnum)transaction.TypeID,
                Profit          = transaction.Total.Value,
                Date            = transaction.Date
            });

            NewTransaction.DataContext = AddViewModel = new AddTransactionViewModel();
        }
        public async Task ItShouldReturnTheMatchingAccountWithTransaction()
        {
            var id = "123";

            var accountDetailViewModel = new AccountDetailViewModel
            {
                AccountId   = 123,
                Balance     = 0m,
                PayeSchemes = new ResourceList(
                    new List <ResourceViewModel>
                {
                    new ResourceViewModel
                    {
                        Id   = "123/123456",
                        Href = "https://tempuri.org/payescheme/{1}"
                    }
                }),
                LegalEntities = new ResourceList(
                    new List <ResourceViewModel>
                {
                    new ResourceViewModel
                    {
                        Id   = "TempUri Limited",
                        Href = "https://tempuri.org/organisation/{1}"
                    }
                }),

                HashedAccountId = "DFGH",
                DateRegistered  = DateTime.Today.AddYears(-2),
                OwnerEmail      = "*****@*****.**",
                DasAccountName  = "Test Account 1"
            };

            AccountApiClient.Setup(x => x.GetResource <AccountDetailViewModel>($"/api/accounts/{id}"))
            .ReturnsAsync(accountDetailViewModel);

            var obscuredPayePayeScheme = "123/123456";

            PayeSchemeObfuscator.Setup(x => x.ObscurePayeScheme(It.IsAny <string>()))
            .Returns(obscuredPayePayeScheme);


            var payeSchemeViewModel = new PayeSchemeViewModel
            {
                AddedDate    = DateTime.Today.AddMonths(-4),
                Ref          = "123/123456",
                Name         = "123/123456",
                DasAccountId = "123",
                RemovedDate  = null
            };

            AccountApiClient.Setup(x => x.GetResource <PayeSchemeViewModel>(It.IsAny <string>()))
            .ReturnsAsync(payeSchemeViewModel);


            /*
             * This is a testing HACK to avoid using a concrete datetime service
             * because our collegues used DateTime.Now in the code!
             * See ASCS-83 for a fix
             */
            var now = DateTime.Now.Date;
            var startOfFirstFinancialYear = new DateTime(2017, 4, 1);
            var monthsToQuery             = (now.Year - startOfFirstFinancialYear.Year) * 12 +
                                            (now.Month - startOfFirstFinancialYear.Month) + 1;

            DatetimeService.Setup(x => x.GetBeginningFinancialYear(startOfFirstFinancialYear))
            .Returns(startOfFirstFinancialYear);


            var isNotZero             = 100m;
            var isTxDateCreated       = DateTime.Today;
            var transactionsViewModel = new TransactionsViewModel
            {
                new TransactionViewModel
                {
                    Description = "Is Not Null",
                    Amount      = isNotZero,
                    DateCreated = isTxDateCreated
                },
                new TransactionViewModel
                {
                    Description = "Is Not Null 2",
                    Amount      = isNotZero,
                    DateCreated = isTxDateCreated
                }
            };

            AccountApiClient.Setup(x => x.GetTransactions(accountDetailViewModel.HashedAccountId,
                                                          It.IsAny <int>(),
                                                          It.IsAny <int>()))
            .ReturnsAsync(transactionsViewModel
                          );

            var actual = await _sut.Get(id, AccountFieldsSelection.Finance);

            Logger.Verify(x => x.Debug(It.IsAny <string>()), Times.Exactly(2));

            PayeSchemeObfuscator
            .Verify(x => x.ObscurePayeScheme(It.IsAny <string>()), Times.Exactly(2));

            AccountApiClient
            .Verify(x => x.GetTransactions(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <int>()),
                    Times.Exactly(monthsToQuery));

            Assert.IsNotNull(actual);
            Assert.IsNotNull(actual.PayeSchemes);
            Assert.AreEqual(1, actual.PayeSchemes.Count());
            Assert.IsNotNull(actual.Transactions);
            Assert.AreEqual(2 * monthsToQuery, actual.Transactions.Count());

            Assert.IsNull(actual.LegalEntities);
            Assert.IsNull(actual.TeamMembers);
        }
示例#26
0
 public Transactions()
 {
     this.InitializeComponent();
     ViewModel = new TransactionsViewModel(MainPage.GlobalSettings.Storages);
 }
示例#27
0
        /// <summary>
        /// Triggered by a user clicking on the Reset button in the Index View.
        /// Creates a new TransactionsViewModel with every Transaction from the Index View's month and year.
        /// Returns the new TransactionsViewModel back to the Index View.
        /// </summary>
        /// <param name="month">Month</param>
        /// <param name="year">Year</param>
        /// <returns> Returns the new TransactionsViewModel to the Index View. </returns>
        public ActionResult Reset(int?month, int?year)
        {
            TransactionsViewModel model = this.CreateModel(month.Value, year.Value);

            return(View("Index", model));
        }
 public TransactionsView()
 {
     InitializeComponent();
     DataContextChanged += (s, e) => { ViewModel = DataContext as TransactionsViewModel; };
 }
示例#29
0
        public string TransactionMasterUpdate(TransactionsViewModel transactionsViewModel, int insttituteId, int financialYearId, int deptmentId, int userId)
        {
            TransactionMaster transactionMaster = new TransactionMaster
            {
                DepartmentId        = deptmentId,
                FinancialYearId     = financialYearId,
                InsertDate          = DateTime.Now,
                InsertUserAccountId = userId,
                InstId         = insttituteId,
                MasterLedgerId = 0,
                ForInstId      = transactionsViewModel.DeptId,
                TotalAmount    = transactionsViewModel.TotalCredit
            };
            DateTime transactionDate = transactionsViewModel.TransactionDate;

            transactionMaster.TransactionDate     = transactionDate.Date;
            transactionMaster.UpdateDate          = DateTime.Now;
            transactionMaster.UpdateUserAccountId = userId;
            transactionMaster.VoucherNo           = transactionsViewModel.NewVocherNo;
            transactionMaster.VoucherTypeId       = transactionsViewModel.VocherType;
            transactionMaster.MasterNarration     = transactionsViewModel.MasterNarration;
            transactionMaster.ChequeNo            = transactionsViewModel.ChequeorCash;
            char[]   separator = new char[] { '/' };
            string[] strArray  = transactionsViewModel.NewVocherNo.Split(separator);
            transactionMaster.UniqueTransactionNo = new int?(Convert.ToInt32(strArray[0]));
            List <AccountsAppWeb.Core.com.kccsasr.accounts.TransactionDetail> list = new List <AccountsAppWeb.Core.com.kccsasr.accounts.TransactionDetail>();

            using (List <AccountLedgers> .Enumerator enumerator = transactionsViewModel.accountLedgers.GetEnumerator())
            {
                while (true)
                {
                    int     ledgerId;
                    decimal debit;
                    decimal credit;
                    bool    flag;
                    while (true)
                    {
                        if (enumerator.MoveNext())
                        {
                            string         str;
                            AccountLedgers current = enumerator.Current;
                            ledgerId = current.LedgerId;
                            debit    = current.Debit;
                            credit   = current.Credit;
                            flag     = false;
                            if (ledgerId == 1)
                            {
                                flag = true;
                                DataSet set1 = new DataSet();
                                DataSet set  = this.accountsAppAPI.OpeningBalance(this.sKey, transactionsViewModel.DeptId, financialYearId, insttituteId, DateTime.Now.AddDays(1.0), 1, 0x10f447);
                                int     num4 = 0;
                                if (set.Tables[0].Rows.Count == 0)
                                {
                                    num4 = 0;
                                }
                                else if (Convert.ToDecimal(set.Tables[0].Rows[0]["Debit"]) > 0M)
                                {
                                    num4 = Convert.ToInt32(set.Tables[0].Rows[0]["Debit"]);
                                }
                                else if (Convert.ToDecimal(set.Tables[0].Rows[0]["Credit"]) > 0M)
                                {
                                    num4 = Convert.ToInt32(set.Tables[0].Rows[0]["Credit"]);
                                }
                                if ((debit > num4) && (Convert.ToInt32(strArray[0]) == 4))
                                {
                                    return("Cash Balance Is Going Negative");
                                }
                            }
                            if (!flag)
                            {
                                break;
                            }
                            if ((credit > 20000M) && (financialYearId == 5))
                            {
                                str = "Cash Amount is too large";
                            }
                            else
                            {
                                if (((credit <= 10000M) || ((financialYearId <= 5) || (transactionMaster.VoucherTypeId == 3))) || (transactionMaster.VoucherTypeId == 5))
                                {
                                    break;
                                }
                                str = "Cash amount is exceeding Rs.10000/-, Please check again";
                            }
                            return(str);
                        }
                        else
                        {
                            goto TR_0000;
                        }
                        break;
                    }
                    AccountsAppWeb.Core.com.kccsasr.accounts.TransactionDetail item = new AccountsAppWeb.Core.com.kccsasr.accounts.TransactionDetail();
                    item.Debit                = debit;
                    item.Credit               = credit;
                    item.LedgerId             = ledgerId;
                    item.IsCashEntry          = flag;
                    item.TransactionDetailsId = 0;
                    item.TransactionMasterId  = 0;
                    item.UniqueID             = "";
                    item.ForInstId            = new int?(transactionsViewModel.DeptId);
                    list.Add(item);
                }
            }
TR_0000:
            return((this.accountsAppAPI.TransactionMasterInsert(insttituteId, transactionMaster, list.ToArray(), transactionsViewModel.MasterTransactionId) <= 0) ? "Transaction Failed" : "Transaction saved");
        }
示例#30
0
 public TransactionView()
 {
     InitializeComponent();
     viewmodel      = ViewModelLocator.Resolve <TransactionsViewModel>();
     BindingContext = viewmodel;
 }
示例#31
0
        public ActionResult Index(TransactionsViewModel transactionsViewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    transactionsViewModel.HighLevelTxnDesc = transactionsViewModel.HighLevelTxnDesc.Trim();
                    if (transactionsViewModel.ReqReference != null)
                    {
                        transactionsViewModel.ReqReference = transactionsViewModel.ReqReference.Trim();
                    }
                    TransactionsViewModel transVM = new TransactionsViewModel();
                    TempData["daId"] = transactionsViewModel.daId;
                    transactionsViewModel.AddTrans(transactionsViewModel);
                    transactionsViewModel.GetScreenAccessRights("Transactions");

                    return(RedirectToAction("Index", "Transactions"));
                }
                TransactionsViewModel transviewmodel = new TransactionsViewModel();
                transviewmodel = transviewmodel.GetTransactions(transactionsViewModel.daId);
                transactionsViewModel.GetScreenAccessRights("Transactions");

                ViewData["transviewmodel1"] = (IEnumerable <TransactionsViewModel>) from u in transviewmodel.lstTransactions
                                              join b in transviewmodel.lstLifeCycle on u.LifeCycleID equals b.LifeCycleID
                                              select new TransactionsViewModel {
                    TransactionSeq = u.TransactionSeq, ReqReference = u.ReqReference, HighLevelTxnID = u.HighLevelTxnID, HighLevelTxnDesc = u.HighLevelTxnDesc, LifeCycleID = b.LifeCycleID, LifeCycleDesc = b.LifeCycleDesc
                };
                //TempData["daId"] = transviewmodel.daId;

                CommonFunctions comfuns = new CommonFunctions();

                var da = comfuns.FindDA(transactionsViewModel.daId);
                transviewmodel.ModuleId = da.ModuleId;
                transviewmodel.daName   = da.DAName;
                TempData["daId"]        = transviewmodel.daId;

                int clientId;
                int projectId;
                int applicationId;
                //int moduleId;

                string projectName;
                string appName;
                string modName;
                //string prodName;


                //transviewmodel.ProductName = prodName;

                comfuns.GetModuleName(transviewmodel.ModuleId, out applicationId, out modName);
                transviewmodel.ApplicationID = applicationId;
                transviewmodel.ModuleName    = modName;

                comfuns.GetApplicationName(applicationId, out projectId, out appName);
                transviewmodel.ProjectID       = projectId;
                transviewmodel.ApplicationName = appName;

                comfuns.GetProjectName(projectId, out clientId, out projectName);
                transviewmodel.ClientID    = clientId;
                transviewmodel.ProjectName = projectName;

                transviewmodel.ClientName = comfuns.GetClientName(clientId);

                return(View(transviewmodel));
            }
            catch (Exception ex)
            {
                errorlogviewmodel = new ErrorLogViewModel();
                errorlogviewmodel.LogError(ex);
                return(View("Error"));
            }
        }