public void TestWithdrawEvent()
        {
            _saving.FlatWithdrawFees = 10;
            List <SavingEvent> savingEvents = _saving.Withdraw(100, TimeProvider.Today, "testDepot", _user, false, null, new PaymentMethod());

            savingEvents[0].Id = 100;
            _savingEventManager.Add(savingEvents[0], _saving.Id);
            SavingEvent retrievedSavingEvent = _savingEventManager.SelectEvents(_saving.Id, _saving.Product).Find(item => item.Id == savingEvents[0].Id);

            CompareEvent(savingEvents[0], retrievedSavingEvent);
        }
Example #2
0
        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);
        }
Example #3
0
        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);
        }
Example #4
0
        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);
        }
Example #5
0
        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);
        }
Example #6
0
        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);
        }
Example #7
0
        public void FlatWithdrawFees()
        {
            SavingsBookProduct product = new SavingsBookProduct()
            {
                WithdrawFeesType    = OSavingsFeesType.Flat,
                FlatWithdrawFeesMin = 1,
                FlatWithdrawFeesMax = 5
            };

            SavingBookContract saving = new SavingBookContract(ApplicationSettings.GetInstance(""),
                                                               new User(), new DateTime(2009, 01, 01), product, null)
            {
                FlatWithdrawFees = 2,
            };

            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, new PaymentMethod());

            Assert.AreEqual(1, withdrawEvents.Count);
            Assert.AreEqual(10, withdrawEvents[0].Amount.Value);
            Assert.AreEqual(2, ((ISavingsFees)withdrawEvents[0]).Fee.Value);
            Assert.AreEqual(988, saving.GetBalance().Value);
        }