Beispiel #1
0
        public ActionResult AddForAjax(AccountingViewModel pageData)
        {
            if (!ModelState.IsValid)
            {
                var errorFields = ModelState.Where(d => d.Value.Errors.Any())
                                  .Select(x => new { x.Key, x.Value.Errors });

                var errors = new List <AjaxErrorResultViewModel>();
                foreach (var item in errorFields)
                {
                    errors.Add(item.Errors.Select(
                                   d => new AjaxErrorResultViewModel()
                    {
                        ClientId     = item.Key,
                        ErrorMessage = d.ErrorMessage
                    }).FirstOrDefault());
                }
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(errors));
            }

            var accountBook = new AccountBook
            {
                Amounttt   = pageData.Amount,
                Categoryyy = (int)pageData.Type,
                Dateee     = pageData.Date,
                Remarkkk   = pageData.Remark,
                Id         = Guid.NewGuid()
            };

            this.accountDbContext.AccountBook.Add(accountBook);
            this.accountDbContext.SaveChanges();

            return(PartialView("ShowHistory", this.GetLastAccountings(10)));
        }
Beispiel #2
0
 public MainWindow()
 {
     InitializeComponent();
     DataContext = new AccountingViewModel(
         new DialogService(),
         new JsonFileService <SelectedInformation>());
 }
Beispiel #3
0
        // GET: System/Accounting
        public ActionResult Index(AccountingSearchModel Search = null, int Page = 1)
        {
            var Accounting = new AccountingViewModel();

            Accounting.UserId = CurrentUser.Id;
            var model       = Accounting.Query(Search);
            var currentPage = Page < 1 ? 1 : Page;
            var PageSize    = 15;

            var result = model.Accounting.ToPagedList(currentPage, PageSize);

            var PayStatus          = Enum.GetNames(typeof(OrderType)).ToList();
            var PaySelectListItems = new List <SelectListItem>();

            for (var i = 0; i < PayStatus.Count; i++)
            {
                PaySelectListItems.Add(new SelectListItem
                {
                    Text     = new BaseDLL().ParsePayStatusType(PayStatus[i]),
                    Value    = PayStatus[i],
                    Selected = Search == null ? false : (PayStatus[i] == Search.Status)
                });
            }

            ViewBag.PayStatus = PaySelectListItems;

            #region ## Hotels DropDownList
            var Items           = _db.Hotel.ToList();
            var SelectListItems = new List <SelectListItem>();

            foreach (var item in Items)
            {
                SelectListItems.Add(new SelectListItem
                {
                    Text     = item.Name,
                    Value    = item.ID.ToString(),
                    Selected = (Search == null || Search.HotelId <= 0) ? false : (item.ID == Search.HotelId)
                });
            }

            ViewBag.Hotels = SelectListItems;
            #endregion

            ViewData.Model = result;
            var Today = DateTime.Now;
            ViewBag.BeginDate = (Search == null || string.IsNullOrEmpty(Search.BeginDate) || DateTime.Parse(Search.BeginDate) <= DateTime.MinValue) ? Today.ToString("yyyy-MM-01") : Search.BeginDate;
            ViewBag.EndDate   = (Search == null || string.IsNullOrEmpty(Search.EndDate) || DateTime.Parse(Search.EndDate) <= DateTime.MinValue) ? Today.ToString("yyyy-MM") + "-" + DateTime.DaysInMonth(Today.Year, Today.Month).ToString() : Search.EndDate;
            ViewBag.KeyWord   = Search.Keyword;
            ViewBag.HotelId   = Search.HotelId;
            ViewBag.Status    = Search.Status;

            ViewBag.AmoutTotal  = model.AmoutTotal;
            ViewBag.IncomeTotal = model.IncomeTotal;

            return(View());
        }
Beispiel #4
0
 public ActionResult AddAccounting([Bind(Include = "Category,Amount,Date,Note")] AccountingViewModel accountViewModel)
 {
     if (ModelState.IsValid)
     {
         _accountingService.Add(accountViewModel);
         _unitOfWork.Commit();
         return(RedirectToAction("Index"));
     }
     return(View("Index"));
 }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereBalanceBelowZeroIsEqualToCreditors()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.BalanceBelowZero, Is.EqualTo(BalanceBelowZeroType.Creditors));
        }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereBackDatingIsEqualTo30()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.BackDating, Is.EqualTo(30));
        }
        public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBusAndNoKeyValueEntryForPostingJournalResultWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalResultWherePostingWarningsIsEmpty()
        {
            Controller sut = CreateSut(hasKeyValueEntryForPostingJournalResultKey: false);

            PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>());

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.PostingJournalResult.PostingWarnings, Is.Empty);
        }
        public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalResultNotEqualToNull()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>());

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.PostingJournalResult, Is.Not.Null);
        }
        public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBusAndNoKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalWhereApplyPostingLinesNotEqualToNull()
        {
            Controller sut = CreateSut(hasKeyValueEntryForPostingJournalKey: false);

            PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>());

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.PostingJournal.ApplyPostingLines, Is.Not.Null);
        }
        public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereEditModeIsEqualToNone()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>());

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.EditMode, Is.EqualTo(EditMode.None));
        }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingViewModelWherePostingLinesIsNull()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.PostingLines, Is.Null);
        }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereEditModeIsEqualToCreate()
        {
            Controller sut = CreateSut();

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.EditMode, Is.EqualTo(EditMode.Create));
        }
        public async Task UpdateAccounting_WhenAccountingViewModelIsValid_ReturnsRedirectToActionResultWhereRouteValuesContainsAccountingNumberWithValueFromAccountingViewModel()
        {
            Controller sut = CreateSut();

            int accountingNumber = _fixture.Create <int>();
            AccountingViewModel    accountingViewModel = CreateAccountingViewModel(accountingNumber);
            RedirectToActionResult result = (RedirectToActionResult)await sut.UpdateAccounting(accountingViewModel);

            Assert.That(result.RouteValues["AccountingNumber"], Is.EqualTo(accountingNumber));
        }
        public async Task UpdateAccounting_WhenAccountingViewModelIsValid_AssertPublishAsyncWasCalledOnCommandBus()
        {
            Controller sut = CreateSut();

            int accountingNumber = _fixture.Create <int>();
            AccountingViewModel accountingViewModel = CreateAccountingViewModel(accountingNumber);
            await sut.UpdateAccounting(accountingViewModel);

            _commandBusMock.Verify(m => m.PublishAsync(It.Is <IUpdateAccountingCommand>(command => command != null && command.AccountingNumber == accountingNumber)), Times.Once);
        }
        public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalResultKeyEqualToPostingJournalResultKeyFromQueryBus()
        {
            string     postingJournalResultKey = _fixture.Create <string>();
            Controller sut = CreateSut(postingJournalResultKey: postingJournalResultKey);

            PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>());

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.PostingJournalResultKey, Is.EqualTo(postingJournalResultKey));
        }
        public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBusAndNoKeyValueEntryForPostingJournalWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalWhereAccountingNumberIsEqualToAccountingNumberFromArgument()
        {
            Controller sut = CreateSut(hasKeyValueEntryForPostingJournalKey: false);

            int accountingNumber     = _fixture.Create <int>();
            PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(accountingNumber);

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.PostingJournal.AccountingNumber, Is.EqualTo(accountingNumber));
        }
Beispiel #17
0
        public ActionResult Index(AccountingViewModel AccountVM, int page = 1)
        {
            if (ModelState.IsValid)
            {
                _accountSvc.Add(AccountVM);
                _accountSvc.Save();

                return(RedirectToAction("Index"));
            }
            return(View(AccountVM));
        }
 public ActionResult Edit([Bind(Include = "Id,Type,Amount,Date,Remark")] AccountingViewModel viewModel)
 {
     if (ModelState.IsValid)
     {
         var accountBook = this.MapAccountingViewModelToAccountBook(viewModel);
         db.Entry(accountBook).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(viewModel));
 }
 private AccountBook MapAccountingViewModelToAccountBook(AccountingViewModel viewModel)
 {
     return(new AccountBook
     {
         Id = viewModel.Id,
         Amounttt = viewModel.Amount,
         Categoryyy = (int)viewModel.Type,
         Dateee = viewModel.Date,
         Remarkkk = viewModel.Remark
     });
 }
        public async Task CreateAccounting_WhenCalled_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereLetterHeadIsEqualToFirstLetterHeadFromLetterHeadCollectionFromQueryBus()
        {
            IEnumerable <ILetterHead> letterHeadCollection = _fixture.CreateMany <ILetterHead>(_random.Next(5, 10)).OrderBy(letterHead => letterHead.Number).ToList();
            Controller sut = CreateSut(letterHeadCollection);

            PartialViewResult result = (PartialViewResult)await sut.CreateAccounting();

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.LetterHead, Is.Not.Null);
            Assert.That(accountingViewModel.LetterHead.Number, Is.EqualTo(letterHeadCollection.First().Number));
        }
Beispiel #21
0
        public ActionResult Create(AccountingViewModel data)
        {
            if (ModelState.IsValid)
            {
                _accountBookService.Add(data);
                _accountBookService.Save();

                return(RedirectToAction("Index"));
            }

            return(PartialView(data));
        }
        public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithAccountingNumberEqualToAccountingNumberOnAccountingFromQueryBus()
        {
            int         accountingNumber = _fixture.Create <int>();
            IAccounting accounting       = _fixture.BuildAccountingMock(accountingNumber).Object;
            Controller  sut = CreateSut(accounting: accounting);

            PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>());

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.AccountingNumber, Is.EqualTo(accountingNumber));
        }
        public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBusAndKeyValueEntryForPostingJournalResultWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWithPostingJournalResultEqualToPostingJournalResultFromQueryBus()
        {
            ApplyPostingJournalResultViewModel postingJournalResult = _fixture.Create <ApplyPostingJournalResultViewModel>();
            IKeyValueEntry keyValueEntryForPostingJournalResultKey  = _fixture.BuildKeyValueEntryMock(toObject: postingJournalResult).Object;
            Controller     sut = CreateSut(keyValueEntryForPostingJournalResultKey: keyValueEntryForPostingJournalResultKey);

            PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>());

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.PostingJournalResult, Is.EqualTo(postingJournalResult));
        }
Beispiel #24
0
        public void Add(AccountingViewModel accountingViewModel)
        {
            var result = new AccountBook()
            {
                Id         = Guid.NewGuid(),
                Categoryyy = accountingViewModel.Category.GetHashCode(),
                Dateee     = accountingViewModel.AccountingDate,
                Amounttt   = accountingViewModel.Amount,
                Remarkkk   = accountingViewModel.Remark,
            };

            Add(result);
        }
Beispiel #25
0
        public void Add(AccountingViewModel accountViewModel)
        {
            var accountBook = new AccountBook()
            {
                Id         = Guid.NewGuid(),
                Amounttt   = accountViewModel.Amount,
                Categoryyy = (int)accountViewModel.Category,
                Dateee     = accountViewModel.Date,
                Remarkkk   = accountViewModel.Note
            };

            _accountingRepository.Add(accountBook);
        }
        public async Task LoadAccounting_WhenAccountingWasReturnedFromQueryBus_ReturnsPartialViewResultWhereModelIsAccountingViewModelWhereLetterHeadsIsEqualToLetterHeadCollectionFromQueryBus()
        {
            IEnumerable <ILetterHead> letterHeadCollection = _fixture.CreateMany <ILetterHead>(_random.Next(5, 10)).ToList();
            Controller sut = CreateSut(letterHeadCollection);

            PartialViewResult result = (PartialViewResult)await sut.LoadAccounting(_fixture.Create <int>());

            AccountingViewModel accountingViewModel = (AccountingViewModel)result.Model;

            Assert.That(accountingViewModel.LetterHeads, Is.Not.Null);
            Assert.That(accountingViewModel.LetterHeads.Count, Is.EqualTo(letterHeadCollection.Count()));
            Assert.That(accountingViewModel.LetterHeads.All(letterHeadViewModel => letterHeadCollection.Any(letterHead => letterHead.Number == letterHeadViewModel.Number)), Is.True);
        }
Beispiel #27
0
        public void Add(AccountingViewModel AccountVM)
        {
            var result = new AccountBook()
            {
                Id         = Guid.NewGuid(),
                Categoryyy = Convert.ToInt32(AccountVM.Category),
                Amounttt   = AccountVM.Amount,
                Dateee     = AccountVM.Date,
                Remarkkk   = AccountVM.Remark
            };

            _accountRep.Add(result);
        }
Beispiel #28
0
        public AccountingViewModel GetCurrentAccountingCard(AccountingViewModel accounting, string name)
        {
            var currentCard    = GetNotNullCurrentCard(accounting.Cards, name) ?? GetDefaultErrorCard();
            var currentDetails = accounting.Details.Where(x => string.Equals(x.Card.Name, name, StringComparison.CurrentCultureIgnoreCase)).ToList();

            return(new AccountingViewModel()
            {
                Cards = new List <Card>()
                {
                    currentCard
                },
                Details = currentDetails,
            });
        }
Beispiel #29
0
 public void CreateDefaultDetails(AccountingViewModel accounting)
 {
     if (accounting.Details.Count == 0)
     {
         accounting.Details.Add(new Detail()
         {
             Card  = accounting.Cards[0],
             Date  = DateTime.Now.ToString("yyyy MMMM dd"),
             Info  = "This is the default card and details.",
             Order = 0,
             Price = 0
         });
     }
 }
        public ActionResult Create([Bind(Include = "Id,Type,Amount,Date,Remark")] AccountingViewModel viewModel)
        {
            if (ModelState.IsValid)
            {
                var accountBook = this.MapAccountingViewModelToAccountBook(viewModel);

                accountBook.Id = Guid.NewGuid();
                db.AccountBook.Add(accountBook);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(viewModel));
        }