示例#1
0
 public void PackageEntryFees()
 {
     EntryFee entryFee = new EntryFee();
     entryFee.Value = (decimal)2.5;
     package.EntryFees = new List<EntryFee>();
     package.EntryFees.Add(entryFee);
     Assert.AreEqual(2.5m, package.EntryFees[0].Value);
 }
        public void RepayWrittenOffLoan()
        {
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, false);
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, false);
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ACCOUNTINGPROCESS, OAccountingProcesses.Cash);
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, 0);
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.INTERESTS_ALSO_CREDITED_IN_FL, 1);
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.DONOTSKIPWEEKENDSININSTALLMENTSDATE, 0);
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.BAD_LOAN_DAYS, "180");

            ProvisionTable _provisionningTable = ProvisionTable.GetInstance(new User() {Id = 1});
            _provisionningTable.ProvisioningRates = new List<ProvisioningRate>();
            _provisionningTable.Add(new ProvisioningRate { Number = 1, NbOfDaysMin = 0, NbOfDaysMax = 0, ProvisioningValue = 0.02, ProvisioningInterest = 0.02, ProvisioningPenalty = 0.02 });
            _provisionningTable.Add(new ProvisioningRate { Number = 2, NbOfDaysMin = 1, NbOfDaysMax = 30, ProvisioningValue = 0.1, ProvisioningInterest = 0.01, ProvisioningPenalty = 0.01 });
            _provisionningTable.Add(new ProvisioningRate { Number = 3, NbOfDaysMin = 31, NbOfDaysMax = 60, ProvisioningValue = 0.25, ProvisioningInterest = 0.025, ProvisioningPenalty = 0.025 });
            _provisionningTable.Add(new ProvisioningRate { Number = 4, NbOfDaysMin = 61, NbOfDaysMax = 90, ProvisioningValue = 0.5, ProvisioningInterest = 0.5, ProvisioningPenalty = 0.5 });
            _provisionningTable.Add(new ProvisioningRate { Number = 5, NbOfDaysMin = 91, NbOfDaysMax = 180, ProvisioningValue = 0.75, ProvisioningInterest = 0.75, ProvisioningPenalty = 0.75 });
            _provisionningTable.Add(new ProvisioningRate { Number = 6, NbOfDaysMin = 181, NbOfDaysMax = 365, ProvisioningValue = 1, ProvisioningInterest = 1, ProvisioningPenalty = 1 });
            _provisionningTable.Add(new ProvisioningRate { Number = 7, NbOfDaysMin = 366, NbOfDaysMax = 99999, ProvisioningValue = 1, ProvisioningInterest = 1, ProvisioningPenalty = 1 });

            Teller.CurrentTeller = null;

            //DynamicMock mockClientManager = new DynamicMock(typeof(ClientManager));
            //DynamicMock mockLoanManager = new DynamicMock(typeof(LoanManager));

            //Loan loan = new Loan
            //{
            //    Amount = 11,
            //    Code = "Test",
            //    InterestRate = 1,
            //    NbOfInstallments = 2,
            //    InstallmentType = new InstallmentType(),
            //    AnticipatedTotalRepaymentPenalties = 2,
            //    NonRepaymentPenalties = new NonRepaymentPenalties(1, 1, 1, 1),
            //    GracePeriod = 2,
            //    Events = new EventStock(),
            //    StartDate = new DateTime(2009, 1, 1),
            //    FundingLine = new FundingLine { Currency = new Currency { Id = 1, Code = "Code", Name = "Name" } },
            //    LoanOfficer = new User(),
            //    Product = new LoanProduct { Currency = new Currency { Id = 1, Code = "Code", Name = "Name" } },
            //    InstallmentList = new List<Installment> { _installment1, _installment2 }
            //};

            //Person person = new Person { Active = false, LoanCycle = 1 };
            //IClient group = new Group { Active = false, LoanCycle = 1, Members = new List<Member> { new Member { Tiers = person } } };

            //mockClientManager.Expect("UpdateClientStatus", group, null);
            //mockClientManager.Expect("UpdateClientLoanCycle", group, null);

            //mockClientManager.Expect("UpdateClientStatus", person, null);
            //mockClientManager.Expect("UpdateClientLoanCycle", person, null);

            //LoanServices loanServices = new LoanServices(null, (ClientManager)mockClientManager.MockInstance, (LoanManager)mockLoanManager.MockInstance);
            //loanServices.SaveLoan(ref loan, 1, ref group);

            //loanServices.Disburse(loan, new DateTime(2008, 1, 1), true, true);
            //loanServices.Repay(loan, group, 1, DateTime.Now, 1, true, 0, 0, false, 0, true);

            //Loan disbursedLoan = loan;
            //disbursedLoan.Disbursed = true;
            //LoanDisbursmentEvent loanDisbursmentEvent = new LoanDisbursmentEvent
            //                                                {
            //                                                    Date = new DateTime(2008, 1, 1),
            //                                                    Amount = disbursedLoan.Amount,
            //                                                    Commission = disbursedLoan.CalculateEntryFeesAmount(),
            //                                                    ClientType = disbursedLoan.ClientType
            //                                                };
            //disbursedLoan.Events.Add(loanDisbursmentEvent);
            //loanServices.Repay(disbursedLoan, group, 1, DateTime.Now, 1, true, 0,0, false, 1, true);
            AddDataForTestingTransaction dataHelper = new AddDataForTestingTransaction();
            int _creditId = dataHelper.AddGenericCreditContractIntoDatabase();

            IClient _client = new Group {Id = 5};
            LoanManager _loanManager = new LoanManager(new User() {Id = 1});
            Loan _loan = _loanManager.SelectLoan(_creditId, true, true, true);

            _loan.CreditCommiteeDate = _loan.StartDate;

            AccountManager accountManager = new AccountManager(new User() {Id = 1});
            //accountManager.AddForCurrency(_loan.Product.Currency.Id);

            FundingLine f = _loan.FundingLine;
            f.Currency.Id = _loan.Product.Currency.Id;
            FundingLineServices fundingLineServices = new FundingLineServices(new User() {Id = 1});

            var ev = new FundingLineEvent
            {
                Code = "KAO",
                Type = OFundingLineEventTypes.Entry,
                CreationDate = new DateTime(2008,1,1),
                EndDate = DateTime.Now.AddDays(1),
                Amount = 1000,
                FundingLine = f,
                Movement = OBookingDirections.Credit,
                IsDeleted = false
            };
            fundingLineServices.AddFundingLineEvent(ev, null);
            f.AddEvent(ev);
            _loan.LoanEntryFeesList=new List<LoanEntryFee>();

            EntryFee productEntryFee = new EntryFee();
            productEntryFee.Value = 1;
            productEntryFee.IsRate = false;
            productEntryFee.Id = 21;
            LoanEntryFee loanEntryFee = new LoanEntryFee();
            loanEntryFee.FeeValue = 1;
            loanEntryFee.ProductEntryFee = productEntryFee;
            loanEntryFee.ProductEntryFeeId = 21;

            LoanServices loanServices = new LoanServices(new User() { Id = 1 });

            PaymentMethod method = new PaymentMethod(1, "Savings", "Savings method", false);
            loanServices.Disburse(_loan, new DateTime(2008, 1, 1), true, false, method);

            ////_loan.WrittenOff = true;
            ////_loan = loanServices.Repay(_loan, _client, 1, DateTime.Now, 10, true, 0, 0,false, 1, true);
            //Assert.AreEqual(_loan.Disbursed, true);
            //_loan.WrittenOff = true;
            //OCurrency prevAmount = _loan.ChartOfAccounts.GetAccountByNumber(OAccounts.RECOVERY_OF_CHARGED_OFF_ASSETS, _loan.Product.Currency.Id).Balance;
            //_loan = loanServices.Repay(_loan, _client, 1, DateTime.Now, 100, true, 0, 0, false, 5, false, OPaymentMethods.Cash, null, false);

            //Assert.AreEqual(_loan.Events.GetNumberOfEvents, 1);
            //_loan.Events.SortEventsByDate();
            //Assert.AreEqual(_loan.Events.GetEvent(0).Code, "ROWO");

            //_loan = loanServices.Repay(_loan, _client, 2, DateTime.Now, 100, true, 0, 0, false, 5, false, OPaymentMethods.Cash, null, false);

            //Assert.AreEqual(_loan.Events.GetNumberOfEvents, 2);

            //_loan.Events.SortEventsByDate();
            //Assert.AreEqual(_loan.Events.GetEvent(0).Code, "ROWO");
        }
        public void SaveLoan_UpdateLoan_Person_NoGuarantor()
        {
            DynamicMock mockInstalmentManager = new DynamicMock(typeof(InstallmentManager));
            DynamicMock mockLoanManager = new DynamicMock(typeof(LoanManager));

            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.ALLOWSMULTIPLELOANS, false);
            Loan loan = new Loan
            {
                Id = 1,
                Amount = 11,
                Code = "Test",
                InterestRate = 1,
                NbOfInstallments = 2,
                InstallmentType = new InstallmentType(),
                AnticipatedTotalRepaymentPenalties = 2,
                NonRepaymentPenalties = new NonRepaymentPenalties(1, 1, 1, 1),
                GracePeriod = 2,
                StartDate = new DateTime(2009, 1, 1),
                FundingLine = new FundingLine { Currency = new Currency { Code = "Code", Name = "Name" } },
                LoanOfficer = new User(),
                Product = new LoanProduct { Currency = new Currency { Code = "Code", Name = "Name" } },
                InstallmentList = new List<Installment> { _installment1, _installment2 },
                Guarantors = new List<Guarantor>()
            };

            EntryFee prodEntryFee = new EntryFee();
            prodEntryFee.Value = 2;
            prodEntryFee.Id = 21;
            prodEntryFee.Name = "Tested";
            LoanEntryFee loanEntryFee = new LoanEntryFee();
            loanEntryFee.FeeValue = 2;
            loanEntryFee.ProductEntryFee = prodEntryFee;
            loanEntryFee.ProductEntryFeeId = 21;

            loan.LoanEntryFeesList = new List<LoanEntryFee>();
            loan.LoanEntryFeesList.Add(loanEntryFee);
            IClient person = new Person { Active = false };

            mockInstalmentManager.Expect("DeleteInstallments", loan.Id, null);
            mockInstalmentManager.Expect("AddInstallments", loan.InstallmentList, loan.Id, null);
            mockLoanManager.Expect("UpdateLoan", loan, null);

            LoanServices loanServices = new LoanServices((InstallmentManager)mockInstalmentManager.MockInstance, null, (LoanManager)mockLoanManager.MockInstance);
            loanServices.SaveLoan(ref loan, 2, ref person);
        }
示例#4
0
        public void SelectProduct_Values()
        {
            LoanProductManager loanProductManager = (LoanProductManager)container["LoanProductManager"];

            LoanProduct loanProduct = loanProductManager.Select(_productWithValues.Id);
            EntryFee entryFee = new EntryFee();
            entryFee.Value = 3;
            loanProduct.EntryFees=new List<EntryFee>();
            loanProduct.EntryFees.Add(entryFee);
            AssertLoanProduct(_productWithValues, loanProduct, false);
        }
示例#5
0
 private void DeleteEntryFeeFromLists(EntryFee entryFee)
 {
     if (entryFee.IsAdded)
     {
         foreach (EntryFee fee in _product.AddedEntryFees)
         {
             if (fee.IdForNewItem != entryFee.IdForNewItem) continue;
             _product.AddedEntryFees.Remove(fee);
             break;
         }
         foreach (EntryFee fee in _product.EntryFees)
         {
             if (fee.IdForNewItem != entryFee.IdForNewItem) continue;
             _product.EntryFees.Remove(fee);
             break;
         }
     }
     else
     {
         foreach (EntryFee fee in _product.EntryFees)
         {
             if (fee.Id != entryFee.Id) continue;
             _product.DeletedEntryFees.Add(fee);
             _product.EntryFees.Remove(fee);
             break;
         }
     }
 }
示例#6
0
        public void TestDisburseWhenBiWeeklyInstallmentType()
        {
            LoanProduct package = new LoanProduct
                                      {
                                          InstallmentType = new InstallmentType(1, "Bi-Weelky", 14, 0),
                                          LoanType = OLoanTypes.Flat,
                                          ChargeInterestWithinGracePeriod = true,
                                          Currency = new Currency { Id = 1 }
                                      };
            Loan myContract = new Loan(package, 1000, 0.02m, 6, 1, new DateTime(2006, 1, 2), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()));

            EntryFee entryFee = new EntryFee();
            entryFee.Value = 5;
            entryFee.IsRate = true;
            entryFee.Id = 21;

            LoanEntryFee loanEntryFee = new LoanEntryFee();
            loanEntryFee.FeeValue = 5;
            loanEntryFee.ProductEntryFee = entryFee;
            loanEntryFee.ProductEntryFeeId = 21;
            myContract.LoanEntryFeesList = new List<LoanEntryFee>();
            myContract.LoanEntryFeesList.Add(loanEntryFee);

            LoanDisbursmentEvent lDE = myContract.Disburse(new DateTime(2006, 1, 6), false, false);

            Assert.AreEqual(new DateTime(2006,1,2), myContract.StartDate);
            Assert.AreEqual(14.29m, myContract.GetInstallment(0).InterestsRepayment.Value);
            Assert.AreEqual(1000m, lDE.Amount.Value);
            Assert.AreEqual(50m, lDE.Commissions[0].Fee.Value);
        }
示例#7
0
        public void TestDisburseWhenDisburseDateEqualsToContractStartDate()
        {
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, true);
            LoanProduct package = new LoanProduct
                                      {
                                          InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                                          LoanType = OLoanTypes.Flat,
                                          ChargeInterestWithinGracePeriod = true,
                                          Currency = new Currency { Id = 1 }
                                      };
            Loan myContract = new Loan(package,1000,0.03m,6,1,new DateTime(2006,1,1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()));
            EntryFee entryFee = new EntryFee();
            entryFee.Value = 5;
            entryFee.IsRate = true;
            entryFee.Id = 21;

            LoanEntryFee loanEntryFee = new LoanEntryFee();
            loanEntryFee.FeeValue = 5;
            loanEntryFee.ProductEntryFee = entryFee;
            loanEntryFee.ProductEntryFeeId = 21;
            myContract.LoanEntryFeesList = new List<LoanEntryFee>();
            myContract.LoanEntryFeesList.Add(loanEntryFee);

            LoanDisbursmentEvent lDE = myContract.Disburse(new DateTime(2006,1,1),false,false);
            Assert.AreEqual(new DateTime(2006,1,1),myContract.StartDate);
            Assert.AreEqual(30m,myContract.GetInstallment(0).InterestsRepayment.Value);
            Assert.AreEqual(1000m,lDE.Amount.Value);
            Assert.AreEqual(50m,lDE.Commissions[0].Fee.Value);
        }
示例#8
0
 public EntryFee SelectEntryFeeById(int entryFeeId)
 {
     EntryFee entryFee = new EntryFee();
     string q =
                     @"SELECT [id]
                      ,[name_of_fee]
                      ,[min]
                      ,[max]
                      ,[value]
                      ,[rate]
                      ,[fee_index]
                      ,[cycle_id]
                     FROM [dbo].[EntryFees]
                     WHERE [id]=@entry_fee_id";
     using (SqlConnection conn = GetConnection())
     using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
     {
         c.AddParam("@entry_fee_id", entryFeeId);
         using (OpenCbsReader r = c.ExecuteReader())
         {
             if (r!= null && !r.Empty)
             while (r.Read())
             {
                 entryFee = GetEntryFee(r);
             }
         }
     }
     return entryFee;
 }
示例#9
0
 public void GetEntryFees_DisableFees_False()
 {
     _myContract.Disburse(new DateTime(2006, 1, 1), true, false);
     EntryFee fee = new EntryFee();
     fee.Value = 3;
     fee.IsRate = true;
     fee.Id = 21;
     LoanEntryFee loanEntryFee = new LoanEntryFee();
     loanEntryFee.FeeValue = 3;
     loanEntryFee.ProductEntryFee = fee;
     loanEntryFee.ProductEntryFeeId = 21;
     _myContract.LoanEntryFeesList = new List<LoanEntryFee>();
     _myContract.LoanEntryFeesList.Add(loanEntryFee);
     Assert.AreEqual(30m, _myContract.GetEntryFees()[0].Value);
 }
示例#10
0
        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);
        }
示例#11
0
 private static EntryFee GetEntryFee(OpenCbsReader r)
 {
     EntryFee entryFee = new EntryFee
                        {
                            Id = r.GetInt("id"),
                            Name = r.GetString("name_of_fee"),
                            Min = r.GetNullDecimal("min"),
                            Max = r.GetNullDecimal("max"),
                            Value = r.GetNullDecimal("value"),
                            IsRate = r.GetNullBool("rate") ?? false,
                            Index = r.GetInt("fee_index"),
                            CycleId = r.GetNullInt("cycle_id")
                        };
     return entryFee;
 }
示例#12
0
        public void UpdateProduct_Values_ExoticInstallmentsTable_AmountCyclesStock_DontUpdateContracts()
        {
            Assert.Ignore();
            LoanProductManager loanProductManager = (LoanProductManager)container["LoanProductManager"];

            LoanProduct loanProduct = loanProductManager.Select(_productWithValues.Id);
            loanProduct.GracePeriod = 8;
            loanProduct.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingInterest;
            loanProduct.AnticipatedTotalRepaymentPenalties = 33;
            loanProduct.ChargeInterestWithinGracePeriod = true;
            loanProduct.NbOfInstallments = 5;
            loanProduct.NonRepaymentPenalties.InitialAmount = 111;
            loanProduct.NonRepaymentPenalties.OLB = 222;
            loanProduct.NonRepaymentPenalties.OverDueInterest = 333;
            loanProduct.NonRepaymentPenalties.OverDuePrincipal = 444;
            loanProduct.ExoticProduct = new ExoticInstallmentsTable { Id = 2, Name = "Exotic2" };
            //            loanProduct.AmountCycles = new AmountCycleStock { Id = 2, Name = "Cycle2" };
            loanProduct.EntryFees = new List<EntryFee>();
            EntryFee entryFee = new EntryFee();
            entryFee.Value = 2;
            entryFee.IsAdded = true;
            loanProduct.EntryFees.Add(entryFee);

            loanProductManager.UpdatePackage(loanProduct,false);
            loanProductManager.InsertEntryFees(loanProduct.EntryFees, loanProduct.Id);
            LoanProduct updatedLoanProduct = loanProductManager.Select(loanProduct.Id);

            updatedLoanProduct.EntryFees = loanProductManager.SelectEntryFeesWithoutCycles(updatedLoanProduct.Id, false);

            AssertLoanProduct(loanProduct, updatedLoanProduct, true);
        }
示例#13
0
        public void UpdateProduct_RangeValues_DontUpdateContracts()
        {
            LoanProductManager loanProductManager = (LoanProductManager)container["LoanProductManager"];

            LoanProduct loanProduct = loanProductManager.Select(_productWithRangeValues.Id);
            loanProduct.GracePeriodMin = 8;
            loanProduct.GracePeriodMax = 12;
            loanProduct.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingInterest;
            loanProduct.AnticipatedTotalRepaymentPenalties = 33;
            loanProduct.ChargeInterestWithinGracePeriod = true;
            loanProduct.NbOfInstallmentsMin = 5;
            loanProduct.NbOfInstallmentsMax = 6;
            loanProduct.NonRepaymentPenaltiesMin.InitialAmount = 111;
            loanProduct.NonRepaymentPenaltiesMin.OLB = 222;
            loanProduct.NonRepaymentPenaltiesMin.OverDueInterest = 333;
            loanProduct.NonRepaymentPenaltiesMin.OverDuePrincipal = 444;
            loanProduct.NonRepaymentPenaltiesMax.InitialAmount = 1111;
            loanProduct.NonRepaymentPenaltiesMax.OLB = 2222;
            loanProduct.NonRepaymentPenaltiesMax.OverDueInterest = 3333;
            loanProduct.NonRepaymentPenaltiesMax.OverDuePrincipal = 4444;

            EntryFee fee = new EntryFee();
            fee.Min = 2;
            fee.Max = 4;
            fee.IsAdded = true;
            loanProduct.EntryFees = new List<EntryFee>();
            loanProduct.EntryFees.Add(fee);

            loanProductManager.UpdatePackage(loanProduct,false);
            loanProductManager.InsertEntryFees(loanProduct.EntryFees, loanProduct.Id);
            LoanProduct updatedLoanProduct = loanProductManager.Select(loanProduct.Id);
            updatedLoanProduct.EntryFees = loanProductManager.SelectEntryFeesWithoutCycles(updatedLoanProduct.Id, false);

            AssertLoanProduct(loanProduct, updatedLoanProduct, false);
        }
示例#14
0
        public void SelectProduct_Values_ExoticInstallmentsTable_AmountCyclesStock()
        {
            Assert.Ignore();
            LoanProductManager loanProductManager = (LoanProductManager)container["LoanProductManager"];
            _productWithValues.ExoticProduct = _exoticInstallmentsTable;
            //            _productWithValues.AmountCycles = _amountCycleStock;
            _productWithValues.Amount = null;
            _productWithValues.Name = "Test";
            _productWithValues.Currency = new Currency { Id = 1 };
            _productWithValues.Id = loanProductManager.Add(_productWithValues);

            LoanProduct selectedProduct = loanProductManager.Select(_productWithValues.Id);

            selectedProduct.EntryFees=new List<EntryFee>();
            EntryFee entryFee = new EntryFee();
            entryFee.Value = 3;
            selectedProduct.EntryFees.Add(entryFee);

            AssertLoanProduct(_productWithValues, selectedProduct, true);
        }
示例#15
0
 public void PackageEntryFeesMin()
 {
     EntryFee fee = new EntryFee();
     fee.Min = (decimal) 2.5;
     package.EntryFees = new List<EntryFee>();
     package.EntryFees.Add(fee);
     Assert.AreEqual(2.5m,package.EntryFees[0].Min);
 }
示例#16
0
        public void GetPaidFees_NoLatePenalties_Commissions()
        {
            _myContract.NonRepaymentPenalties = new NonRepaymentPenalties(0.03, 0, 0, 0);
            EntryFee fee = new EntryFee();
            fee.Value = 3;
            fee.IsRate = true;
            fee.Id = 21;
            LoanEntryFee loanEntryFee = new LoanEntryFee();
            loanEntryFee.FeeValue = 3;
            loanEntryFee.ProductEntryFee = fee;
            loanEntryFee.ProductEntryFeeId = 21;
            _myContract.LoanEntryFeesList = new List<LoanEntryFee>();
            _myContract.LoanEntryFeesList.Add(loanEntryFee);
            _myContract.Disburse(new DateTime(2006, 1, 1), true, false);
            _myContract.Repay(1, new DateTime(2006, 2, 1), 500, true, true);

            Assert.AreEqual(30m,_myContract.GetPaidFees().Value);
        }
示例#17
0
        public void TestDisburseWhenMontlyInstallmentTypeAndAlignDateWithRealDisbuseDate()
        {
            ApplicationSettings pDataParam = ApplicationSettings.GetInstance("");
            pDataParam.DeleteAllParameters();
            pDataParam.AddParameter("ALIGN_INSTALLMENTS_ON_REAL_DISBURSEMENT_DATE", true);
            pDataParam.AddParameter(OGeneralSettings.DONOTSKIPWEEKENDSININSTALLMENTSDATE, false);
            pDataParam.AddParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, true);
            pDataParam.AddParameter(OGeneralSettings.PAYFIRSTINSTALLMENTREALVALUE, true);

            LoanProduct package = new LoanProduct
                                      {
                                          InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                                          LoanType = OLoanTypes.Flat,
                                          ChargeInterestWithinGracePeriod = true,
                                          Currency = new Currency { Id = 1 }
                                      };
            Loan myContract = new Loan(package,1000,0.02m,6,1,new DateTime(2006,1,2), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()));
            EntryFee entryFee = new EntryFee();
            entryFee.Value = 5;
            entryFee.IsRate = true;
            entryFee.Id = 21;

            LoanEntryFee loanEntryFee = new LoanEntryFee();
            loanEntryFee.FeeValue = 5;
            loanEntryFee.ProductEntryFee = entryFee;
            loanEntryFee.ProductEntryFeeId = 21;
            myContract.LoanEntryFeesList = new List<LoanEntryFee>();
            myContract.LoanEntryFeesList.Add(loanEntryFee);

            LoanDisbursmentEvent lDE = myContract.Disburse(new DateTime(2006,1,2),true,false);
            Assert.AreEqual(new DateTime(2006, 1, 2), myContract.StartDate);
            Assert.AreEqual(20m,myContract.GetInstallment(0).InterestsRepayment.Value);
            Assert.AreEqual(new DateTime(2006,2,2),myContract.GetInstallment(0).ExpectedDate);
            Assert.AreEqual(1000m,lDE.Amount.Value);
            Assert.AreEqual(50m, lDE.Commissions[0].Fee.Value);
        }
示例#18
0
 private void InitializeAdditionalEmptyRowInListView()
 {
     if (lvEntryFees.Items.Count < 11)
     {
         EntryFee entryFee = new EntryFee();
         ListViewItem tItem = new ListViewItem("") { Tag = entryFee };
         tItem.SubItems.Add("");
         tItem.SubItems.Add("");
         tItem.SubItems.Add("");
         tItem.SubItems.Add("");
         tItem.SubItems.Add("");
         tItem.SubItems.Add("");
         tItem.SubItems.Add("");
         tItem.SubItems.Add("");
         tItem.SubItems.Add(lvEntryFees.Items.Count.ToString(CultureInfo.CurrentCulture));
         lvEntryFees.Items.Add(tItem);
     }
 }
示例#19
0
        public void TestDisburseWhenDisableFeesTrue()
        {
            ApplicationSettings pDataParam = ApplicationSettings.GetInstance("");
            pDataParam.DeleteAllParameters();
            pDataParam.AddParameter("ALIGN_INSTALLMENTS_ON_REAL_DISBURSEMENT_DATE", false);
            pDataParam.AddParameter("PAY_FIRST_INSTALLMENT_REAL_VALUE", true);
            pDataParam.AddParameter(OGeneralSettings.DONOTSKIPWEEKENDSININSTALLMENTSDATE, false);
            pDataParam.AddParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, true);

            LoanProduct package = new LoanProduct
                                      {
                                          InstallmentType = new InstallmentType(1, "Bi-Weelky", 14, 0),
                                          LoanType = OLoanTypes.Flat,
                                          ChargeInterestWithinGracePeriod = true,
                                          Currency = new Currency { Id = 1 }
                                      };
            Loan myContract = new Loan(package,1000,0.02m,6,1,new DateTime(2006,1,2), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()));
            EntryFee productFee = new EntryFee();
            productFee.Value = 5;
            productFee.IsRate = true;

            LoanEntryFee entryFee = new LoanEntryFee();
            entryFee.FeeValue = 5;
            entryFee.ProductEntryFee = productFee;
            myContract.LoanEntryFeesList = new List<LoanEntryFee>();
            myContract.LoanEntryFeesList.Add(entryFee);

            LoanDisbursmentEvent lDE = myContract.Disburse(new DateTime(2006,1,6),false,true);
            Assert.AreEqual(new DateTime(2006,1,2),myContract.StartDate);
            Assert.AreEqual(14.29m,myContract.GetInstallment(0).InterestsRepayment.Value);
            Assert.AreEqual(1000m,lDE.Amount.Value);
            Assert.AreEqual(null, lDE.Commissions);
        }
示例#20
0
        private static EntryFee GetEntryFeeFromListView(ListViewItem item)
        {
            decimal? min = string.IsNullOrEmpty(item.SubItems[IdxMin].Text) ? null : (decimal?)Convert.ToDecimal(item.SubItems[IdxMin].Text);
            decimal? max = string.IsNullOrEmpty(item.SubItems[IdxMax].Text) ? null : (decimal?)Convert.ToDecimal(item.SubItems[IdxMax].Text);
            decimal? v = string.IsNullOrEmpty(item.SubItems[IdxValue].Text) ? null : (decimal?)Convert.ToDecimal(item.SubItems[IdxValue].Text);
            int id = string.IsNullOrEmpty(item.SubItems[IdxId].Text) ? 0 : Convert.ToInt32(item.SubItems[IdxId].Text);
            int? cycleId = string.IsNullOrEmpty(item.SubItems[IdxCycleId].Text) ? null : (int?)Convert.ToInt32(item.SubItems[IdxCycleId].Text);

            EntryFee entryFee = new EntryFee
            {
                Id = id,
                Name = item.SubItems[IdxNameOfFee].Text,
                Min = min,
                Max = max,
                Value = v,
                IsRate = Convert.ToBoolean(item.SubItems[IdxIsRate].Text),
                IsAdded = id <= 0,
                CycleId = cycleId,
                IdForNewItem = 0,// Convert.ToInt32(item.SubItems[IdxIdForNewItem].Text),
                Index = Convert.ToInt32(item.SubItems[IdxIndex].Text)
            };
            return entryFee;
        }
示例#21
0
        public void TestDisburseWhenDisburseDateGreaterThanContractStartDate()
        {
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true);
            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.INCREMENTALDURINGDAYOFF, true);
            //startdate = 1/1/2006
            //expectedFirstInstallment = 1/2/2006
            //real startdate = 6/1/2006
            LoanProduct package = new LoanProduct
                                      {
                                          InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                                          LoanType = OLoanTypes.Flat,
                                          ChargeInterestWithinGracePeriod = true,
                                          Currency = new Currency { Id = 1 }
                                      };
            EntryFee productEntryFee = new EntryFee();
            productEntryFee.IsRate = true;
            productEntryFee.Value = 5;//5% of an amount
            productEntryFee.Id = 21;
            productEntryFee.Name = "Test entry fee";
            package.EntryFees = new List<EntryFee>();
            package.EntryFees.Add(productEntryFee);

            Loan myContract = new Loan(
                                        package,
                                        1000,
                                        0.03m,
                                        6,
                                        1,
                                        new DateTime(2006,1,1),
                                        new User(),
                                        ApplicationSettings.GetInstance(""),
                                        NonWorkingDateSingleton.GetInstance(""),
                                        ProvisionTable.GetInstance(new User()),
                                        ChartOfAccounts.GetInstance(new User())
                                        );

            LoanEntryFee fee = new LoanEntryFee();
            fee.ProductEntryFee = package.EntryFees[0];
            fee.FeeValue = (decimal)fee.ProductEntryFee.Value;
            fee.ProductEntryFeeId = (int) package.EntryFees[0].Id;
            myContract.LoanEntryFeesList=new List<LoanEntryFee>();
            myContract.LoanEntryFeesList.Add(fee);

            LoanDisbursmentEvent lDE = myContract.Disburse(new DateTime(2006,1,6),false,false);
            Assert.AreEqual(new DateTime(2006,1,1),myContract.StartDate);
            Assert.AreEqual(25m,myContract.GetInstallment(0).InterestsRepayment.Value);
            Assert.AreEqual(1000m,lDE.Amount.Value);
            Assert.AreEqual(50m, lDE.Commissions[0].Fee.Value);
        }
示例#22
0
 public void SelectAllProducts_OnlyForPerson_DontShowDeleted()
 {
     LoanProductManager loanProductManager = (LoanProductManager)container["LoanProductManager"];
     List<LoanProduct> list = loanProductManager.SelectAllPackages(false, OClientTypes.Person);
     EntryFee entryFee = new EntryFee();
     entryFee.Value = 3;
     list[0].EntryFees = new List<EntryFee>();
     list[0].EntryFees.Add(entryFee);
     Assert.AreEqual(1,list.Count);
     AssertLoanProduct(_productWithValues, list[0], false);
     _productWithValues.ClientType = '-';
     _productWithValues.Id = 4;
     _productWithValues.Name = "Product4";
 }