Skip to content

Commit

Permalink
Merge branch 'main' into another
Browse files Browse the repository at this point in the history
  • Loading branch information
filza2112 authored Jul 31, 2023
2 parents 246cfd4 + 6f12cac commit 679c4f7
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 9 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ def simple_interest_rate(request: SimpleInterestRateRequest):
"Principle amount": 30.9,
"Interest Paid": -10.669999999999998,
"Interest Rate": "-82.87378640776697%"
}
} ```
```
+Update the Docs
```
Expand Down
7 changes: 6 additions & 1 deletion DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ 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 /saving_goal | Saving Goal Calculator | - `current_savings` (float): The current amount of savings. |
| | | - `monthly_contributions` (float): The amount of money contributed each month towards the savings goal. |
| | | - `interest_rate` (float): The annual interest rate on the savings. |
| | | - `goal_amount ` (float): The desired savings goal amount. |
|-----------------------------|----------------------------------------|----------------------------------------------------------------------|
|---------------------------|----------------------------------------|---------------------------------------------------------|
| GET /ppf_calculator | Calculate Public Provident Fund(PPF) | - `depos` (int): Annual Deposit. |
| | | - `tenure` (int): Total years of investment. |
| | | - `interest` (float): percentage interest rate. |
| | | - `interest` (float): percentage interest rate. |
20 changes: 18 additions & 2 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2269,7 +2269,6 @@ Sample Output
"price_elasticity": -1.5
}
```
**POST** `/average_payment_period`
- Request body : `{
Expand All @@ -2291,7 +2290,24 @@ Sample Output
```
**POST** `/saving_goal `
- Request body : `{
"current_savings": 100,
"monthly_contributions ": 200,
"interest_rate" 5,
"goal_amount" 5000
}`
- Sample output
```py
{
"Tag": "Saving Goal Calculator",
"months_required": 18,
"total_contributions": 3600,
"interest_earned": 315.27777777777777
}```
**POST** `/ppf_calculator`
- Request body : `{
Expand All @@ -2308,4 +2324,4 @@ Sample Output
"No. of Years": 15,
"percentage interst Rate": 7.1,
"Total Value of PPF": "13560"
}
}
7 changes: 7 additions & 0 deletions helpers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2055,6 +2055,12 @@ def average_payment_period(beginning_accounts_payable: float, ending_accounts_pa
app = average_accounts_payable / (total_credit_purchases / 365)
return app

# Function to Saving Goal Calculator

def saving_goal(current_savings: float, monthly_contributions: float, interest_rate: float, goal_amount: float):
savings_ratio = current_savings / goal_amount
return savings_ratio

# Function to calculate Modified Internal Rate of Return (MIRR)

def calculate_modified_internal_rate_of_return(ending_cash_flow: float,
Expand All @@ -2071,3 +2077,4 @@ def ppf_calculator(depos:int,
a=1+interest/100
total_value= depos*(((a**tenure) - 1)/(interest/100))*a
return total_value

22 changes: 18 additions & 4 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,10 @@
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.Saving_Goal import saving_goal
from tasks.modified_internal_rate_of_return import calculate_modified_internal_rate_of_return_task
from tasks.PPFCalculator import ppf_calculator


# Creating the app
app = FastAPI(
title="FinTech API",
Expand Down Expand Up @@ -1976,7 +1976,6 @@ def price_elasticity(request: PriceElasticity):
request.initial_quantity,
request.final_quantity )


# Endpoint to calculate Average Payment Period
@app.post(
"/average_payment_period",
Expand All @@ -1987,12 +1986,27 @@ 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(
"/saving_goal",
tags=["saving_goal"],
description="Calculate Saving Goal",
)
def saving_goal(request: SavingGoal):
return saving_goal(request.current_savings ,
request.monthly_contributions ,
request.interest_rate,
request.goal_amount )

#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)
def ppf_calculator(request: PPFCalculator):
return ppf_calculator(request.depos, request.tenure, request.interest)

20 changes: 20 additions & 0 deletions tasks/Saving_Goal.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from fastapi import HTTPException, status

def saving_goal(current_savings: float, monthly_contributions: float, interest_rate: float, goal_amount: float):
try:
while current_savings < goal_amount:
months_required += 1
total_contributions += monthly_contributions
current_savings += monthly_contributions
interest_earned += (current_savings * interest_rate / 100) / 12

if current_savings >= goal_amount:

return {
"months_required": months_required,
"total_contributions": total_contributions,
"interest_earned": interest_earned,

}
except:
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
8 changes: 7 additions & 1 deletion validators/request_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,12 +649,18 @@ class AveragePaymentPeriod(BaseModel):
ending_accounts_payable: float
total_credit_purchases: float

class SavingGoal(BaseModel):
current_savings: float
monthly_contributions : float
interest_rate: float
goal_amount: float

class ModifiedInternalRateOfReturn(BaseModel):
ending_cash_flow: float
initial_cash_flow: float
number_of_periods: int

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

0 comments on commit 679c4f7

Please sign in to comment.