private OCurrency CalculateLateAndAnticipatedFees(DateTime pDate)
        {
            OCurrency fees = 0;
            Loan contract = _contract.Copy();
            new Repayment.RepayLateInstallments.CalculateInstallments(_cCo, contract, _user, _generalSettings,_nWds).CalculateNewInstallmentsWithLateFees(pDate);
            for (int i = 0; i < contract.NbOfInstallments; i++)
            {
                Installment installment = contract.GetInstallment(i);
                if (!installment.IsRepaid && installment.ExpectedDate <= pDate)
                {
                    fees += installment.FeesUnpaid;
                    installment.PaidCapital = installment.CapitalRepayment;
                    installment.PaidInterests = installment.InterestsRepayment;
                }
            }
            if (!_cCo.KeepExpectedInstallments)
                fees += new CalculationBaseForAnticipatedFees(_cCo, contract).CalculateFees(pDate);

            return _contract.UseCents ? Math.Round(fees.Value, 2, MidpointRounding.AwayFromZero) : Math.Round(fees.Value, 0, MidpointRounding.AwayFromZero);
        }
 public AnticipatedFeesCalculate(CreditContractOptions pCCO,Loan pContract)
 {
     _loan = pContract;
     _bTcffar = new CalculationBaseForAnticipatedFees(pCCO,pContract);
 }
        private OCurrency CalculateLateAndAnticipatedFees(DateTime pDate, int pInstallmentNumber)
        {
            OCurrency fees = 0;
            Loan contract = _contract.Copy();
            new Repayment.RepayLateInstallments.CalculateInstallments(_cCo, contract, _user, _generalSettings,_nWds).CalculateNewInstallmentsWithLateFees(pDate);

            for (int i = 0; i < contract.NbOfInstallments; i++)
            {
                Installment installment = contract.GetInstallment(i);
                if (!installment.IsRepaid && installment.ExpectedDate <= pDate && installment.Number != pInstallmentNumber) //late
                {
                    fees += installment.FeesUnpaid;
                    installment.PaidCapital = installment.CapitalRepayment;
                    installment.PaidInterests = installment.InterestsRepayment;
                }
                else if (!installment.IsRepaid && installment.ExpectedDate <= pDate && installment.Number == pInstallmentNumber) //late
                {
                    fees += installment.FeesUnpaid;
                    break;
                }
                else if(!installment.IsRepaid && installment.ExpectedDate > pDate && installment.Number != pInstallmentNumber)
                {
                    if (!_cCo.KeepExpectedInstallments)
                        fees += new CalculationBaseForAnticipatedFees(_cCo, contract).CalculateFees(pDate);
                    break;
                }
            }
            return fees;
        }