public void Accept()
        {
            LoanProduct product     = new LoanProduct(99, "Loan", 5.25m);
            LoanAmount  amount      = new LoanAmount("USD", 200_000);
            var         application = new LoanApplication(42,
                                                          product,
                                                          amount,
                                                          "Sarah",
                                                          25,
                                                          "133 Pluralsight Drive, Draper, Utah",
                                                          65_000);

            var mockIdentityVerifier = new Mock <IIdentityVerifier>();

            mockIdentityVerifier.Setup(x => x.Validate("Sarah",
                                                       25,
                                                       "133 Pluralsight Drive, Draper, Utah"))
            .Returns(true);

            var mockCreditScorer = new Mock <ICreditScorer>();

            var sut = new LoanApplicationProcessor(mockIdentityVerifier.Object,
                                                   mockCreditScorer.Object);

            sut.Process(application);

            Assert.That(application.GetIsAccepted(), Is.True);
        }
        public void TestCalculateMaximumAmountWithFlateBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOverDueWithoutInterestAndKeepExpectedInstallment()
        {
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                LoanType        = OLoanTypes.Flat,
                ChargeInterestWithinGracePeriod = true,
                Currency = new Currency {
                    Id = 1
                }
            };

            package.KeepExpectedInstallment = true;
            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.OverDuePrincipal = 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(""));

            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, false);
            //30 + 230 + 200 * 0.003 * 12 = 268.4 => 267
            // Assert.AreEqual(267, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2));
            Assert.AreEqual(267, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 0));

            ApplicationSettings.GetInstance("").UpdateParameter(OGeneralSettings.CALCULATIONLATEFEESDURINGPUBLICHOLIDAYS, true);

            //30 + 230 + 200 * 0.003 * 14 = 268.4 => 268
            Assert.AreEqual(268, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2));
        }
        public void TestCalculateMaximumAmountWithFlateBadLoanWith42DaysLateWhenNonRepaymentFeesBaseOnInitialAmountAndKeepExpectedInstallmentAndCancelFeesSetToFalse()
        {
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                LoanType        = OLoanTypes.Flat,
                ChargeInterestWithinGracePeriod = true,
                Currency = new Currency {
                    Id = 1
                }
            };

            package.KeepExpectedInstallment = true;
            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.InitialAmount = 0.0123;
            myContract.AnticipatedTotalRepaymentPenalties  = 0.01;

            //42 days late
            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.0123 * 42 = 776.6 => 777
            //  Assert.AreEqual(777, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2));
            Assert.AreEqual(777, Math.Round(this.repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 0));
        }
Beispiel #4
0
        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);
        }
        public void DecliningRate_ExoticInstallments_GracePeriod()
        {
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                LoanType        = OLoanTypes.DecliningFixedInstallments,
                ChargeInterestWithinGracePeriod = true,
                ExoticProduct = new ExoticInstallmentsTable
                {
                    new ExoticInstallment(1, 0.1, null),
                    new ExoticInstallment(2, 0.1, null),
                    new ExoticInstallment(3, 0.1, null),
                    new ExoticInstallment(4, 0.1, null),
                    new ExoticInstallment(5, 0.1, null),
                    new ExoticInstallment(6, 0.5, null)
                },
                Currency = new Currency {
                    Id = 1
                }
            };

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

            _AssertSpecifiedInstallment(myContract.GetInstallment(0), 1, new DateTime(2006, 2, 1), 30, 0, 1000);
            _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 3, 1), 30, 100, 1000);
            _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 4, 3), 27, 100, 900);
            _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 5, 1), 24, 100, 800);
            _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 6, 1), 21, 100, 700);
            _AssertSpecifiedInstallment(myContract.GetInstallment(5), 6, new DateTime(2006, 7, 3), 18, 100, 600);
            _AssertSpecifiedInstallment(myContract.GetInstallment(6), 7, new DateTime(2006, 8, 1), 15, 500, 500);
        }
        public void InitializeIdentityVerifier()
        {
            // Arrange
            LoanProduct product     = new LoanProduct(99, "Loan", 5.25m);
            LoanAmount  amount      = new LoanAmount("USD", 200_000);
            var         application = new LoanApplication(42,
                                                          product,
                                                          amount,
                                                          "Sarah",
                                                          25,
                                                          "133 Pluralsight Drive, Draper, Utah",
                                                          65_000);

            var mockIdentityVerifier = new Mock <IIdentityVerifier>();

            mockIdentityVerifier
            .Setup(x => x.Validate(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <string>()))
            .Returns(true);

            var mockCreditScorer = new Mock <ICreditScorer>();

            mockCreditScorer
            .Setup(x => x.Score)
            .Returns(300);

            var sut = new LoanApplicationProcessor(mockIdentityVerifier.Object, mockCreditScorer.Object);

            // Act
            sut.Process(application);

            // Assert
            mockIdentityVerifier.Verify(x => x.Initialize());
        }
        public void FlateBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOverDueWithInterestAndKeepExpectedInstallment()
        {
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                LoanType        = OLoanTypes.Flat,
                ChargeInterestWithinGracePeriod = true,
                Currency = new Currency {
                    Id = 1, UseCents = true
                }
            };

            package.KeepExpectedInstallment = true;
            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.OverDuePrincipal = 0.003;
            myContract.NonRepaymentPenalties.OverDueInterest  = 0.003;
            myContract.AnticipatedTotalRepaymentPenalties     = 0.01;

            ApplicationSettings.GetInstance("").UpdateParameter("CALCULATION_LATE_FEES_DURING_PUBLIC_HOLIDAYS", true);

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

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

            //30 + 230 + 30 * 0.003 * 42 + 230 * 0.003 *14
            Assert.AreEqual(273.44m, Math.Round(repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2));
            //NOT CALCULATION_LATE_FEES_DURING_PUBLIC_HOLIDAYS
            ApplicationSettings.GetInstance("").UpdateParameter("CALCULATION_LATE_FEES_DURING_PUBLIC_HOLIDAYS", false);

            //30 + 230 + 30 * 0.003 * 36 + 230 * 0.003 *12
            Assert.AreEqual(270.74m, repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value);
        }
Beispiel #8
0
 private static void CheckValueForPackageGracePeriod(LoanProduct pPackage)
 {
     if (!ServicesHelper.CheckMinMaxAndValueCorrectlyFilled(pPackage.GracePeriodMin, pPackage.GracePeriodMax, pPackage.GracePeriod))
     {
         throw new OpenCbsPackageSaveException(OpenCbsPackageSaveExceptionEnum.GracePeriodGroupBadlyInformed);
     }
 }
Beispiel #9
0
 private static void CheckValueForPackageAnticipatedTotalRepaymentPenalties(LoanProduct pPackage)
 {
     if (!ServicesHelper.CheckMinMaxAndValueCorrectlyFilled(pPackage.AnticipatedTotalRepaymentPenaltiesMin, pPackage.AnticipatedTotalRepaymentPenaltiesMax, pPackage.AnticipatedTotalRepaymentPenalties))
     {
         throw new OpenCbsPackageSaveException(OpenCbsPackageSaveExceptionEnum.AnticipatedRepaymentPenaltiesBadlyInformed);
     }
 }
Beispiel #10
0
        public void SetCyclesParamsForContract(LoanProduct product, Loan credit, Client client, bool isContractForCreation)
        {
            if (isContractForCreation)
            {
                if (product.LoanAmountCycleParams == null ||
                    product.RateCycleParams == null ||
                    product.MaturityCycleParams == null)
                {
                    product.LoanAmountCycleParams =
                        ServicesProvider.GetInstance().GetProductServices().GetLoanAmountCycleParameters((int)product.CycleId);
                    product.RateCycleParams =
                        ServicesProvider.GetInstance().GetProductServices().GetInterestRateCycleParams((int)product.CycleId);
                    product.MaturityCycleParams =
                        ServicesProvider.GetInstance().GetProductServices().GetMaturityCycleParams(product.Id, (int)product.CycleId);
                }

                if (product.LoanAmountCycleParams.Count != 0 &&
                    product.RateCycleParams.Count != 0 &&
                    product.MaturityCycleParams.Count != 0)
                {
                    SetLoanAmountCycle(product, client.LoanCycle);
                    SetRateCycle(product, client.LoanCycle);
                    SetMaturityCycle(product, client.LoanCycle);
                }
            }
            else if (credit != null)
            {
                product.AmountMin           = credit.AmountMin;
                product.AmountMax           = credit.AmountMax;
                product.InterestRateMin     = credit.InterestRateMin;
                product.InterestRateMax     = credit.InterestRateMax;
                product.NbOfInstallmentsMin = credit.NmbOfInstallmentsMin;
                product.NbOfInstallmentsMax = credit.NmbOfInstallmentsMax;
            }
        }
Beispiel #11
0
 public LoanProduct FindPackage(int idPackage)
 {
     try
     {
         LoanProduct package = _productManager.Select(idPackage);
         if (package == null)
         {
             return(null);
         }
         if (package.FundingLine != null)
         {
             package.FundingLine = _fundingLineManager.SelectFundingLineById(package.FundingLine.Id, false);
         }
         if (package.CycleId != null)
         {
             package.LoanAmountCycleParams = _productManager.SelectLoanAmountCycleParams((int)package.CycleId);
             package.RateCycleParams       = _productManager.SelectRateCycleParams((int)package.CycleId);
             package.MaturityCycleParams   = _productManager.SelectMaturityCycleParams((int)package.CycleId);
         }
         GetEntryFees(package);
         return(package);
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Beispiel #12
0
 private LoanProduct MapLoanProduct(LoanProductViewModel model, LoanProduct loanProduct)
 {
     loanProduct.Id                = model.LoanProductId;
     loanProduct.MinAmount         = model.MinAmount;
     loanProduct.MaxAmount         = model.MaxAmount;
     loanProduct.Percentage        = model.Percentage;
     loanProduct.MinPeriodInMonth  = model.MinPeriodInMonth;
     loanProduct.MaxPeriodInMonth  = model.MaxPeriodInMonth;
     loanProduct.Name              = model.Name;
     loanProduct.Description       = model.Description;
     loanProduct.Type              = model.Type;
     loanProduct.Status            = LoanProductStatus.Draft;
     loanProduct.FineDayPercentage = model.FineDayPercentage;
     loanProduct.AdvancedRepaymentFirstPossibleMonth = model.AdvancedRepaymentFirstPossibleMonth;
     loanProduct.AdvancedRepaymentFinePercentage     = model.AdvancedRepaymentFinePercentage;
     loanProduct.Requirements.Id = model.Requirements.LoanProductRequirementsId;
     loanProduct.Requirements.MinWorkOnLastJobInMonths = model.Requirements.MinWorkOnLastJobInMonths;
     loanProduct.Requirements.MinSalary          = model.Requirements.MinSalary;
     loanProduct.Requirements.NeedEarningsRecord = model.Requirements.NeedEarningsRecord;
     loanProduct.Requirements.NeedGuarantors     = model.Requirements.NeedGuarantors;
     loanProduct.Requirements.GuarantorsCount    = model.Requirements.GuarantorsCount;
     loanProduct.Requirements.Approvers          =
         this.userService.GetRoles()
         .Where(x => model.Requirements.Approvers.Select(approver => approver.ToString()).Contains(x.Name))
         .ToList();
     return(loanProduct);
 }
        public void DeclineWhenCreditScoreError()
        {
            LoanProduct product     = new LoanProduct(99, "Loan", 5.25m);
            LoanAmount  amount      = new LoanAmount("USD", 200_000);
            var         application = new LoanApplication(42,
                                                          product,
                                                          amount,
                                                          "Sarah",
                                                          25,
                                                          "133 Pluralsight Drive, Draper, Utah",
                                                          65_000);

            var mockIdentityVerifier = new Mock <IIdentityVerifier>();

            mockIdentityVerifier.Setup(x => x.Validate("Sarah",
                                                       25,
                                                       "133 Pluralsight Drive, Draper, Utah"))
            .Returns(true);

            var mockCreditScorer = new Mock <ICreditScorer>();

            mockCreditScorer.Setup(x => x.ScoreResult.ScoreValue.Score).Returns(300);

            mockCreditScorer.Setup(x => x.CalculateScore(It.IsAny <string>(), It.IsAny <string>()))
            .Throws(new InvalidOperationException("Test Exception"));


            var sut = new LoanApplicationProcessor(mockIdentityVerifier.Object,
                                                   mockCreditScorer.Object);

            sut.Process(application);

            Assert.That(application.GetIsAccepted(), Is.False);
        }
        public void CalculateScore()
        {
            LoanProduct product     = new LoanProduct(99, "Loan", 5.25m);
            LoanAmount  amount      = new LoanAmount("USD", 200_000);
            var         application = new LoanApplication(42,
                                                          product,
                                                          amount,
                                                          "Sarah",
                                                          25,
                                                          "133 Pluralsight Drive, Draper, Utah",
                                                          65_000);

            var mockIdentityVerifier = new Mock <IIdentityVerifier>();

            mockIdentityVerifier.Setup(x => x.Validate("Sarah",
                                                       25,
                                                       "133 Pluralsight Drive, Draper, Utah"))
            .Returns(true);



            var mockCreditScorer = new Mock <ICreditScorer>();

            mockCreditScorer.Setup(x => x.ScoreResult.ScoreValue.Score).Returns(300);

            var sut = new LoanApplicationProcessor(mockIdentityVerifier.Object,
                                                   mockCreditScorer.Object);

            sut.Process(application);

            mockCreditScorer.Verify(x => x.CalculateScore(
                                        "Sarah", "133 Pluralsight Drive, Draper, Utah"),
                                    Times.Once);
        }
 public FrmAvalaibleLoanProducts()
 {
     InitializeComponent();
     _package = new LoanProduct();
     InitializePackages();
     webBrowserPackage.ObjectForScripting = this;
 }
Beispiel #16
0
 private static void CheckCumpolsorySavingSettings(LoanProduct pPackage)
 {
     if (!ServicesHelper.CheckMinMaxAndValueCorrectlyFilled(pPackage.CompulsoryAmountMin, pPackage.CompulsoryAmountMax, pPackage.CompulsoryAmount))
     {
         throw new OpenCbsPackageSaveException(OpenCbsPackageSaveExceptionEnum.CompulsorySavingSettingsEmpty);
     }
 }
        public void UpdateProduct_Values_DontUpdateContracts()
        {
            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.EntryFees = new List <EntryFee>();
            EntryFee fee = new EntryFee();

            fee.Value   = 2;
            fee.IsAdded = true;
            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);
        }
Beispiel #18
0
 private static void CheckValueForCreditInsuranceValues(LoanProduct pPackage)
 {
     if (pPackage.CreditInsuranceMin > pPackage.CreditInsuranceMax)
     {
         throw  new OpenCbsPackageSaveException(OpenCbsPackageSaveExceptionEnum.InsuranceBadlyFilled);
     }
 }
        public void Flate_BadLoan_42dayslate_OnOLB_KeepNotExpectedInstallment()
        {
            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);

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

            //30 + 230 + 1000 * 0.003 * 42 = 386
            Assert.AreEqual(386, Math.Round(repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2));
        }
Beispiel #20
0
        private SalaryAdvanceView()
        {
            InitializeComponent();

            if (MainController.LoggedUser.TransactionDate != GlobalSettings.DateOfOpenTransaction)
            {
                MessageWindow.ShowAlertMessage("Cannot create transactions using current date settings.");
                btnDetails.IsEnabled = btnPost.IsEnabled = false;
                return;
            }

            var code = GlobalSettings.CodeOfSalaryAdvance;

            if (string.IsNullOrEmpty(code))
            {
                MessageWindow.ShowAlertMessage("Salary Advance code not set!");
                btnDetails.IsEnabled = btnPost.IsEnabled = false;
                return;
            }

            btnPost.Click    += btnPost_Click;
            btnDetails.Click += btnDetails_Click;

            _loanProduct = LoanProduct.GetList().First(a => a.ProductCode == code);

            // initialize cash voucher entry for salary advance
            _cashVoucher = new CashVoucher
            {
                VoucherNo = Voucher.LastDocumentNo(VoucherTypes.CV) + 1,
            };

            DataContext = _cashVoucher;
        }
        public void Declining_BadLoanWith42dayslateWhenNonRepaymentFeesBaseOnInitialAmountAndKeepExpectedInstallment()
        {
            ApplicationSettings.GetInstance("").UpdateParameter("CALCULATION_LATE_FEES_DURING_PUBLIC_HOLIDAYS", true);
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                LoanType        = OLoanTypes.DecliningFixedInstallments,
                ChargeInterestWithinGracePeriod = true,
                Currency = new Currency {
                    Id = 1, UseCents = true
                },
                RoundingType = ORoundingType.Approximate
            };

            package.KeepExpectedInstallment = true;
            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.InitialAmount = 0.003;
            myContract.AnticipatedTotalRepaymentPenalties  = 0.01;

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

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

            //30 + 218.35 + 1000 * 0.003 * 42
            Assert.AreEqual(374.35m, repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value);
        }
        public bool Remove(int loanProductId)
        {
            LoanProduct entity = this.gangsterBankUnitOfWork.LoanProductsRepository.GetById(loanProductId);

            this.gangsterBankUnitOfWork.LoanProductsRepository.Remove(entity);
            return(true);
        }
        public void DecliningRate_ExoticInstallments_NoGracePeriod_RoundingValue()
        {
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                LoanType        = OLoanTypes.DecliningFixedInstallments,
                ChargeInterestWithinGracePeriod = true,
                ExoticProduct = new ExoticInstallmentsTable
                {
                    new ExoticInstallment(1, 0.1, null),
                    new ExoticInstallment(2, 0.1, null),
                    new ExoticInstallment(3, 0.1, null),
                    new ExoticInstallment(4, 0.1, null),
                    new ExoticInstallment(5, 0.1, null),
                    new ExoticInstallment(6, 0.5, null)
                },
                Currency = new Currency {
                    Id = 1
                }
            };
            Loan myContract = new Loan(package, 950, 0.03m, 6, 0, new DateTime(2006, 1, 1), new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""), ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()));

            _AssertSpecifiedInstallment(myContract.GetInstallment(0), 1, new DateTime(2006, 2, 1), 28, 95, 950);
            _AssertSpecifiedInstallment(myContract.GetInstallment(1), 2, new DateTime(2006, 3, 1), 26, 95, 855);
            _AssertSpecifiedInstallment(myContract.GetInstallment(2), 3, new DateTime(2006, 4, 3), 23, 95, 760);
            _AssertSpecifiedInstallment(myContract.GetInstallment(3), 4, new DateTime(2006, 5, 1), 20, 95, 665);
            _AssertSpecifiedInstallment(myContract.GetInstallment(4), 5, new DateTime(2006, 6, 1), 17, 95, 570);
            _AssertSpecifiedInstallment(myContract.GetInstallment(5), 6, new DateTime(2006, 7, 3), 14, 475, 475);
        }
 public void ChangeLoanProductStatus(LoanProduct loanProduct, LoanProductStatus newStatus)
 {
     Contract.Requires <ArgumentNullException>(loanProduct.IsNotNull());
     this.VerifyLoanProductCreationWorkflow(loanProduct, newStatus);
     loanProduct.Status = newStatus;
     this.gangsterBankUnitOfWork.LoanProductsRepository.CreateOrUpdate(loanProduct);
 }
        public void AddContractRuleForLoanProduct()
        {
            Account        genericAccount  = _accountManager.Select(1);
            Account        specificAccount = _accountManager.Select(2);
            LoanProduct    loanProduct     = _loanProductManager.Select(1);
            EventType      eventType       = _eventManager.SelectEventTypeByEventType("RGLE");
            EventAttribute eventAttribute  = _eventManager.SelectEventAttributeByCode("principal");

            ContractAccountingRule rule = new ContractAccountingRule
            {
                DebitAccount     = genericAccount,
                CreditAccount    = specificAccount,
                ProductType      = OProductTypes.Loan,
                LoanProduct      = loanProduct,
                ClientType       = OClientTypes.Corporate,
                BookingDirection = OBookingDirections.Credit,
                EventAttribute   = eventAttribute,
                EventType        = eventType
            };

            rule.Id = _accountingRuleManager.AddAccountingRule(rule);
            Assert.AreNotEqual(0, rule.Id);

            ContractAccountingRule retrievedRule = _accountingRuleManager.Select(rule.Id) as ContractAccountingRule;

            _compareRules(rule, retrievedRule);
        }
        public void ChangeLoanProductStatus(int loanProductId, LoanProductStatus status)
        {
            Contract.Requires <ArgumentOutOfRangeException>(loanProductId.IsPositive());
            LoanProduct loanProduct = this.gangsterBankUnitOfWork.LoanProductsRepository.GetById(loanProductId);

            this.ChangeLoanProductStatus(loanProduct, status);
        }
        public void TestCalculateMaximumAmountWithDecliningBadLoanWith42dayslateWhenNonRepaymentFeesBaseOnOverDueWithInterestAndKeepNotExpectedInstallment()
        {
            LoanProduct package = new LoanProduct
            {
                InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                LoanType        = OLoanTypes.DecliningFixedInstallments,
                ChargeInterestWithinGracePeriod = true,
                Currency = new Currency {
                    Id = 1
                },
                RoundingType = ORoundingType.Approximate
            };

            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.OverDueInterest  = 0.003;
            myContract.NonRepaymentPenalties.OverDuePrincipal = 0.003;
            myContract.AnticipatedTotalRepaymentPenalties     = 0.01;

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

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

            //30 + 218.35 + 30 * 0.003 * 42 + 218.35 * 0.003 * 14 = 30 + 218 + 4 + 9 = 261
            Assert.AreEqual(261, Math.Round(repayStrategy.CalculateMaximumAmountToRegradingLoan(new DateTime(2006, 3, 15)).Value, 2));
        }
 public bool CreateLoanProduct(LoanProduct loanProduct)
 {
     loanProduct.Status = LoanProductStatus.Draft;
     this.gangsterBankUnitOfWork.LoanProductsRepository.CreateOrUpdate(loanProduct);
     //this.gangsterBankUnitOfWork.LoanProductsRequirmentsRepository.CreateOrUpdate(loanProduct.Requirements);
     return(true);
 }
Beispiel #29
0
        public void Add()
        {
            const string title       = "Add new Loan Product";
            const string message     = "Please enter a description";
            var          inputWindow = new InputWindow(message, title);

            if (inputWindow.ShowDialog() == true)
            {
                var input = inputWindow.InputText;
                if (string.IsNullOrEmpty(input))
                {
                    MessageWindow.ShowAlertMessage("Please specify a Loan Product Name");
                    return;
                }
                var newLoanProduct = LoanProduct.WhereTitleIs(input);
                if (newLoanProduct != null)
                {
                    MessageWindow.ShowAlertMessage(input + "already exists");
                    return;
                }

                var editView = new EditLoanProductView(input);
                if (editView.ShowDialog() == true)
                {
                    newLoanProduct = new LoanProduct();
                    newLoanProduct.Find(editView.CurrentItem.ID);
                    _lookup.Add(newLoanProduct);
                    _viewModel.Collection.Add(newLoanProduct);
                }
            }
        }
Beispiel #30
0
        private static Loan _SetContract(OLoanTypes pLoansType, NonRepaymentPenalties pNonRepaymentPenalties,
                                         bool pKeepExpectedInstallment)
        {
            var 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;

            var 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);
        }