public void CalculateInterest_AccrualhMode_Daily_EndOfYear_OneClosure_AfterOneWeek() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); _product.InterestFrequency = OSavingInterestFrequency.EndOfYear; SavingBookContract saving = new SavingBookContract( ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = _product, InterestRate = 0.1, AgioFees = 8 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); 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; Assert.AreEqual(7, accrualEvents); Assert.AreEqual(0, postingEvents); Assert.AreEqual(1000m, saving.GetBalance().Value); }
public void PostingInterests_12Posting() { // Assert.Ignore(); 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 creationDate = new DateTime(2009, 01, 01); SavingBookContract saving = new SavingBookContract( ApplicationSettings.GetInstance(""), user, creationDate, null ) { Product = product, InterestRate = 0.1 }; DateTime closureDate = new DateTime(2010, 01, 01); saving.NextMaturity = saving.CreationDate.Date; saving.NumberOfPeriods = 1; saving.FirstDeposit(1000, creationDate, 0, user, new Teller()); saving.NextMaturity = DateCalculationStrategy.GetNextMaturity( saving.CreationDate.Date, saving.Product.Periodicity, saving.NumberOfPeriods); List<SavingInterestsAccrualEvent> interestsAccrualEvents = saving.CalculateInterest(closureDate, new User {Id = 1}); foreach (var accrualEvent in interestsAccrualEvents) { saving.Events.Add(accrualEvent); } List<SavingInterestsPostingEvent> list = new List<SavingInterestsPostingEvent>(); List<SavingInterestsPostingEvent> postingEvents = new List<SavingInterestsPostingEvent>(); while (saving.NextMaturity.Value <= closureDate) { list = saving.PostingInterests(saving.NextMaturity.Value, new User() {Id = 1}); postingEvents.AddRange(list); foreach (var postingEvent in list) { saving.Events.Add(postingEvent); } saving.NextMaturity = DateCalculationStrategy.GetNextMaturity(saving.NextMaturity.Value, saving.Periodicity, 1); } list = saving.PostingInterests(new DateTime(2010, 01, 01), new User { Id = 1 }); Assert.AreEqual(12, postingEvents.Count); }
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 CalculateInterest_AccrualMode_Weekly_EndOfYear_OneClosure_DayOfCreation() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); _product.InterestBase = OSavingInterestBase.Weekly; _product.InterestFrequency = OSavingInterestFrequency.EndOfYear; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 15), null) { Product = _product, InterestRate = 0.1 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 15), null, new User(), Teller.CurrentTeller); List<SavingEvent> events = saving.Closure(new DateTime(2009, 01, 15, 1, 1, 1), new User() { Id = 1 }); int accrualEvents = saving.Events.FindAll(item => item is SavingInterestsAccrualEvent).Count; int postingEvents = saving.Events.FindAll(item => item is SavingInterestsPostingEvent).Count; Assert.AreEqual(events.Count, 1); Assert.AreEqual(accrualEvents, 0); Assert.AreEqual(postingEvents, 0); Assert.AreEqual(saving.GetBalance(), 1000); }
public void CalculateInterest_AccrualMode_Weekly_EndOfWeek_OneClosure_AfterOneWeek() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); _product.InterestBase = OSavingInterestBase.Weekly; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = _product, InterestRate = 0.1, ManagementFees = 10, AgioFees = 0.1 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); List<SavingEvent> events = saving.Closure(new DateTime(2009, 01, 08, 1, 1, 1), new User() { Id = 1 }); int accrualEvents = saving.Events.FindAll(item => item is SavingInterestsAccrualEvent).Count; int postingEvents = saving.Events.FindAll(item => item is SavingInterestsPostingEvent).Count; Assert.AreEqual(3, events.Count); Assert.AreEqual(1, accrualEvents); Assert.AreEqual(1, postingEvents); Assert.AreEqual(1100m, saving.GetBalance().Value); }
public void Get_Balance_At_Date() { SavingsBookProduct product = new SavingsBookProduct() { WithdrawFeesType = OSavingsFeesType.Flat, FlatWithdrawFees = 0 }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), product, null) { FlatWithdrawFees = 0, DepositFees = 5, CloseFees = 6, ManagementFees = 7}; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); // saving.Deposit(100, new DateTime(2009, 02, 01), "depot", new User(), false, false, OPaymentMethods.Cash, null, null); saving.Deposit(100, new DateTime(2009, 02, 01), "depot", new User(), false, false, OSavingsMethods.Cash, null, null); saving.Withdraw(230, new DateTime(2009, 02, 03), "retrait", new User(), false, null); Assert.AreEqual(saving.GetBalance(new DateTime(2009, 01, 31)), 1000); Assert.AreEqual(saving.GetBalance(new DateTime(2009, 02, 01)), 1100); Assert.AreEqual(saving.GetBalance(new DateTime(2009, 02, 02)), 1100); Assert.AreEqual(saving.GetBalance(new DateTime(2009, 02, 03)), 870); }
public void Get_Set_CreationDate() { SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2008, 10, 21), null); saving.FirstDeposit(12m, new DateTime(2008, 10, 21), 0, new User(), Teller.CurrentTeller); Assert.AreEqual(new DateTime(2008, 10, 21), saving.CreationDate); }
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_TwoOperation_In_OneDay() { 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(250, new DateTime(2009, 01, 15), "retrait", new User(), false, null); // saving.Deposit(100, new DateTime(2009, 01, 15), "depot", new User(), true, false, OPaymentMethods.Cash, null, null); saving.Deposit(100, new DateTime(2009, 01, 15), "depot", new User(), true, false, OSavingsMethods.Cash, null, 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, 75); }
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" }; _product = 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), _product, null); _saving.FirstDeposit(12m, new DateTime(2007, 08, 11), 0, new User(), new Teller()); User.CurrentUser = new User {Id = 1}; Teller.CurrentTeller = new Teller(); }
public void CalculateInterest_AccrualMode_Daily_EndOfMonth_OneClosure_65Days_AfterCreation() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); _product.InterestFrequency = OSavingInterestFrequency.EndOfMonth; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = _product, InterestRate = 1, ManagementFees = 0, AgioFees = 0 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); saving.Closure(new DateTime(2009, 03, 07), new User() { Id = 1 }); int accrualEvents = saving.Events.FindAll(item => item is SavingInterestsAccrualEvent).Count; int postingEvents = saving.Events.FindAll(items => items is SavingInterestsPostingEvent).Count; //OCurrency interests = saving.Events.Where(item => item is SavingInterestsAccrualEvent).Sum(item => item.Amount.Value); Assert.AreEqual(accrualEvents, 65); Assert.AreEqual(postingEvents, 2); Assert.AreEqual(saving.GetBalance(), 929000); }
public void Get_Set_Product() { SavingsBookProduct product = new SavingsBookProduct { Id = 1 }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), TimeProvider.Today, null) {Product = product}; saving.FirstDeposit(12m, TimeProvider.Today, 0, new User(), Teller.CurrentTeller); Assert.AreEqual(product, saving.Product); }
public void OneMgmtFeeEvent() { // Fix // Assert.Ignore(); _saving = new SavingBookContract( ApplicationSettings.GetInstance(""), new User(), new DateTime(2007, 08, 11), _product, null ); _saving.FirstDeposit(10000m, new DateTime(2007, 08, 11), 0, new User(), Teller.CurrentTeller); _saving.AgioFees = 0.1; _saving.ManagementFees = 50; _saving.Closure(new DateTime(2007, 9, 11), new User()); List<SavingEvent> events = _saving.Events.FindAll(item => item is SavingManagementFeeEvent); Assert.AreEqual(events.Count, 1); }
public void Get_Set_InitialAmount() { List<SavingEvent> events = new List<SavingEvent> { new SavingWithdrawEvent {Amount = 75, Date = new DateTime(2008, 10, 21)}, new SavingDepositEvent {Amount = 12.46m, Date = new DateTime(2008, 08, 18)}, new SavingDepositEvent {Amount = 86, Date = new DateTime(2008, 09, 01)} }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2008, 07, 18), null); saving.InitialAmount = 1000; saving.FirstDeposit(1000, new DateTime(2008, 07, 18), null, new User(), Teller.CurrentTeller); saving.Events.AddRange(events); Assert.AreEqual(1023.46m, saving.GetBalance().Value); Assert.AreEqual(1000m, saving.InitialAmount.Value); }
public void Get_Set_Id() { SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), TimeProvider.Today, null) {Id = 1}; saving.FirstDeposit(12m, TimeProvider.Today, 0, new User(), Teller.CurrentTeller); Assert.AreEqual(1, saving.Id); }
public void Get_Set_Events() { List<SavingEvent> events = new List<SavingEvent>(); SavingInitialDepositEvent eventDeposit = new SavingInitialDepositEvent { Id = 1, Date = new DateTime(2008, 10, 18), Description = "First deposit of 100", Amount = 100 }; events.Add(eventDeposit); SavingWithdrawEvent eventWithdraw = new SavingWithdrawEvent { Id = 2, Date = new DateTime(2008, 10, 08), Description = "2nd withdraw of 75", Amount = 75 }; events.Add(eventWithdraw); SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2008, 08, 18), null); saving.FirstDeposit(100, new DateTime(2008, 08, 18), null, new User(), Teller.CurrentTeller); saving.Events.AddRange(events); Assert.AreEqual(events.Count+1, saving.Events.Count); saving.Events.Sort(); events.Sort(); Assert.AreEqual(100m, saving.Events[0].Amount.Value); Assert.AreEqual(75m, saving.Events[1].Amount.Value); Assert.AreEqual(100m, saving.Events[2].Amount.Value); }
public void CalculateInterest_OneWeek_Withdraw_FirstDayOfMonth() { 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(100, new DateTime(2009, 01, 01), "retrait", new User(), false, null, new PaymentMethod()); 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, 90); }
public void CalculateInterest_AccrualMode_Daily_EndOfMonth_OneClosure_TwoMonthsAndOneBrouette_AfterCreation() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); _product.InterestFrequency = OSavingInterestFrequency.EndOfMonth; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = _product, InterestRate = 0.01, ManagementFees = 10, AgioFees = 0.1 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); saving.Closure(new DateTime(2009, 02, 04), new User() { Id = 1 }); int accrualEvents = saving.Events.FindAll(item => item is SavingInterestsAccrualEvent).Count; int postingEvents = saving.Events.FindAll(items => items is SavingInterestsPostingEvent).Count; Assert.AreEqual(accrualEvents, 34); Assert.AreEqual(postingEvents, 1); Assert.AreEqual(saving.GetBalance(), 1299.9); }
public void TestSavingIsValid_InitialAmountTooSmall() { 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(1, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); Assert.Fail("Saving Contract shouldn't pass validation test before save (initial amount < product.min)."); } catch (OpenCbsSavingException exception) { Assert.AreEqual((int)OpenCbsSavingExceptionEnum.EntryFeesIsInvalid, (int)exception.Code); } }
public void CalculateInterest_AccrualMode_Daily_EndOfWeek_OneClosure_On_PostingDate() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = _product, InterestRate = 0.01, AgioFees = 0 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); saving.Closure(new DateTime(2009, 01, 05), new User() { Id = 1 }); int accrualEvents = saving.Events.FindAll(item => item is SavingInterestsAccrualEvent).Count; int postingEvents = saving.Events.FindAll(items => items is SavingInterestsPostingEvent).Count; OCurrency interests = saving.Events.Where(item => item is SavingInterestsAccrualEvent).Sum(item => item.Amount.Value); Assert.AreEqual(accrualEvents, 4); Assert.AreEqual(postingEvents, 0); Assert.AreEqual(saving.GetBalance(), 1000); }
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 Create_Saving_Book_Account_With_EntryFees() { SavingsBookProduct product = new SavingsBookProduct() { Name = "NewSavingProduct", InitialAmountMin = 1000, InitialAmountMax = 2000, DepositMin = 100, DepositMax = 200, WithdrawingMin = 100, WithdrawingMax = 200, InterestRate = 0.2, BalanceMin = 1000, BalanceMax = 2000, InterestBase = OSavingInterestBase.Monthly, InterestFrequency = OSavingInterestFrequency.EndOfYear, CalculAmountBase = OSavingCalculAmountBase.MinimalAmount, ClientType = OClientTypes.All, EntryFeesMin = 5, EntryFeesMax = 15, Currency = new Currency { Id = 1 } }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), product, null); saving.InitialAmount = 1000; saving.EntryFees = 10; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), 10, new User(), Teller.CurrentTeller); Assert.AreEqual(saving.GetBalance(), 1000); Assert.AreEqual(saving.Events.Count, 1); Assert.AreEqual(saving.InitialAmount, 1000); Assert.AreEqual(saving.EntryFees, 10); }
public void CalculateInterest_OneMonth() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Monthly, InterestFrequency = OSavingInterestFrequency.EndOfYear, CalculAmountBase = OSavingCalculAmountBase.MinimalAmount }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = product, InterestRate = 0.1 }; saving.FirstDeposit(100, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); 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, 10); }
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 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 Get_Set_Code_ForPerson() { SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2007, 08, 11), null) {Code = "", Product = new SavingsBookProduct() {Id = 2, Code = "SavingProduct"}}; saving.FirstDeposit(12m, new DateTime(2007, 08, 11), 0, new User(), Teller.CurrentTeller); saving.GenerateSavingCode(new Person { Id = 2, FirstName="Vincent", LastName = "Guigui" }, 3, "BC/YY/PC-PS/CN-ID", "BC"); Assert.AreEqual("S/BC/2007/SAVIN-4/GUIG-2", saving.Code); saving.GenerateSavingCode(new Person { Id = 2, FirstName = "Vincent", LastName = "Guigui" }, 4, "IC/BC/CS/ID", "BC"); Assert.AreEqual("BC/05/00002", saving.Code); }
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_AccrualMode_Monthly_EndOfYear_OneClosure_On_PostingDate() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); _product.InterestBase = OSavingInterestBase.Monthly; _product.InterestFrequency = OSavingInterestFrequency.EndOfYear; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) { Product = _product, InterestRate = 0.1, ManagementFees = 10, AgioFees = 0.1 }; saving.FirstDeposit(1000, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); saving.Closure(new DateTime(2010, 01, 01, 1, 1, 1), new User() { Id = 1 }); int accrualEvents = saving.Events.FindAll(item => item is SavingInterestsAccrualEvent).Count; int postingEvents = saving.Events.FindAll(item => item is SavingInterestsPostingEvent).Count; Assert.AreEqual(accrualEvents, 12); Assert.AreEqual(postingEvents, 1); Assert.AreEqual(2014.0, saving.GetBalance().Value); }
public void Charge_agio_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); saving.Closure(new DateTime(2009, 1, 12), new User()); //agio for ten days Assert.AreEqual(-111.55, saving.GetBalance().Value); }
public void CalculateInterest_AccrualhMode_Daily_EndOfYear_OneClosure_AfterOneWeek_Agio() { ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual); _product.InterestFrequency = OSavingInterestFrequency.EndOfYear; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), null) {Product = _product, InterestRate = 0.1, AgioFees = 0.1}; saving.FirstDeposit(-100, new DateTime(2009, 01, 01), 0, new User(), Teller.CurrentTeller); 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; /*Assert.AreEqual(accrualEvents, 7); Assert.AreEqual(postingEvents, 0); Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.ACCOUNT_PAYABLE_INTERESTS_ON_SAVINGS_BOOKS, 1).Balance.Value, 700); Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.SAVINGS, 1).Balance.Value, 1000); Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.CASH, 1).Balance.Value, 1000); Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.INTERESTS_ON_DEPOSIT_ACCOUNT, 1).Balance.Value, 700); */ 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(), -194.88); // 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, 7); Assert.AreEqual(saving.GetBalance(), 5.12); }