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);
        }
        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);
        }
        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);
        }
        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);
        }
        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);
        }
        public void TestCalculateEntryFeesAmount()
        {
            Loan myContract = new Loan(new User(),
                ApplicationSettings.GetInstance(""),
                NonWorkingDateSingleton.GetInstance(""),
                ProvisionTable.GetInstance(new User()),
                ChartOfAccounts.GetInstance(new User()));
            new Loan(new User(),
                ApplicationSettings.GetInstance(""),
                NonWorkingDateSingleton.GetInstance(""),
                ProvisionTable.GetInstance(new User()),
                ChartOfAccounts.GetInstance(new User()));
            myContract.Amount = 500;
            myContract.LoanEntryFeesList = new List<LoanEntryFee>();
            LoanEntryFee fee = new LoanEntryFee();
            fee.FeeValue = (decimal) 0.02;

            myContract.LoanEntryFeesList.Add(fee);
            Assert.AreEqual(10m,myContract.CalculateEntryFeesAmount(true)[0].Value);
        }
Exemple #7
0
        public List<LoanEntryFee> GetDefaultLoanEntryFees(Loan loan, IClient client)
        {
            _productServices = ServicesProvider.GetInstance().GetProductServices();
            List<EntryFee> entryFees = _productServices.GetProductEntryFees(loan.Product, client);
            var loanEntryFees = new List<LoanEntryFee>();

            foreach (EntryFee fee in entryFees)
            {
                LoanEntryFee loanFee = new LoanEntryFee();
                loanFee.ProductEntryFee = fee;
                if (fee.Min != null)
                    loanFee.FeeValue = (decimal) fee.Min;
                else
                    loanFee.FeeValue = (decimal) fee.Value;
                loanEntryFees.Add(loanFee);
            }
            return loanEntryFees;
        }
        private void btnSave_Click(object sender, EventArgs e)
        {
            bool isError = false;

            if (_CheckIfMoneyIsEnough())
                if (!MessageBox.Show(MultiLanguageStrings.GetString(Ressource.VillageForm, "MoneyNotEnoughForAll.Text"), @"!",
                    MessageBoxButtons.YesNo).Equals(DialogResult.Yes))
                        return;

            if (_product.GracePeriod == null && !_CheckGracePeriod())
            {
                MessageBox.Show(MultiLanguageStrings.GetString(Ressource.VillageForm, "GracePeriodNotCorrect"),
                    MultiLanguageStrings.GetString(Ressource.VillageForm, "GracePeriod"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            foreach (ListViewItem item in lvMembers.Items)
            {
                if (item == _itemTotal) continue;
                if (!item.Checked) continue;
                if (_product.UseCompulsorySavings && item.SubItems[IdxCompulsorySavings].Tag == null)
                {
                    string text = string.Format(@"The loan of client '{0}' requires a compulsory savings account!", ((VillageMember)item.Tag).Tiers.Name);
                    MessageBox.Show(text, @"No compulsory savings", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    return;
                }

                /*if (item.SubItems[IdxPaymentMethod].Tag != null &&
                    item.SubItems[IdxPaymentMethod].Tag.ToString() == OPaymentMethods.Savings.ToString())
                {
                    if (_product.UseCompulsorySavings && item.SubItems[IdxCompulsorySavings].Tag == null)
                    {
                        string text = string.Format(@"The loan of client '{0}' requires a compulsory savings account!", ((VillageMember)item.Tag).Tiers.Name);
                        MessageBox.Show(text, @"No compulsory savings", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                        return;
                    }
                }*/
            }

            if(!_nsgForm.Save()) return;

            Loan loan = null;
            VillageMember member;

            try
            {
                foreach (ListViewItem item in lvMembers.Items)
                {
                    if (!item.Checked || item == _itemTotal) continue;
                    member = item.Tag as VillageMember;
                    Project project;
                    if (null == member) continue;

                    OCurrency amount = (OCurrency)item.SubItems[IdxAmount].Tag;
                    decimal interest = (decimal)item.SubItems[IdxInterest].Tag;
                    int gracePeriod = (int)item.SubItems[IdxGracePeriod].Tag;
                    int installments = (int)item.SubItems[IdxInstallments].Tag;
                    DateTime date = Convert.ToDateTime(item.SubItems[IdxCreationDate].Tag);

                    //creation of loan
                    loan = new Loan(_product,
                                    amount,
                                    interest,
                                    installments,
                                    gracePeriod,
                                    date,
                                    _village.MeetingDay,
                                    User.CurrentUser,
                                    ServicesProvider.GetInstance().GetGeneralSettings(),
                                    ServicesProvider.GetInstance().GetNonWorkingDate(),
                                    CoreDomainProvider.GetInstance().GetProvisioningTable(),
                                    CoreDomainProvider.GetInstance().GetChartOfAccounts())
                    {
                        NonRepaymentPenalties =
                        {
                            InitialAmount = _product.NonRepaymentPenalties.InitialAmount ?? 0,
                            OLB = _product.NonRepaymentPenalties.OLB ?? 0,
                            OverDuePrincipal = _product.NonRepaymentPenalties.OverDuePrincipal ?? 0,
                            OverDueInterest = _product.NonRepaymentPenalties.OverDueInterest ?? 0
                        },
                        InstallmentType = _product.InstallmentType,
                        AnticipatedTotalRepaymentPenalties = 0,
                        FundingLine = item.SubItems[IdxFundingLine].Tag as FundingLine,
                        LoanOfficer = (User)item.SubItems[IdxLoanOfficer].Tag,
                        Synchronize = false,
                        ContractStatus = OContractStatus.Pending,
                        CreditCommitteeCode = string.Empty,
                        GracePeriod = gracePeriod,
                        GracePeriodOfLateFees = _product.GracePeriodOfLateFees,
                        AmountMin = member.Product.AmountMin,
                        AmountMax = member.Product.AmountMax,
                        InterestRateMin = member.Product.InterestRateMin,
                        InterestRateMax = member.Product.InterestRateMax,
                        NmbOfInstallmentsMin = member.Product.NbOfInstallmentsMin,
                        NmbOfInstallmentsMax = member.Product.NbOfInstallmentsMax
                    };
                    loan.InstallmentList =
                        ServicesProvider.GetInstance().GetContractServices().SimulateScheduleCreation(loan);
                    loan.LoanEntryFeesList = new List<LoanEntryFee>();
                    foreach (EntryFee fee in loan.Product.EntryFees)
                    {
                        LoanEntryFee loanEntryFee = new LoanEntryFee();
                        loanEntryFee.ProductEntryFee = fee;
                        loanEntryFee.ProductEntryFeeId = (int)fee.Id;
                        if (fee.Value.HasValue)
                            loanEntryFee.FeeValue = (decimal)fee.Value;
                        else
                            loanEntryFee.FeeValue = (decimal)fee.Min;
                        loan.LoanEntryFeesList.Add(loanEntryFee);
                    }

                    var client = member.Tiers;
                    if (0 == client.Projects.Count)
                    {
                        project = new Project("Village");
                        project.Name = "Village";
                        project.Code = "Village";
                        project.Aim = "Village";
                        project.BeginDate = date;
                        project.Id = ServicesProvider.GetInstance().GetProjectServices().SaveProject(project, client);
                        member.Tiers.AddProject(project);
                    }
                    project = client.Projects[0];

                    // Compulsory savings
                    if (_product.UseCompulsorySavings)
                    {
                        loan.CompulsorySavings = (SavingBookContract)item.SubItems[IdxCompulsorySavings].Tag;
                        loan.CompulsorySavingsPercentage = (int)item.SubItems[IdxCompulsoryPercentage].Tag;
                    }
                    var person = client as Person;
                    if (person == null) throw new ApplicationException("Member can not be other than person.");
                    loan.EconomicActivity = person.Activity;

                    ServicesProvider.GetInstance().GetContractServices().CheckLoanFilling(loan);
                    loan.NsgID = _village.Id;
                    ServicesProvider.GetInstance().GetContractServices().SaveLoan(ref loan, project.Id, ref client);
                    project.AddCredit(loan, loan.ClientType);
                    if (!_village.Active)
                    {
                        _village.Active = true;
                        ServicesProvider.GetInstance().GetContractServices().UpdateVillageStatus(_village);
                    }
                    loan.Closed = false;
                    client.Active = true;
                    client.Status = OClientStatus.Active;
                    member.ActiveLoans.Add(loan);
                }
            }
            catch (Exception ex)
            {
                isError = true;
                loan.ContractStatus = OContractStatus.Pending;
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }

            if (!isError)
            {
                DialogResult = DialogResult.OK;
                Close();
            }
        }
Exemple #9
0
 public List<LoanEntryFee> SelectInstalledLoanEntryFees(int loanId)
 {
     List<LoanEntryFee> loanEntryFees = new List<LoanEntryFee>();
     string q =
         @"SELECT id
                 ,[entry_fee_id]
                 ,[fee_value]
           FROM [dbo].[CreditEntryFees]
           WHERE [credit_id]=@credit_id";
     using (SqlConnection conn = GetConnection())
     using (OpenCbsCommand c = new OpenCbsCommand(q, conn))
     {
         c.AddParam("@credit_id", loanId);
         using (OpenCbsReader r = c.ExecuteReader())
         {
             while (r.Read())
             {
                 LoanEntryFee lef = new LoanEntryFee();
                 lef.Id = r.GetInt("id");
                 lef.ProductEntryFeeId = r.GetInt("entry_fee_id");
                 lef.FeeValue = r.GetDecimal("fee_value");
                 loanEntryFees.Add(lef);
             }
         }
     }
     return loanEntryFees;
 }
Exemple #10
0
        private void AddTranche()
        {
            var configuration = GetTrancheConfiguration();

            var entryFeesForm = new LoanEntryFeesForm
                {
                    EntryFees = _contract
                        .LoanEntryFeesList
                        .GroupBy(i => i.ProductEntryFeeId)
                        .Select(i => i.First())
                        .Select(fee =>
                            {
                                var result = new LoanEntryFee
                                    {
                                        FeeValue =
                                            fee.ProductEntryFee.IsRate
                                                ? configuration.Amount*fee.FeeValue/100
                                                : fee.FeeValue,
                                        Id = fee.Id,
                                        ProductEntryFee = fee.ProductEntryFee,
                                        ProductEntryFeeId = fee.ProductEntryFeeId
                                    };
                                return result;
                            }).ToList()
                };
            if (entryFeesForm.ShowDialog() != DialogResult.OK) return;

            try
            {

                _contract = ServicesProvider
                    .GetInstance()
                    .GetContractServices()
                    .AddTranche(_contract, _client, GetTrancheConfiguration(), entryFeesForm.EntryFees, (PaymentMethod)
                                                                                              cmbPaymentMethod.
                                                                                                  SelectedItem);
                DialogResult = DialogResult.OK;
                Close();
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
            }
        }
        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);
        }
        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");
        }
Exemple #13
0
 public void Get_Set_EntryFees()
 {
     LoanEntryFee entryFee = new LoanEntryFee();
     entryFee.FeeValue = (decimal) 3.2;
     _myContract.LoanEntryFeesList = new List<LoanEntryFee>();
     _myContract.LoanEntryFeesList.Add(entryFee);
     Assert.AreEqual(3.2, _myContract.LoanEntryFeesList[0].FeeValue);
 }
Exemple #14
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);
        }
Exemple #15
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);
 }