Ejemplo n.º 1
0
 private void LoanValidationOrigination(LoanValidationEvent pLoanValidationEvent, Loan pContract, SqlTransaction sqlTransac)
 {
     _eventManagement.AddLoanEvent(pLoanValidationEvent, pContract.Id, sqlTransac);
 }
Ejemplo n.º 2
0
        private Event ReadEvent(OpenCbsReader r)
        {
            Event e;

            if (r.GetNullInt("lde_id").HasValue)
            {
                e = GetLoanDisbursmentEvent(r);
            }
            else if (r.GetNullInt("woe_id").HasValue)
            {
                e = GetWriteOffEvent(r);
            }
            else if (r.GetNullInt("rle_id").HasValue)
            {
                e = GetReschedulingLoanEvent(r);
            }
            else if (r.GetNullInt("rpe_id").HasValue)
            {
                e = GetRepaymentEvent(r);
            }
            else if (r.GetNullInt("tranche_id").HasValue)
            {
                e = GetTrancheLoanEvent(r);
            }
            else if (r.GetNullInt("liae_id").HasValue)
            {
                e = GetLoanInterestAccruingEvent(r);
            }
            else if (r.GetNullInt("ov_id").HasValue)
            {
                e = GetOverdueEvent(r);
            }
            else if (r.GetNullInt("pe_id").HasValue)
            {
                e = GetProvisionEvent(r);
            }
            else if (r.GetNullInt("ef_id").HasValue)
            {
                e = GetEntryFeeEvent(r);
            }
            else if (r.GetNullInt("cie_id").HasValue)
            {
                e = GetCreditInsuranceEvent(r);
            }
            else if (r.GetString("code").StartsWith("S"))
            {
                e = GetSavingEvent(r);
            }
            else
            {
                if(r.GetString("code").Equals("LOVE"))
                    e = new LoanValidationEvent{Id = r.GetInt("event_id")};
                else if (r.GetString("code").Equals("LOCE"))
                    e = new LoanCloseEvent{Id = r.GetInt("event_id")};
                else
                    e = new RegEvent {Id = r.GetInt("event_id")};
            }

            GetEvent(r, e);

            return e;
        }
Ejemplo n.º 3
0
        public Loan UpdateContractStatus(Loan credit, Project project, IClient client, bool undoValidation)
        {
            CheckOperationDate(credit.CreditCommiteeDate.Value);
            using (SqlConnection conn = _loanManager.GetConnection())
            using (SqlTransaction sqlTransaction = conn.BeginTransaction())
            {

                try
                {
                    if (credit.StartDate.Date < ((DateTime) credit.CreditCommiteeDate).Date)
                        throw new OpenCbsContractSaveException(
                            OpenCbsContractSaveExceptionEnum.LoanWasValidatedLaterThanDisbursed);

                    Loan tempLoan = credit.Copy();

                    LoanValidationEvent lve = null;
                    if (undoValidation)
                    {
                        if (tempLoan.Events.GetLastLoanNonDeletedEvent != null &&
                            tempLoan.Events.GetLastLoanNonDeletedEvent is LoanValidationEvent)
                        {
                            ((LoanValidationEvent) tempLoan.Events.GetLastLoanNonDeletedEvent).Amount = credit.Amount;
                            _ePs.CancelFireEvent(tempLoan.Events.GetLastLoanNonDeletedEvent, sqlTransaction, tempLoan,
                                                 tempLoan.Product.Currency.Id);
                            tempLoan.Events.GetLastLoanNonDeletedEvent.Deleted = true;
                        }
                    }
                    else if (tempLoan.ContractStatus == OContractStatus.Validated)
                    {
                        lve = new LoanValidationEvent();
                        lve.Amount = tempLoan.Amount;
                        lve.Date = tempLoan.CreditCommiteeDate.Value;
                        lve.Cancelable = true;
                        lve.User = _user;
                        lve.Deleted = false;

                        if (Teller.CurrentTeller != null && Teller.CurrentTeller.Id != 0)
                            lve.TellerId = Teller.CurrentTeller.Id;

                        _ePs.FireEvent(lve, tempLoan, sqlTransaction);
                        tempLoan.Events.Add(lve);
                    }
                    _loanManager.UpdateLoanStatus(tempLoan, sqlTransaction);
                    project.SetStatus();
                    new ProjectServices(_user).UpdateProjectStatus(project, sqlTransaction);
                    client.SetStatus();
                    new ClientServices(_user).UpdateClientStatus(client, sqlTransaction);

                    FundingLineEvent pendingFundingLineEvent = new FundingLineEvent
                        {
                            Code =
                                string.Concat(
                                    OFundingLineEventTypes.Commitment.
                                                           ToString(), "/", tempLoan.Code),
                            Type = OFundingLineEventTypes.Commitment,
                            FundingLine =
                                _fundingLineServices.SelectFundingLineById(
                                    tempLoan.FundingLine.Id, sqlTransaction),
                            Movement = OBookingDirections.Debit,
                            CreationDate = TimeProvider.Now,
                            Amount = tempLoan.Amount
                            ,
                            AttachTo = lve
                        };
                    //if this is a new validate event, register it, otherwise delete previous validate event
                    if (tempLoan.ContractStatus == OContractStatus.Validated)
                        tempLoan.FundingLine.AddEvent(_fundingLineServices.AddFundingLineEvent(pendingFundingLineEvent,
                                                                                               sqlTransaction));
                    else if (undoValidation)
                    {
                        DeleteFundingLineEvent(ref tempLoan, pendingFundingLineEvent, sqlTransaction);
                    }
                    sqlTransaction.Commit();
                    return tempLoan;
                }
                catch (Exception ex)
                {
                    sqlTransaction.Rollback();
                    throw ex;
                }
            }
        }
Ejemplo n.º 4
0
 public void AddLoanEvent(LoanValidationEvent evnt, int contractId, SqlTransaction sqlTransac)
 {
     evnt.Id=AddLoanEventHead(evnt, contractId, sqlTransac);
 }