示例#1
0
        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);
        }
示例#2
0
文件: Daily.cs 项目: aelhadi/opencbs
        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);
        }
示例#3
0
        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);
        }
示例#4
0
        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);
        }
示例#5
0
文件: Weekly.cs 项目: aelhadi/opencbs
        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);
        }
示例#6
0
        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);
        }
示例#7
0
        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);
        }
示例#8
0
        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);
        }