public OCurrency CalculateMaximumAmountToRegradingLoan(DateTime pDate)
        {
            OCurrency amount = 0;

            //capital
            amount += _contract.CalculateActualOlb(pDate);

            //interest
            if (_cCo.CancelInterests)
            {
                amount += _cCo.ManualInterestsAmount;
            }
            else
            {
                amount += _contract.CalculateRemainingInterests(pDate);
            }

            //fees
            if (_cCo.CancelFees)
            {
                amount += _cCo.ManualFeesAmount;
                amount += _cCo.ManualCommissionAmount;
            }
            else
            {
                amount += _CalculateLateAndAnticipatedFees(pDate);
            }

            int decimalPoint = _contract.UseCents ? _generalSettings.InterestRateDecimalPlaces : 0;

            return(Math.Round(amount.Value, decimalPoint, MidpointRounding.AwayFromZero));
        }
        public OCurrency CalculateMaximumAmountAuthorizedToRepay(DateTime pDate)
        {
            OCurrency amount = 0;

            //capital
            amount += _contract.CalculateActualOlb();

            //interest
            if (_cCo.CancelInterests)
            {
                amount += _cCo.ManualInterestsAmount;
            }

            else
            {
                //calculate Remaining Interests when loan is calculated on it
                if (_cCo.LoansType == OLoanTypes.Flat && !_cCo.KeepExpectedInstallments)
                {
                    amount += _contract.CalculateRemainingInterests(pDate);
                }
                else if (_cCo.LoansType != OLoanTypes.Flat && _cCo.LoansType != OLoanTypes.DecliningFixedPrincipal &&
                         !_cCo.KeepExpectedInstallments)
                {
                    amount += _contract.CalculateRemainingInterests(pDate);
                }
                else
                {
                    if (_cCo.LoansType == OLoanTypes.DecliningFixedPrincipal && !_cCo.KeepExpectedInstallments)
                    {
                        DateTime?installmentDate = null;

                        foreach (Installment installment in _contract.InstallmentList)
                        {
                            if (!installment.IsRepaid && installmentDate == null &&
                                (installment.ExpectedDate - pDate).Days > 0)
                            {
                                installmentDate = installment.ExpectedDate;
                            }
                        }

                        if (installmentDate > pDate)
                        {
                            amount += _contract.CalculateRemainingInterests(pDate);
                        }
                        else
                        {
                            amount += _contract.CalculateRemainingInterests();
                        }
                    }
                    else
                    {
                        amount += _contract.CalculateRemainingInterests();
                    }
                }
            }

            //commission
            if (_cCo.CancelFees)
            {
                amount += _cCo.ManualFeesAmount;
                amount += _cCo.ManualCommissionAmount;
            }
            else
            {
                amount += CalculateLateAndAnticipatedFees(pDate);
            }

            int decimalPoint = _contract.UseCents ? _generalSettings.InterestRateDecimalPlaces : 0;

            return(Math.Round(amount.Value, decimalPoint, MidpointRounding.AwayFromZero));
        }
Exemplo n.º 3
0
 public OCurrency BaseToCalculateFees(DateTime pDate)
 {
     return((_contract.CalculateRemainingInterests().Value - _contract.CalculateRemainingInterests(pDate).Value) * Convert.ToDecimal(_contract.AnticipatedTotalRepaymentPenalties));
 }