Example #1
0
        public void TestExoticProductCorrectlySetAndRetrieved()
        {
            ExoticInstallmentsTable agro = new ExoticInstallmentsTable();

            agro.Name = "agro";
            Assert.AreEqual("agro", agro.Name);
        }
        public void GetNumberOfInstallments()
        {
            ExoticInstallmentsTable product = new ExoticInstallmentsTable();

            product.Add(e1);
            product.Add(e2);
            Assert.AreEqual(2, product.GetNumberOfInstallments);
        }
Example #3
0
 private static void CheckValueForPackageExoticProduct(ExoticInstallmentsTable exoticProduct)
 {
     if (exoticProduct == null)
     {
         throw new OpenCbsPackageSaveException(OpenCbsPackageSaveExceptionEnum.ExoticProductIsNull);
     }
     if (exoticProduct.Id == 0)
     {
         throw new OpenCbsPackageSaveException(OpenCbsPackageSaveExceptionEnum.ExoticProductIsBad);
     }
 }
Example #4
0
        public void PackageExoticProductCorrectlySetAndRetrieved()
        {
            ExoticInstallmentsTable exoticProduct = new ExoticInstallmentsTable();
            ExoticInstallment       e1            = new ExoticInstallment();

            e1.Number         = 1;
            e1.PrincipalCoeff = 0.23;
            e1.InterestCoeff  = 0.15;
            exoticProduct.Add(e1);
            package.ExoticProduct = exoticProduct;
            Assert.IsTrue(package.ExoticProduct.Equals(exoticProduct));
        }
        public void TestGetSumOfInterestCoeffWhenSumIsNull()
        {
            ExoticInstallment exoticInstallment1 = new ExoticInstallment();
            ExoticInstallment exoticInstallment2 = new ExoticInstallment();

            ExoticInstallmentsTable product = new ExoticInstallmentsTable();

            product.Add(exoticInstallment1);
            product.Add(exoticInstallment2);

            Assert.AreEqual(0, product.SumOfInterestCoeff);
        }
Example #6
0
        public ExoticInstallmentsTable AddExoticInstallmentInExoticProduct(ExoticInstallmentsTable product, ExoticInstallment exoticInstallment, int installmentCount, bool declining)        //fait
        {
            if (!declining)
            {
                if (exoticInstallment.PrincipalCoeff == 0 && !exoticInstallment.InterestCoeff.HasValue)
                {
                    throw new OpenCbsPackageSaveException(OpenCbsPackageSaveExceptionEnum.ExoticInstallmentIsNull);
                }
            }

            exoticInstallment.Number = installmentCount;
            product.Add(exoticInstallment);
            return(product);
        }
        public void TestSumForDecliningInterestRateType()
        {
            var i1 = new ExoticInstallment()
            {
                PrincipalCoeff = 0.7, InterestCoeff = 0
            };
            var i2 = new ExoticInstallment()
            {
                PrincipalCoeff = 0.3, InterestCoeff = 0
            };
            var exotic = new ExoticInstallmentsTable();

            exotic.Add(i1);
            exotic.Add(i2);
            Assert.IsTrue(exotic.CheckIfSumIsOk(OLoanTypes.DecliningFixedPrincipal));
        }
        public void TestGetSumOfInterestCoeff()
        {
            ExoticInstallment exoticInstallment1 = new ExoticInstallment();

            exoticInstallment1.InterestCoeff = 123;
            ExoticInstallment exoticInstallment2 = new ExoticInstallment();

            exoticInstallment2.InterestCoeff = 100;

            ExoticInstallmentsTable product = new ExoticInstallmentsTable();

            product.Add(exoticInstallment1);
            product.Add(exoticInstallment2);

            Assert.AreEqual(223, product.SumOfInterestCoeff);
        }
        public void TestIsExoticProductForDecliningRatePackage()
        {
            exoticProduct = new ExoticInstallmentsTable();

            e1                = new ExoticInstallment();
            e1.Number         = 1;
            e1.PrincipalCoeff = 0.4;
            e1.InterestCoeff  = null;

            e2                = new ExoticInstallment();
            e2.Number         = 2;
            e2.PrincipalCoeff = 0.3;
            e2.InterestCoeff  = null;
            exoticProduct.Add(e1);
            exoticProduct.Add(e2);

            Assert.IsTrue(exoticProduct.IsExoticProductForDecliningRatePackage);
        }
        public void SetUp()
        {
            exoticProduct      = new ExoticInstallmentsTable();
            exoticProduct.Id   = 1;
            exoticProduct.Name = "proportional interest rate with 6 installments";

            e1                = new ExoticInstallment();
            e1.Number         = 1;
            e1.PrincipalCoeff = 0.4;
            e1.InterestCoeff  = 0.2;

            e2                = new ExoticInstallment();
            e2.Number         = 2;
            e2.PrincipalCoeff = 0.3;
            e2.InterestCoeff  = 0.15;
            exoticProduct.Add(e1);
            exoticProduct.Add(e2);
        }
        public void CheckSumOfInterestAndPrincipal_InterestCoefEgal90_PrincipalCoeffEgal10()
        {
            ExoticInstallment exoticInstallment1 = new ExoticInstallment();

            exoticInstallment1.InterestCoeff  = 70;
            exoticInstallment1.PrincipalCoeff = 0;
            ExoticInstallment exoticInstallment2 = new ExoticInstallment();

            exoticInstallment2.InterestCoeff  = 20;
            exoticInstallment2.PrincipalCoeff = 10;

            ExoticInstallmentsTable product = new ExoticInstallmentsTable();

            product.Add(exoticInstallment1);
            product.Add(exoticInstallment2);

            Assert.IsFalse(product.CheckIfSumIsOk(OLoanTypes.Flat));
        }
Example #12
0
        public int AddExoticProduct(ExoticInstallmentsTable pExoticProduct, OLoanTypes loanType)
        {
            if (_productManager.IsThisExoticProductNameAlreadyExist(pExoticProduct.Name))
            {
                throw new OpenCbsPackageSaveException(OpenCbsPackageSaveExceptionEnum.ExoticProductNameAlreadyExist);
            }
            if (!pExoticProduct.CheckIfSumIsOk(loanType))
            {
                throw new OpenCbsPackageSaveException(OpenCbsPackageSaveExceptionEnum.ExoticProductSumInIncorrect);
            }

            pExoticProduct.Id = _productManager.AddExoticInstallmentsTable(pExoticProduct);

            foreach (ExoticInstallment installment in pExoticProduct)
            {
                _productManager.AddExoticInstallment(installment, pExoticProduct);
            }

            return(pExoticProduct.Id);
        }
        private static ExoticInstallmentsTable _SetExotic(bool pForDecliningLoan)
        {
            ExoticInstallmentsTable exoticProduct = new ExoticInstallmentsTable();

            if (!pForDecliningLoan)
            {
                exoticProduct.Add(new ExoticInstallment(1, 0.1, 0.1));
                exoticProduct.Add(new ExoticInstallment(2, 0.2, 0));
                exoticProduct.Add(new ExoticInstallment(3, 0.1, 0.2));
                exoticProduct.Add(new ExoticInstallment(4, 0, 0));
                exoticProduct.Add(new ExoticInstallment(5, 0.4, 0.5));
                exoticProduct.Add(new ExoticInstallment(6, 0.2, 0.2));
            }
            else
            {
                exoticProduct.Add(new ExoticInstallment(1, 0.1, null));
                exoticProduct.Add(new ExoticInstallment(2, 0.2, null));
                exoticProduct.Add(new ExoticInstallment(3, 0.4, null));
                exoticProduct.Add(new ExoticInstallment(4, 0, null));
                exoticProduct.Add(new ExoticInstallment(5, 0.2, null));
                exoticProduct.Add(new ExoticInstallment(6, 0.1, null));
            }
            return(exoticProduct);
        }
        private static Loan _SetContract(OLoanTypes pLoansType, bool pKeepExpectedInstallment, int pGracePeriod, int pMaturity, ExoticInstallmentsTable pExoticProduct)
        {
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                LoanType        = pLoansType,
                ChargeInterestWithinGracePeriod = true,
                KeepExpectedInstallment         = pKeepExpectedInstallment,
                ExoticProduct = pExoticProduct,
                AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB,
                Currency = new Currency {
                    Id = 1, UseCents = true
                },
                RoundingType = ORoundingType.Approximate
            };

            return(new Loan(package, 1000, 0.03m, pMaturity, pGracePeriod, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()))
            {
                BadLoan = false,
                AnticipatedTotalRepaymentPenalties = 0.01,
                NonRepaymentPenalties = { InitialAmount = 0.003 }
            });
        }
 private static void _AssertExoticInstallmentTable(ExoticInstallmentsTable pExoticInstallmentsTable, string pName, int pNumberOfExoticInstallment)
 {
     Assert.AreEqual(pName, pExoticInstallmentsTable.Name);
     Assert.AreEqual(pNumberOfExoticInstallment, pExoticInstallmentsTable.GetNumberOfInstallments);
 }
        private void _SetUp()
        {
            _exoticInstallmentsTable = new ExoticInstallmentsTable
            {
                Id   = 1,
                Name = "Exotic"
            };
            _exoticInstallmentsTable.Add(new ExoticInstallment(1, 1, 1));

            _productWithValues = new LoanProduct
            {
                Id              = 1,
                Name            = "Product1",
                Code            = "Code",
                Delete          = false,
                ClientType      = 'I',
                Amount          = 1000,
                InterestRate    = 1,
                InstallmentType = new InstallmentType {
                    Id = 1
                },
                GracePeriod      = 1,
                NbOfInstallments = 6,
                AnticipatedTotalRepaymentPenalties     = 10,
                KeepExpectedInstallment                = true,
                ChargeInterestWithinGracePeriod        = true,
                AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingInterest,
                NonRepaymentPenalties = new NonRepaymentPenaltiesNullableValues
                {
                    OverDueInterest  = 2,
                    InitialAmount    = 3,
                    OLB              = 4,
                    OverDuePrincipal = 5
                },
            };
            EntryFee fee = new EntryFee();

            fee.Value = 3;
            _productWithValues.EntryFees = new List <EntryFee>();
            _productWithValues.EntryFees.Add(fee);

            _productWithRangeValues = new LoanProduct
            {
                Id          = 2,
                Name        = "Product2",
                Code        = "Code2",
                Delete      = false,
                ClientType  = 'C',
                FundingLine = new FundingLine {
                    Id = 1
                },
                AmountMin       = 1000,
                AmountMax       = 10111,
                InterestRateMin = 1,
                InterestRateMax = 3,
                InstallmentType = new InstallmentType {
                    Id = 1
                },
                GracePeriodMin      = 1,
                GracePeriodMax      = 5,
                NbOfInstallmentsMin = 3,
                NbOfInstallmentsMax = 10,
                AnticipatedTotalRepaymentPenaltiesMin = 1,
                AnticipatedTotalRepaymentPenaltiesMax = 4,
                KeepExpectedInstallment                = true,
                ChargeInterestWithinGracePeriod        = true,
                AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingInterest,
                NonRepaymentPenaltiesMin               = new NonRepaymentPenaltiesNullableValues
                {
                    OverDueInterest  = 1,
                    InitialAmount    = 2,
                    OLB              = 3,
                    OverDuePrincipal = 4
                },
                NonRepaymentPenaltiesMax = new NonRepaymentPenaltiesNullableValues
                {
                    OverDueInterest  = 11,
                    InitialAmount    = 12,
                    OLB              = 13,
                    OverDuePrincipal = 14
                },
            };
            _productWithRangeValues.EntryFees = new List <EntryFee>();
            EntryFee entryFee2 = new EntryFee();

            entryFee2.Min = 0;
            entryFee2.Max = 10;
            _productWithRangeValues.EntryFees.Add(entryFee2);
        }
        public void TestGetSumOfInterestCoeffWhenNoInstallment()
        {
            ExoticInstallmentsTable product = new ExoticInstallmentsTable();

            Assert.AreEqual(0, product.SumOfInterestCoeff);
        }