Esempio n. 1
0
        // Returns Dictionary containing enriched financial-table information: debt income ratio, debt income ratio rating, insurance rating, mortgage rating, and utility rating
        public static Dictionary <String, String> Process(Dictionary <String, String> results, Newtonsoft.Json.Linq.JObject data)
        {
            double monthlyIncome = Enrich.RemoveDollarSignComma(data["totalMonthlyIncome"]);

            results.Add("debtIncomeRatio", ComputeDebtIncomeRatio(data, monthlyIncome));
            results.Add("debtIncomeRatioRating", RateDebtIncomeRatio(data, monthlyIncome));
            results.Add("insuranceRating", RateInsurance(data, monthlyIncome));
            results.Add("utilityRating", RateUtility(data, monthlyIncome));
            results.Add("mortgageRating", RateMortgage(data, monthlyIncome));
            return(results);
        }
Esempio n. 2
0
        // Returns letter rating representing the percentage of monthly income spent on mortgage/rent: A: <10%, B: 10-20%, C: 20-24%, D: 24-28%, F: >28%
        public static string RateMortgage(Newtonsoft.Json.Linq.JObject data, double monthlyIncome)
        {
            double mortgage = Enrich.RemoveDollarSignComma(data["mortgageOrRent"]);

            if (mortgage == -1 || monthlyIncome == -1)
            {
                return(null);
            }
            double percentage = mortgage / monthlyIncome;

            return(rate(percentage * 100, 10, 20, 24, 28));
        }
Esempio n. 3
0
        // Returns letter rating representing the percentage of monthly income spent on utilities: A: <2%, B: 2-5%, C: 5-8%, D: 8-10%, F: >10%
        public static string RateInsurance(Newtonsoft.Json.Linq.JObject data, double monthlyIncome)
        {
            double insurance = Enrich.RemoveDollarSignComma(data["insuranceSubtotal"]);

            if (insurance == -1 || monthlyIncome == -1)
            {
                return(null);
            }
            double percentage = insurance / monthlyIncome;

            return(rate(percentage * 100, 2, 3, 4, 5));
        }
Esempio n. 4
0
        // Returns debt to income ratio: debt includes total amount of monthly income spent on loans/mortage/rent
        public static string ComputeDebtIncomeRatio(Newtonsoft.Json.Linq.JObject data, double monthlyIncome)
        {
            double loanTotal = Enrich.RemoveDollarSignComma(data["loansSubtotal"]);
            double mortgage  = Enrich.RemoveDollarSignComma(data["mortgageOrRent"]);

            if (loanTotal == -1 || mortgage == -1 || monthlyIncome == -1)
            {
                return(null);
            }
            double debtRatio = (loanTotal + mortgage) / monthlyIncome;

            return(debtRatio.ToString().Substring(0, 4));
        }
Esempio n. 5
0
        // Returns letter rating representing the percentage of monthly income spent on utilities: A: <2%, B: 2-5%, C: 5-8%, D: 8-10%, F: >10%
        public static string RateUtility(Newtonsoft.Json.Linq.JObject data, double monthlyIncome)
        {
            double phone       = Enrich.RemoveDollarSignComma(data["phone"]);
            double electricity = Enrich.RemoveDollarSignComma(data["electricity"]);

            if (phone == -1 || electricity == -1 || monthlyIncome == -1)
            {
                return(null);
            }
            double percentage = (phone + electricity) / monthlyIncome;

            return(rate(percentage * 100, 2, 5, 8, 10));
        }
Esempio n. 6
0
        // Returns disposable income: yearly compensation - federal tax - socail security tax - medicare tax
        public static string ComputeDisposableIncome(Newtonsoft.Json.Linq.JObject data)
        {
            double compensation             = Enrich.RemoveDollarSignComma(data["compensation"]);
            double federalIncomeTaxWithheld = Enrich.RemoveDollarSignComma(data["federalIncomeTaxWithheld"]);
            double ssTaxWithheld            = Enrich.RemoveDollarSignComma(data["ssTaxWithheld"]);
            double medicareTaxWithheld      = Enrich.RemoveDollarSignComma(data["medicareTaxWithheld"]);

            if (compensation == -1 || federalIncomeTaxWithheld == -1 || ssTaxWithheld == -1 || medicareTaxWithheld == -1)
            {
                return(null);
            }
            double disposableIncome = compensation - federalIncomeTaxWithheld - ssTaxWithheld - medicareTaxWithheld;

            return(disposableIncome.ToString());
        }