Esempio n. 1
0
 public void RepayCommission(Installment pInstallment, ref OCurrency pAmountPaid, ref OCurrency pCommisionEvent)
 {
     if (!_pCCO.CancelFees)
         AutomaticRepayMethod(pInstallment, ref pAmountPaid, ref pCommisionEvent);
     else
         ManualRepayMethod(pInstallment, ref pAmountPaid, ref pCommisionEvent);
 }
Esempio n. 2
0
 public void Repay(Installment pInstallment, ref OCurrency pAmountPaid, ref OCurrency pFeesEvent)
 {
     //Nothing to modify
     pInstallment.PaidFees += pFeesEvent;
     pAmountPaid -= pFeesEvent;
     pFeesEvent = 0;
 }
 public FixedInstallmentStrategy(Loan pContract, OCurrency pStartAmount, int pNumberOfInstalments, ApplicationSettings pGeneralSettings)
 {
     _contract = pContract;
     _startAmount = pStartAmount;
     _numberOfInstallmentsToPay = pNumberOfInstalments;
     _roundingPoint = pContract.UseCents ? 2 : 0;
     _generalSettings = pGeneralSettings;
 }
Esempio n. 4
0
 private static void ManualRepayMethod(Installment pInstallment, ref OCurrency pAmountPaid, ref OCurrency pCommisionEvent)
 {
     pInstallment.PaidCommissions = pCommisionEvent;
     pInstallment.CommissionsUnpaid = 0;
     pAmountPaid -= pCommisionEvent;
     pCommisionEvent = 0;
     //Nothing to modify
 }
Esempio n. 5
0
 public Group()
     : base(new List<Project>(), OClientTypes.Group)
 {
     _members = new List<Member>();
     _historyMembers = new List<Member>();
     _leader = new Member();
     TotalContractAmount = 0;
 }
Esempio n. 6
0
        public FlatStrategy(Loan pContract, ApplicationSettings pGeneralSettings, OCurrency pInitialOlbOfContractBeforeRescheduling)
        {
            _roundingPoint = pContract.UseCents ? 2 : 0;

            _initialOlbOfContractBeforeRescheduling = pInitialOlbOfContractBeforeRescheduling;
            _contract = pContract;
            _generalSettings = pGeneralSettings;
        }
Esempio n. 7
0
 public LoanAmountCycle(int id, int loanCycle,  OCurrency min, OCurrency max, int cycleObjectId, int cycleId)
 {
     Id = id;
     LoanCycle = loanCycle;
     Min = min;
     Max = max;
     CycleObjectId = cycleObjectId;
     CycleId = cycleId;
 }
Esempio n. 8
0
 public BookingToView(OBookingDirections pDirection, OCurrency pAmount, DateTime pDate, double? pExchangeRate, string pContractCode, string pEventCode)
 {
 	Direction = pDirection;
 	_amount = pAmount;
 	Date = pDate;
 	_exchangeRate = pExchangeRate;
 	ContractCode = pContractCode;
 	EventCode = pEventCode;
 }
Esempio n. 9
0
 public LoanSharesForm(Loan pLoan, Group pGroup)
 {
     InitializeComponent();
     _loan = pLoan;
     _group = pGroup;
     _total = _loan.LoanShares.Sum(x => x.Amount.Value);
     
     InitializeControls();
 }
Esempio n. 10
0
        public Booking(int pNumber, Account pCreditaccount, OCurrency pAmount, Account pDebitaccount, OAccountingLabels pLabel, DateTime pDate, Branch branch)
		{
            Number = pNumber;
            CreditAccount = pCreditaccount;
            DebitAccount = pDebitaccount;
            _amount = pAmount;
		    Label = pLabel;
            Date = pDate;
            Branch = branch;
		}
Esempio n. 11
0
        public Account(string accountNumber, string label, OCurrency   balance, string typeCode, bool debitPlus, OAccountCategories category, int pCurrencyId)
		{
			_number = accountNumber;
			_label = label;
			_balance = balance;
			TypeCode = typeCode;
			_debitPlus = debitPlus;
			AccountCategory = category;
            CurrencyId = pCurrencyId;
		}
        public void RepayNextInstallments(ref OCurrency amountPaid, ref OCurrency interestEvent, ref OCurrency interestPrepayment, ref OCurrency principalEvent, ref OCurrency feesEvent, ref OCurrency commissionsEvent)
        {
            if (amountPaid == 0) return;
            for(int i = 0 ; i < _contract.NbOfInstallments ; i++)
            {
                Installment installment = _contract.GetInstallment(i);
                if (!installment.IsRepaid && amountPaid > 0)
                {
                    //commission
                    _methodToRepayCommission.RepayCommission(installment, ref amountPaid, ref commissionsEvent);
                    if (amountPaid == 0) break;

                    //penalty
                    _methodToRepayFees.RepayFees(installment, ref amountPaid, ref feesEvent);
                    if (amountPaid == 0) break;

                    //Interests
                    if (amountPaid == 0) return;
                    _methodToRepayInterest.RepayInterest(installment, ref amountPaid, ref interestEvent,ref interestPrepayment);

                    //principal
                    if (amountPaid == 0)
                    {
                        _paidInstallments.Add(installment);
                        return;
                    }

                    OCurrency principalHasToPay = installment.CapitalRepayment - installment.PaidCapital;

                    if (AmountComparer.Compare(amountPaid, principalHasToPay) < 0)
                    {
                        installment.PaidCapital += amountPaid;
                        installment.PaidCapital = Math.Round(installment.PaidCapital.Value, 2);
                        principalEvent += amountPaid;
                        amountPaid = 0;
                    }
                    else if (AmountComparer.Compare(amountPaid, principalHasToPay) > 0)
                    {
                        installment.PaidCapital = installment.CapitalRepayment;
                        amountPaid -= principalHasToPay;
                        principalEvent += principalHasToPay;
                    }
                    else
                    {
                        installment.PaidCapital += amountPaid;
                        installment.PaidCapital = Math.Round(installment.PaidCapital.Value, 2);
                        principalEvent += amountPaid;
                        amountPaid = 0;
                    }

                    _paidInstallments.Add(installment);
                }
            }
        }
Esempio n. 13
0
        public CloseSavingsForm(OCurrency pBalance)
        {
            InitializeComponent();

            lbTotalAmountValue.Text = pBalance.GetFormatedValue(UseCents);
            gbCloseFees.Enabled = false;
            _amount = pBalance;
            _closeFees = 0;

            Initialize();
        }
        /// <summary>
        /// This method recalculates installments for a declining rate exotic loan in case of over payment.
        /// </summary>
        public void RepayNextInstallments(ref OCurrency amountPaid, ref OCurrency interestEvent, ref OCurrency interestPrepayment, ref OCurrency principalEvent, ref OCurrency feesEvent, ref OCurrency commissionsEvent)
        {
            OCurrency totalAmount = 0;
            bool firstInstallmentToRepay = false;
            double baseTocalculatePrincipalCoeff = 0;

            if(amountPaid > 0)
            {
                for (int i = 0; i < _contract.NbOfInstallments; i++)
                {
                    Installment installment = _contract.GetInstallment(i);
                    if (installment.IsRepaid &&  installment.Number > _contract.GracePeriod)
                        baseTocalculatePrincipalCoeff += _contract.Product.ExoticProduct.GetExoticInstallment(i - _contract.GracePeriod.Value).PrincipalCoeff;
                }

                baseTocalculatePrincipalCoeff = 1 - baseTocalculatePrincipalCoeff;

                for(int i = 0;i < _contract.NbOfInstallments;i++)
                {
                    Installment installment = _contract.GetInstallment(i);
                    if(!installment.IsRepaid && installment.Number <= _contract.GracePeriod)  //during Grace Period
                    {
                        installment.OLB -= amountPaid;
                        installment.CapitalRepayment = 0;
                        installment.InterestsRepayment = Math.Round(installment.OLB.Value * Convert.ToDecimal(_contract.InterestRate),2);
                    }
                    else if(!installment.IsRepaid && !firstInstallmentToRepay)
                    {
                        ExoticInstallment exoticInstallment = _contract.Product.ExoticProduct.GetExoticInstallment(i - _contract.GracePeriod.Value);
                        firstInstallmentToRepay = true;
                        installment.OLB -= amountPaid;
                        totalAmount = installment.OLB;

                        installment.CapitalRepayment = Math.Round(totalAmount.Value * Convert.ToDecimal(exoticInstallment.PrincipalCoeff / baseTocalculatePrincipalCoeff),2);
                        installment.InterestsRepayment = Math.Round(installment.OLB.Value * Convert.ToDecimal(_contract.InterestRate),2);
                    }
                    else if(!installment.IsRepaid)
                    {
                        ExoticInstallment exoticInstallment = _contract.Product.ExoticProduct.GetExoticInstallment(i - _contract.GracePeriod.Value);
                        Installment _installment = _contract.GetInstallment(i - 1);
                        installment.OLB  = _installment.OLB - _installment.CapitalRepayment;

                        installment.CapitalRepayment = Math.Round(totalAmount.Value * Convert.ToDecimal(exoticInstallment.PrincipalCoeff / baseTocalculatePrincipalCoeff),2);
                        installment.InterestsRepayment = Math.Round(installment.OLB.Value * Convert.ToDecimal(_contract.InterestRate),2); 
                    }

                    _paidInstallments.Add(installment);
                }

                principalEvent += amountPaid;
                amountPaid = 0;
            }
        }
Esempio n. 15
0
 public CreditContractOptions(OLoanTypes pLoanType, bool pKeepExpectedInstallments,
     bool pCancelFees, OCurrency pManualFeesAmount, OCurrency pManualCommissionAmount,
     bool pCancelInterests, OCurrency pManualInterestsAmount,
     OAnticipatedRepaymentPenaltiesBases pAnticipatedTotalRepaymentPenaltiesBase)
 {
     _loanType = pLoanType;
     _keepExpectedInstallments = pKeepExpectedInstallments;
     _cancelFees = pCancelFees;
     _manualFeesAmount = pManualFeesAmount;
     _manualCommissionAmount = pManualCommissionAmount;
     _cancelInterests = pCancelInterests;
     _manualInterestsAmount = pManualInterestsAmount;
     _anticipatedTotalRepaymentPenaltiesBase = pAnticipatedTotalRepaymentPenaltiesBase;
 }
Esempio n. 16
0
        public CloseSavingsForm(ISavingProduct savingBookProduct, OCurrency pBalance, OCurrency pCloseFees)
        {
            InitializeComponent();

            _amount = pBalance;
            _closeFees = pCloseFees;

            if (savingBookProduct is SavingsBookProduct)
                _savingsBookProduct = (SavingsBookProduct)savingBookProduct;
            lbTotalAmountValue.Text = pBalance.GetFormatedValue(UseCents);
            gbCloseFees.Enabled = (_closeFees.Value > 0);

            Initialize();
        }
Esempio n. 17
0
 public Installment(DateTime expectedDate,OCurrency interestRepayment,OCurrency capitalRepayment,
                    OCurrency paidCapital, OCurrency paidInterests, OCurrency paidFees, DateTime? paidDate, int number)
 {
     ExpectedDate = expectedDate;
     _interestsRepayment = interestRepayment;
     _capitalRepayment = capitalRepayment;
     _paidCapital = paidCapital;
     _paidInterests = paidInterests;
     _paidFees = paidFees;
     PaidDate = paidDate;
     Number = number;
     CalculatedPenalty = 0m;
     IsLastToRepay = false;
 }
Esempio n. 18
0
        public void Repay(ref OCurrency pAmountPaid, ref OCurrency pFeesEvent, ref OCurrency pCommissionsEvent, ref OCurrency pInterestEvent)
        {
            if (_cco.CancelFees && (_cco.ManualFeesAmount + _cco.ManualCommissionAmount) >= 0)
            {
                pCommissionsEvent = _cco.ManualCommissionAmount;
                pFeesEvent = _cco.ManualFeesAmount;

                if (AmountComparer.Compare(pAmountPaid, _cco.ManualFeesAmount + _cco.ManualCommissionAmount) > 0)
                {
                    //pAmountPaid -= _cco.ManualFeesAmount + _cco.ManualCommissionAmount;
                }
                else
                    pAmountPaid = 0;
            }

            if (_cco.KeepExpectedInstallments)
            {
                if (_cco.CancelInterests && _cco.ManualInterestsAmount >= 0)
                {
                    OCurrency manualInterestAmount = _cco.ManualInterestsAmount;
                    for(int i = 0;i<_contract.NbOfInstallments;i++)
                    {
                        Installment installment = _contract.GetInstallment(i);
                        if(!installment.IsRepaid && pAmountPaid > 0 && manualInterestAmount > 0)
                        {
                            OCurrency interestHasToPay = installment.InterestsRepayment - installment.PaidInterests;
                            if (AmountComparer.Compare(manualInterestAmount,interestHasToPay) > 0)
                            {
                                pInterestEvent += interestHasToPay;
                                installment.PaidInterests = installment.InterestsRepayment;
                                pAmountPaid -= interestHasToPay;
                                manualInterestAmount -= interestHasToPay;
                            }
                            else
                            {
                                pInterestEvent += manualInterestAmount;
                                installment.PaidInterests += manualInterestAmount;
                                pAmountPaid -= manualInterestAmount;
                                manualInterestAmount = 0;
                            }

                            PaidIstallments.Add(installment);
                        }
                    }
                }
            }
        }
Esempio n. 19
0
 private static void AutomaticRepayMethod(Installment pInstallment, ref OCurrency pAmountPaid, ref OCurrency pCommisionEvent)
 {
     if (AmountComparer.Compare(pAmountPaid, pInstallment.CommissionsUnpaid) > 0)
     {
         pCommisionEvent += pInstallment.CommissionsUnpaid;
         pAmountPaid -= pInstallment.CommissionsUnpaid;
         pInstallment.PaidCommissions += pInstallment.CommissionsUnpaid;
         pInstallment.CommissionsUnpaid = 0;
     }
     else
     {
         pCommisionEvent += pAmountPaid;
         pInstallment.PaidCommissions += pAmountPaid;
         pInstallment.CommissionsUnpaid -= pAmountPaid;
         pAmountPaid = 0;
     }
 }
Esempio n. 20
0
        public void CalculateFees(DateTime pDate, ref OCurrency pAmountPaid, ref OCurrency pFeesEvent)
        {
            OCurrency fees = _loan.UseCents 
                                        ? Math.Round(_bTcffar.CalculateFees(pDate).Value,2) 
                                        : Math.Round(_bTcffar.CalculateFees(pDate).Value, 0);

            if(AmountComparer.Compare( fees, pAmountPaid) > 0)
            {
                pFeesEvent += pAmountPaid;
                pAmountPaid = 0;
            }
            else
            {
                pAmountPaid -= fees;
                pFeesEvent += fees;
            }
        }
Esempio n. 21
0
        public OpenSavingsForm(OCurrency pInitialAmount, OCurrency pEntryFees, 
                               SavingsBookProduct savingsProduct, bool isReopen)
        {
            _savingsProduct = savingsProduct;
            _initialAmount = pInitialAmount;
            _entryFees = pEntryFees;
            _isReopen = isReopen;

            InitializeComponent();
            Initialize();

            if (_isReopen)
            {
                lbEntryFees.Text = GetString("lbReopenFees.Text");
                lbEntryFeesConfirmation.Text = GetString("lbReopenFeesConfirmation.Text");
                gbModifyInitialAmountEntryFees.Text = GetString("gbModifyInitialAmountReopenFees.Text");
            }
        }
Esempio n. 22
0
        public void Repay(Installment pInstallment, ref OCurrency pAmountPaid, ref OCurrency pFeesEvent)
        {
            if (AmountComparer.Compare(pAmountPaid, pInstallment.FeesUnpaid) > 0)
            {
                pFeesEvent += pInstallment.FeesUnpaid;
                pAmountPaid -= pInstallment.FeesUnpaid;
                pInstallment.PaidFees += pInstallment.FeesUnpaid;
                pInstallment.FeesUnpaid = 0;

            }
            else
            {
                pFeesEvent += pAmountPaid;
                pInstallment.PaidFees += pAmountPaid;
                pInstallment.FeesUnpaid -= pAmountPaid;
                pAmountPaid = 0;
            }
        }
Esempio n. 23
0
        public void Repay(Installment pInstallment, ref OCurrency pAmountPaid, ref OCurrency pInterestEvent, ref OCurrency pInterestPrepayment)
        {
            if (AmountComparer.Compare(pAmountPaid, pInstallment.InterestsRepayment - pInstallment.PaidInterests) > 0)
            {
                OCurrency interestHasToPay = pInstallment.InterestsRepayment - pInstallment.PaidInterests;

                pAmountPaid -= interestHasToPay;
                pInterestEvent += interestHasToPay;
                pInterestPrepayment += interestHasToPay;
                pInstallment.PaidInterests += interestHasToPay;
            }
            else
            {
                pInstallment.PaidInterests += pAmountPaid;
                pInterestEvent += pAmountPaid;
                pInterestPrepayment += pAmountPaid;
                pAmountPaid = 0;
            }
        }
        public void RepayNextInstallments(ref OCurrency amountPaid, ref OCurrency interestEvent, ref OCurrency interestPrepayment, ref OCurrency principalEvent, ref OCurrency feesEvent, ref OCurrency commissionsEvent)
        {
            int installmentNumber = 0;
            OCurrency interest = 0;
            _contract.InstallmentList.Sort((x, y) => x.ExpectedDate.CompareTo(y.ExpectedDate));
            foreach (Installment installment in _contract.InstallmentList)
            {
                if (!installment.IsRepaid)
                {
                    if (_generalSettings.AccountingProcesses == OAccountingProcesses.Accrual)
                    {
                        interest = 0;
                        amountPaid -= interest;
                        interestEvent += interest;
                        installmentNumber = installment.Number;
                    }

                    principalEvent += amountPaid;
                    OCurrency startAmount = _contract.GetInstallment(installment.Number - 1).OLB - amountPaid;
                    amountPaid = 0;

                    if (installment.Number <= _contract.GracePeriod.Value)
                    {
                        _CalculateInstallments(installment.Number, startAmount, _contract.NbOfInstallments - _contract.GracePeriod.Value);
                    }
                    else
                    {
                        _CalculateInstallments(installment.Number, startAmount,_contract.NbOfInstallments - installment.Number + 1);
                    }
                    break;
                }

                _paidInstallments.Add(installment);
            }

            if (installmentNumber != 0)
            {
                _contract.GetInstallment(installmentNumber - 1).InterestsRepayment = interest;
                _contract.GetInstallment(installmentNumber - 1).PaidInterests = interest;
            }
        }
        public CalculateInstallmentsStrategy(CalculateInstallmentsOptions pCio, OCurrency pStartAmount, int pNumberOfInstallments, ApplicationSettings pGeneralSettings)
        {
            _generalSettings = pGeneralSettings;
            OCurrency initialOlbOfContractBeforeRescheduling = Loan.InitialOlbOfContractBeforeRescheduling;

            if (pCio.IsExotic)
            {
                if (pCio.LoanType == OLoanTypes.Flat)
                    _iCi = new Flat.ExoticStrategy(pCio.Contract, _generalSettings);
                else
                    _iCi = new Declining.ExoticStrategy(pCio.Contract, _generalSettings);
            }
            else
            {
                if (pCio.Contract.InterestRate == 0)
                {
                    _iCi = new FlatStrategy(pCio.Contract, _generalSettings, initialOlbOfContractBeforeRescheduling);
                }
                else
                {
                    switch (pCio.LoanType)
                    {
                        case OLoanTypes.Flat:
                            _iCi = new FlatStrategy(pCio.Contract, _generalSettings, initialOlbOfContractBeforeRescheduling);
                            break;
                        case OLoanTypes.DecliningFixedInstallments:
                            _iCi = new FixedInstallmentStrategy(pCio.Contract, pStartAmount, pNumberOfInstallments,
                                                                _generalSettings);
                            break;
                        case OLoanTypes.DecliningFixedPrincipal:
                            _iCi = new FixedPrincipalStrategy(pCio.Contract, _generalSettings);
                            break;
                        case OLoanTypes.DecliningFixedPrincipalWithRealInterest:
                            _iCi = new FixedPrincipalWithRealInterest(pCio.Contract, _generalSettings);
                            break;
                    }
                }
            }
        }
        public void RepayNextInstallments(ref OCurrency amountPaid, ref OCurrency interestEvent, ref OCurrency interestPrepayment, ref OCurrency principalEvent, ref OCurrency feesEvent, ref OCurrency commissionsEvent)
        {
            if (amountPaid <= 0) return;
            OCurrency totalInterest = 0;
            OCurrency totalPrincipal = 0;
            double nbInterest = 0;
            double nbPrincipal = 0;

            foreach (Installment installment in _contract.InstallmentList)
            {
                if(installment.InterestsRepayment - installment.PaidInterests > 0)
                {
                    totalInterest += (installment.InterestsRepayment - installment.PaidInterests);
                    if (!_contract.GracePeriod.HasValue)
                    {
                        nbInterest += _contract.Product.ExoticProduct.GetExoticInstallment(installment.Number - 1).InterestCoeff.Value;
                    }
                    else if (installment.Number > _contract.GracePeriod.Value)
                    {
                        nbInterest += _contract.Product.ExoticProduct.GetExoticInstallment(installment.Number - 1 - _contract.GracePeriod.Value).InterestCoeff.Value;
                    }							
                }

                if(installment.CapitalRepayment - installment.PaidCapital > 0)
                {
                    totalPrincipal += (installment.CapitalRepayment - installment.PaidCapital);
                    if (!_contract.GracePeriod.HasValue)
                    {
                        nbPrincipal += _contract.Product.ExoticProduct.GetExoticInstallment(installment.Number - 1).PrincipalCoeff;
                    }
                    else if (installment.Number > _contract.GracePeriod.Value)
                    {
                        nbPrincipal += _contract.Product.ExoticProduct.GetExoticInstallment(installment.Number - 1 - _contract.GracePeriod.Value).PrincipalCoeff;
                    }
                }
            }

            if(AmountComparer.Compare(amountPaid,totalInterest) > 0)
            {
                amountPaid -= totalInterest;
                interestEvent += totalInterest;
                interestPrepayment += totalInterest;
                totalInterest = 0;
            }
            else
            {
                totalInterest -= amountPaid;
                interestEvent += amountPaid;
                interestPrepayment += amountPaid;
                amountPaid = 0;
            }

            if(AmountComparer.Compare(amountPaid,totalPrincipal) > 0)
            {
                amountPaid -= totalPrincipal;
                principalEvent += totalPrincipal;
                totalPrincipal = 0;
            }
            else
            {
                totalPrincipal -= amountPaid;
                principalEvent += amountPaid;
                amountPaid = 0;
            }

            if(totalInterest != 0)
                totalInterest = totalInterest / (Convert.ToDecimal(nbInterest) * 10);

            if(totalPrincipal != 0)
                totalPrincipal = totalPrincipal / (Convert.ToDecimal(nbPrincipal) * 10);

            OCurrency interestForLastInstallment = 0;
            OCurrency capitalForLastInstallment = 0;

            for (int i = 0; i < _contract.NbOfInstallments; i++)
            {
                Installment installment = _contract.GetInstallment(i);
                if(!installment.IsRepaid)
                {
                    ExoticInstallment exoticInstallment;

                    if (!_contract.GracePeriod.HasValue)
                    {
                        exoticInstallment = _contract.Product.ExoticProduct.GetExoticInstallment(i);

                        OCurrency tempInterest = Convert.ToDecimal(exoticInstallment.InterestCoeff)*totalInterest*(double)10;
                        OCurrency tempCapital = Convert.ToDecimal(exoticInstallment.PrincipalCoeff)*totalPrincipal*(double)10;

                        installment.InterestsRepayment = Math.Truncate(tempInterest.Value);
                        installment.CapitalRepayment = Math.Truncate(tempCapital.Value);

                        interestForLastInstallment += tempInterest - installment.InterestsRepayment;
                        capitalForLastInstallment += tempCapital - installment.CapitalRepayment;

                    }
                    else if (installment.Number > _contract.GracePeriod.Value)
                    {
                        exoticInstallment = _contract.Product.ExoticProduct.GetExoticInstallment(i - _contract.GracePeriod.Value);

                        OCurrency tempInterest = Convert.ToDecimal(exoticInstallment.InterestCoeff) * totalInterest * (double)10;
                        OCurrency tempCapital = Convert.ToDecimal(exoticInstallment.PrincipalCoeff) * totalPrincipal * (double)10;

                        installment.InterestsRepayment = Math.Truncate(tempInterest.Value);
                        installment.CapitalRepayment = Math.Truncate(tempCapital.Value);

                        interestForLastInstallment += tempInterest - installment.InterestsRepayment;
                        capitalForLastInstallment += tempCapital - installment.CapitalRepayment;
                    }
                    else
                    {
                        OCurrency tempInterest = 0;
                        if (totalInterest != 0)
                            tempInterest = totalPrincipal * Convert.ToDecimal(_contract.InterestRate);

                        installment.InterestsRepayment = Math.Truncate(tempInterest.Value);
                        installment.CapitalRepayment = 0;

                        interestForLastInstallment += tempInterest - installment.InterestsRepayment;
                    }
                }

                _paidInstallments.Add(installment);
            }

            Installment lastInstallment = _contract.GetInstallment(_contract.NbOfInstallments - 1);
            lastInstallment.InterestsRepayment += interestForLastInstallment;
            lastInstallment.CapitalRepayment += capitalForLastInstallment;
            lastInstallment.InterestsRepayment = lastInstallment.InterestsRepayment;
            lastInstallment.CapitalRepayment = lastInstallment.CapitalRepayment;

            lastInstallment.InterestsRepayment = Math.Round(lastInstallment.InterestsRepayment.Value, 0);
            lastInstallment.CapitalRepayment = Math.Round(lastInstallment.CapitalRepayment.Value, 0);
        }
        public void RepayNextInstallments(ref OCurrency amountPaid, ref OCurrency interestEvent, ref OCurrency interestPrepayment, ref OCurrency principalEvent, ref OCurrency feesEvent, ref OCurrency commissionsEvent)
        {			
            if(amountPaid > 0)
            {
                OCurrency totalInterest = 0;
                OCurrency totalPrincipal = 0;
                double nbInterest = 0;
                double nbPrincipal = 0;

                foreach(Installment _installment in _contract.InstallmentList)
                {
                    if(_installment.InterestsRepayment - _installment.PaidInterests > 0)
                    {
                        totalInterest += (_installment.InterestsRepayment - _installment.PaidInterests);
                        if(!_contract.GracePeriod.HasValue)
                        {
                            nbInterest += _contract.Product.ExoticProduct.GetExoticInstallment(_installment.Number - 1).InterestCoeff.Value;
                        }
                        else if(_installment.Number > _contract.GracePeriod.Value)
                        {
                            nbInterest += _contract.Product.ExoticProduct.GetExoticInstallment(_installment.Number - 1 - _contract.GracePeriod.Value).InterestCoeff.Value;
                        }							
                    }

                    if(_installment.CapitalRepayment - _installment.PaidCapital > 0)
                    {
                        totalPrincipal += (_installment.CapitalRepayment - _installment.PaidCapital);
                        if(!_contract.GracePeriod.HasValue)
                        {
                            nbPrincipal += _contract.Product.ExoticProduct.GetExoticInstallment(_installment.Number - 1).PrincipalCoeff;
                        }
                        else if(_installment.Number > _contract.GracePeriod.Value)
                        {
                            nbPrincipal += _contract.Product.ExoticProduct.GetExoticInstallment(_installment.Number - 1 - _contract.GracePeriod.Value).PrincipalCoeff;
                        }
                    }
                }

                if(AmountComparer.Compare(amountPaid,totalInterest) > 0)
                {
                    amountPaid -= totalInterest;
                    interestEvent += totalInterest;
                    interestPrepayment += totalInterest;
                    totalInterest = 0;
                }
                else
                {
                    totalInterest -= amountPaid;
                    interestEvent += amountPaid;
                    interestPrepayment += amountPaid;
                    amountPaid = 0;
                }

                if(AmountComparer.Compare(amountPaid,totalPrincipal) > 0)
                {
                    amountPaid -= totalPrincipal;
                    principalEvent += totalPrincipal;
                    totalPrincipal = 0;
                }
                else
                {
                    totalPrincipal -= amountPaid;
                    principalEvent += amountPaid;
                    amountPaid = 0;
                }

                if(totalInterest != 0)
                    totalInterest = totalInterest / (Convert.ToDecimal(nbInterest) * 10);

                if(totalPrincipal != 0)
                    totalPrincipal = totalPrincipal / (Convert.ToDecimal(nbPrincipal) * 10);

                for(int i = 0;i< _contract.NbOfInstallments;i++)
                {
                    Installment _installment = _contract.GetInstallment(i);
                    if(!_installment.IsRepaid)
                    {
                        ExoticInstallment exoticInstallment = null;

                        if(!_contract.GracePeriod.HasValue)
                        {
                            exoticInstallment = _contract.Product.ExoticProduct.GetExoticInstallment(i);
                            _installment.InterestsRepayment = Convert.ToDecimal(exoticInstallment.InterestCoeff.Value) * totalInterest *(double) 10;
                            _installment.CapitalRepayment = Convert.ToDecimal(exoticInstallment.PrincipalCoeff) * totalPrincipal * (double)10;
                        }
                        else if(_installment.Number > _contract.GracePeriod.Value)
                        {
                            exoticInstallment = _contract.Product.ExoticProduct.GetExoticInstallment(i - _contract.GracePeriod.Value);
                            _installment.InterestsRepayment = Convert.ToDecimal(exoticInstallment.InterestCoeff.Value) * totalInterest * (double)10;
                            _installment.CapitalRepayment = Convert.ToDecimal(exoticInstallment.PrincipalCoeff) * totalPrincipal * (double)10;
                        }
                        else
                        {
                            _installment.InterestsRepayment = totalInterest * Convert.ToDecimal(_contract.InterestRate);
                            _installment.CapitalRepayment = 0;
                        }
                    }
                }
            }
        }
Esempio n. 28
0
 private void bSave_Click(object sender, EventArgs e)
 {
     _entryFees = udEntryFees.Value;
     _initialAmount = nudInitialAmount.Value;
 }
Esempio n. 29
0
 private static void _AssertSpecifiedInstallment(Installment pInstallment, OCurrency pInterestRepayment, OCurrency pCapitalRepayment, OCurrency pOLB, OCurrency pPaidCapital, OCurrency pPaidInterest)
 {
     Assert.AreEqual(pInterestRepayment.Value, pInstallment.InterestsRepayment.Value);
     Assert.AreEqual(pCapitalRepayment.Value, pInstallment.CapitalRepayment.Value);
     Assert.AreEqual(pOLB.Value, pInstallment.OLB.Value);
     Assert.AreEqual(pPaidCapital.Value, pInstallment.PaidCapital.Value);
     Assert.AreEqual(pPaidInterest.Value, pInstallment.PaidInterests.Value);
 }
Esempio n. 30
0
 private static void _AssertSpecifiedInstallment(Installment pInstallment,int pNumber, DateTime pExpectedDate,OCurrency pInterestRepayment, OCurrency pCapitalRepayment,OCurrency pOLB, OCurrency pPaidCapital, OCurrency pPaidInterest)
 {
     Assert.AreEqual(pNumber, pInstallment.Number);
     Assert.AreEqual(pExpectedDate, pInstallment.ExpectedDate);
     Assert.AreEqual(pInterestRepayment.Value, pInstallment.InterestsRepayment.Value);
     Assert.AreEqual(pCapitalRepayment.Value, pInstallment.CapitalRepayment.Value);
     Assert.AreEqual(pOLB.Value, pInstallment.OLB.Value);
     Assert.AreEqual(pPaidCapital.Value, pInstallment.PaidCapital.Value);
     Assert.AreEqual(pPaidInterest.Value, pInstallment.PaidInterests.Value);
 }
Esempio n. 31
0
 static public bool Equals(OCurrency a1, OCurrency a2)
 {
     return(Math.Abs(a1.Value - a2.Value) < OcurrencyDelta.Value ? true : false);
 }