コード例 #1
0
        public static CustomerAccount CreateContractUnit(AccountType accountType, int customerId, Stock.Stock stock, DateTime startDate, decimal rentalAmount, IEnumerable <ContractType> contractTypes, int paymentPeriodId)
        {
            switch (accountType)
            {
            case AccountType.Purchase:
                var contractUnitPurchase = new PurchaseAccount {
                    CustomerId = customerId
                };
                GetDefaultContracts(contractTypes, startDate).ForEach(contractUnitPurchase.AddContract);
                return(contractUnitPurchase);

            case AccountType.Rent:
                var cur = new RentalAccount
                {
                    CustomerId     = customerId,
                    RentedContract = new RentalContract {
                        StartDate = startDate, PaymentPeriodId = paymentPeriodId
                    },
                    RequiresInvoicingProErrata = true,
                };
                if (stock != null)
                {
                    cur.AddRentedUnitAndUpdateContract(new RentedUnit {
                        StockId = stock.StockId, Stock = stock, Amount = rentalAmount, RentedDate = startDate
                    });
                }
                return(cur);

            default:
                throw new ApplicationException("Unknown Contract type supplied to ContractUnitFactory");
            }
        }
コード例 #2
0
        public ActionResult AddRentAccountStep5(AddRentAccountVM mAddRentAccountVm)
        {
            if (ModelState.IsValid)
            {
                var rentAcc = TempAccountAsAddRentAccountVM();
                if (TryUpdateModel(rentAcc))
                {
                    var newAccount = new RentalAccount
                    {
                        AlternateAddressInstructions = rentAcc.AlternateAddressInstructions,
                        AlternateAddress             = rentAcc.AlternateAddress,
                        CustomerId        = rentAcc.CustomerId,
                        AttachedContracts = new List <Contract>(),
                        RentedUnits       = new List <RentedUnit>(),
                        OneOffItems       = new List <OneOffItem>(),
                    };
                    foreach (RentedUnit mRentedUnit in rentAcc.RentedUnits)
                    {
                        var rentedUnit = new RentedUnit
                        {
                            Amount     = mRentedUnit.Amount,
                            RentedDate = mRentedUnit.RentedDate,
                            StockId    = mRentedUnit.StockId,
                            Stock      = _stockService.GetStock(mRentedUnit.StockId),
                            Deposit    = mRentedUnit.Deposit,
                        };
                        newAccount.AddRentedUnitAndUpdateContract(rentedUnit);
                    }
                    foreach (var oneOffItem in rentAcc.OneOffItems)
                    {
                        var newOneOffItem = new OneOffItem
                        {
                            Description  = oneOffItem.Description,
                            Charge       = oneOffItem.Charge,
                            Date         = rentAcc.StartDate,
                            Quantity     = oneOffItem.Quantity,
                            OneOffTypeId = oneOffItem.OneOffTypeId
                        };
                        newAccount.OneOffItems.Add(newOneOffItem);
                    }

                    if (ExecuteRepositoryAction(() =>
                    {
                        _accountService.AddTempAccount(newAccount);
                        _accountService.CommitChanges();
                    }))
                    {
                        var acceptAccount = new AcceptAccountVM
                        {
                            CustomerAccountId = newAccount.CustomerAccountId,
                            FullPayment       = (mAddRentAccountVm.Payment > 0)
                        };
                        Session["_accountId"] = acceptAccount;
                        return(RedirectToAction(Stepper2.NextStep()));
                    }
                }
            }
            return(View(mAddRentAccountVm));
        }
コード例 #3
0
 public void UpdateRentalContractUnit(RentalAccount entity, int oldPaymentPeriodId)
 {
     _contractUnitRepsoitory.Update(entity);
 }
コード例 #4
0
 public void AddRentAccount(RentalAccount newAccount)
 {
     _customerAccountRepository.Add(newAccount);
 }
コード例 #5
0
 public RentalAccountVM(RentalAccount account)
 {
     _rentalAccount = account;
 }
コード例 #6
0
        public ActionResult AddAccount(NewAccountVM mNewAccountVm)
        {
            if (!ModelState.IsValid)
            {
                return(View(mNewAccountVm));
            }

            var newAccVm = TempRepository <NewAccountVM> .Entity;

            if (TryUpdateModel(newAccVm))
            {
                CustomerAccount account = null;
                switch (newAccVm.AccountType)
                {
                case AccountType.Purchase:
                    account = new PurchaseAccount();
                    break;

                case AccountType.Rent:
                    account = new RentalAccount();
                    break;
                }
                account.AlternateAddressInstructions = newAccVm.AlternateAddressInstructions;
                account.AlternateAddress             = newAccVm.AlternateAddress;
                account.CustomerId = newAccVm.CustomerId;
                account.OpenedDate = newAccVm.StartDate;

                _accountService.AddAccount(account);
                _accountService.CommitChanges();
                return(RedirectToAction("Edit", "Customer",
                                        new
                {
                    id = account.CustomerId,
                    moveOnToEditAccount = account.CustomerAccountId
                }));
            }
            //if (TryUpdateModel(newAccVm))
            //{
            //    if (TempAccount == null || TempAccount.AccountType != newAccVm.AccountType)
            //    {
            //        TempAccount = _accountService.AccountBuilder(newAccVm.AccountType, newAccVm.CustomerId);
            //        //TempAccount.OneOffItems = InitiateOneOffItems();
            //    }
            //    switch (TempAccount.AccountType)
            //    {
            //        case AccountType.Purchase:
            //            if ((TempAccount as AddPurchaseAccountVM) == null)
            //            {
            //                TempAccount = Mapper.Map<PurchaseAccount, AddPurchaseAccountVM>(TempAccount as PurchaseAccount);
            //                //TempAccount.OneOffItems = InitiateOneOffItems(c => c.PurchaseDefault);
            //                (TempAccountAsAddPurchaseAccountVM()).StartDate = mNewAccountVm.StartDate;
            //            }
            //            else
            //            {
            //                if (mNewAccountVm.StartDate != TempAccountAsAddPurchaseAccountVM().StartDate)
            //                {
            //                    var newStartDate = mNewAccountVm.StartDate;
            //                    TempAccountAsAddPurchaseAccountVM().StartDate = newStartDate;
            //                    TempAccountAsAddPurchaseAccountVM().PurchasedUnits.ForEach(u => u.PurchasedDate = newStartDate);
            //                    TempAccountAsAddPurchaseAccountVM().PurchasedUnits.ForEach(u => u.Contracts.ForEach(c => c.SetStartDate(newStartDate)));
            //                }
            //            }
            //            BuildPurchaseAccountStepper();
            //            return RedirectToAction(Stepper2.NextStep());
            //        case AccountType.Rent:
            //            TempAccount = (TempAccount is AddRentAccountVM) ? TempAccount : Mapper.Map<RentalAccount, AddRentAccountVM>(TempAccount as RentalAccount);
            //            TempAccount.OneOffItems = InitiateOneOffItems(c => c.RentalDefault);
            //            (TempAccountAsAddRentAccountVM()).StartDate = mNewAccountVm.StartDate;
            //            BuildRentAccountStepper();
            //            return RedirectToAction(Stepper2.NextStep());
            //    }
            //}
            return(View(mNewAccountVm));
        }