Example #1
0
        public RepaymentEvent CopyAsRepaymentEvent()
        {
            RepaymentEvent rPe;

            if (Code == "PRLR")
                rPe = new RescheduledLoanRepaymentEvent();
            else if (Code == "PBLR")
                rPe = new BadLoanRepaymentEvent();
            else if (Code == "PRWO")
                rPe = new RepaymentOverWriteOffEvent();
            else
                rPe = new RepaymentEvent();

            rPe.AccruedInterest = this.AccruedInterest;
            rPe.Cancelable = this.Cancelable;
            rPe.ClientType = this.ClientType;
            rPe.Commissions = this.Commissions;
            rPe.Date = this.Date;
            rPe.InstallmentNumber = this.InstallmentNumber;
            rPe.InterestPrepayment = this.InterestPrepayment;
            rPe.Interests = this.Interests;
            rPe.PastDueDays = this.PastDueDays;
            rPe.Penalties = this.Penalties;
            rPe.Principal = this.Principal;
            rPe.RepaymentType = this.RepaymentType;

            return rPe;
        }
 public void TestCopyBadLoanRepaymentEvent()
 {
     BadLoanRepaymentEvent BLDE = new BadLoanRepaymentEvent{InstallmentNumber = 1,Principal = 100.34m,Interests = 100,Commissions = 200.34m,Penalties = 0,AccruedProvision = 294.34m,ClientType = OClientTypes.Group};
     BadLoanRepaymentEvent BLDECopy = BLDE.Copy() as BadLoanRepaymentEvent;
     Assert.AreEqual(BLDE.AccruedProvision.Value, BLDECopy.AccruedProvision.Value);
     Assert.AreEqual(BLDE.Code, BLDECopy.Code);
     Assert.AreEqual(BLDE.Fees.Value, BLDECopy.Fees.Value);
     Assert.AreEqual(BLDE.Id, BLDECopy.Id);
     Assert.AreEqual(BLDE.InstallmentNumber, BLDECopy.InstallmentNumber);
     Assert.AreEqual(BLDE.Interests.Value, BLDECopy.Interests.Value);
     if(BLDE.OLB.HasValue)
         Assert.AreEqual(BLDE.OLB.Value, BLDECopy.OLB.Value);
     if(BLDE.Principal.HasValue)
     Assert.AreEqual(BLDE.Principal.Value, BLDECopy.Principal.Value);
 }
Example #3
0
        public RepaymentEvent CopyAsRepaymentEvent()
        {
            RepaymentEvent rPe;

            if (Code == "PRLR")
            {
                rPe = new RescheduledLoanRepaymentEvent();
            }
            else if (Code == "PBLR")
            {
                rPe = new BadLoanRepaymentEvent();
            }
            else if (Code == "PRWO")
            {
                rPe = new RepaymentOverWriteOffEvent();
            }
            else
            {
                rPe = new RepaymentEvent();
            }

            rPe.AccruedInterest    = this.AccruedInterest;
            rPe.Cancelable         = this.Cancelable;
            rPe.ClientType         = this.ClientType;
            rPe.Commissions        = this.Commissions;
            rPe.Date               = this.Date;
            rPe.InstallmentNumber  = this.InstallmentNumber;
            rPe.InterestPrepayment = this.InterestPrepayment;
            rPe.Interests          = this.Interests;
            rPe.PastDueDays        = this.PastDueDays;
            rPe.Penalties          = this.Penalties;
            rPe.Principal          = this.Principal;
            rPe.RepaymentType      = this.RepaymentType;

            return(rPe);
        }
Example #4
0
 private static void _AssertBadLoanRepaymentEvent(BadLoanRepaymentEvent pEvent, DateTime pDate, int pPastDueDays, OCurrency pPrincipal,
                                                  OCurrency pInterest, OCurrency pFees, int pInstallmentNumber)
 {
     _AssertRepaymentEvent(pEvent, "RBLE", pDate, pPastDueDays, pPrincipal, pInterest, pFees, pInstallmentNumber);
 }
Example #5
0
        private RepaymentEvent CreateRepaymentEvent(int installmentNumber, 
                                                    DateTime pDate, 
                                                    OCurrency penaltiesEvent, 
                                                    OCurrency commissionsEvent,
                                                    OCurrency interestEvent, 
                                                    OCurrency interestPrepayment, 
                                                    OCurrency pincipalEvent, 
                                                    int overDueDays,
                                                    bool isGroup, 
                                                    OPaymentType repaymentType, 
                                                    bool pending)
        {
            //We need to generate specific RepaymentEvent in case of bad loan or rescheduled loan
            RepaymentEvent rPe = !_badLoan && Rescheduled && !_writtenOff
                                     ? new RescheduledLoanRepaymentEvent()
                                     : (_badLoan && !_writtenOff
                                        ? new BadLoanRepaymentEvent()
                                            : (_writtenOff ?
                                                new RepaymentOverWriteOffEvent()
                                                : new RepaymentEvent()));

            if ((overDueDays > 0 || penaltiesEvent > 0) && !_writtenOff)
                rPe = new BadLoanRepaymentEvent();
            penaltiesEvent = penaltiesEvent > 0 ? penaltiesEvent : (-1.0)*penaltiesEvent;
            //identification of pending event must be the last action
            if (pending) rPe = new PendingRepaymentEvent(rPe);

            rPe.PastDueDays = overDueDays;
            rPe.InstallmentNumber = installmentNumber;
            rPe.Date = pDate;
            rPe.Penalties = penaltiesEvent;
            rPe.Commissions = commissionsEvent;
            rPe.Interests = interestEvent;

            if (_product.LoanType == OLoanTypes.DecliningFixedPrincipalWithRealInterest
                && repaymentType == OPaymentType.TotalPayment)
            {
                repaymentType = OPaymentType.TotalPayment;
            }
            else
            {
                if (InstallmentList[installmentNumber - 1].ExpectedDate <= pDate)
                {
                    repaymentType = OPaymentType.StandardPayment;
                }
            }

            rPe.RepaymentType = repaymentType;

            if(EscapedMember != null)
            {
                rPe.RepaymentType = OPaymentType.PersonTotalPayment;
            }

            rPe.InterestPrepayment = interestPrepayment;
            rPe.Principal = pincipalEvent;
            rPe.Cancelable = true;
            rPe.ClientType = isGroup ? OClientTypes.Group : OClientTypes.Person;

            // Test if the client has repaid the total principal, interests and penalties owed at date D
            //	In this case, the loan will be regraded to good loan and provision will be cancelled.
            if (_badLoan && !pending)
                _badLoan = _IsBadLoan(rPe, pDate);

            return rPe;
        }
Example #6
0
        private RepaymentEvent GetRepaymentEvent(OpenCbsReader r)
        {
            RepaymentEvent e = new RepaymentEvent {Id = r.GetInt("rpe_id")};
            switch (r.GetString("event_type"))
            {
                case "RBLE":
                    {
                        e = new BadLoanRepaymentEvent {Id = r.GetInt("rpe_id")};
                        break;
                    }
                case "RRLE":
                    {
                        e = new RescheduledLoanRepaymentEvent {Id = r.GetInt("rpe_id")};
                        break;
                    }
                case "ROWO":
                    {
                        e = new RepaymentOverWriteOffEvent { Id = r.GetInt("rpe_id") };
                        break;
                    }
                case "PRLR":
                    {
                        e = new PendingRepaymentEvent(r.GetString("event_type"))
                                {Id = r.GetInt("rpe_id")};
                        break;
                    }
                case "PBLR":
                    {
                        e = new PendingRepaymentEvent(r.GetString("event_type"))
                                {Id = r.GetInt("rpe_id")};
                        break;
                    }
                case "PRWO":
                    {
                        e = new PendingRepaymentEvent(r.GetString("event_type"))
                                {Id = r.GetInt("rpe_id")};
                        break;
                    }
                case "PERE":
                    {
                        e = new PendingRepaymentEvent(r.GetString("event_type"))
                                {Id = r.GetInt("rpe_id")};
                        break;
                    }
            }

            e.Principal = r.GetMoney("rpe_principal");
            e.Interests = r.GetMoney("rpe_interests");
            e.Penalties = r.GetMoney("rpe_penalties");
            e.Commissions = r.GetMoney("rpe_commissions");
            e.PastDueDays = r.GetInt("rpe_past_due_days");
            e.InstallmentNumber = r.GetInt("rpe_installment_number");
            e.PaymentMethodId = r.GetNullInt("rpe_pm");
            e.PaymentMethod = e.PaymentMethodId == null ? null :
                _paymentMethodManager.SelectPaymentMethodById(e.PaymentMethodId.Value);

            e.CalculatedPenalties = r.GetMoney("rpe_calculated_penalties");
            e.WrittenOffPenalties = r.GetMoney("rpe_written_off_penalties");
            e.UnpaidPenalties = r.GetMoney("rpe_unpaid_penalties");

            e.Code = r.GetString("event_type");

            if (e.Code != "RBLE")
                e.RepaymentType = OPaymentType.StandardPayment;

            // set type of payment
            switch (r.GetString("event_type").Trim())
            {
                case "ATR":
                    {
                        e.RepaymentType = OPaymentType.TotalPayment;
                        break;
                    }
                case "APR":
                    {
                        e.RepaymentType = OPaymentType.PartialPayment;
                        break;
                    }
                case "APTR":
                    {
                        e.RepaymentType = OPaymentType.PersonTotalPayment;
                        break;
                    }
            }

            return e;
        }
Example #7
0
 public void TestBadLoanRepaymentEventAccruedProvision()
 {
     BadLoanRepaymentEvent bRE = new BadLoanRepaymentEvent{Interests = 100,AccruedProvision = 23};
     Assert.AreEqual(100m,bRE.Interests.Value);
     Assert.AreEqual(23m,bRE.AccruedProvision.Value);
 }
Example #8
0
 public void TestRepaymentEventCodeCorrectlyGeneratedWhenBadLoanAndRescheduled()
 {
     BadLoanRepaymentEvent bRE = new BadLoanRepaymentEvent();
     Assert.AreEqual("RBLE",bRE.Code);
 }
 public void TestOLBCorrectlyGetAndRetrieved()
 {
     BadLoanRepaymentEvent BLDE = new BadLoanRepaymentEvent();
     BLDE.OLB = 100.367m;
     Assert.AreEqual(100.367m, BLDE.OLB.Value);
 }
 public void TestCodeCorrectlyGetAndRetrieved()
 {
     BadLoanRepaymentEvent BLDE = new BadLoanRepaymentEvent();
     Assert.AreEqual("RBLE", BLDE.Code);
 }
 public void TestCancelableCorrectlySetAndRetrieved()
 {
     BadLoanRepaymentEvent BLDE = new BadLoanRepaymentEvent();
     BLDE.Cancelable = true;
     Assert.IsTrue(BLDE.Cancelable);
 }
 public void TestAccruedProvisionCorrectlyGetAndRetrieved()
 {
     BadLoanRepaymentEvent BLDE = new BadLoanRepaymentEvent();
     BLDE.AccruedProvision = 100.367m;
     Assert.AreEqual(100.367m, BLDE.AccruedProvision.Value);
 }