{"id": ["None", "3"], "use_py": ["None", "False"], "based_on": ["None", "taxable_gross_pay"], "contracts": ["None", "payroll.Contract.None"], "is_active": ["None", "True"], "created_at": ["None", "2025-06-21 08:42:34.764000"], "created_by": ["None", "1"], "description": ["None", ""], "modified_by": ["None", "1"], "python_code": ["None", "\"\"\"\nfederal_tax.py\n\"\"\"\n\nYEARLY_TAXABLE_INCOME = 189000.52\n\n\ndef calcluate_federal_tax(yearly_income: int, **kwargs) -> float:\n    \"\"\"\n    Federal Tax calculation method\n\n    yearly_income: The early converted 'based on' amount\n\n    eg: yearly_income-> 189000 then taxable_amount-> 39312.0 (yearly)\n    \"\"\"\n\n    def filter_brackets(brackets: list) -> list:\n        \"\"\"\n        This method to filter out the actual brackets/brackets range\n        \"\"\"\n        # brackets that contains actual bracket range, calculated_rate, and diff amount\n        filterd_brackets = []\n        for bracket in brackets:\n            if bracket[\"max\"] > bracket[\"min\"]:\n\n                # bracket: {'rate': 12, 'min': 11000, 'max': 44725}\n\n                # finding diff amount and adding to the bracket\n                bracket[\"diff\"] = bracket[\"max\"] - bracket[\"min\"]\n                # find bracket rate from the difference and adding to bracket\n                bracket[\"calculated_rate\"] = (bracket[\"rate\"] / 100) * bracket[\"diff\"]\n\n                # bracket: {'rate': 12, 'min': 11000, 'max': 44725, 'diff': 33725, 'calculated_rate': 4047.0}\n\n                filterd_brackets.append(bracket)\n                continue\n            # returning valid filtered brackets\n            return filterd_brackets\n        # returning valid filtered brackets\n        return filterd_brackets\n\n    # filter_brackets method/function will sort out the brackets\n\n    # for example for the 189000 yearly income come in the 32% group,\n    # so the final the max considered as min(231250,189000) which is 189000\n    brackets = [\n        {\"rate\": 10, \"min\": 0, \"max\": min(11000, yearly_income)},\n        {\"rate\": 12, \"min\": 11000, \"max\": min(44725, yearly_income)},\n        {\"rate\": 22, \"min\": 44725, \"max\": min(95375, yearly_income)},\n        {\"rate\": 24, \"min\": 95375, \"max\": min(182100, yearly_income)},\n        {\"rate\": 32, \"min\": 182100, \"max\": min(231250, yearly_income)},\n        {\"rate\": 35, \"min\": 231250, \"max\": min(578125, yearly_income)},\n        {\"rate\": 37, \"min\": 578125, \"max\": max(578125, yearly_income)},\n    ]\n\n    # filtering the brackets to actual range\n    brackets = filter_brackets(brackets=brackets)\n\n    # finding yearly taxable amount\n    taxable_amount = sum(bracket[\"calculated_rate\"] for bracket in brackets)\n\n    \"\"\"\n    use formated_result method to print the table\n    \"\"\"\n    # formated_result(brackets=brackets, taxable_amount=taxable_amount)\n\n    # returning the taxable amount later on the yearly taxable amount-\n    # is converted to daily and calculate federal tax for the total days between the\n    # Payslip period\n    return taxable_amount\n\n\ndef formated_result(brackets: dict, taxable_amount: float) -> None:\n    \"\"\"\n    It will print the brackets such a formated way\n    \"\"\"\n    col_width = 7\n    print(\"----------------------Brackets----------------------\")\n    print(\n        f\"|{'Rate':<{col_width}}  |{'Min':<{col_width}} |{'Max':<{col_width}}  |{'Taxable':<{col_width}}  |{'Bracket Tax':<{col_width}} |\"\n    )\n\n    for bracket in brackets:\n        print(\n            f\"|{bracket['rate']:<{col_width}}% |{bracket['min']:<{col_width}} | {bracket['max']:<{col_width}} | {bracket['diff']:<{col_width}} | {round(bracket['calculated_rate'],2):<{col_width + 3}} |\"\n        )\n\n    print(f\"|             YEARLY TAXABLE INCOME    | {taxable_amount}    |\")\n    print(\"----------------------------------------------------\")\n\n\nmonth_taxable = calcluate_federal_tax(YEARLY_TAXABLE_INCOME)\nprint(\"YEARLY TAXABLE AMOUNT\", month_taxable)"], "filing_status": ["None", "Married Filing Jointly (MFJ)"]}