public void PostingInterests_NoPosting() { // Assert.Ignore(); SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfYear, Periodicity = new InstallmentType("Yearly", 0, 12) }; 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, 02, 01), new User { Id = 1 }); Assert.AreEqual(list.Count, 0); }
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 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 SavingBookContract(ApplicationSettings pApplicationSettings, User pUser, SavingsBookProduct pProduct) { base.Product = pProduct; Events = new List<SavingEvent>(); ApplicationSettings = pApplicationSettings; User = pUser; _loans = new List<Loan>(); UseTermDeposit = pProduct.UseTermDeposit; }
public SavingBookContract(ApplicationSettings pApplicationSettings, User pUser, DateTime pCreationDate, SavingsBookProduct pProduct, IClient pClient) { Client = pClient; CreationDate = pCreationDate; base.Product = pProduct; Events = new List<SavingEvent>(); ApplicationSettings = pApplicationSettings; User = pUser; _loans = new List<Loan>(); }
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 CloseSavingsForm(ISavingProduct savingBookProduct, OCurrency pBalance, OCurrency pCloseFees) { InitializeComponent(); _amount = pBalance; _closeFees = pCloseFees; if (savingBookProduct is SavingsBookProduct) _savingsBookProduct = (SavingsBookProduct)savingBookProduct; lbTotalAmountValue.Text = pBalance.GetFormatedValue(UseCents); gbCloseFees.Enabled = (_closeFees.Value > 0); Initialize(); }
public FrmAddSavingBookProduct(SavingsBookProduct product) { InitializeComponent(); _savingsProduct = product; InitializeComboBoxCurrencies(); LoadInterestComboBox(); LoadManagementFeeFreq(); LoadAgioFeesFrequency(); InitializeClientTypes(); InitializeControls(product); LoadPostingFrequency(); InitializeTabPageTermDeposit(); _savingsProduct.PackageMode = OPackageMode.Edit; }
public FrmAddSavingBookProduct() { _savingsProduct = new SavingsBookProduct(); InitializeComponent(); InitializeComboBoxCurrencies(); LoadInterestComboBox(); LoadManagementFeeFreq(); LoadAgioFeesFrequency(); InitializeClientTypes(); LoadPostingFrequency(); InitializeTabPageTermDeposit(); _savingsProduct.PackageMode = OPackageMode.Insert; rbFlatWithdrawFees_CheckedChanged(this, null); rbFlatTransferFees_CheckedChanged(this, null); }
public void CalculateInterest_NoDay() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfYear }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 07, 01), null) { Product = product, InterestRate = 0.1 }; List<SavingInterestsAccrualEvent> list = new List<SavingInterestsAccrualEvent>(); list = saving.CalculateInterest(new DateTime(2009, 07, 01), new User { Id = 1 }); Assert.AreEqual(list.Count, 0); }
public OpenSavingsForm(OCurrency pInitialAmount, OCurrency pEntryFees, SavingsBookProduct savingsProduct, bool isReopen) { _savingsProduct = savingsProduct; _initialAmount = pInitialAmount; _entryFees = pEntryFees; _isReopen = isReopen; InitializeComponent(); Initialize(); if (_isReopen) { lbEntryFees.Text = GetString("lbReopenFees.Text"); lbEntryFeesConfirmation.Text = GetString("lbReopenFeesConfirmation.Text"); gbModifyInitialAmountEntryFees.Text = GetString("gbModifyInitialAmountReopenFees.Text"); } }
public void PostingInterests_OnePosting() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfWeek, Periodicity = new InstallmentType("Weekly", 7, 0) }; User user = new User(){Id=1}; SavingBookContract saving = new SavingBookContract( ApplicationSettings.GetInstance(""), user, new DateTime(2009, 01, 01), null) { Product = product, InterestRate = 0.1 }; saving.NextMaturity = saving.GetNextMaturity(saving.CreationDate, saving.Periodicity); saving.FirstDeposit(1000, saving.CreationDate, 0, user, new Teller()); List<SavingInterestsPostingEvent> list = new List<SavingInterestsPostingEvent>(); List<SavingInterestsPostingEvent> postingEvents = new List<SavingInterestsPostingEvent>(); DateTime closureDate = new DateTime(2009, 01, 05); List<SavingInterestsAccrualEvent> accrualEvents = saving.CalculateInterest(closureDate, user); foreach (var accrualEvent in accrualEvents) { saving.Events.Add(accrualEvent); } list = saving.PostingInterests(saving.NextMaturity.Value, user); postingEvents.AddRange(list); foreach (var postingEvent in list) { saving.Events.Add(postingEvent); } Assert.AreEqual( 1, postingEvents.Count); }
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); }
private void InitializeControls(SavingsBookProduct product) { cbCurrency.SelectedItem = _savingsProduct.Currency; tbName.Text = _savingsProduct.Name; tbCodeSavingProduct.Text = _savingsProduct.Code; tbBalanceMax.Text = _savingsProduct.BalanceMax.GetFormatedValue(_savingsProduct.UseCents); tbBalanceMin.Text = _savingsProduct.BalanceMin.GetFormatedValue(_savingsProduct.UseCents); tbDrawingMax.Text = _savingsProduct.WithdrawingMax.GetFormatedValue(_savingsProduct.UseCents); tbWithDrawingMin.Text = _savingsProduct.WithdrawingMin.GetFormatedValue(_savingsProduct.UseCents); tbInitialAmountMax.Text = _savingsProduct.InitialAmountMax.GetFormatedValue(_savingsProduct.UseCents); tbInitialAmountMin.Text = _savingsProduct.InitialAmountMin.GetFormatedValue(_savingsProduct.UseCents); tbTransferMin.Text = _savingsProduct.TransferMin.GetFormatedValue(_savingsProduct.UseCents); tbTransferMax.Text = _savingsProduct.TransferMax.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.InterestRateMax.HasValue) tbInterestRateMax.Text = (_savingsProduct.InterestRateMax.Value * 100).ToString(); if (_savingsProduct.InterestRateMin.HasValue) tbInterestRateMin.Text = (_savingsProduct.InterestRateMin.Value * 100).ToString(); if (_savingsProduct.InterestRate.HasValue) tbInterestRateValue.Text = (_savingsProduct.InterestRate.Value * 100).ToString(); cbPosting.SelectedValue = _savingsProduct.InterestFrequency.ToString(); cbAccrual.Text = _savingsProduct.InterestBase.ToString(); if (_savingsProduct.InterestBase == OSavingInterestBase.Monthly || _savingsProduct.InterestBase == OSavingInterestBase.Weekly) cbCalculAmount.SelectedValue = _savingsProduct.CalculAmountBase.ToString(); if (_savingsProduct.EntryFees.HasValue) tbEntryFeesValue.Text = _savingsProduct.EntryFees.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.EntryFeesMin.HasValue) tbEntryFeesMin.Text = _savingsProduct.EntryFeesMin.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.EntryFeesMax.HasValue) tbEntryFeesMax.Text = _savingsProduct.EntryFeesMax.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.WithdrawFeesType == OSavingsFeesType.Flat) { if (_savingsProduct.FlatWithdrawFees.HasValue) tbWithdrawFees.Text = _savingsProduct.FlatWithdrawFees.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.FlatWithdrawFeesMin.HasValue) tbWithdrawFeesMin.Text = _savingsProduct.FlatWithdrawFeesMin.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.FlatWithdrawFeesMax.HasValue) tbWithdrawFeesMax.Text = _savingsProduct.FlatWithdrawFeesMax.GetFormatedValue(_savingsProduct.UseCents); rbFlatWithdrawFees.Checked = true; } else { if (_savingsProduct.RateWithdrawFees.HasValue) tbWithdrawFees.Text = (_savingsProduct.RateWithdrawFees.Value * 100).ToString(); if (_savingsProduct.RateWithdrawFeesMin.HasValue) tbWithdrawFeesMin.Text = (_savingsProduct.RateWithdrawFeesMin.Value * 100).ToString(); if (_savingsProduct.RateWithdrawFeesMax.HasValue) tbWithdrawFeesMax.Text = (_savingsProduct.RateWithdrawFeesMax.Value * 100).ToString(); rbRateWithdrawFees.Checked = true; } if (_savingsProduct.TransferFeesType == OSavingsFeesType.Flat) { if (_savingsProduct.FlatTransferFees.HasValue) tbTransferFees.Text = _savingsProduct.FlatTransferFees.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.FlatTransferFeesMin.HasValue) tbTransferFeesMin.Text = _savingsProduct.FlatTransferFeesMin.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.FlatTransferFeesMax.HasValue) tbTransferFeesMax.Text = _savingsProduct.FlatTransferFeesMax.GetFormatedValue(_savingsProduct.UseCents); rbFlatTransferFees.Checked = true; } else { if (_savingsProduct.RateTransferFees.HasValue) tbTransferFees.Text = (_savingsProduct.RateTransferFees.Value * 100).ToString(); if (_savingsProduct.RateTransferFeesMin.HasValue) tbTransferFeesMin.Text = (_savingsProduct.RateTransferFeesMin.Value * 100).ToString(); if (_savingsProduct.RateTransferFeesMax.HasValue) tbTransferFeesMax.Text = (_savingsProduct.RateTransferFeesMax.Value * 100).ToString(); rbRateTransferFees.Checked = true; } if (ServicesProvider.GetInstance().GetSavingProductServices().IsThisProductAlreadyUsed(product.Id)) { tbName.Enabled = false; tbCodeSavingProduct.Enabled = false; cbCurrency.Enabled = false; gbFrequency.Enabled = false; rbFlatTransferFees.Enabled = false; rbFlatWithdrawFees.Enabled = false; rbRateTransferFees.Enabled = false; rbRateWithdrawFees.Enabled = false; } if (_savingsProduct.CloseFees.HasValue) tbCloseFees.Text = _savingsProduct.CloseFees.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.CloseFeesMin.HasValue) tbCloseFeesMin.Text = _savingsProduct.CloseFeesMin.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.CloseFeesMax.HasValue) tbCloseFeesMax.Text = _savingsProduct.CloseFeesMax.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.ManagementFees.HasValue) tbManagementFees.Text = _savingsProduct.ManagementFees.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.ManagementFeesMin.HasValue) tbManagementFeesMin.Text = _savingsProduct.ManagementFeesMin.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.ManagementFeesMax.HasValue) tbManagementFeesMax.Text = _savingsProduct.ManagementFeesMax.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.OverdraftFees.HasValue) tbOverdraftFees.Text = _savingsProduct.OverdraftFees.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.OverdraftFeesMin.HasValue) tbOverdraftFeesMin.Text = _savingsProduct.OverdraftFeesMin.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.OverdraftFeesMax.HasValue) tbOverdraftFeesMax.Text = _savingsProduct.OverdraftFeesMax.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.AgioFees.HasValue) tbAgioFees.Text = (_savingsProduct.AgioFees.Value * 100).ToString(); if (_savingsProduct.AgioFeesMin.HasValue) tbAgioFeesMin.Text = (_savingsProduct.AgioFeesMin.Value * 100).ToString(); if (_savingsProduct.AgioFeesMax.HasValue) tbAgioFeesMax.Text = (_savingsProduct.AgioFeesMax.Value * 100).ToString(); if (_savingsProduct.ReopenFees.HasValue) tbReopenFeesValue.Text = _savingsProduct.ReopenFees.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.ReopenFeesMin.HasValue) tbReopenFeesMin.Text = _savingsProduct.ReopenFeesMin.GetFormatedValue(_savingsProduct.UseCents); if (_savingsProduct.ReopenFeesMax.HasValue) tbReopenFeesMax.Text = _savingsProduct.ReopenFeesMax.GetFormatedValue(_savingsProduct.UseCents); }
private SavingBookContract GetSavingContract(IClient client) { User user = ServicesProvider.GetInstance().GetUserServices().FindAll(false)[0]; User.CurrentUser = user; SavingBookContract savingContract = new SavingBookContract( ServicesProvider.GetInstance().GetGeneralSettings(), user); client.Branch = new Branch() { Id = 1, Code = "Test" }; SavingsBookProduct product = new SavingsBookProduct(); product.AgioFees = 0; product.BalanceMin = 0; product.BalanceMax = 5000; product.ChequeDepositFees = 0; product.ClientType = OClientTypes.All; product.CloseFees = 0; product.InterestRate = 0; product.TransferMin = 1; product.TransferMax = 5000; product.WithdrawingMin = 1; product.WithdrawingMax = 5000; product.ReopenFees = 0; product.RateWithdrawFees = 0; product.TransferFeesType = OSavingsFeesType.Flat; product.FlatTransferFees = 0; product.FlatWithdrawFees = 0; product.WithdrawFeesType = OSavingsFeesType.Flat; product.EntryFees = 0; product.DepositFees = 0; product.DepositMin = 1; product.DepositMax = 5000; product.ManagementFees = 0; product.Code = "test"; product.Name = "Test"; product.InitialAmountMin = 0; product.InitialAmountMax = 5000; product.Currency = new Currency(){Id=1}; product.InterestFrequency = OSavingInterestFrequency.EndOfMonth; product.InterestBase = OSavingInterestBase.Daily; product.OverdraftFees = 0; product.InterBranchTransferFee.Value = 0; product.ManagementFeeFreq = new InstallmentType(1,"Test",30,1); product.AgioFeesFreq = new InstallmentType(1,"test",30,1); ServicesProvider.GetInstance().GetSavingProductServices().SaveProduct(product); savingContract.Product = product; savingContract.InterestRate = 0; savingContract.FlatTransferFees = 0; savingContract.FlatWithdrawFees = 0; savingContract.DepositFees = 0; savingContract.CloseFees = 0; savingContract.ReopenFees = 0; savingContract.ManagementFees = 0; savingContract.AgioFees = 0; savingContract.Branch = client.Branch; savingContract.SavingsOfficer = user; savingContract.CreationDate = DateTime.Now; savingContract.Code = "test"; savingContract.InitialAmount = 1; savingContract.EntryFees = 0; ServicesProvider.GetInstance().GetSavingServices().SaveContract(savingContract, (Client) client); ServicesProvider.GetInstance().GetSavingServices().Deposit(savingContract, DateTime.Now, 4000, string.Empty, user, false, OSavingsMethods.Cash, null, new Teller()); return savingContract; }
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 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); }
protected override void SetUp() { base.SetUp(); _productManager = (SavingProductManager)container["SavingProductManager"]; _savingManager = (SavingManager)container["SavingManager"]; _savingEventManager = (SavingEventManager)container["SavingEventManager"]; Assert.IsNotNull(_savingManager); Assert.IsNotNull(_productManager); _savingsBookProduct = _productManager.SelectSavingsBookProduct(1); Assert.IsNotNull(_savingsBookProduct); User.CurrentUser.Id = 1; }
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 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); }
private void EditSavingBookProduct(SavingsBookProduct sProduct) { FrmAddSavingBookProduct editProductForm = new FrmAddSavingBookProduct(sProduct); if (editProductForm.ShowDialog() == DialogResult.OK) { refreshListView(); ((MainView)MdiParent).SetInfoMessage(GetString("ModifiSavingProduct.Text")); } }
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 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 SetUp() { _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 }, AgioFeesMin = 4, AgioFeesMax = 7 }; }
private void buttonFirstDeposit_Click(object sender, EventArgs e) { if (!CheckDataInOpenFiscalYear()) return; try { _savingsBookProduct = _saving.Product; var openSavingsForm = new OpenSavingsForm(_saving.InitialAmount, _saving.EntryFees, _savingsBookProduct, false); DialogResult result = openSavingsForm.ShowDialog(); if (result == DialogResult.OK) { SavingServices.FirstDeposit(_saving, openSavingsForm.InitialAmount, TimeProvider.Now, openSavingsForm.EntryFees, User.CurrentUser, Teller.CurrentTeller); SavingServices.UpdateInitialData(_saving.Id, openSavingsForm.InitialAmount, openSavingsForm.EntryFees); _saving = SavingServices.GetSaving(_saving.Id); for (int i = 0; i < _client.Savings.Count(); i++) { if (_client.Savings[i].Id == _saving.Id) { _client.Savings[i] = _saving; } } tBSavingCode.Text = _saving.Code; DisplaySaving(_saving); DisplaySavings(_client.Savings); DisplaySavingEvent(_saving); pnlSavingsButtons.Enabled = true; buttonFirstDeposit.Visible = false; } } catch (Exception ex) { new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog(); } }
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); }
private string _CreateHtmlForShowingPackage(SavingsBookProduct pSavingsProduct) { string img = "package.png"; if (pSavingsProduct.Delete) img = "package_delete.png"; string productInitialAmount = String.Format(GetString("Between.Text") + " {0} "+ GetString("And.Text") + " {1}", pSavingsProduct.InitialAmountMin.GetFormatedValue(pSavingsProduct.UseCents), pSavingsProduct.InitialAmountMax.GetFormatedValue(pSavingsProduct.UseCents)); string productBalance = String.Format(GetString("Between.Text") + " {0} " + GetString("And.Text") + " {1}", pSavingsProduct.BalanceMin.GetFormatedValue(pSavingsProduct.UseCents), pSavingsProduct.BalanceMax.GetFormatedValue(pSavingsProduct.UseCents)); string productWithdrawing = String.Format(GetString("Between.Text") + " {0} " + GetString("And.Text") + " {1}", pSavingsProduct.WithdrawingMin.GetFormatedValue(pSavingsProduct.UseCents), pSavingsProduct.WithdrawingMax.GetFormatedValue(pSavingsProduct.UseCents)); string productInterestRate = pSavingsProduct.InterestRate.HasValue ? ServicesHelper.ConvertNullableDoubleToString(pSavingsProduct.InterestRate.Value, true) + "%" : string.Format(GetString("Between.Text") + " {0} "+ GetString("And.Text") + " {1}%", ServicesHelper.ConvertNullableDoubleToString(pSavingsProduct.InterestRateMin.Value, true), ServicesHelper.ConvertNullableDoubleToString(pSavingsProduct.InterestRateMax.Value, true)); string productDeposit = String.Format(GetString("Between.Text") + " {0} " + GetString("And.Text") + " {1}", pSavingsProduct.DepositMin.GetFormatedValue(true), pSavingsProduct.DepositMax.GetFormatedValue(pSavingsProduct.UseCents)); string productEntryFees = pSavingsProduct.EntryFees.HasValue ? pSavingsProduct.EntryFees.GetFormatedValue(pSavingsProduct.UseCents) : string.Format(GetString("Between.Text") + " {0} " + GetString("And.Text") + " {1}", pSavingsProduct.EntryFeesMin.GetFormatedValue(pSavingsProduct.UseCents), pSavingsProduct.EntryFeesMax.GetFormatedValue(pSavingsProduct.UseCents)); string productInterestBase = GetString(pSavingsProduct.InterestBase.ToString() + ".Text"); string productInterestFrequency = GetString(pSavingsProduct.InterestFrequency.ToString() + ".Text"); string productInterestCalculAmountBase = pSavingsProduct.CalculAmountBase.HasValue ? GetString(pSavingsProduct.CalculAmountBase.ToString() + ".Text") : "-----"; string productTransfer = String.Format(GetString("Between.Text") + " {0} " + GetString("And.Text") + " {1}", pSavingsProduct.TransferMin.GetFormatedValue(pSavingsProduct.UseCents), pSavingsProduct.TransferMax.GetFormatedValue(pSavingsProduct.UseCents)); string text = string.Format(@" <form id='{1}' name='package{1}'> <table id={1} cellpadding='0' cellspacing='0' border='0' class='list_content' onclick='click_book(this,{1});' onmouseenter='mouse_enter_book(this);' onmouseleave='mouse_leave_book(this);'> <tr> <td> <table class='book_list' cellpadding='0' cellspacing='0' border='0'> <tr> <td> <table cellpadding='0' cellspacing='0' border='0'> <tr> <td><img id='{1}' src='{0}'/></td> </tr> </table> </td> </tr> </table> </td> <td style='width:100%'> <span > <span class='title_popup'>" + GetString("SavingBookProduct.Text") + @" : {2} ({13})</span> <table cellpadding='0' cellspacing='0' border='0'> <tr> <td> <span class='details'>" + GetString("InitialAmount.Text") + @"</span> </td> <td> <span class='description'> {3}</span> </td> <td><span style='margin-left:15px;'></span></td> <td> <span class='details'>" + GetString("Balance.Text") + @"</span> </td> <td> <span class='description'> {4}</span> </td> <td><span style='margin-left:15px;'></span></td> <td> <span class='details'></span> </td> <td> <span class='description'> </span> </td> </tr> <tr> <td> <span class='details'>" + GetString("Withdrawing.Text") + @"</span> </td> <td> <span class='description'> {5}</span> </td> <td><span style='margin-left:15px;'></span></td> <td> <span class='details'>" + GetString("InterestRate.Text") + @"</span> </td> <td> <span class='description'> {6}</span> </td> <td><span style='margin-left:15px;'></span></td> <td> <span class='details'></span> </td> <td> <span class='description'> </span> </td> </tr> <tr> <td> <span class='details'>" + GetString("Deposit.Text") + @"</span> </td> <td> <span class='description'> {7}</span> </td> <td><span style='margin-left:15px;'></span></td> <td> <span class='details'>" + GetString("InterestFrequency.Text") + @"</span> </td> <td> <span class='description'> {8}</span> </td> <td><span style='margin-left:15px;'></span></td> <td colspan='5'></td> </tr> <tr> <td> <span class='details'>" + GetString("InterestBase.Text") + @"</span> </td> <td> <span class='description'> {9}</span> </td> <td><span style='margin-left:15px;'></span></td> <td> <span class='details'>"+GetString("BasedOn.Text")+@"</span> </td> <td> <span class='description'> {10}</span> </td> <td><span style='margin-left:15px;'></span></td> <td colspan='5'></td> </tr> <tr> <td> <span class='details'>" + GetString("Transfer.Text") + @"</span> </td> <td> <span class='description'> {11}</span> </td> <td><span style='margin-left:15px;'></span></td> <td> <span class='details'>" + GetString("EntryFees.Text") + @"</span> </td> <td> <span class='description'> {12}</span> </td> <td><span style='margin-left:15px;'></span></td> <td colspan='8'> </td> </tr> </table> </span> </td> </tr> </table></form>", Path.Combine(UserSettings.GetTemplatePath, img), pSavingsProduct.Id, pSavingsProduct.Name, productInitialAmount, productBalance, productWithdrawing, productInterestRate, productDeposit, productInterestFrequency, productInterestBase, productInterestCalculAmountBase, productTransfer, productEntryFees, pSavingsProduct.Code); return text; }
public void Cancel_Last_Event() { SavingsBookProduct product = new SavingsBookProduct { Id = 1, InterestBase = OSavingInterestBase.Daily, InterestFrequency = OSavingInterestFrequency.EndOfWeek }; SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""), new User(), new DateTime(2009, 01, 01), product, null) { InterestRate = 0.1 }; saving.FirstDeposit(100, new DateTime(2009, 01, 01), null, new User(), Teller.CurrentTeller); Assert.AreEqual(saving.GetBalance(), 100); saving.CancelLastEvent(); Assert.AreEqual(saving.GetBalance(), 100); }
private void InitializeTabPageSavingDetails(ISavingProduct product) { try { Text = _title; _savingsBookProduct = (SavingsBookProduct)product; DisplaySavingProduct(product); tabControlSavingsDetails.TabPages.Clear(); tabControlSavingsDetails.TabPages.Add(tabPageSavingsAmountsAndFees); tabControlSavingsDetails.TabPages.Add(tabPageSavingsEvents); tabControlSavingsDetails.TabPages.Add(tabPageLoans); ; _saving = new SavingBookContract(ServicesProvider.GetInstance().GetGeneralSettings(), User.CurrentUser, (SavingsBookProduct)product); if (((SavingsBookProduct)product).UseTermDeposit) tabControlSavingsDetails.TabPages.Add(tpTermDeposit); groupBoxSaving.Text = string.Format("{0}", MultiLanguageStrings.GetString(Ressource.ClientForm, "SavingsBook.Text")); groupBoxSaving.ForeColor = Color.FromArgb(0, 88, 56); tabControlPerson.TabPages.Remove(tabPageSavingDetails); tabControlPerson.TabPages.Add(tabPageSavingDetails); tabControlPerson.SelectedTab = tabPageSavingDetails; InitializeSavingsGeneralControls(); InitializeTabPageTermDeposit(); InitializeSavingsFees(); btSavingsUpdate.Visible = false; groupBoxSaving.Enabled = true; pnlSavingsButtons.Enabled = false; groupBoxSaving.Name += string.Format(" {0}", product.Name); int numbersOfSavings = SavingServices.GetSavingCount(_client); _saving.GenerateSavingCode(_client, numbersOfSavings, ServicesProvider.GetInstance().GetGeneralSettings().SavingsCodeTemplate, ServicesProvider.GetInstance().GetGeneralSettings().ImfCode, _client.Branch.Code); int nextSavingsId = SavingServices.GetLastSavingsId() + 1; tBSavingCode.Text = _saving.Code + '/' + nextSavingsId.ToString(); InitializeSavingsOfficersComboBox(); DisplaySavingEvent(_saving); DisplaySavingLoans(_saving); //InitializeCustomizableFields(OCustomizableFieldEntities.Savings, null, false); LoadSavingsExtensions(); } catch (Exception ex) { new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog(); } }
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); }