def calculate(self) -> DeductionResult:
        explanation = [
            f"Next, we deduct dependent care costs: ${self.dependent_care_costs}."
        ]

        return DeductionResult(
            result=self.dependent_care_costs,
            explanation=explanation
        )
    def calculate(self) -> DeductionResult:
        earned_income_deduction = round(0.2 * self.monthly_job_income)
        explanation = [
            ("Next, we add the earned income deduction. " +
             f"This is equal to 20% of income from jobs or self-employment: "),
            (''),
            (f"${self.monthly_job_income} x 0.2 = " +
             f"${earned_income_deduction} earned income deduction")
        ]

        return DeductionResult(result=earned_income_deduction,
                               explanation=explanation)
    def calculate(self) -> DeductionResult:
        if self.child_support_payments_treatment != 'DEDUCT':
            return DeductionResult(
                result=0,
                explanation=[
                    'Court-ordered child support payments are not deductible in this state.'
                ])

        if self.court_ordered_child_support_payments == 0:
            return DeductionResult(
                result=0,
                explanation=[
                    'This household does not make monthly court-ordered ' +
                    'child support payments, so the child-support payment ' +
                    'deduction does not apply.'
                ])

        return DeductionResult(
            result=(self.court_ordered_child_support_payments),
            explanation=[
                "Next, we deduct the monthly cost of court-ordered " +
                f"child support payments: ${self.court_ordered_child_support_payments}."
            ])
Beispiel #4
0
    def calculate(self) -> DeductionResult:
        explanation = [
            "Next, deduct monthly medical expenses for elderly or disabled household members beyond $35. "
        ]

        if not self.household_includes_elderly_or_disabled:
            explanation.append(
                "In this case, there are no elderly or disabled members of " +
                "the household, so the deduction does not apply. ")

            return DeductionResult(result=0, explanation=explanation)

        if self.medical_expenses_for_elderly_or_disabled == 0:
            explanation.append(
                "In this case, there are no monthly medical expenses to deduct. "
            )

            return DeductionResult(result=0, explanation=explanation)

        if 35 > self.medical_expenses_for_elderly_or_disabled:
            explanation.append(
                "In this case, medical expenses are below the $35 monthly threshold for deduction. "
            )

            return DeductionResult(result=0, explanation=explanation)

        medical_expenses_deduction = self.medical_expenses_for_elderly_or_disabled - 35
        explanation.append(
            "The medical expenses deduction is equal to monthly medical expenses "
            + "beyond $35.")
        explanation.append('')
        explanation.append(
            f"${self.medical_expenses_for_elderly_or_disabled} - $35 = " +
            f"${medical_expenses_deduction} medical expenses deduction")

        return DeductionResult(result=medical_expenses_deduction,
                               explanation=explanation)
    def calculate(self) -> DeductionResult:
        deductions_api = FetchStandardDeductions(
            state_or_territory=self.state_or_territory,
            household_size=self.household_size,
            standard_deductions=self.standard_deductions,
            fiscal_year=2020)

        standard_deduction = deductions_api.standard_deduction()

        standard_deduction_pdf_url = 'https://fns-prod.azureedge.net/sites/default/files/media/file/FY20-Maximum-Allotments-Deductions.pdf'
        explanation = [
            "\nNext, we need to take into account deductions. " +
            f"We start with a standard deduction of ${standard_deduction}. " +
            f"<a class='why why-small' href='{standard_deduction_pdf_url}' target='_blank'>why?</a>"
        ]

        return DeductionResult(result=standard_deduction,
                               explanation=explanation)
    def calculate(self) -> DeductionResult:
        explanation = [
            "Next, deduct monthly medical expenses for elderly or disabled household members beyond $35. "
        ]

        if not self.household_includes_elderly_or_disabled:
            explanation.append(
                "In this case, there are no elderly or disabled members of " +
                "the household, so the deduction does not apply. ")

            return DeductionResult(result=0, explanation=explanation)

        if self.medical_expenses_for_elderly_or_disabled == 0:
            explanation.append(
                "In this case, there are no monthly medical expenses to deduct. "
            )

            return DeductionResult(result=0, explanation=explanation)

        if 35 >= self.medical_expenses_for_elderly_or_disabled:
            explanation.append(
                "In this case, medical expenses are below the $35 monthly threshold for deduction. "
            )

            return DeductionResult(result=0, explanation=explanation)

        if self.standard_medical_deduction is True:
            standard_medical_deduction_amount = self.standard_medical_deduction_amount
            medical_expenses = self.medical_expenses_for_elderly_or_disabled

            expenses_above_standard = medical_expenses > (
                standard_medical_deduction_amount + 35)

            if expenses_above_standard:
                medical_expenses_deduction = medical_expenses - 35

                explanation.append(
                    f"Medical expenses are greater than the Standard Medical Deduction amount of ${standard_medical_deduction_amount}. "
                    +
                    f"In this case, the full medical expense amount less $35 can be deducted, which comes to ${medical_expenses_deduction}. "
                )

                return DeductionResult(result=medical_expenses_deduction,
                                       explanation=explanation)
            else:
                explanation.append(
                    f"This state has a Standard Medical Deduction amount of ${standard_medical_deduction_amount}. "
                )

                return DeductionResult(
                    result=standard_medical_deduction_amount,
                    explanation=explanation)

        medical_expenses_deduction = self.medical_expenses_for_elderly_or_disabled - 35
        explanation.append(
            "The medical expenses deduction is equal to monthly medical expenses "
            + "beyond $35.")

        explanation.append('')
        explanation.append(
            f"${self.medical_expenses_for_elderly_or_disabled} - $35 = " +
            f"${medical_expenses_deduction} medical expenses deduction")

        return DeductionResult(result=medical_expenses_deduction,
                               explanation=explanation)
    def calculate(self) -> DeductionResult:
        explanation = [
            'Next, we calculate the Excess Shelter Deduction. To calculate ' +
            'this deduction, we need to find half of the household adjusted income. '
            +
            'Adjusted income is equal to gross income, minus all deductions calculated '
            + 'up to this point.'
        ]

        half_adjusted_income = round(self.adjusted_income / 2)

        half_adjusted_income_explanation = (
            f"For this household, adjusted income is ${self.adjusted_income} "
            + f"and half of adjusted income is ${half_adjusted_income}.")
        explanation.append(half_adjusted_income_explanation)

        shelter_costs_explanation = (
            'Next, add up shelter costs by adding any costs of rent, mortgage '
            +
            'payments, homeowners insurance and property taxes, and utility costs. '
            + "Let's start with everything except utilities:")
        explanation.append(shelter_costs_explanation)

        base_shelter_costs = self.rent_or_mortgage + self.homeowners_insurance_and_taxes

        shelter_costs_math_explanation = (
            f"${self.rent_or_mortgage} rent or mortgage + " +
            f"${self.homeowners_insurance_and_taxes} homeowners insurance and taxes = "
            + f"${base_shelter_costs}")
        explanation.append(shelter_costs_math_explanation)

        # Handle utilities:
        start_utilities_explanation = ("Now let's factor in utility costs.")
        explanation.append(start_utilities_explanation)

        if self.mandatory_standard_utility_allowances:
            if self.utility_allowance is None or self.utility_allowance == 'NONE':
                # In this case the client has either:
                #
                # * Explicitly told us the end user does not qualify for a
                # standard utility allowance ("NONE"), or,
                #
                # * The client has left the field blank (None); we assume that
                # the end user does not pay for utilities separately and
                # for that reason does not receive a SUA deduction:
                #
                shelter_costs = base_shelter_costs
                utilities_explanation = (
                    'In this case there is no deduction for utilities, likely '
                    +
                    'because the household is not billed separately for utilities.'
                )
            else:
                utility_allowance_amount = self.standard_utility_allowances[
                    self.utility_allowance]
                shelter_costs = base_shelter_costs + utility_allowance_amount
                utilities_explanation = (
                    f"In this case, a standard utility deduction of ${utility_allowance_amount} applies, "
                    +
                    f"so total shelter plus utilities costs come to ${shelter_costs}."
                )
        else:
            shelter_costs = base_shelter_costs + self.utility_costs
            utilities_explanation = (
                f"In this case, the household has utility costs of ${self.utility_costs}, "
                +
                f"so total shelter plus utilities costs come to ${shelter_costs}."
            )

        explanation.append(utilities_explanation)

        # If shelter costs are less than half of adjusted income, no deduction applied.
        if half_adjusted_income > shelter_costs:
            explanation.append(
                'In this case, shelter costs do not exceed half of adjusted income, '
                + 'so the excess shelter deduction does not apply.')

            return DeductionResult(result=0, explanation=explanation)

        raw_deduction_amount = shelter_costs - half_adjusted_income

        excess_shelter_costs_math_intro = (
            'Subtract half of adjusted income from shelter costs to find ' +
            'the base deduction amount:')
        explanation.append(excess_shelter_costs_math_intro)

        excess_shelter_costs_math_explanation = (
            f"${shelter_costs} shelter costs - " +
            f"${half_adjusted_income} half of adjusted income = " +
            f"${raw_deduction_amount} base deduction")
        explanation.append(excess_shelter_costs_math_explanation)

        # If household includes elderly or disabled person, no limit on
        # the amount of the excess shelter deduction.
        if self.household_includes_elderly_or_disabled:
            deduction_amount = raw_deduction_amount
            explanation.append(
                'Because the household includes an elderly or disabled household '
                +
                'member, there is no limit to the excess shelter deduction ' +
                f"amount, so the full deduction amount of ${deduction_amount} applies."
            )

            return DeductionResult(result=deduction_amount,
                                   explanation=explanation)

        # If household does not include an elderly or disabled person,
        # check to see if the deduction amount would be above the limit.
        deductions_api = FetchMaxShelterDeductions(
            state_or_territory=self.state_or_territory,
            household_size=self.household_size,
            max_shelter_deductions=self.max_shelter_deductions,
            fiscal_year=2020)

        maximum_shelter_deduction = deductions_api.maximum_shelter_deduction()

        if raw_deduction_amount > maximum_shelter_deduction:
            explanation.append(
                'In this case, the household has a maximum excess shelter ' +
                f"deduction of ${maximum_shelter_deduction}, so the maximum " +
                'deduction amount applies.')

            return DeductionResult(result=maximum_shelter_deduction,
                                   explanation=explanation)

        # Finally, handle case where household does not include an elderly or
        # disabled person and the deduction amount does not exceed the limit.
        deduction_amount = raw_deduction_amount

        return DeductionResult(result=deduction_amount,
                               explanation=explanation)