Example #1
0
        public CalculatePaymentResponse CalculatePayment(CalculatePaymentRequest req)
        {
            var res = new CalculatePaymentResponse();

            try
            {
                using (var container = new TransactionModelContainer())
                {
                    var payment = new Payment("SystemService", -1,
                                              req.CustomerName, "CARPASS", req.PaymentItems.CreatePaymentItems());

                    res.CustomerName              = payment.CustomerName;
                    res.GrandTotal                = payment.GrandTotal();
                    res.RemainingAmount           = payment.RemainingAmount();
                    res.TotalVatAmount            = payment.TotalVat();
                    res.TotalWithholdingTaxAmount = payment.TotalWithholdingTax();
                    res.TotalBeforeAdjustment     = payment.TotalNoDiscount();
                    res.TotalAdjustment           = payment.TotalDiscount();
                    res.PaymentItems              = payment.PaymentItems.CreateCalculatePaymentItems();

                    res.Succeed();
                }
            }
            catch (Exception ex)
            {
                res.Fail(ex);
                CreateLog(ex);
            }
            return(res);
        }
Example #2
0
        // ------------------------------------------------

        public CalculatePaymentResponse CalculatePayment(CalculatePaymentRequest req)
        {
            var retVal = new CalculatePaymentResponse();

            // --------------------------------------------------------
            // plug the values from the input into the mortgage formula

            var payment = (req.LoanAmount - req.DownPayment) * (Math.Pow((1 + req.InterestRate / 12), req.NumberOfPayments) * req.InterestRate) / (12 * (Math.Pow((1 + req.InterestRate / 12), req.NumberOfPayments) - 1));

            // ----------------------------------------------------
            // add on a monthly property tax and property insurance

            payment = payment + ((req.AnnualTax + req.AnnualInsurancePmt) / 12);

            // --------------------------------------------------------
            // place the monthly payment calculated into the temp field

            retVal.PaymentAmount = Math.Round((decimal)payment, 2);

            return(retVal);
        }