public void PostingInterests_OnePosting() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfYear }; SavingBookContract saving = new SavingBookContract( ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = product, InterestRate = 0.1 }; List <SavingInterestsPostingEvent> list = new List <SavingInterestsPostingEvent>(); list = saving.PostingInterests(new DateTime(2010, 01, 01), new User { Id = 1 }); Assert.AreEqual(list.Count, 1); }
public void Test_RetrieveForSavings() { SavingsBookProduct savingsBookProduct = new SavingsBookProduct() { Id = 1 }; Person person = new Person { FirstName = "Michael", LastName = "Krejci", Activity = new EconomicActivity(1, "Agriculture", null, false) }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), savingsBookProduct); person.Savings.Add(saving); Account specficAccount = _rules.GetSpecificAccount(OAccounts.CASH_CREDIT, saving, OBookingDirections.Both); Assert.AreEqual(null, specficAccount); specficAccount = _rules.GetSpecificAccount(OAccounts.CASH, saving, OBookingDirections.Both); Assert.AreEqual("1020", specficAccount.Number); }
public void CalculateInterest_ThirtyDay() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfYear }; SavingBookContract saving = new SavingBookContract( ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = product, InterestRate = 0.1 }; List <SavingInterestsAccrualEvent> list = new List <SavingInterestsAccrualEvent>(); list = saving.CalculateInterest(new DateTime(2009, 01, 31), new User { Id = 1 }); Assert.AreEqual(31, list.Count); }
public void Charge_close_reopen_fees() { SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 1, 1), null) { Product = _bookProduct, AgioFees = 0.01, ChequeDepositFees = 100, DepositFees = 50, CloseFees = 100, ReopenFees = 100, OverdraftFees = 100 }; Currency currency = new Currency() { UseCents = true, Code = "SOM", Id = 1, IsPivot = true, Name = "SOM" }; List <SavingEvent> closeEvents = saving.Close(new DateTime(2009, 1, 2), new User(), "closing", false, Teller.CurrentTeller, false); Assert.AreEqual(OSavingsStatus.Closed, saving.Status); foreach (SavingEvent closeEvent in closeEvents) { Assert.AreEqual(closeEvent.Fee, saving.CloseFees); } }
public void TestSavingIsValid_TransferIsInvalid() { SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), TimeProvider.Today, null) { InterestRate = 0.13, Product = _savingsProduct }; SavingBookContract savingTarget = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), TimeProvider.Today, null) { InterestRate = 0.13, Product = _savingsProduct, Status = OSavingsStatus.Closed }; _savingServices = new SavingServices(null, null, new User { Id = 6 }); try { _savingServices.Transfer(saving, saving, TimeProvider.Today, 99, 0, "transfer", new User(), false); Assert.Fail("Saving Contract shouldn't pass validation test before transfer (Saving source = Saving Target)."); } catch (OpenCbsSavingException exception) { Assert.AreEqual((int)OpenCbsSavingExceptionEnum.SavingsContractForTransferIdenticals, (int)exception.Code); } try { _savingServices.Transfer(saving, savingTarget, TimeProvider.Today, 99, 0, "transfer", new User(), false); Assert.Fail("Saving Contract shouldn't pass validation test before transfer (Saving Target is Closed)."); } catch (OpenCbsSavingException exception) { Assert.AreEqual((int)OpenCbsSavingExceptionEnum.CreditTransferAccountInvalid, (int)exception.Code); } }
public int SendNotification(SavingEvent savingEvent, OPaymentMethods paymentMethod) { if (person == null) { throw new ArgumentNullException("client"); } var messageTemplate = GetLocalizedActiveMessageTemplate("Client.LoanDisbursementNotification"); if (messageTemplate == null) { return(0); } SavingBookContract savingsContract = (SavingBookContract)SavingsService.GetSaving(savingEvent.ContracId); //tokens var tokens = new List <Token>(); MessageTokenProvider.AddPersonTokens(tokens, person); MessageTokenProvider.AddSavingEventTokens(tokens, savingEvent, savingsContract); tokens.Add(new Token("Messaging.CurrentDate", DateTime.Now.ToShortDateString())); tokens.Add(new Token("Messaging.CurrentTime", DateTime.Now.ToShortTimeString())); //event notification EventPublisher.MessageTokensAdded(messageTemplate, tokens); var emailAccount = GetEmailAccountOfMessageTemplate(messageTemplate); var toEmail = person.Email; var toName = person.FullName; return(SendNotification(messageTemplate, emailAccount, tokens, toEmail, toName)); }
public void TestSavingIsValid_InitialAmountTooBig() { Assert.Ignore(); SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), TimeProvider.Today, null) { InterestRate = 0.13, Product = _savingsProduct }; _savingServices = new SavingServices(null, null, new User { Id = 6 }); try { Client client = new Person { Id = 1 }; _savingServices.SaveContract(saving, client); saving.FirstDeposit(100000000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); Assert.Fail("Saving Contract shouldn't pass validation test before save (initial amount > product.max)."); } catch (OpenCbsSavingException exception) { Assert.AreEqual((int)OpenCbsSavingExceptionEnum.EntryFeesIsInvalid, (int)exception.Code); } }
public void TestSaving_When_InitialAmount_IsNull() { Assert.Ignore(); SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User()) { CreationDate = TimeProvider.Today, InterestRate = 0.13, Product = _savingsProduct }; _savingServices = new SavingServices(null, null, new User { Id = 6 }); try { _savingServices.SaveContract(saving, new Person { Id = 6 }); saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); Assert.Fail("Saving Contract shouldn't pass validation test before save (Initial Amount is Null)."); } catch (OpenCbsSavingException exception) { Assert.AreEqual(exception.Code, OpenCbsSavingExceptionEnum.EntryFeesIsInvalid); } }
public void CalculateInterest_OneWeek() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Weekly, InterestFrequency = OSavingInterestFrequency.EndOfYear, CalculAmountBase = OSavingCalculAmountBase.MinimalAmount }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 05), null) { Product = product, InterestRate = 0.1 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); List <SavingInterestsAccrualEvent> list = new List <SavingInterestsAccrualEvent>(); list = saving.CalculateInterest(new DateTime(2009, 01, 12), new User { Id = 1 }); Assert.AreEqual(list.Count, 1); Assert.AreEqual(list[0].Amount, 100); }
public void Charge_overdaft_fees() { SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = _bookProduct, AgioFees = 0.01, ChequeDepositFees = 100, DepositFees = 50, CloseFees = 100, ReopenFees = 100, OverdraftFees = 100 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); Currency currency = new Currency() { UseCents = true, Code = "SOM", Id = 1, IsPivot = true, Name = "SOM" }; Assert.AreEqual(1000, saving.GetBalance().Value); //Below, we explicitly implement withdraw method from <Saving services>.<Withdraw>, since withdraw method of 'saving' object doesn't implement // overdraft fee by default List <SavingEvent> withdrawEvents = saving.Withdraw(1100, new DateTime(2009, 1, 2), "withdraw", new User(), false, null); if (saving.GetBalance() < 0 && !saving.InOverdraft) { saving.ChargeOverdraftFee(new DateTime(2009, 1, 2), new User()); } Assert.AreEqual(-200, saving.GetBalance().Value); }
public void AddSavingBook() { SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User() { Id = 1 }, new DateTime(2009, 01, 01), _savingsBookProduct, null) { Code = "S/CR/2009/SAVIN-1/BAR-1", Status = OSavingsStatus.Active, InterestRate = 0.01, FlatWithdrawFees = 3, FlatTransferFees = 3 }; saving.InitialAmount = 1000; saving.EntryFees = 10; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); User user = new User { Id = 1 }; saving.Events[0].User = user; saving.Events[0].Id = 400; saving.SavingsOfficer = user; saving.Id = _savingManager.Add(saving, new Person { Id = 6 }); _savingEventManager.Add(saving.Events[0], saving.Id); SavingBookContract retrievedSaving = (SavingBookContract)_savingManager.Select(saving.Id); _compareSavings(saving, retrievedSaving); }
public void PostingInterests_NoPosting() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfMonth, Periodicity = new InstallmentType("Monthly", 0, 1) }; SavingBookContract saving = new SavingBookContract( ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = product, InterestRate = 0.1, NextMaturity = new DateTime(2009, 01, 01) }; List <SavingInterestsPostingEvent> list = new List <SavingInterestsPostingEvent>(); list = saving.PostingInterests(new DateTime(2009, 01, 02), new User { Id = 1 }); Assert.AreEqual(0, list.Count); }
public void PostingInterests_OnePosting() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfDay, Periodicity = new InstallmentType("Daily", 1, 0) }; SavingBookContract saving = new SavingBookContract( ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = product, InterestRate = 0.1 }; saving.NextMaturity = saving.CreationDate; List <SavingInterestsPostingEvent> list = new List <SavingInterestsPostingEvent>(); list = saving.PostingInterests( saving.NextMaturity.Value, new User { Id = 1 } ); Assert.AreEqual(1, list.Count); }
public void CalculateInterest_TwoOperation_In_OneDay() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Weekly, InterestFrequency = OSavingInterestFrequency.EndOfYear, CalculAmountBase = OSavingCalculAmountBase.MinimalAmount, WithdrawFeesType = OSavingsFeesType.Flat, FlatWithdrawFees = 0 }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = product, InterestRate = 0.1, FlatWithdrawFees = 0 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); saving.Withdraw(250, new DateTime(2009, 01, 02), "retrait", new User(), false, null); // saving.Deposit(100, new DateTime(2009, 02, 01), "depot", new User(), true, false, OPaymentMethods.Cash, null, null); saving.Deposit(100, new DateTime(2009, 02, 01), "depot", new User(), true, false, OSavingsMethods.Cash, null, null); List <SavingInterestsAccrualEvent> list = new List <SavingInterestsAccrualEvent>(); list = saving.CalculateInterest(new DateTime(2009, 01, 08), new User { Id = 1 }); Assert.AreEqual(list.Count, 1); Assert.AreEqual(list[0].Amount, 75); }
public void CalculateInterest_OneMonth_Withdraw() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Monthly, InterestFrequency = OSavingInterestFrequency.EndOfYear, CalculAmountBase = OSavingCalculAmountBase.MinimalAmount, WithdrawFeesType = OSavingsFeesType.Flat, FlatWithdrawFees = 0 }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = product, InterestRate = 0.1, FlatWithdrawFees = 0 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); saving.Withdraw(100, new DateTime(2009, 01, 15), "depot", new User(), false, null); List <SavingInterestsAccrualEvent> list = new List <SavingInterestsAccrualEvent>(); list = saving.CalculateInterest(new DateTime(2009, 02, 01), new User { Id = 1 }); Assert.AreEqual(list.Count, 1); Assert.AreEqual(list[0].Amount, 90); }
public void TestSavingIsValid_TransferAmountIsInvalid() { Assert.Ignore(); SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), TimeProvider.Today, null) { Id = 1, InterestRate = 0.13, Product = _savingsProduct }; SavingBookContract savingTarget = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), TimeProvider.Today, null) { Id = 2, InterestRate = 0.13, Product = _savingsProduct }; _savingManagerMock = new DynamicMock(typeof(SavingManager)); _savingServices = new SavingServices((SavingManager)_savingManagerMock.MockInstance, null, new User { Id = 6 }); _savingManagerMock.Expect("UpdateAccountsBalance", saving, null); _savingManagerMock.Expect("UpdateAccountsBalance", savingTarget, null); try { _savingServices.Transfer(saving, savingTarget, TimeProvider.Today, 99, 0, "transfer", new User(), false); Assert.Fail("Saving Contract shouldn't pass validation test before transfer (transfer amount < transfer.min)."); } catch (OpenCbsSavingException exception) { Assert.AreEqual((int)OpenCbsSavingExceptionEnum.TransferAmountIsInvalid, (int)exception.Code); } _savingManagerMock.Expect("UpdateAccountsBalance", saving, null); _savingManagerMock.Expect("UpdateAccountsBalance", savingTarget, null); try { _savingServices.Transfer(saving, savingTarget, TimeProvider.Today, 301, 0, "transfer", new User(), false); Assert.Fail("Saving Contract shouldn't pass validation test before transfer (transfer amount > transfer.max)."); } catch (OpenCbsSavingException exception) { Assert.AreEqual((int)OpenCbsSavingExceptionEnum.TransferAmountIsInvalid, (int)exception.Code); } _savingManagerMock.Expect("UpdateAccountsBalance", saving, null); _savingManagerMock.Expect("UpdateAccountsBalance", savingTarget, null); try { _savingServices.Transfer(saving, savingTarget, TimeProvider.Today, 200, 0, "transfer", new User(), false); Assert.Fail("Saving Contract shouldn't pass validation test before transfer (balance < balance.min)."); } catch (OpenCbsSavingException exception) { Assert.AreEqual((int)OpenCbsSavingExceptionEnum.BalanceIsInvalid, (int)exception.Code); } }
public void SavingUnblockEventOnLoanRepayment() { SavingsBookProduct savingsProduct = new SavingsBookProduct { Id = 1, Name = "SavingProduct", Code = "P123", InitialAmountMin = 1000, InitialAmountMax = 2000, DepositMin = 250, DepositMax = 400, WithdrawingMin = 400, WithdrawingMax = 450, TransferMin = 100, TransferMax = 300, InterestRateMin = 0.12, InterestRateMax = 0.20, BalanceMin = 1000, BalanceMax = 2000, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfMonth, EntryFeesMin = 10, EntryFeesMax = 20, Currency = new Currency { Id = 1 }, WithdrawFeesType = OSavingsFeesType.Flat, FlatWithdrawFeesMin = 1, FlatWithdrawFeesMax = 5, TransferFeesType = OSavingsFeesType.Flat, FlatTransferFeesMin = 1, FlatTransferFeesMax = 5, DepositFeesMin = 1, DepositFeesMax = 5, ManagementFeeFreq = new InstallmentType { Id = 1, Name = "Monthly", NbOfDays = 0, NbOfMonths = 1 }, AgioFeesFreq = new InstallmentType { Id = 2, Name = "Daily", NbOfDays = 1, NbOfMonths = 0 } }; SavingBookContract compulsorySaving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User()) { CreationDate = _contractStartDate, InterestRate = 0.13, Product = savingsProduct }; _myContract.CompulsorySavings = compulsorySaving; _myContract.CompulsorySavingsPercentage = 5; _myContract.Disburse(_contractStartDate, true, true); _myContract.Repay(1, _contractStartDate, 1180, false, true); //Totall repayment Assert.IsTrue(compulsorySaving.Events.Any(e => !e.Deleted && e.Code == OSavingEvents.UnblockCompulsorySavings)); }
public void PostingInterests_TenPosting() { // Assert.Ignore(); SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfDay, Periodicity = new InstallmentType("Daily", 1, 0) }; DateTime postingDate = new DateTime(2009, 01, 10); SavingBookContract saving = new SavingBookContract( ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = product, InterestRate = 0.1, NextMaturity = new DateTime(2009, 01, 01) }; List <SavingInterestsPostingEvent> list = new List <SavingInterestsPostingEvent>(); List <SavingInterestsAccrualEvent> savingInterestsAccrualEvents = saving.CalculateInterest( new DateTime(2009, 01, 10), new User { Id = 1 }); foreach (SavingInterestsAccrualEvent accrualEvent in savingInterestsAccrualEvents) { saving.Events.Add(accrualEvent); } saving.NextMaturity = saving.CreationDate.AddDays(-1); while ( DateCalculationStrategy.GetNextMaturity(saving.NextMaturity.Value, saving.Product.Periodicity, 1) <= postingDate) { saving.NextMaturity = DateCalculationStrategy.GetNextMaturity(saving.NextMaturity.Value, saving.Product.Periodicity, 1); list.AddRange(saving.PostingInterests(saving.NextMaturity.Value, new User { Id = 1 })); foreach (var postingEvent in list) { saving.Events.Add(postingEvent); } list.Clear(); } Assert.AreEqual(10, saving.Events.FindAll(item => item is SavingInterestsPostingEvent).Count); }
public void SeveralMgmtFeeEvents() { _saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2007, 08, 11), _bookProduct, null); _saving.AgioFees = 0.1; _saving.ManagementFees = 50; _saving.FirstDeposit(10000, new DateTime(2007, 08, 01), null, new User(), Teller.CurrentTeller); _saving.Closure(new DateTime(2007, 12, 31), new User()); List <SavingEvent> events = _saving.Events.FindAll(item => item is SavingManagementFeeEvent); Assert.AreEqual(events.Count, 4); Assert.AreEqual(9800, _saving.GetBalance().Value); }
public void PostingInterests_ThreePosting() { // Assert.Ignore(); SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfWeek, Periodicity = new InstallmentType("Weekly", 7, 0) }; User user = new User() { Id = 1 }; DateTime creationDate = new DateTime(2009, 01, 01); DateTime postingDate = new DateTime(2009, 01, 26); SavingBookContract saving = new SavingBookContract( ApplicationSettings.GetInstance(""), user, creationDate, null) { Product = product, InterestRate = 0.1 }; saving.FirstDeposit(1000, saving.CreationDate, 0, user, new Teller()); List <SavingInterestsAccrualEvent> accrualEvents = saving.CalculateInterest(postingDate, user); foreach (var accrualEvent in accrualEvents) { saving.Events.Add(accrualEvent); } List <SavingInterestsPostingEvent> list = new List <SavingInterestsPostingEvent>(); List <SavingInterestsPostingEvent> postingEvents = new List <SavingInterestsPostingEvent>(); saving.NextMaturity = saving.GetNextMaturity(saving.CreationDate, saving.Periodicity); while (saving.NextMaturity <= postingDate) { list = saving.PostingInterests(saving.NextMaturity.Value, new User { Id = 1 }); postingEvents.AddRange(list); foreach (var postingEvent in list) { saving.Events.Add(postingEvent); } saving.NextMaturity = saving.GetNextMaturity(saving.NextMaturity.Value, saving.Periodicity); } Assert.AreEqual(3, postingEvents.Count); }
public void Init(IClient client, Loan loan, Guarantee guarantee, SavingBookContract savings, IList <IPrintButtonContextMenuStrip> printMenus) { _printButton.AttachmentPoint = AttachmentPoint.CreditCommittee; Visibility visibility; switch (client.Type) { case OClientTypes.Person: visibility = Visibility.Individual; break; case OClientTypes.Group: visibility = Visibility.Group; break; case OClientTypes.Corporate: visibility = Visibility.Corporate; break; default: visibility = Visibility.All; break; } _printButton.Visibility = visibility; _printButton.ReportInitializer = report => { report.SetExtra("loan", loan); report.SetParamValue("user_id", User.CurrentUser.Id); if (loan != null) { report.SetParamValue("contract_id", loan.Id); } }; _printButton.LoadReports(); foreach (var item in printMenus) { var menuItems = item.GetContextMenuStrip(client, loan, guarantee, savings, AttachmentPoint.CreditCommittee.ToString()); if (menuItems == null) { continue; } foreach (var menuItem in menuItems) { _printButton.Menu.Items.Add(menuItem); } } }
public void Test_SimulateCloseAccount() { Assert.Ignore(); _savingServices = new SavingServices(null, null, new User { Id = 6 }); SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User { Id = 6 }, new DateTime(2009, 01, 01), _savingsProduct, null) { InterestRate = 0.15, ManagementFees = 0, AgioFees = 0 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); Assert.AreEqual(_savingServices.SimulateCloseAccount(saving, new DateTime(2009, 02, 15), new User(), false, Teller.CurrentTeller).GetBalance(), 5650); }
public void PostingInterests_OnePosting() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfMonth, Periodicity = new InstallmentType("Monthly", 0, 1) }; User user = new User() { Id = 1 }; DateTime closureDate = new DateTime(2009, 02, 01); SavingBookContract saving = new SavingBookContract( ApplicationSettings.GetInstance(""), user, new DateTime(2009, 01, 01), null ) { Product = product, InterestRate = 0.1 }; saving.NextMaturity = DateCalculationStrategy.GetNextMaturity(saving.CreationDate.Date, saving.Periodicity, 1); List <SavingInterestsAccrualEvent> savingInterestsAccrualEvents = saving.CalculateInterest(closureDate, user); foreach (var accrualEvent in savingInterestsAccrualEvents) { saving.Events.Add(accrualEvent); } List <SavingInterestsPostingEvent> list = new List <SavingInterestsPostingEvent>(); list = saving.PostingInterests(closureDate, user); Assert.AreEqual(1, list.Count); }
public void SetUp() { ApplicationSettings dataParam = ApplicationSettings.GetInstance(""); dataParam.DeleteAllParameters(); dataParam.AddParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash); Currency currency = new Currency() { UseCents = true, Code = "SOM", Id = 1, IsPivot = true, Name = "SOM" }; _bookProduct = new SavingsBookProduct { CalculAmountBase = OSavingCalculAmountBase.MinimalAmount, Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfWeek, ManagementFeeFreq = new InstallmentType { Id = 1, Name = "Monthly", NbOfDays = 0, NbOfMonths = 1 }, AgioFeesFreq = new InstallmentType { Id = 2, Name = "Daily", NbOfDays = 1, NbOfMonths = 0 }, WithdrawFeesType = OSavingsFeesType.Flat, FlatWithdrawFees = 0, Currency = currency }; _saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2007, 08, 11), _bookProduct, null); }
public void Charge_reopen_fees() { SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 1, 1), null) { Product = _bookProduct, AgioFees = 0.01, ChequeDepositFees = 100, DepositFees = 50, CloseFees = 100, ReopenFees = 100, OverdraftFees = 100 }; saving.Close(new DateTime(2009, 1, 2), new User(), "closing", false, Teller.CurrentTeller, false); List <SavingEvent> reopenEvents = saving.Reopen(100, new DateTime(2009, 1, 3), new User(), "reopen", false); foreach (SavingEvent reopenEvent in reopenEvents) { Assert.AreEqual(saving.ReopenFees, reopenEvent.Fee); } }
public void RateWithdrawFees() { SavingsBookProduct product = new SavingsBookProduct() { WithdrawFeesType = OSavingsFeesType.Rate, RateWithdrawFeesMin = 0.01, RateWithdrawFeesMax = 0.05 }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), product, null) { RateWithdrawFees = 0.03 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); List <SavingEvent> withdrawEvents = saving.Withdraw(10, new DateTime(2009, 01, 02), "withdraw", new User(), false, null); Assert.AreEqual(1, withdrawEvents.Count); Assert.AreEqual(10, withdrawEvents[0].Amount.Value); Assert.AreEqual(0.3, ((ISavingsFees)withdrawEvents[0]).Fee.Value); Assert.AreEqual(989.7, saving.GetBalance().Value); }
public void CalculateInterest_AccrualhMode_Daily_EndOfYear_OneClosure_AfterOneWeek_Agio() { Assert.Ignore(); ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); _bookProduct.InterestFrequency = OSavingInterestFrequency.EndOfYear; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = _bookProduct, InterestRate = 0.1, AgioFees = 0.1 }; saving.Closure(new DateTime(2009, 01, 08), new User() { Id = 1 }); int accrualEvents = saving.Events.FindAll(item => item is SavingInterestsAccrualEvent).Count; int postingEvents = saving.Events.FindAll(items => items is SavingInterestsPostingEvent).Count; List <SavingEvent> agioEvents = saving.Events.FindAll(items => items is SavingAgioEvent); Assert.AreEqual(agioEvents.Count, 7); Assert.AreEqual(agioEvents[0].Fee, 10); Assert.AreEqual(saving.GetBalance(), -170); // saving.Deposit(200, new DateTime(2009, 01, 08), "depot", new User(), false, false, OPaymentMethods.Cash, null, null); saving.Deposit(200, new DateTime(2009, 01, 08), "depot", new User(), false, false, OSavingsMethods.Cash, null, null); //saving.Withdraw(230, new DateTime(2009, 02, 03), "retrait", new User(), false); saving.Closure(new DateTime(2009, 01, 15), new User() { Id = 1 }); List <SavingEvent> agioEvents2 = saving.Events.FindAll(items => items is SavingAgioEvent); Assert.AreEqual(agioEvents2.Count, 13); Assert.AreEqual(agioEvents2[9].Fee, 13); Assert.AreEqual(saving.GetBalance(), -51); }
public void UpdateAccountsBalanceSaving() { Assert.Ignore(); // Ru55 SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User() { Id = 1 }, new DateTime(2009, 01, 01), _savingsBookProduct, null) { Code = "S/CR/2009/SAVIN-1/BAR-2", Status = OSavingsStatus.Active, InterestRate = 0.01, FlatWithdrawFees = 3, FlatTransferFees = 3, AgioFees = 0.1 }; saving.Events[0].User = new User() { Id = 1 }; saving.Id = _savingManager.Add(saving, new Person { Id = 6 }); saving = (SavingBookContract)_savingManager.Select(saving.Id); saving.Closure(new DateTime(2009, 02, 01), new User { Id = 1 }); saving.Withdraw(50, new DateTime(2009, 02, 01), "testWithdraw", new User { Id = 1 }, false, null, new PaymentMethod()); saving.Closure(new DateTime(2010, 01, 01), new User { Id = 1 }); SavingBookContract retrievedSaving = (SavingBookContract)_savingManager.Select(saving.Id); }
public void CloseSaving() { SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User() { Id = 1 }, new DateTime(2009, 01, 01), _savingsBookProduct, null) { Code = "S/CR/2009/SAVIN-1/BAR-1", Status = OSavingsStatus.Active, InterestRate = 0.01, FlatWithdrawFees = 3 }; saving.InitialAmount = 1000; saving.EntryFees = 10; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); User user = new User { Id = 1 }; saving.Events[0].User = user; saving.SavingsOfficer = user; saving.Id = _savingManager.Add(saving, new Person() { Id = 6 }); saving.Status = OSavingsStatus.Closed; saving.ClosedDate = new DateTime(2009, 10, 01); _savingManager.UpdateStatus(saving.Id, saving.Status, saving.ClosedDate.Value); SavingBookContract retrievedSaving = (SavingBookContract)_savingManager.Select(saving.Id); Assert.AreEqual(OSavingsStatus.Closed, retrievedSaving.Status); Assert.AreEqual(new DateTime(2009, 10, 01), retrievedSaving.ClosedDate.Value); }
public void CalculateInterest_NoDay() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Weekly, InterestFrequency = OSavingInterestFrequency.EndOfYear, CalculAmountBase = OSavingCalculAmountBase.MinimalAmount }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 05), null) { Product = product, InterestRate = 0.1 }; List <SavingInterestsAccrualEvent> list = new List <SavingInterestsAccrualEvent>(); list = saving.CalculateInterest(new DateTime(2009, 01, 05), new User { Id = 1 }); Assert.AreEqual(list.Count, 0); }
public EndOfWeek(SavingBookContract pSaving, User pUser, int pWeekEndDay2) { _saving = pSaving; _user = pUser; _weekEndDay2 = pWeekEndDay2; }
public PostingMethods(SavingBookContract pSaving, User pUser) { _saving = pSaving; _user = pUser; }
public Monthly(SavingBookContract pSaving, User pUser) { _saving = pSaving; _user = pUser; }
public EndOfMonth(SavingBookContract pSaving, User pUser) { _saving = pSaving; _user = pUser; }