Beispiel #1
0
        public FinancialAnalysis(LoanRequest loanRequest, VAT vat)
        {
            //The loan Request contains all the necessary data
            //to calculate a Financial Analysis.
            _loanRequest = loanRequest;
            _financeUtil = new ZiblerFinanceUtilities ();

            //Establish what loans are present
            foreach (Loan existingLoan in _loanRequest.Loans)
            {
                if (existingLoan.LoanType == LoanType.CapitalDeTrabajo)
                {
                    _wrkngCptlAmrtztn = CreateAmortizationTable (existingLoan, vat);
                    _wrkngCptlLoan = existingLoan;
                    _financeUtil.AddAmortizationPaymentDates (_wrkngCptlAmrtztn.AmortizationTable,
                                                              _wrkngCptlAmrtztn.StartDate,
                                                              _wrkngCptlAmrtztn.PaymentFrequency,
                                                              Country.Mexico);
                }
                if (existingLoan.LoanType == LoanType.Refaccionario)
                {
                    _fxdAsstAmrtztn = CreateAmortizationTable (existingLoan, vat);
                    _fxdAsstLoan = existingLoan;
                    _financeUtil.AddAmortizationPaymentDates (_fxdAsstAmrtztn.AmortizationTable,
                                                              _fxdAsstAmrtztn.StartDate,
                                                              _fxdAsstAmrtztn.PaymentFrequency,
                                                              Country.Mexico);
                }
            }
        }
Beispiel #2
0
        /// <summary>
        /// Recalculates the Interest and VAT values
        /// for the local _amortization table. It takes care of
        /// loading the VAT and Interest Rate values depending
        /// on the amortization date.
        /// </summary>
        private void RecalculateInterestAndVAT(Amortization amort)
        {
            try
            {
                /* Calculate the Interest and VAT values, based on the active Interest and VAT
                * rates at the time of the amortization */
                foreach (AmortizationEntry amrtztn in amort.AmortizationTable)
                {
                    DateTime? searchDate = null;

                    /* Use the statement date to calculate the interest since the date for the
                    * amortization is in the future */
                    bool useStmntDate =
                    DateUtilities.IsFirstDateGreaterThanSecondDate (amrtztn.Date,
                                                                    Convert.ToDateTime (_stmntDate));

                    if (useStmntDate)
                        searchDate = _stmntDate;
                    else
                        searchDate = amrtztn.Date;

                    decimal intrstRtVl = GetInterestRateValue (Convert.ToDateTime (searchDate));
                    decimal vatValue = GetVATValue (Convert.ToDateTime (searchDate));
                    decimal grssErngsMrgn = _loan.GrossEarningsMargin;

                    /* Add the gross earnings margin */
                    intrstRtVl = intrstRtVl + grssErngsMrgn;

                    amort.RecalculateAmortization (amrtztn.Number, intrstRtVl, vatValue);
                }
            }
            /* If the exception was thrown here, just pass it up */
            catch (ZiblerBusinessComponentsException ex)
            {
                throw;
            }
            /* Catch any Data Layer or other exception and throw an unkown exception */
            catch (Exception ex)
            {
                ZiblerBusinessComponentsUnknownException exc
                = new ZiblerBusinessComponentsUnknownException (ex);

                /* Throw the new exception */
                throw exc;
            }
        }
Beispiel #3
0
        /// <summary>
        /// Creates the amortization table. This function takes every amortization and
        /// calculates the payment based on the current Interest and VAT values.
        /// </summary>
        private void CreateAmortizationTable(ref Amortization amort)
        {
            try
            {
                AmortizationFactory amrtztnFctry = new AmortizationFactory ();

                amort = amrtztnFctry.CreateAmortization (_loan.AmortizationTableType,
                                                         _loan.LoanedAmount,
                                                         _loan.NumberOfAmortizations,
                                                         _loan.PaymentFrequency,
                                                         0.0m,
                                                         _loan.GracePeriod,
                                                         Convert.ToDateTime (_loan.StartDate),
                                                         0.0m);

                //Calculate the amortization.
                amort.CalculateAmortizationTable ();

                //Add the dates
                _financeUtil.AddAmortizationPaymentDates (amort.AmortizationTable,
                                                          amort.StartDate,
                                                          amort.PaymentFrequency,
                                                          Country.Mexico);
            }
            /* If the exception was thrown here, just pass it up */
            catch (ZiblerBusinessComponentsException ex)
            {
                throw;
            }
            /* Catch any Data Layer or other exception and throw an unkown exception */
            catch (Exception ex)
            {
                ZiblerBusinessComponentsUnknownException exc
                = new ZiblerBusinessComponentsUnknownException (ex);

                /* Throw the new exception */
                throw exc;
            }
        }