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 2 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
4 changes: 4 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ The initial price of the product or service. |
| | | - `ending_inventory` (float): The final amount of accounts payable ending the cycle. |
| | | - `total_credit_purchases` (float): The amount of purchases on credit during the cycle. |
|-----------------------------|----------------------------------------|---------------------------------------------------------------------|
|---------------------------|----------------------------------------|---------------------------------------------------------|
| GET /ppf_calculator | Calculate Public Provident Fund(PPF) | - `depos` (int): Annual Deposit. |
| | | - `tenure` (int): Total years of investment. |
| | | - `interest` (float): percentage interest rate. |
20 changes: 19 additions & 1 deletion ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2250,4 +2250,22 @@ Sample Output
"Average Accounts Payable": 102500,
"Average Payment Period": "33.7days",
}
```
```

**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 @@ -2055,3 +2055,11 @@ def average_payment_period(beginning_accounts_payable: float, ending_accounts_pa
app = average_accounts_payable / (total_credit_purchases / 365)
return app

# 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
11 changes: 11 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@
from tasks.financialAssestRatio import financial_assest_ratio
from tasks.PriceElasticity import calculate_price_elasticity
from tasks.average_payment_period import average_payment_period_task
from tasks.PPFCalculator import ppf_calculator

# Creating the app
app = FastAPI(
Expand Down Expand Up @@ -271,6 +272,7 @@ def index():
"/profit_percent": "Calculates the profit percentage",
"/loss_percent": "Calculates the loss percentage",
"/average_payment_period": "Calculate Average Payment Period a metric that allows a business to see how long it takes on average to pay its vendors."
"/ppf_calculator": "Calculates Public Provident Fund(PPF)"
},
}

Expand Down Expand Up @@ -1966,3 +1968,12 @@ 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 Public Provident Fund(PPF)

@app.post(
"/ppf_calculator",
tags=["ppf_calculator"],
description="Calculates Public Provident Fund(PPF)",
)
def simple_interest_rate(request: PPFCalculator):
return simple_interest_rate_task(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)
7 changes: 6 additions & 1 deletion validators/request_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,4 +647,9 @@ class PriceElasticity(BaseModel):
class AveragePaymentPeriod(BaseModel):
beginning_accounts_payable: float
ending_accounts_payable: float
total_credit_purchases: float
total_credit_purchases: float

class PPFcalculator(BaseModel):
depos:int
tenure:int
interest:float
Loading