Exemplo n.º 1
0
 private static SavingEvent GetSavingsEvent(string code)
 {
     SavingEvent e;
     switch (code)
     {
         case OSavingEvents.Deposit:
             e = new SavingDepositEvent();
             break;
         case OSavingEvents.Withdraw:
             e = new SavingWithdrawEvent();
             break;
         case OSavingEvents.Accrual:
             e = new SavingInterestsAccrualEvent();
             break;
         case OSavingEvents.Posting:
             e = new SavingInterestsPostingEvent();
             break;
         case OSavingEvents.InitialDeposit:
             e = new SavingInitialDepositEvent();
             break;
         case OSavingEvents.CreditTransfer:
             e = new SavingCreditTransferEvent();
             break;
         case OSavingEvents.DebitTransfer:
             e = new SavingDebitTransferEvent();
             break;
         case OSavingEvents.ManagementFee:
             e = new SavingManagementFeeEvent();
             break;
         case OSavingEvents.SavingClosure:
             e = new SavingClosureEvent();
             break;
         case OSavingEvents.Close:
             e = new SavingCloseEvent();
             break;
         case OSavingEvents.OverdraftFees:
             e = new SavingOverdraftFeeEvent();
             break;
         case OSavingEvents.Agio:
             e = new SavingAgioEvent();
             break;
         case OSavingEvents.PendingDeposit:
             e = new SavingPendingDepositEvent();
             break;
         case OSavingEvents.Reopen:
             e = new SavingReopenEvent();
             break;
         case OSavingEvents.PendingDepositRefused:
             e = new SavingPendingDepositRefusedEvent();
             break;
         case OSavingEvents.SpecialOperationCredit:
             e = new SavingCreditOperationEvent();
             break;
         case OSavingEvents.SpecialOperationDebit:
             e = new SavingDebitOperationEvent();
             break;
         case OSavingEvents.InterBranchCreditTransfer:
             e = new SavingCreditInterBranchTransferEvent();
             break;
         case OSavingEvents.InterBranchDebitTransfer:
             e = new SavingDebitInterBranchTransferEvent();
             break;
         case OSavingEvents.LoanDisbursement:
             e = new SavingLoanDisbursementEvent();
             break;
         case OSavingEvents.SavingLoanRepayment:
             e = new LoanRepaymentFromSavingEvent();
             break;
         case OSavingEvents.BlockCompulsarySavings:
             e = new SavingBlockCompulsarySavingsEvent();
             break;
         case OSavingEvents.UnblockCompulsorySavings:
             e = new SavingUnblockCompulsorySavingsEvent();
             break;
         default:
             Debug.Fail("Failed to create saving event object");
             throw new Exception();
     }
     return e;
 }
Exemplo n.º 2
0
 public void FireSavingBlockEvent(SavingBlockCompulsarySavingsEvent savingBlockEvent, int contracId, SqlTransaction sqlTransac)
 {
     _savingEventManagement.Add(savingBlockEvent, contracId, sqlTransac);
 }
Exemplo n.º 3
0
        /// <summary>
        /// Method to Disburse money for the contract
        /// </summary>
        /// <param name="pDisburseDate">Date of disbursment</param>
        /// <param name="pDisableFees">when true, entry commission paid for this contract are set to 0</param>
        /// <param name="pAlignInstallmentsDatesOnRealDisbursmentDate"></param>
        /// <returns>A LoanDisburment event if correct date of disbursment. /!\Becarful, loan must be non debursed </returns>
        public LoanDisbursmentEvent Disburse(DateTime pDisburseDate, bool pAlignInstallmentsDatesOnRealDisbursmentDate, bool pDisableFees)
        {
            LoanDisbursmentEvent e = _generalSettings.AccountingProcesses == OAccountingProcesses.Cash
                                         ? GenerateEvents.Cash.GenerateLoanDisbursmentEvent(this, _generalSettings,
                                                                                            pDisburseDate,
                                                                                            pAlignInstallmentsDatesOnRealDisbursmentDate,
                                                                                            pDisableFees, _user)
                                         : GenerateEvents.Accrual.GenerateLoanDisbursmentEvent(this, _generalSettings,
                                                                                               pDisburseDate,
                                                                                               pAlignInstallmentsDatesOnRealDisbursmentDate,
                                                                                               pDisableFees, _user);
            e.Interest = GetTotalInterestDue();
            if (!pDisableFees)
            {
                List<OCurrency> entryFees = GetEntryFees();
                if (entryFees != null)
                {
                    e.Commissions = new List<LoanEntryFeeEvent>();
                    for (int i=0; i<entryFees.Count; i++)
                    {
                        LoanEntryFeeEvent loanEntryFeeEvent = new LoanEntryFeeEvent
                                                                  {
                                                                      Fee =
                                                                          Product.Currency.UseCents
                                                                              ? Math.Round(entryFees[i].Value, 2)
                                                                              : Math.Round(entryFees[i].Value,
                                                                                           MidpointRounding.AwayFromZero),
                                                                      Code = "LEE" + LoanEntryFeesList[i].ProductEntryFee.Index,
                                                                      DisbursementEventId = e.Id,
                                                                      Cancelable = true,
                                                                      User = User.CurrentUser,
                                                                      Date = e.Date
                                                                  };
                        e.Commissions.Add(loanEntryFeeEvent);

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

                        if (loanEntryFeeEvent.Fee > 0)
                        {
                            Events.Add(loanEntryFeeEvent);
                        }
                    }
                }
            }

            if (HasCompulsoryAmount())
            {
                SavingBlockCompulsarySavingsEvent savingBlockEvent = new SavingBlockCompulsarySavingsEvent();
                Debug.Assert(CompulsorySavingsPercentage != null,
                             string.Format(
                                 "Loan with code {0}, should be cheked for compulsory existance, before adding saving block event",
                                 Code)
                    );
                OCurrency csAmount = (Amount.Value * CompulsorySavingsPercentage.Value) / 100m;
                int contracId = CompulsorySavings.Id;
                savingBlockEvent.ContracId = contracId;
                savingBlockEvent.User = _user;
                savingBlockEvent.Amount = csAmount;
                savingBlockEvent.Date = StartDate;
                savingBlockEvent.EntryDate = TimeProvider.Now;
                savingBlockEvent.Cancelable = true;
                CompulsorySavings.Events.Add(savingBlockEvent);
            }

            CreditInsuranceEvent cie = GetCreditInsuranceEvent(e);
            if (cie.Commission > 0)
                Events.Add(cie);

            GivenTranches.Clear();
            TrancheEvent trancheEvent = new TrancheEvent
            {
                StartDate = pDisburseDate,
                Maturity = NbOfInstallments,
                Amount = Amount,
                InterestRate = (decimal)InterestRate,
                ApplyNewInterest = false,
                Number = 0
            };

            GivenTranches.Add(trancheEvent);
            return e;
        }