Esempio n. 1
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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }