Ejemplo n.º 1
0
 private void ReschedulingOfALoanOrigination(RescheduleLoanEvent rescheduleLoanEvent, Loan pContract, SqlTransaction sqlTransac)
 {
     _eventManagement.AddLoanEvent(rescheduleLoanEvent, pContract.Id, sqlTransac);
 }
Ejemplo n.º 2
0
 private static void _AssertReschedulingLoanEvent(RescheduleLoanEvent pEvent, DateTime pDate, OCurrency pAmount, int pNbOfMaturity, int dateOffset)
 {
     Assert.AreEqual("ROLE", pEvent.Code);
     Assert.AreEqual(pDate, pEvent.Date);
     Assert.AreEqual(pAmount.Value, pEvent.Amount.Value);
     Assert.AreEqual(pNbOfMaturity, pEvent.NbOfMaturity);
 }
Ejemplo n.º 3
0
        public Loan Reschedule(Loan loan, IClient client, ScheduleConfiguration rescheduleConfiguration)
        {
            using (var connection = _loanManager.GetConnection())
            using (var transaction = connection.BeginTransaction())
            {
                try
                {
                    var copyOfLoan = SimulateRescheduling(loan, rescheduleConfiguration);
                    var rescheduleLoanEvent = new RescheduleLoanEvent
                        {
                            Amount = copyOfLoan.CalculateActualOlb(),
                            Date = rescheduleConfiguration.StartDate,
                            ClientType = client.Type,
                            Interest = rescheduleConfiguration.InterestRate,
                            BadLoan = loan.BadLoan,
                            NbOfMaturity = rescheduleConfiguration.NumberOfInstallments,
                            GracePeriod = rescheduleConfiguration.GracePeriod,
                            ChargeInterestDuringGracePeriod = rescheduleConfiguration.ChargeInterestDuringGracePeriod,
                            InstallmentNumber =
                                copyOfLoan.GetLastFullyRepaidInstallment() == null
                                    ? 1
                                    : copyOfLoan.GetLastFullyRepaidInstallment().Number + 1,
                            PreferredFirstInstallmentDate = rescheduleConfiguration.PreferredFirstInstallmentDate,
                            User = _user,
                            PreviousInterestRate = rescheduleConfiguration.PreviousInterestRate,
                        };

                    //insert into table TrancheEvent
                    _ePs.FireEvent(rescheduleLoanEvent, copyOfLoan, transaction);

                    ArchiveInstallments(loan, rescheduleLoanEvent, transaction);

                    //delete all the old installments of the table Installments
                    _instalmentManager.DeleteInstallments(loan.Id, transaction);

                    //insert all the new installments in the table Installments
                    _instalmentManager.AddInstallments(copyOfLoan.InstallmentList, copyOfLoan.Id, transaction);

                    copyOfLoan.Events.Add(rescheduleLoanEvent);
                    transaction.Commit();

                    SetClientStatus(copyOfLoan, client);
                    return copyOfLoan;
                }
                catch
                {
                    transaction.Rollback();
                    throw;
                }
            }
        }
Ejemplo n.º 4
0
        public void Add_ReschedulingLoanEvent()
        {
            EventManager eventManager = (EventManager)container["EventManager"];

            RescheduleLoanEvent rescheduleLoanEvent = new RescheduleLoanEvent
                                               {
                                                   Id = 14,
                                                   User = new User { Id = 1 },
                                                   Date = new DateTime(2006, 7, 21),
                                                   PreferredFirstInstallmentDate = new DateTime(2006, 8, 21),
                                                   Amount = 2345,
                                                   NbOfMaturity = 4,
                                                   Interest = 100,
                                                   PreviousInterestRate = 0
                                               };
            eventManager.AddLoanEvent(rescheduleLoanEvent, 1);
            Assert.AreNotEqual(0, rescheduleLoanEvent.Id);
        }
Ejemplo n.º 5
0
        public void Select_Added_ReschedulingLoanEvent()
        {
            EventManager eventManager = (EventManager)container["EventManager"];

            RescheduleLoanEvent rescheduleLoanEvent = new RescheduleLoanEvent
            {
                Id = 14,
                User = new User { Id = 1 },
                Date = new DateTime(2006, 7, 21),
                PreferredFirstInstallmentDate = new DateTime(2006, 8, 21),
                Amount = 2345,
                NbOfMaturity = 4,
                Interest = 100,
                PreviousInterestRate = 0
            };
            eventManager.AddLoanEvent(rescheduleLoanEvent, 1);

            EventStock eventStock = eventManager.SelectEvents(2);
            foreach (Event e in eventStock.GetEvents())
            {
                if (e is RescheduleLoanEvent)
                    _AssertReschedulingLoanEvent(e as RescheduleLoanEvent, new DateTime(2006, 7, 21), 2345, 3, 4);
            }
        }
Ejemplo n.º 6
0
        public void AddLoanEvent(RescheduleLoanEvent rescheduleLoanEvent, int contractId, SqlTransaction sqlTransac)
        {
            rescheduleLoanEvent.Id = AddLoanEventHead(rescheduleLoanEvent, contractId, sqlTransac);

            const string q = @"INSERT INTO [ReschedulingOfALoanEvents]
                                    ([id], [amount], [nb_of_maturity], [date_offset], [interest], [grace_period], [charge_interest_during_shift], [charge_interest_during_grace_period])
                                    VALUES(@id, @amount, @maturity,@dateOffset, @interest, @gracePeriod, @chargeInterestDuringShift, @chargeInterestDuringGracePeriod)";

            using(OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac))
            {
                SetLoanReschedulingEvent(rescheduleLoanEvent, c);
                c.ExecuteNonQuery();
            }
        }
Ejemplo n.º 7
0
        public RescheduleLoanEvent Reschedule(ReschedulingOptions ro, Loan contract, NonWorkingDateSingleton nwdS, ApplicationSettings applicationSettings)
        {
            _contract = contract;
            _nwdS = nwdS;
            _generalSettings = applicationSettings;

            switch (contract.Product.LoanType)
            {
                case OLoanTypes.Flat:
                    _Reschedule_Flat(ro);
                    break;

                case OLoanTypes.DecliningFixedPrincipal:
                    _Reschedule_FixedPrincipal(ro);
                    break;

                case OLoanTypes.DecliningFixedInstallments:
                    _Reschedule_DecliningFixedInstallments(ro);
                    break;
            }

            _Reschedule_AdjustOverpaid();

            RescheduleLoanEvent rSe = new RescheduleLoanEvent
                                          {
                                              Date = ro.ReschedulingDate,
                                              Amount = contract.CalculateActualOlb(),
                                              Interest = contract.GetTotalInterestDue(),
                                              ClientType = contract.ClientType,
                                              BadLoan = contract.BadLoan,
                                              NbOfMaturity = ro.NewInstallments,
                                              DateOffset = ro.RepaymentDateOffset,
                                              GracePeriod = ro.GracePeriod,
                                              ChargeInterestDuringShift = ro.ChargeInterestDuringShift,
                                              ChargeInterestDuringGracePeriod = ro.ChargeInterestDuringGracePeriod,
                                              InstallmentNumber =
                                                  contract.GetLastFullyRepaidInstallment() == null
                                                      ? 1
                                                      : contract.GetLastFullyRepaidInstallment().Number + 1
                                          };
            _contract.CalculateStartDates();
            return rSe;
        }
Ejemplo n.º 8
0
 private static void SetLoanReschedulingEvent(RescheduleLoanEvent pEvent, OpenCbsCommand c)
 {
     c.AddParam("@id", pEvent.Id);
     c.AddParam("@amount", pEvent.Amount);
     c.AddParam("@maturity", pEvent.NbOfMaturity);
     c.AddParam("@dateOffset", pEvent.DateOffset);
     c.AddParam("@interest", pEvent.Interest);
     c.AddParam("@gracePeriod", pEvent.GracePeriod);
     c.AddParam("@chargeInterestDuringShift", pEvent.ChargeInterestDuringShift);
     c.AddParam("@chargeInterestDuringGracePeriod", pEvent.ChargeInterestDuringGracePeriod);
 }
Ejemplo n.º 9
0
 public void AddLoanEvent(RescheduleLoanEvent rescheduleLoanEvent, int contractId)
 {
     using (SqlConnection connection = GetConnection())
     using (SqlTransaction transaction = connection.BeginTransaction())
     {
         try
         {
             AddLoanEvent(rescheduleLoanEvent, contractId, transaction);
             transaction.Commit();
         }
         catch (Exception)
         {
             transaction.Rollback();
             throw;
         }
     }
 }
Ejemplo n.º 10
0
 public void TestReschedulingOfALoanEventAmount()
 {
     RescheduleLoanEvent rSLE = new RescheduleLoanEvent();
     rSLE.Amount = 32.45m;
     Assert.AreEqual(32.45m,rSLE.Amount.Value);
 }
Ejemplo n.º 11
0
 public void TestReschedulingOfALoanEventBadLoanBoolean()
 {
     RescheduleLoanEvent rSE = new RescheduleLoanEvent {BadLoan = true};
     Assert.IsTrue(rSE.BadLoan);
 }
Ejemplo n.º 12
0
 public void TestIfReschedulingOfALoanCodeCorrectlySetAndRetrieved()
 {
     RescheduleLoanEvent rOLE = new RescheduleLoanEvent();
     Assert.AreEqual("ROLE",rOLE.Code);
 }
Ejemplo n.º 13
0
        private static OCurrency GetValue(RescheduleLoanEvent eventItem, ContractAccountingRule rule)
        {
            OCurrency amount = 0;

            if (rule.EventAttribute.Name.ToLower() == "amount")
            {
                amount = eventItem.Amount;
            }

            if (rule.EventAttribute.Name.ToLower() == "interest")
            {
                amount = eventItem.Interest;
            }
            return amount;
        }
Ejemplo n.º 14
0
        public void AddLoanEvent(RescheduleLoanEvent rescheduleLoanEvent, int contractId, SqlTransaction transaction)
        {
            rescheduleLoanEvent.Id = AddLoanEventHead(rescheduleLoanEvent, contractId, transaction);

            const string q = @"
                INSERT INTO [ReschedulingOfALoanEvents]
                (
                    [id],
                    [amount],
                    [nb_of_maturity],
                    [interest],
                    [previous_interest_rate],
                    [grace_period],
                    [charge_interest_during_grace_period],
                    [preferred_first_installment_date]
                )
                VALUES
                (
                    @id,
                    @amount,
                    @maturity,
                    @interest,
                    @previous_interest_rate,
                    @gracePeriod,
                    @chargeInterestDuringGracePeriod,
                    @preferredFirstInstallmentDate
                )
            ";

            using(OpenCbsCommand c = new OpenCbsCommand(q, transaction.Connection, transaction))
            {
                SetLoanReschedulingEvent(rescheduleLoanEvent, c);
                c.ExecuteNonQuery();
            }
        }
Ejemplo n.º 15
0
 private static void SetLoanReschedulingEvent(RescheduleLoanEvent pEvent, OpenCbsCommand c)
 {
     c.AddParam("@id", pEvent.Id);
     c.AddParam("@amount", pEvent.Amount);
     c.AddParam("@maturity", pEvent.NbOfMaturity);
     c.AddParam("@interest", pEvent.Interest);
     c.AddParam("@previous_interest_rate", pEvent.PreviousInterestRate);
     c.AddParam("@gracePeriod", pEvent.GracePeriod);
     c.AddParam("@chargeInterestDuringGracePeriod", pEvent.ChargeInterestDuringGracePeriod);
     c.AddParam("@preferredFirstInstallmentDate", pEvent.PreferredFirstInstallmentDate);
 }
Ejemplo n.º 16
0
        public void Add_ReschedulingLoanEvent()
        {
            EventManager eventManager = (EventManager)container["EventManager"];

            RescheduleLoanEvent rescheduleLoanEvent = new RescheduleLoanEvent
                                               {
                                                   Id = 14,
                                                   User = new User { Id = 1 },
                                                   Date = new DateTime(2006, 7, 21),
                                                   Amount = 2345,
                                                   NbOfMaturity = 4,
                                                   DateOffset = 0,
                                                   Interest = 100
                                               };
            eventManager.AddLoanEvent(rescheduleLoanEvent, 1);
            Assert.AreNotEqual(0, rescheduleLoanEvent.Id);
        }