-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
275 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
version: "3" | ||
services: | ||
api: | ||
build: . | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
|
||
from helpers import functions | ||
from fastapi import HTTPException, status | ||
|
||
|
||
def interest_coverage_ratio_task(revenue:float, cost_of_goods_services:float, operating_expenses:float, interest_expense:float): | ||
try: | ||
EBIT = revenue - cost_of_goods_services - operating_expenses | ||
ratio = functions.interest_coverage_ratio(revenue, cost_of_goods_services, operating_expenses, interest_expense) | ||
return{ | ||
"Tag": "Interest Coverage Ratio", | ||
"Revenue": revenue, | ||
"Cost of Goods and Services": cost_of_goods_services, | ||
"Operating Expenses": operating_expenses, | ||
"Interest Expenses": interest_expense, | ||
"Earnings Before Interest and Taxes": EBIT, | ||
"Interest Coverage Ratio": f"{ratio}%", | ||
} | ||
|
||
except: | ||
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
from helpers import functions | ||
from fastapi import HTTPException, status | ||
|
||
|
||
def margin_of_safety_task(current_sales:float, break_even_point: float): | ||
try: | ||
margin = functions.margin_of_safety (current_sales, break_even_point) | ||
return{ | ||
"Tag": "Margin Of Safety", | ||
"Current Sales": current_sales, | ||
"Break Even Point": break_even_point, | ||
"Margin Of Safety": f"{margin}%", | ||
} | ||
except: | ||
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
from helpers import functions | ||
from fastapi import HTTPException, status | ||
|
||
def tax_bracket_calculator(income: float, filing_status: str,): | ||
try: | ||
""" | ||
Calculate the applicable tax bracket and tax liability based on a user's income and tax filing status (United States, 2021 tax brackets for single filers). | ||
Parameters: | ||
income (float): The user's total income. | ||
filing_status (str): The user's tax filing status ('single', 'married_joint', 'married_separate', 'head_of_household'). | ||
Returns: | ||
dict: A dictionary containing the applicable tax bracket and tax liability. | ||
- 'Tax Bracket': The user's applicable tax bracket as a percentage. | ||
- 'Tax Liability': The calculated tax liability amount. | ||
""" | ||
# Tax brackets and their corresponding tax rates (United States, 2021 tax brackets for single filers) | ||
tax_brackets = { | ||
0: 0.10, | ||
9875: 0.12, | ||
40125: 0.22, | ||
85525: 0.24, | ||
163300: 0.32, | ||
207350: 0.35, | ||
518400: 0.37, | ||
} | ||
|
||
# Find the applicable tax bracket and calculate the tax liability | ||
tax_liability = 0 | ||
remaining_income = income | ||
|
||
for bracket, tax_rate in tax_brackets.items(): | ||
if remaining_income <= bracket: | ||
tax_liability += remaining_income * tax_rate | ||
break | ||
else: | ||
taxable_income_in_bracket = bracket - max(0, income - remaining_income) | ||
tax_liability += taxable_income_in_bracket * tax_rate | ||
remaining_income -= taxable_income_in_bracket | ||
|
||
return { | ||
"Tag": "Accrued Interest", | ||
'Tax Bracket': "{:.2%}".format(tax_rate), | ||
'Tax Liability': tax_liability, | ||
} | ||
except: | ||
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) |
Oops, something went wrong.