예제 #1
0
 private static void _AssertWriteOffEvent(WriteOffEvent pEvent, DateTime pDate, OCurrency pOLB, OCurrency pAccruedInterests, OCurrency pAccruedPenalties,
     int pPastDueDays)
 {
     Assert.AreEqual("WROE", pEvent.Code);
     Assert.AreEqual(pDate, pEvent.Date);
     Assert.AreEqual(pPastDueDays, pEvent.PastDueDays);
     Assert.AreEqual(pOLB.Value, pEvent.OLB.Value);
     Assert.AreEqual(pAccruedInterests.Value, pEvent.AccruedInterests.Value);
     Assert.AreEqual(pAccruedPenalties.Value, pEvent.AccruedPenalties.Value);
 }
예제 #2
0
 private void WriteOffOrigination(WriteOffEvent writeOffEvent, Loan loanContract, SqlTransaction sqlTransac)
 {
     _eventManagement.AddLoanEvent(writeOffEvent, loanContract.Id, sqlTransac);
 }
예제 #3
0
        public void Add_WriteOffEvent()
        {
            EventManager eventManager = (EventManager)container["EventManager"];

            WriteOffEvent writeOffEvent = new WriteOffEvent
            {
                Id = 15,
                User = new User { Id = 1 },
                Date = new DateTime(2006, 7, 21),
                OLB = 34,
                AccruedInterests = 355,
                AccruedPenalties = 433,
                PastDueDays = 3,
                OverduePrincipal = 0
            };

            eventManager.AddLoanEvent(writeOffEvent, 1);
            Assert.AreNotEqual(0, writeOffEvent.Id);
        }
예제 #4
0
        public void Select_Added_WriteOffEvent()
        {
            EventManager eventManager = (EventManager)container["EventManager"];

            WriteOffEvent writeOffEvent = new WriteOffEvent
            {
                Id = 15,
                User = new User { Id = 1 },
                Date = new DateTime(2006, 7, 21),
                OLB = 34,
                AccruedInterests = 355,
                AccruedPenalties = 433,
                PastDueDays = 3,
                OverduePrincipal = 0
            };

            eventManager.AddLoanEvent(writeOffEvent, 1);

            EventStock eventStock = eventManager.SelectEvents(2);
            foreach (Event e in eventStock.GetEvents())
            {
                if (e is WriteOffEvent)
                    _AssertWriteOffEvent(e as WriteOffEvent, new DateTime(2006, 7, 21), 34, 355, 433, 3);
            }
        }
예제 #5
0
        public void AddLoanEvent(WriteOffEvent writeOffEvent, int contractId, SqlTransaction sqlTransac)
        {
            writeOffEvent.Id = AddLoanEventHead(writeOffEvent, contractId, sqlTransac);

            const string q = @"INSERT INTO [WriteOffEvents]
                                       ([id],
                                        [olb],
                                        [accrued_interests],
                                        [accrued_penalties],
                                        [past_due_days],
                                        [overdue_principal])
                                     VALUES(@id, @olb, @accruedInterests, @accruedPenalties, @pastDueDays, @overdue_principal)
                                    SELECT SCOPE_IDENTITY()";

            using(OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac))
            {
                SetLoanWriteOffEvent(writeOffEvent, c);
                c.ExecuteNonQuery();
            }
        }
예제 #6
0
파일: Loan.cs 프로젝트: TalasZh/opencbs
 /// <summary>
 /// This method sets contract to write off. The loan is definitely considered to loss when the loan is bad for more
 /// than 1 year.
 /// </summary>
 /// <param name="onDate"></param>
 /// <returns>A WriteOffEvent or null if :
 /// - past due days is lower than 365 days
 /// - no PastDueLoanEvent with past due days greater than 180 days were fired before
 /// - loan has already been degraded to loan loss
 /// </returns>
 public WriteOffEvent WriteOff(DateTime onDate)
 {
     if (!_writtenOff)
     {
         _writtenOff = true;
         ContractStatus = OContractStatus.WrittenOff;
         WriteOffEvent wOe = new WriteOffEvent
         {
             Date = onDate,
             ClientType = _clientType,
             OLB = CalculateActualOlb(),
             PastDueDays = _CalculatePastDue(onDate),
             AccruedInterests = GetUnpaidInterest(onDate),
             AccruedPenalties = GetUnpaidLatePenalties(onDate),
             OverduePrincipal = CalculateOverduePrincipal(onDate),
             IsFired = false,
             Cancelable = true,
             InstallmentNumber = GetLastNumberOfInstallments()
         };
         Events.Add(wOe);
         CreditInsuranceEvent lciw = GenerateCreditInsuranceEventForWriteOff(onDate);
         if (lciw!=null)
             Events.Add(lciw);
         return wOe;
     }
     return null;
 }
예제 #7
0
 private static void SetLoanWriteOffEvent(WriteOffEvent pEvent, OpenCbsCommand c)
 {
     c.AddParam("@id", pEvent.Id);
     c.AddParam("@olb", pEvent.OLB);
     c.AddParam("@accruedInterests", pEvent.AccruedInterests);
     c.AddParam("@accruedPenalties", pEvent.AccruedPenalties);
     c.AddParam("@pastDueDays", pEvent.PastDueDays);
     c.AddParam("@overdue_principal", pEvent.OverduePrincipal);
 }
예제 #8
0
 public void AddLoanEvent(WriteOffEvent writeOffEvent, int contractId)
 {
     using (SqlConnection connection = GetConnection())
     using (SqlTransaction transaction = connection.BeginTransaction())
     {
         try
         {
             AddLoanEvent(writeOffEvent, contractId, transaction);
             transaction.Commit();
         }
         catch (Exception)
         {
             transaction.Rollback();
             throw;
         }
     }
 }
예제 #9
0
 public void TestWriteOffEventOutstandingAmount()
 {
     WriteOffEvent wROE = new WriteOffEvent();
     wROE.OLB = 3456.1m;
     Assert.AreEqual(3456.1m,wROE.OLB.Value);
 }
예제 #10
0
 public void TestWriteOffEventAccruedPenalties()
 {
     WriteOffEvent wROE = new WriteOffEvent();
     wROE.AccruedPenalties = 3456.1m;
     Assert.AreEqual(3456.1m,wROE.AccruedPenalties.Value);
 }
예제 #11
0
 public void TestWriteOffEventAccruedInterests()
 {
     WriteOffEvent wROE = new WriteOffEvent();
     wROE.AccruedInterests = 3456.1m;
     Assert.AreEqual(3456.1m,wROE.AccruedInterests.Value);
 }
예제 #12
0
 public void TestIfWriteOffEventCodeCorrectlySetAndRetrieved()
 {
     WriteOffEvent wROE = new WriteOffEvent();
     Assert.AreEqual("WROE",wROE.Code);
 }
예제 #13
0
        private static OCurrency GetValue(WriteOffEvent eventItem, ContractAccountingRule rule)
        {
            OCurrency amount = 0;

            switch (rule.EventAttribute.Name.ToLower())
            {
                case "olb":
                    amount = eventItem.OLB;
                    break;
                case "accrued_interests":
                    amount = eventItem.AccruedInterests;
                    break;
                case "accrued_penalties":
                    amount = eventItem.AccruedPenalties;
                    break;
                case "past_due_days":
                    amount = eventItem.PastDueDays;
                    break;
                case "overdue_principal":
                    amount = eventItem.OverduePrincipal;
                    break;
            }
            return amount;
        }