Beispiel #1
0
        } // TestPayments

        static void Main(string[] args)
        {
            SchemeResult schemeResult = new SchemeResult("ABC", new CoverSection("PRIMARY", 100.0));

            schemeResult.AddCoverSection(new CoverSection("COV1", 10.0));
            schemeResult.AddCoverSection(new CoverSection("COV2", 20.0));
            schemeResult.AddCoverSection(new CoverSection("COV3", 30.0));

            //// Test duplicate Cover Section exception
            //try
            //{
            //    schemeResult.AddCoverSection(new CoverSection("COV3", 40.0));
            //}
            //catch (Exception eek)
            //{
            //    Console.WriteLine(eek.Message);
            //}

            Console.WriteLine();
            Console.WriteLine("Scheme {0} : Premium {1}", schemeResult.Code, schemeResult.TotalPremium);
            Console.WriteLine();
            Console.WriteLine("Primary Cover Section {0} : Full Premium = {1}", schemeResult.PrimaryCoverSection.Code, schemeResult.PrimaryCoverSection.Premium);
            foreach (CoverSection coverSectionOriginal in schemeResult.AdditionalCoverSectionContainer)
            {
                Console.WriteLine("    Additional Cover Section {0} : Full Premium {1}", coverSectionOriginal.Code, coverSectionOriginal.Premium);
            }

            TestPayments(schemeResult, 11);
            TestPayments(schemeResult, 12);
        }
        private async Task <Scheme?> GetSchemeAsync(Type matchingType, MethodInfo matchingMethod)
        {
            foreach (ISchemeMapper schemeMapper in _schemeMappers)
            {
                SchemeResult result = await schemeMapper.MapAsync(matchingType, matchingMethod);

                if (result.ResultType == SchemeResultType.SchemeMapped)
                {
                    return(result.Scheme);
                }
            }

            return(null);
        }
Beispiel #3
0
        } // SchemeResult

        static void TestPayments(SchemeResult schemeResult, int instalmentCount)
        {
            schemeResult.CalculateMonthlyPaymentPremiums(instalmentCount);

            Console.WriteLine();
            Console.WriteLine("Total premium = {0}", schemeResult.TotalPremium.ToString("F2"));
            Console.WriteLine("Number of instalments = {0}", schemeResult.InstalmentCount);
            Console.WriteLine("Deposit = {0}", schemeResult.Deposit.ToString("F2"));
            Console.WriteLine("Total calculated loan = {0}", schemeResult.TotalCalculatedLoan.ToString("F2"));
            Console.WriteLine("Monthly payment = {0}", schemeResult.MonthlyPayment.ToString("F2"));
            Console.WriteLine("Total payments = {0}", schemeResult.MonthlyPayment * schemeResult.InstalmentCount);
            Console.WriteLine("Total Cover Section Annual Payments = {0}", schemeResult.TotalAnnualPayment.ToString("F2"));
            Console.WriteLine("Total payments including deposit = {0}", (schemeResult.TotalAnnualPayment + schemeResult.Deposit).ToString("F2"));
            Console.WriteLine("Difference of Total payments (including deposit) and Premium is {0}",
                              (schemeResult.TotalAnnualPayment + schemeResult.Deposit - schemeResult.TotalPremium).ToString("F2"));
            Console.WriteLine();
            Console.WriteLine("Primary Cover Section {0} : Full Premium = {1}, Payment per month = {2}",
                              schemeResult.PrimaryCoverSection.Code,
                              schemeResult.PrimaryCoverSection.Premium.ToString("F2"),
                              schemeResult.PrimaryCoverSection.MonthlyPayment.ToString("F2"));
            Console.WriteLine("Total payment difference from calculated loan = {0}", schemeResult.TotalPaymentDifferenceFromCalculatedLoan.ToString("F2"));
            double totalCoverSectionPayment = schemeResult.PrimaryCoverSection.MonthlyPayment * instalmentCount;

            foreach (CoverSection coverSection in schemeResult.AdditionalCoverSectionContainer)
            {
                Console.WriteLine("    Cover Section {0} : Full Premium = {1}, Payment per month = {2}",
                                  coverSection.Code,
                                  coverSection.Premium.ToString("F2"),
                                  coverSection.MonthlyPayment.ToString("F2"));
                totalCoverSectionPayment += coverSection.MonthlyPayment * instalmentCount;
            }
            double totalPaymentsWithMultiplePaymentCorrection = totalCoverSectionPayment + schemeResult.MultiplePaymentCorrection;

            Console.WriteLine("Total Cover Section payment made = {0}. Correction = {1}. Total = {2}",
                              totalCoverSectionPayment,
                              schemeResult.MultiplePaymentCorrection.ToString("F2"),
                              totalPaymentsWithMultiplePaymentCorrection.ToString("F2"));
            if (Math.Abs(totalPaymentsWithMultiplePaymentCorrection - (schemeResult.MonthlyPayment * schemeResult.InstalmentCount)) < 1.0e-6)
            {
                Console.WriteLine("     Corrected total of Cover Section Payments agrees with total payments");
            }
            else
            {
                Console.WriteLine("**** Corrected total of Cover Section Payments {0} does not agree with total payments {1}",
                                  totalPaymentsWithMultiplePaymentCorrection, schemeResult.MonthlyPayment * schemeResult.InstalmentCount);
            }
            Console.WriteLine("Total Cover Section payment plus deposit = {0}", schemeResult.Deposit + schemeResult.TotalAnnualPayment);
        } // TestPayments