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
                }
            };
            Loan myContract = 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()));

            myContract.BadLoan = false;
            myContract.AnticipatedTotalRepaymentPenalties  = 0.01;
            myContract.NonRepaymentPenalties.InitialAmount = 0.003;
            return(myContract);
        }
Exemplo n.º 2
0
        public void TestCalculateMaximumAmountWithFlateBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOLBAndKeepNotExpectedInstallment()
        {
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                LoanType        = OLoanTypes.Flat,
                ChargeInterestWithinGracePeriod = true,
                Currency = new Currency {
                    Id = 1
                }
            };

            package.KeepExpectedInstallment = false;
            package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB;
            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()));

            myContract.BadLoan = true;
            myContract.NonRepaymentPenalties.OLB          = 0.003;
            myContract.AnticipatedTotalRepaymentPenalties = 0.01;

            CreditContractOptions cCO = new CreditContractOptions(package.LoanType, package.KeepExpectedInstallment, false, 0, 0, false, 0, package.AnticipatedTotalRepaymentPenaltiesBase);

            this.repayStrategy = new CalculateMaximumAmountToRegradingLoanStrategy(cCO, myContract, new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""));

            //30 + 230 + 1000 * 0.003 * 42 = 386
            Assert.AreEqual(386, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2));
        }
        public void RepayInstallments_DontCancelFees_InitialAmount_RepaymentTwicelyADay()
        {
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "10-days", 10, 0),
                LoanType        = OLoanTypes.Flat,
                ChargeInterestWithinGracePeriod = true,
                Currency = new Currency {
                    Id = 1
                }
            };

            package.KeepExpectedInstallment = true;
            package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB;

            Loan myContract = new Loan(package, 8000, 0.03333m, 5, 0, new DateTime(2010, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()));

            myContract.BadLoan = false;
            myContract.AnticipatedTotalRepaymentPenalties = 0.01;
            myContract.NonRepaymentPenalties = new NonRepaymentPenalties(0, 0, 0.0667, 0.01);

            myContract.CalculateInstallments(true);

            myContract.Disburse(new DateTime(2010, 1, 1), false, true);
            myContract.Repay(1, new DateTime(2010, 1, 8), 30, false, true);

            RepaymentEvent rPE = myContract.Repay(1, new DateTime(2010, 1, 11), 0, false, true);

            Assert.AreEqual(rPE.Penalties, 0);
        }
Exemplo n.º 4
0
        private static Loan _SetContract(OLoanTypes pLoansType, NonRepaymentPenalties pNonRepaymentPenalties, bool pKeepExpectedInstallment)
        {
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                LoanType        = pLoansType,
                ChargeInterestWithinGracePeriod = true,
                Currency = new Currency {
                    Id = 1, UseCents = true
                },
                RoundingType = ORoundingType.Approximate
            };

            package.KeepExpectedInstallment = pKeepExpectedInstallment;
            package.AnticipatedTotalRepaymentPenaltiesBase = OAnticipatedRepaymentPenaltiesBases.RemainingOLB;
            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()));

            myContract.BadLoan = true;
            myContract.AnticipatedTotalRepaymentPenalties = 0.01;
            myContract.NonRepaymentPenalties = pNonRepaymentPenalties;
            return(myContract);
        }
Exemplo n.º 5
0
        public Settings GetCurrentSettings(bool pIncludePackages)
        {
            Settings settings = new Settings();
            // General parameters
            SettingGroup generalParameters = new SettingGroup(GENERAL_PARAMETERS);

            settings.Add(generalParameters);
            ApplicationSettings gp = ApplicationSettings.GetInstance(_user.Md5);


            generalParameters.Add(new Setting(OGeneralSettings.ACCOUNTINGPROCESS, ((int)gp.AccountingProcesses).ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.ALLOWSMULTIPLELOANS, gp.IsAllowMultipleLoans.ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.ALLOWSMULTIPLEGROUPS, gp.IsAllowMultipleGroups.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.BAD_LOAN_DAYS, gp.BadLoanDays.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, gp.IsCalculationLateFeesDuringHolidays.ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.CEASE_LAIE_DAYS, gp.CeaseLateDays.ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.CITYMANDATORY, gp.IsCityMandatory.ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.CONTRACT_CODE_TEMPLATE, gp.ContractCodeTemplate));
            generalParameters.Add(new Setting(OGeneralSettings.COUNTRY, gp.Country));
            generalParameters.Add(new Setting(OGeneralSettings.AUTOMATIC_ID, gp.IsAutomaticID.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.DONOTSKIPWEEKENDSININSTALLMENTSDATE, gp.DoNotSkipNonWorkingDays.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.ENFORCE_ID_PATTERN, gp.EnforceIDPattern.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.GROUPMINMEMBERS, gp.GroupMinMembers.ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.GROUPMAXMEMBERS, gp.GroupMaxMembers.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.VILLAGEMINMEMBERS, gp.VillageMinMembers.ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.VILLAGEMAXMEMBERS, gp.VillageMaxMembers.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.CLIENT_AGE_MIN, gp.ClientAgeMin.ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.CLIENT_AGE_MAX, gp.ClientAgeMax.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.MAX_LOANS_COVERED, gp.MaxLoansCovered.ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.MAX_GUARANTOR_AMOUNT, gp.MaxGuarantorAmount.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.ID_PATTERN, gp.IDPattern));
            generalParameters.Add(new Setting(OGeneralSettings.INTERESTS_ALSO_CREDITED_IN_FL, gp.InterestsCreditedInFL.ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.INCREMENTALDURINGDAYOFF, gp.IsIncrementalDuringDayOff.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.LATEDAYSAFTERACCRUALCEASES, gp.LateDaysAfterAccrualCeases.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.MAX_NUMBER_INSTALLMENT, gp.MaxNumberInstallment.ToString()));;
            generalParameters.Add(new Setting(OGeneralSettings.MFI_NAME, gp.MfiName));

            generalParameters.Add(new Setting(OGeneralSettings.OLBBEFOREREPAYMENT, gp.IsOlbBeforeRepayment.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.PAYFIRSTINSTALLMENTREALVALUE, gp.PayFirstInterestRealValue.ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.PENDING_SAVINGS_MODE, gp.PendingSavingsMode));

            generalParameters.Add(new Setting(OGeneralSettings.SAVINGS_CODE_TEMPLATE, gp.SavingsCodeTemplate));

            generalParameters.Add(new Setting(OGeneralSettings.VAT_RATE, gp.VatRate.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.WEEKENDDAY1, gp.WeekEndDay1.ToString()));
            generalParameters.Add(new Setting(OGeneralSettings.WEEKENDDAY2, gp.WeekEndDay2.ToString()));

            generalParameters.Add(new Setting(OGeneralSettings.INTEREST_RATE_DECIMAL_PLACES, Convert.ToString(gp.InterestRateDecimalPlaces)));
            generalParameters.Add(new Setting(OGeneralSettings.STOP_WRITEOFF_PENALTY, Convert.ToString(gp.IsStopWriteOffPenalty.ToString())));
            generalParameters.Add(new Setting(OGeneralSettings.MODIFY_ENTRY_FEE, Convert.ToString(gp.ModifyEntryFee.ToString())));

            // Provisioning Rules
            SettingGroup provisioningRules = new SettingGroup(PROVISIONING_RULES);

            settings.Add(provisioningRules);
            foreach (ProvisioningRate prate in ProvisionTable.GetInstance(_user).ProvisioningRates)
            {
                provisioningRules.Add(new Setting(prate.Number.ToString(), String.Format("{0}/{1}/{2}/{3}/{4}",
                                                                                         prate.NbOfDaysMin,
                                                                                         prate.NbOfDaysMax,
                                                                                         prate.ProvisioningValue,
                                                                                         prate.ProvisioningInterest,
                                                                                         prate.ProvisioningPenalty)));
            }

            // Public Holidays
            SettingGroup publicHolidays = new SettingGroup(PUBLIC_HOLIDAYS);

            settings.Add(publicHolidays);
            foreach (DateTime entry in ServicesProvider.GetInstance().GetNonWorkingDate().PublicHolidays.Keys)
            {
                publicHolidays.Add(new Setting(ServicesProvider.GetInstance().GetNonWorkingDate().PublicHolidays[entry], (entry).ToString("dd/MM/yyyy")));
            }
            //if (pIncludePackages)
            //{
            //    // Packages
            //    SettingGroup packages = new SettingGroup(PACKAGES);
            //    settings.Add(packages);
            //    List<LoanProduct> allPackages = new ProductServices(_user).FindAllPackages(false, OClientTypes.Both);
            //    foreach (LoanProduct package in allPackages)
            //    {
            //        Setting p = new Setting(package.Name, null);
            //        //p.Package = package;
            //        packages.Add(p);
            //    }
            //}
            return(settings);
        }
Exemplo n.º 6
0
        public void Get_Set_Credits()
        {
            _project.AddCredit(new Loan(new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User())), OClientTypes.Group);
            Assert.AreEqual(1, _project.Credits.Count);

            Assert.AreEqual(OClientTypes.Group, _project.Credits[0].ClientType);
        }
Exemplo n.º 7
0
 protected override void SetUp()
 {
     base.SetUp();
     _loanManager = (LoanManager)container["LoanManager"];
     _loan        = new Loan(new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()))
     {
         ClientType  = OClientTypes.Person,
         LoanOfficer = new User {
             Id = 1
         },
         BranchCode            = "DU",
         CreationDate          = DateTime.Today.AddDays(-1),
         StartDate             = DateTime.Today,
         AlignDisbursementDate = DateTime.Today,
         CloseDate             = DateTime.Today.AddDays(1),
         Product = new LoanProduct {
             Id = 1, Currency = new Currency {
                 Id = 1
             }
         },
         Amount          = 1000m,
         InterestRate    = 3,
         InstallmentType = new InstallmentType {
             Id = 1
         },
         NbOfInstallments = 2,
         FundingLine      = new FundingLine {
             Id = 1
         },
         InstallmentList = new List <Installment> {
             _installment1, _installment2
         },
         EconomicActivityId = 1,
         EconomicActivity   = new EconomicActivity {
             Id = 1
         },
         GracePeriodOfLateFees = 0
     };
 }
Exemplo n.º 8
0
        private void FillProvisioningRule()
        {
            var table = ProvisionTable.GetInstance(_user);

            table.ProvisioningRates = _provisioningRuleManager.SelectAllProvisioningRates();
        }
        private static Loan _SetContract(OAnticipatedRepaymentPenaltiesBases pAnticipatedRepaymentBase, double pAnticipated, bool pKeepExpectedInstallment, bool useCents)
        {
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                LoanType        = OLoanTypes.Flat,
                ChargeInterestWithinGracePeriod        = true,
                KeepExpectedInstallment                = pKeepExpectedInstallment,
                AnticipatedTotalRepaymentPenaltiesBase = pAnticipatedRepaymentBase,
                Currency = new Currency {
                    Id = 1, UseCents = useCents
                }
            };

            return(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()))
            {
                BadLoan = false,
                AnticipatedTotalRepaymentPenalties = pAnticipated,
                NonRepaymentPenalties = { InitialAmount = 0.003 }
            });
        }