public void CalculateInterest_AccrualMode_Daily_EndOfYear_OneClosure_AfterOneDay()
        {
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual);

            Currency currency = new Currency() { UseCents = false, Code = "SOM", Id = 1, IsPivot = true, Name = "SOM" };
            CompulsorySavingsProduct product = new CompulsorySavingsProduct();
            product.Currency = currency;

            CompulsorySavings saving = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()), new User(),
                1000, new DateTime(2009, 01, 1), null) { InterestRate = 0.1, Product = product };

            List<SavingEvent> events = saving.Closure(new DateTime(2009, 01, 2, 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, 2);
            Assert.AreEqual(accrualEvents, 1);
            Assert.AreEqual(postingEvents, 0);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.ACCOUNT_PAYABLE_INTERESTS_ON_COMPULSORY_SAVINGS, 1).Balance.Value, 100);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.COMPULSORY_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, 100);
            Assert.AreEqual(saving.GetBalance(), 1000);
        }
Beispiel #2
0
        public void CalculateInterest_CashMode_Daily_EndOfYear_OneClosure_On_PostingDate()
        {
            Currency currency = new Currency()
            {
                UseCents = false, Code = "SOM", Id = 1, IsPivot = true, Name = "SOM"
            };
            CompulsorySavingsProduct product = new CompulsorySavingsProduct();

            product.Currency = currency;

            CompulsorySavings saving = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()), new User(),
                                                             1000, new DateTime(2009, 01, 01), null)
            {
                InterestRate = 0.1, Product = product
            };

            saving.Closure(new DateTime(2010, 01, 01), 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, 365);
            Assert.AreEqual(postingEvents, 1);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.ACCOUNT_PAYABLE_INTERESTS_ON_COMPULSORY_SAVINGS, 1).Balance.Value, 0);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.COMPULSORY_SAVINGS, 1).Balance.Value, 37500);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.CASH, 1).Balance.Value, 1000);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.INTERESTS_ON_DEPOSIT_ACCOUNT, 1).Balance.Value, 36500);
            Assert.AreEqual(saving.GetBalance(), 37500);
        }
Beispiel #3
0
        public void CalculateInterest_AccrualMode_Daily_EndOfYear_OneClosure_OneDayBefore_PostingDate()
        {
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Accrual);

            Currency currency = new Currency()
            {
                UseCents = false, Code = "SOM", Id = 1, IsPivot = true, Name = "SOM"
            };
            CompulsorySavingsProduct product = new CompulsorySavingsProduct();

            product.Currency = currency;

            CompulsorySavings saving = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()), new User(),
                                                             1000, new DateTime(2009, 01, 01), null)
            {
                InterestRate = 0.1, Product = product
            };

            saving.Closure(new DateTime(2009, 12, 31), 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, 364);
            Assert.AreEqual(postingEvents, 0);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.ACCOUNT_PAYABLE_INTERESTS_ON_COMPULSORY_SAVINGS, 1).Balance.Value, 36400);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.COMPULSORY_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, 36400);
            Assert.AreEqual(saving.GetBalance(), 1000);
        }
Beispiel #4
0
        public void CloseAccount()
        {
            Currency currency = new Currency()
            {
                UseCents = false, Code = "SOM", Id = 1, IsPivot = true, Name = "SOM"
            };
            CompulsorySavingsProduct product = new CompulsorySavingsProduct();

            product.Currency = currency;

            CompulsorySavings saving = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()), new User(),
                                                             1000, new DateTime(2009, 01, 01), null)
            {
                InterestRate = 0.01, Product = product
            };

            List <SavingEvent> events = saving.Close(new DateTime(2009, 02, 26), new User()
            {
                Id = 1
            }, "Close savings contract", false);

            int accrualEvents = saving.Events.FindAll(item => item is SavingInterestsAccrualEvent).Count;
            int postingEvents = saving.Events.FindAll(item => item is SavingInterestsPostingEvent).Count;

            Assert.AreEqual(events.Count, 58);
            Assert.AreEqual(accrualEvents, 56);
            Assert.AreEqual(postingEvents, 1);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.ACCOUNT_PAYABLE_INTERESTS_ON_COMPULSORY_SAVINGS, 1).Balance.Value, 0);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.COMPULSORY_SAVINGS, 1).Balance.Value, 1560);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.CASH, 1).Balance.Value, 1000);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.INTERESTS_ON_DEPOSIT_ACCOUNT, 1).Balance.Value, 560);
            Assert.AreEqual(saving.GetBalance(), 1560);
            Assert.AreEqual(saving.Status, OSavingsStatus.Closed);
        }
Beispiel #5
0
        public void Get_Set_Product()
        {
            CompulsorySavingsProduct product = new CompulsorySavingsProduct {
                Id = 1
            };
            CompulsorySavings CompulsorySavings = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()), new User(), 12m, TimeProvider.Today, product, null);

            Assert.AreEqual(product, CompulsorySavings.Product);
        }
Beispiel #6
0
        public void Get_BalanceMin_At_Date()
        {
            CompulsorySavingsProduct product           = new CompulsorySavingsProduct();
            CompulsorySavings        CompulsorySavings = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()),
                                                                               new User(), 1000, new DateTime(2009, 01, 01), product, null);

            CompulsorySavings.Withdraw(100, new DateTime(2009, 02, 02), "retrait", new User(), false);
            CompulsorySavings.Deposit(230, new DateTime(2009, 02, 02), "depot", new User(), false, false, OSavingsMethods.Cash);

            Assert.AreEqual(CompulsorySavings.GetBalanceMin(new DateTime(2009, 01, 01)), 1000);
            Assert.AreEqual(CompulsorySavings.GetBalanceMin(new DateTime(2009, 02, 01)), 1000);
            Assert.AreEqual(CompulsorySavings.GetBalanceMin(new DateTime(2009, 02, 02)), 900);
        }
 public void Get_Set_Product()
 {
     CompulsorySavingsProduct product = new CompulsorySavingsProduct { Id = 1 };
     CompulsorySavings CompulsorySavings = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()), new User(), 12m, TimeProvider.Today, product, null);
     Assert.AreEqual(product, CompulsorySavings.Product);
 }
        public void Get_Balance_At_Date()
        {
            CompulsorySavingsProduct product = new CompulsorySavingsProduct();
            CompulsorySavings CompulsorySavings = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()),
                new User(), 1000, new DateTime(2009, 01, 01), product, null);
            CompulsorySavings.Deposit(100, new DateTime(2009, 02, 01), "depot", new User(), false, false, OSavingsMethods.Cash);
            CompulsorySavings.Withdraw(230, new DateTime(2009, 02, 03), "retrait", new User(), false);

            Assert.AreEqual(CompulsorySavings.GetBalance(new DateTime(2009, 01, 31)), 1000);
            Assert.AreEqual(CompulsorySavings.GetBalance(new DateTime(2009, 02, 01)), 1100);
            Assert.AreEqual(CompulsorySavings.GetBalance(new DateTime(2009, 02, 02)), 1100);
            Assert.AreEqual(CompulsorySavings.GetBalance(new DateTime(2009, 02, 03)), 870);
        }
        public void CloseAccount()
        {
            Currency currency = new Currency() { UseCents = false, Code = "SOM", Id = 1, IsPivot = true, Name = "SOM" };
            CompulsorySavingsProduct product = new CompulsorySavingsProduct();
            product.Currency = currency;

            CompulsorySavings saving = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()), new User(),
                1000, new DateTime(2009, 01, 01), null) { InterestRate = 0.01, Product = product };

            List<SavingEvent> events = saving.Close(new DateTime(2009, 02, 26), new User() { Id = 1 }, "Close savings contract", false);

            int accrualEvents = saving.Events.FindAll(item => item is SavingInterestsAccrualEvent).Count;
            int postingEvents = saving.Events.FindAll(item => item is SavingInterestsPostingEvent).Count;

            Assert.AreEqual(events.Count, 58);
            Assert.AreEqual(accrualEvents, 56);
            Assert.AreEqual(postingEvents, 1);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.ACCOUNT_PAYABLE_INTERESTS_ON_COMPULSORY_SAVINGS, 1).Balance.Value, 0);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.COMPULSORY_SAVINGS, 1).Balance.Value, 1560);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.CASH, 1).Balance.Value, 1000);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.INTERESTS_ON_DEPOSIT_ACCOUNT, 1).Balance.Value, 560);
            Assert.AreEqual(saving.GetBalance(), 1560);
            Assert.AreEqual(saving.Status, OSavingsStatus.Closed);
        }
        public void CalculateInterest_CashMode_Daily_EndOfYear_OneClosure_On_PostingDate()
        {
            Currency currency = new Currency() { UseCents = false, Code = "SOM", Id = 1, IsPivot = true, Name = "SOM" };
            CompulsorySavingsProduct product = new CompulsorySavingsProduct();
            product.Currency = currency;

            CompulsorySavings saving = new CompulsorySavings(ApplicationSettings.GetInstance(""), ChartOfAccounts.GetInstance(new User()), new User(),
                1000, new DateTime(2009, 01, 01), null) { InterestRate = 0.1, Product = product };

            saving.Closure(new DateTime(2010, 01, 01), 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, 365);
            Assert.AreEqual(postingEvents, 1);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.ACCOUNT_PAYABLE_INTERESTS_ON_COMPULSORY_SAVINGS, 1).Balance.Value, 0);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.COMPULSORY_SAVINGS, 1).Balance.Value, 37500);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.CASH, 1).Balance.Value, 1000);
            Assert.AreEqual(saving.ChartOfAccounts.GetAccountByNumber(OAccounts.INTERESTS_ON_DEPOSIT_ACCOUNT, 1).Balance.Value, 36500);
            Assert.AreEqual(saving.GetBalance(), 37500);
        }