Esempio n. 1
0
 private void ProvisionEventOrigination(ProvisionEvent provisionEvent, Loan loanContract, SqlTransaction sqlTransac)
 {
     _eventManagement.AddLoanEvent(provisionEvent, loanContract.Id, sqlTransac);
 }
Esempio n. 2
0
        public Loan AddProvisionEvent(Loan loan, ProvisionEvent provisionEvent)
        {
            using (SqlConnection conn = _savingEventManager.GetConnection())
            using (SqlTransaction sqlTransaction = conn.BeginTransaction())
            {
                try
                {
                    //insert into table ProvisionEvent
                    _ePs.FireEvent(provisionEvent, loan, sqlTransaction);

                    //loan.Events.Add(provisionEvent);
                    sqlTransaction.Commit();

                    return loan;
                }
                catch (Exception ex)
                {
                    if (sqlTransaction != null)
                        sqlTransaction.Rollback();

                    throw ex;
                }
            }
        }
Esempio n. 3
0
        public void AddLoanEvent(ProvisionEvent provisionEvent, int contractId, SqlTransaction sqlTransac)
        {
            provisionEvent.Id = AddLoanEventHead(provisionEvent, contractId, sqlTransac);

            const string q = @"INSERT INTO [ProvisionEvents](
                                       id,
                                       amount,
                                       rate,
                                       overdue_days)
                                     VALUES(@id, @amount, @rate, @overdue_days)";

            using (OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac))
            {
                c.AddParam("@id", provisionEvent.Id);
                c.AddParam("@amount", provisionEvent.Amount);
                c.AddParam("@rate", provisionEvent.Rate);
                c.AddParam("@overdue_days", provisionEvent.OverdueDays);
                c.ExecuteNonQuery();
            }
        }
Esempio n. 4
0
        public ProvisionEvent GetProvisionEvent(DateTime dateTime, ProvisionTable provisionTable)
        {
            int lateDays = CalculatePastDueSinceLastRepayment(dateTime);
            OCurrency rate = 0;

            foreach (ProvisioningRate provisioningRate in provisionTable.ProvisioningRates)
            {
                if(lateDays >= provisioningRate.NbOfDaysMin && lateDays <= provisioningRate.NbOfDaysMax)
                {
                    rate = (decimal)provisioningRate.Rate;
                }

                if(Rescheduled && provisioningRate.NbOfDaysMin  < 0 && provisioningRate.NbOfDaysMax < 0)
                {
                    rate = (decimal)provisioningRate.Rate;
                }
            }

            ProvisionEvent provisionEvent = new ProvisionEvent
            {
                Id = 0,
                Code = "LLPE",
                Amount = GetOlb() * rate,
                OverdueDays = lateDays,
                Rate = rate,
                Date = TimeProvider.Now,
                User = User.CurrentUser,
                Description = Code,
                ContracId = Id
            };

            //check if we have a event for that date
            ProvisionEvent p = Events.GetProvisionEvents().Find(item => item.Date == provisionEvent.Date.Date
                                                     && item.Amount == provisionEvent.Amount
                                                     && item.OverdueDays == provisionEvent.OverdueDays);

            if (provisionEvent.Amount > 0 && p == null)
            {
                Events.Add(provisionEvent);
                return provisionEvent;
            }
            return null;
        }
Esempio n. 5
0
        private static OCurrency GetValue(ProvisionEvent eventItem, ContractAccountingRule rule)
        {
            OCurrency amount = 0;

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