Esempio n. 1
0
        public void AddLoanDisbursmentEvent()
        {
            EventManager eventManager = (EventManager)container["EventManager"];

            LoanDisbursmentEvent loanDisbursmentEvent = new LoanDisbursmentEvent
                                            {
                                                Id = 10,
                                                User = new User { Id = 1 },
                                                Date = new DateTime(2006, 7, 21),
                                                Amount = 100,
                                            };
            loanDisbursmentEvent.Commissions = new List<LoanEntryFeeEvent>();
            LoanEntryFeeEvent commission = new LoanEntryFeeEvent();
            commission.Fee = 10;
            loanDisbursmentEvent.Commissions.Add(commission);

            PaymentMethod method = new PaymentMethod(1, "Savings", "Savings method", false);
            loanDisbursmentEvent.PaymentMethod = method;

            eventManager.AddLoanEvent(loanDisbursmentEvent, 1);
            Assert.AreNotEqual(0, loanDisbursmentEvent.Id);
        }
Esempio n. 2
0
        private void LoanDisbursmentOrigination(LoanDisbursmentEvent loanDisbursmentEvent, Loan loanContract, SqlTransaction sqlTransac)
        {
            int eventId = _eventManagement.AddLoanEvent(loanDisbursmentEvent, loanContract.Id, sqlTransac);
               loanDisbursmentEvent.Id = eventId;
               if (loanDisbursmentEvent.Commissions != null)
               {
               foreach (LoanEntryFeeEvent entryFeeEvent in loanDisbursmentEvent.Commissions)
               {
                   if (entryFeeEvent.Fee == 0) continue;
                   entryFeeEvent.DisbursementEventId = eventId;
                   entryFeeEvent.User = loanDisbursmentEvent.User;
                   entryFeeEvent.TellerId = loanDisbursmentEvent.TellerId;

                   if (loanContract.CompulsorySavings != null)
                       entryFeeEvent.Comment = loanContract.CompulsorySavings.Code;

                   int feeEventId = _eventManagement.AddLoanEventHead(entryFeeEvent, loanContract.Id, sqlTransac);
                   entryFeeEvent.Id = feeEventId;
                   if (entryFeeEvent.Fee != 0) _eventManagement.AddLoanEntryFeesEvent(entryFeeEvent, sqlTransac);
               }
               }
        }
Esempio n. 3
0
        public void TestMethodeCopyCredit()
        {
            LoanProduct package = new LoanProduct
                                      {
                                          InstallmentType = new InstallmentType(1, "Monthly", 0, 1),
                                          LoanType = OLoanTypes.DecliningFixedInstallments,
                                          ChargeInterestWithinGracePeriod = true,
                                          Currency = new Currency { Id = 1 }
                                      };
            package.KeepExpectedInstallment = false;
            Loan contractSource = new Loan(package,1500,0.03m,9,1,new DateTime(2006,1,2),
                new User(), ApplicationSettings.GetInstance(""), NonWorkingDateSingleton.GetInstance(""),
                ProvisionTable.GetInstance(new User()), ChartOfAccounts.GetInstance(new User()));
            RepaymentEvent rE1 = new RepaymentEvent
                                     {
                                         Id = 1,
                                         InstallmentNumber = 1,
                                         Principal = 200,
                                         Interests = 100,
                                         Commissions = 0,
                                         Penalties = 0,
                                         ClientType = OClientTypes.Group
                                     };
            LoanDisbursmentEvent lDE = new LoanDisbursmentEvent{Id = 2,Date = DateTime.Today,Amount = 100, ClientType = OClientTypes.Group};

            contractSource.Code = "HHHHJKLLJJBNBJJ";
            contractSource.AnticipatedTotalRepaymentPenalties = 0.02;
            contractSource.Events.Add(rE1);
            contractSource.Events.Add(lDE);

            Loan contractDestination = contractSource.Copy();

            Assert.AreEqual(contractSource.Amount.Value, contractDestination.Amount.Value);
            Assert.AreEqual(contractSource.AnticipatedTotalRepaymentPenalties,contractDestination.AnticipatedTotalRepaymentPenalties);
            Assert.AreEqual(contractSource.Code,contractDestination.Code);
            Assert.AreEqual(contractSource.ClientType,contractDestination.ClientType);
            Assert.AreEqual(contractSource.InstallmentList.Count,contractDestination.InstallmentList.Count);
            Assert.AreEqual(contractSource.InstallmentList[0].Number,contractDestination.InstallmentList[0].Number);
            Assert.AreEqual(contractSource.InstallmentList[1].Number,contractDestination.InstallmentList[1].Number);

            //            ((LoanDisbursmentEvent)contractSource.Events.GetEvent(1)).Commission = 22;
            //            Assert.IsTrue(((LoanDisbursmentEvent)contractDestination.Events.GetEvent(1)).Commission == 0);
            //            Assert.IsFalse(((LoanDisbursmentEvent)contractDestination.Events.GetEvent(1)).Commission == 22);

            contractSource.InstallmentList[0].Number = 4;
            Assert.IsFalse(contractDestination.InstallmentList[0].Number == 4);
            Assert.IsTrue(contractDestination.InstallmentList[0].Number == 1);
        }
        private bool InitializeLoanDisburseEvent()
        {
            try
            {
                _loanDisbursmentEvent = ServicesProvider.GetInstance().GetContractServices().DisburseSimulation(_loan,
                                                                                                                _alignInstallmentsDatesOnRealDisbursmentDate,
                                                                                                                _newStartDate,
                                                                                                                _disableFees);

                if (_loanDisbursmentEvent != null)
                {
                    _lbAmountValue.Text = _loanDisbursmentEvent.Amount.GetFormatedValue(_loan.UseCents);
                    lblAmountCurrency.Text = _loan.Product.Currency.Code;
                    _lbLoanCodeValue.Text = _loan.Code;
                    if (!_feeModified)
                        SetFeeAmount();
                    lblEntryFeeCurrency.Text = _loan.Product.Currency.Code;
                    InitializeExternalCurrency();
                }
            }
            catch (Exception ex)
            {
                new frmShowError(CustomExceptionHandler.ShowExceptionText(ex)).ShowDialog();
                _exchangeRate = null;
                InitializeExternalCurrency();
                return false;
            }
            return true;
        }
Esempio n. 5
0
 private static void _AssertLoanDisbursmentEvent(LoanDisbursmentEvent pEvent, DateTime pDate, OCurrency pAmount, OCurrency pCommission)
 {
     Assert.AreEqual("LODE", pEvent.Code);
     Assert.AreEqual(pDate, pEvent.Date);
     Assert.AreEqual(pAmount.Value, pEvent.Amount.Value);
 }
Esempio n. 6
0
 private CreditInsuranceEvent GetCreditInsuranceEvent(LoanDisbursmentEvent disbursmentEvent)
 {
     CreditInsuranceEvent cie = new CreditInsuranceEvent
                                    {
                                        Date = disbursmentEvent.Date,
                                        Cancelable = true,
                                        User = User.CurrentUser,
                                        Code = "LCIE",
                                        Principal = 0,
                                        Commission = Amount * Insurance / 100,
                                        TellerId = disbursmentEvent.TellerId
                                    };
     return cie;
 }
Esempio n. 7
0
        public void Select_Added_loanDisbursmentEvent()
        {
            EventManager eventManager = (EventManager)container["EventManager"];

            LoanDisbursmentEvent loanDisbursmentEvent = new LoanDisbursmentEvent
            {
                Id = 100,
                User = new User { Id = 1 },
                Date = new DateTime(2006, 7, 21),
                Amount = 100,
            };
            var commission = new LoanEntryFeeEvent();
            commission.Fee = 10;
            loanDisbursmentEvent.Commissions = new List<LoanEntryFeeEvent>();
            loanDisbursmentEvent.Commissions.Add(commission);

            PaymentMethod method = new PaymentMethod(1, "Savings", "Savings method", false);
            loanDisbursmentEvent.PaymentMethod = method;

            eventManager.AddLoanEvent(loanDisbursmentEvent, 2);
            EventStock eventStock = eventManager.SelectEvents(2);

            foreach (Event e in eventStock.GetEvents())
            {
                if (e is LoanDisbursmentEvent)
                    _AssertLoanDisbursmentEvent(e as LoanDisbursmentEvent, new DateTime(2006, 7, 21), 100, 10);
            }
        }
Esempio n. 8
0
        public int AddLoanEvent(LoanDisbursmentEvent evnt, int contractId, SqlTransaction sqlTransac)
        {
            evnt.Id = AddLoanEventHead(evnt, contractId, sqlTransac);

            const string q = @"INSERT INTO [LoanDisbursmentEvents]([id], [amount], [fees], [interest], [payment_method_id])
                                    VALUES(@id, @amount, @fees, @interest, @payment_method_id)";

            using(OpenCbsCommand c = new OpenCbsCommand(q, sqlTransac.Connection, sqlTransac))
            {
                GetLoanDisbursmentEvent(evnt, c);
                c.ExecuteNonQuery();
            }
            return evnt.Id;
        }
Esempio n. 9
0
 private static void GetLoanDisbursmentEvent(LoanDisbursmentEvent evnt, OpenCbsCommand c)
 {
     c.AddParam("@id", evnt.Id);
     c.AddParam("@amount", evnt.Amount.Value);
     c.AddParam("@fees", 0);
     c.AddParam("@interest", evnt.Interest.HasValue ? evnt.Interest.Value : 0);
     c.AddParam("@payment_method_id", evnt.PaymentMethod.Id);
 }
Esempio n. 10
0
 public int AddLoanEvent(LoanDisbursmentEvent evnt, int contractId)
 {
     using (SqlConnection connection = GetConnection())
     using (SqlTransaction transaction = connection.BeginTransaction())
     {
         try
         {
             int result = AddLoanEvent(evnt, contractId, transaction);
             transaction.Commit();
             return result;
         }
         catch(Exception)
         {
             transaction.Rollback();
             throw;
         }
     }
 }
Esempio n. 11
0
 public void SetUp()
 {
     loanDisbursmentEvent = new LoanDisbursmentEvent();
 }
Esempio n. 12
0
 public void TestLoanDisbursmentEventAmount()
 {
     LoanDisbursmentEvent LDIE = new LoanDisbursmentEvent {Amount = 432.3m};
     Assert.AreEqual(432.3m,LDIE.Amount.Value);
 }
Esempio n. 13
0
 public void TestIfLoanDisbursmentEventCodeCorrectlySetAndRetrieved()
 {
     LoanDisbursmentEvent lODE = new LoanDisbursmentEvent();
     Assert.AreEqual("LODE",lODE.Code);
 }
Esempio n. 14
0
        private static OCurrency GetValue(LoanDisbursmentEvent eventItem, ContractAccountingRule rule)
        {
            OCurrency amount = 0;
            if (rule.EventAttribute.Name.ToLower() == "amount")
            {
                amount = eventItem.Amount;
            }

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

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