Exemplo n.º 1
0
 public ActionResult AddRentAccountStep6(AcceptAccountVM mAcceptAccountVm) // Accept Contract View/Print and finish
 {
     if (ModelState.IsValid)
     {
         var newAccount = _accountService.GetAccount(mAcceptAccountVm.CustomerAccountId) as RentalAccount;
         if (ExecuteRepositoryAction(() =>
         {
             newAccount.IsTemp = false;
             _accountService.UpdateAccount(newAccount);
             foreach (var rental in newAccount.RentedUnits)
             {
                 _accountTransactionService.AddAccountTransaction(newAccount.CustomerAccountId, AccountTransactionType.Rental, rental.Amount, AccountTransactionInputType.Charge, rental.StockId, rental.Stock.ManufacturerModel);
                 _accountTransactionService.AddAccountTransaction(newAccount.CustomerAccountId, AccountTransactionType.Deposit, rental.Deposit, AccountTransactionInputType.Charge, rental.StockId, rental.Stock.ManufacturerModel);
                 if (mAcceptAccountVm.FullPayment)
                 {
                     _accountTransactionService.AddAccountTransaction(newAccount.CustomerAccountId, AccountTransactionType.Rental, -rental.Amount, AccountTransactionInputType.Payment, rental.StockId, rental.Stock.ManufacturerModel);
                     _accountTransactionService.AddAccountTransaction(newAccount.CustomerAccountId, AccountTransactionType.Deposit, -rental.Deposit, AccountTransactionInputType.Payment, rental.StockId, rental.Stock.ManufacturerModel);
                 }
             }
             _accountTransactionService.AddAccountTransaction(newAccount.CustomerAccountId, AccountTransactionType.OneOff, newAccount.TotalOneOffItems, AccountTransactionInputType.Charge);
             if (mAcceptAccountVm.FullPayment)
             {
                 _accountTransactionService.AddAccountPaymentTransaction(newAccount.CustomerAccountId, AccountTransactionType.OneOff, -newAccount.TotalOneOffItems);
             }
             _accountService.CommitChanges();
         }))
         {
             return(RedirectToAction("Edit", "Customer",
                                     new
             {
                 id = newAccount.CustomerId,
                 moveOnToEditAccount = newAccount.CustomerAccountId
             }));
         }
     }
     return(View(mAcceptAccountVm));
 }
Exemplo n.º 2
0
 private void UpdateTransactionsFromBasket(RentalBasket basket)
 {
     foreach (var rental in basket.RentedUnits)
     {
         _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Rental,
                                                          rental.Amount, AccountTransactionInputType.Charge, rental.StockId, rental.Stock.ManufacturerModel);
         _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Deposit,
                                                          rental.Deposit, AccountTransactionInputType.Charge, rental.StockId, rental.Stock.ManufacturerModel);
         if (basket.FullPayment)
         {
             _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Rental,
                                                              -rental.Amount, AccountTransactionInputType.Payment, rental.StockId, rental.Stock.ManufacturerModel);
             _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Deposit,
                                                              -rental.Deposit, AccountTransactionInputType.Payment, rental.StockId, rental.Stock.ManufacturerModel);
         }
     }
     _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.OneOff,
                                                      basket.TotalOneOffItems, AccountTransactionInputType.Charge);
     if (basket.FullPayment)
     {
         _accountTransactionService.AddAccountPaymentTransaction(basket.CustomerAccountId, AccountTransactionType.OneOff,
                                                                 -basket.TotalOneOffItems);
     }
 }
Exemplo n.º 3
0
 private void UpdateTransactionsFromBasket(PurchaseBasket basket)
 {
     foreach (var purchase in basket.PurchasedUnits)
     {
         _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Purchase,
                                                          purchase.Total, AccountTransactionInputType.Charge, purchase.StockId, purchase.Stock.ManufacturerModel);
         _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Service,
                                                          purchase.TotalContracts, AccountTransactionInputType.Charge, purchase.StockId, purchase.Stock.ManufacturerModel);
         if (basket.FullPayment)
         {
             _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Purchase,
                                                              -purchase.Total, AccountTransactionInputType.Payment, purchase.StockId, purchase.Stock.ManufacturerModel);
             _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.Service,
                                                              -purchase.TotalContracts, AccountTransactionInputType.Payment, purchase.StockId, purchase.Stock.ManufacturerModel);
         }
     }
     _accountTransactionService.AddAccountTransaction(basket.CustomerAccountId, AccountTransactionType.OneOff,
                                                      basket.TotalOneOffItems, AccountTransactionInputType.Charge);
     if (basket.FullPayment)
     {
         _accountTransactionService.AddAccountPaymentTransaction(basket.CustomerAccountId, AccountTransactionType.OneOff,
                                                                 basket.TotalOneOffItems);
     }
 }
Exemplo n.º 4
0
 public ActionResult _ReceiveCollections(ReceiveCollectionsVM mReceiveCollectionsVM)
 {
     try
     {
         var collectionsWithPayments = mReceiveCollectionsVM.Collections.Where(c => c.Payment != 0);
         foreach (var collection in collectionsWithPayments)
         {
             _accountTransactionService.AddAccountTransaction(collection.CustomerAccountId,
                                                              (AccountTransactionType)collection.AccountTransactionType, -(decimal)collection.Payment, AccountTransactionInputType.Payment, collection.GroupId, collection.Note);
         }
         _accountTransactionService.CommitChanges();
         return(ReturnJsonFormSuccess());
     }
     catch (Exception ex)
     {
         return(ReturnJsonError(ex.Message));
     }
 }
        public ActionResult _MakeAdjustment(AdjustmentVM mAdjustmentVM)
        {
            if (TryValidateModel(mAdjustmentVM))
            {
                if (ExecuteRepositoryAction(() =>
                {
                    _accountsService.AddAccountTransaction(
                        mAdjustmentVM.CustomerAccountId,
                        (AccountTransactionType)mAdjustmentVM.AccountTransactionTypeId, mAdjustmentVM.Amount,
                        AccountTransactionInputType.Adjustment, mAdjustmentVM.GroupId, mAdjustmentVM.Note);
                    _accountsService.CommitChanges();
                }))
                {
                    return(ReturnJsonFormSuccess());
                }
            }

            return(PartialView(mAdjustmentVM));
        }