Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PPF calculator #458

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ The initial price of the product or service. |
| POST /margin_of_safety | Calculate margin of safety | - `current_sales` (float): The amount of current sales. |
| | | - `break_even_point` (float): The break_even_point amount. |
|--------------------------- ---|----------------------------------------|---------------------------------------------------------|
| GET /ppf_calculator | Calculate Public Provident Fund(PPF) | - `depos` (int): Annual Deposit. |
| | | - `tenure` (int): Total years of investment. |
| | | - `interest` (float): percentage interest rate. |
22 changes: 20 additions & 2 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2289,6 +2289,7 @@ Sample Output
}
```


**POST** `/saving_goal `

- Request body : `{
Expand All @@ -2305,8 +2306,6 @@ Sample Output
"months_required": 18,
"total_contributions": 3600,
"interest_earned": 315.27777777777777
}
```

**POST** `/interest_coverage_ratio`

Expand Down Expand Up @@ -2362,3 +2361,22 @@ Sample Output
"Margin Of Safety": 8%,
}
```


**POST** `/ppf_calculator`

- Request body : `{
"depos": 500,
"tenure": 15,
"interest": 7.1
}`

- Sample Output

```py
"Tag": "PPF Calcultor",
"Amount Anually deposited": 500,
"No. of Years": 15,
"percentage interst Rate": 7.1,
"Total Value of PPF": "13560"
}
8 changes: 8 additions & 0 deletions helpers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2112,3 +2112,11 @@ def tax_bracket_calculator(income:float, filing_status:str):
def margin_of_safety(current_sales:float, break_even_point: float):
margin = ((current_sales - break_even_point) / current_sales) * 100
return margin

# Function to Calculate PPF
def ppf_calculator(depos:int,
tenure:int,
interest:float):
a=1+interest/100
total_value= depos*(((a**tenure) - 1)/(interest/100))*a
return total_value
15 changes: 15 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@
from tasks.interest_coverage_ratio import interest_coverage_ratio_task
from tasks.tax_bracket_calculator import tax_bracket_calculator
from tasks.margin_of_safety import margin_of_safety_task
from tasks.PPFCalculator import ppf_calculator

# Creating the app
app = FastAPI(
Expand Down Expand Up @@ -279,7 +280,9 @@ def index():
"/modified_internal_rate_of_return": "Calculate modified internal rate of return",
"/interest_coverage_ratio": "Calculates interest coverage ratio",
"/margin_of_safety": "Calculates margin of safety",
"/ppf_calculator": "Calculates Public Provident Fund(PPF)",


},
}

Expand Down Expand Up @@ -1990,6 +1993,7 @@ def average_payment_period(request: AveragePaymentPeriod):
return average_payment_period_task(request.beginning_accounts_payable ,
request.ending_accounts_payable , request.total_credit_purchases)


# Endpoint to calculate Saving Goal

@app.post(
Expand Down Expand Up @@ -2033,3 +2037,14 @@ def tax_bracket_calculator(request: TaxBracketCalculator):
)
def margin_of_safety(request: MarginOfSafety):
return margin_of_safety_task(request.current_sales, request.break_even_point)


#Endpoint to Calculate Public Provident Fund(PPF)

@app.post(
"/ppf_calculator",
tags=["ppf_calculator"],
description="Calculates Public Provident Fund(PPF)",
)
def ppf_calculator(request: PPFCalculator):
return ppf_calculator(request.depos, request.tenure, request.interest)
12 changes: 12 additions & 0 deletions tasks/PPFCalculator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
def ppf_calculator(depos:int,tenure:int,interest:float):
try:
rate = functions.ppf_calculator(depos, tenure, interest)
return {
"Tag": "PPF Calculator",
"Total amount invested annualy": depos,
"No. of years": tenure,
"percentage interst rate": interest,
"Final Total value": f"{total_value}",
}
except:
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
5 changes: 5 additions & 0 deletions validators/request_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -673,3 +673,8 @@ class TaxBracketCalculator(BaseModel):
class MarginOfSafety(BaseModel):
current_sales:float
break_even_point: float

class PPFCalculator(BaseModel):
depos:int
tenure:int
interest:float