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

Financial goal planner endpoint #447

Closed
Closed
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
7 changes: 7 additions & 0 deletions DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ The initial price of the product or service. |
| | | - `initial_quantity` (float): The initial quantity demanded of the product or service. |
| | | - `final_quantity` (float): The final quantity demanded of the product or service. |
|----------------------------|----------------------------------------|----------------------------------------------------------------------|
| GET /financial_goal_planner | Financial Goal Planner Calculator | - `initial_savings_amount`(int):
The initial amount of savings. |
| | | - `monthly_savings_amount` (int): The amount you plan to save. |
| | | - `target_savings_amount` (int): The total amount of savings. |
| | | - `timeframe` (int): The fiduration in which you plan to achieve. |
|----------------------------|----------------------------------------|----------------------------------------------------------------------|

| GET /average_payment_period | Calculate Average Payment Period | - `beginning_accounts_payable` (float): The amount of accounts payable beginning the cycle. |
| | | - `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. |
Expand Down
26 changes: 26 additions & 0 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2269,6 +2269,13 @@ Sample Output
"price_elasticity": -1.5
}
```
**POST** `/financial_goal_planner`

- Request body : `{
"initial_savings_amount": 1000,
"monthly_savings_amount": 200,
"target_savings_amount": 5000,
"timeframe": 12
**POST** `/average_payment_period`

- Request body : `{
Expand All @@ -2280,6 +2287,25 @@ Sample Output

```py
{
"Tag": "financial goal planner",
"monthly_savings_goal": 333
"total_savings_goal": 4000
"savings_schedule": [
(1, 1200),
(2, 1400),
(3, 1600),
(4, 1800),
(5, 2000),
(6, 2200),
(7, 2400),
(8, 2600),
(9, 2800),
(10, 3000),
(11, 3200),
(12, 3400)
]
}
```
"Tag": "Average Payment Period",
"Beginning Accounts Payable": 110000,
"Ending Accounts Payable": 95000,
Expand Down
25 changes: 25 additions & 0 deletions helpers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2047,6 +2047,31 @@ def calculate_price_elasticity(initial_price: float, final_price: float, initial

return price_elasticity

# Function to calculate Financial goal planner

def financial_goal_planner(initial_savings, monthly_savings, target_savings, timeframe):
total_savings_goal = target_savings - initial_savings
months = timeframe if isinstance(timeframe, int) else timeframe * 12
monthly_savings_goal = total_savings_goal / months

savings_schedule = []
current_savings = initial_savings

for month in range(1, months + 1):
current_savings += monthly_savings
savings_schedule.append((month, current_savings))

savings_ratio = current_savings / target_savings

output = {
"monthly_savings_goal": monthly_savings_goal,
"total_savings_goal": total_savings_goal,
"savings_schedule": savings_schedule,
"savings_ratio": savings_ratio
}

return output

# Function to Calculate Average Payment Period

def average_payment_period(beginning_accounts_payable: float, ending_accounts_payable: float,
Expand Down
18 changes: 18 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@
from tasks.cash_conversion_cycle import cash_conversion_cycle_task
from tasks.financialAssestRatio import financial_assest_ratio
from tasks.PolicyPremium import calculate_policy_premium
from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod, capmRequest, DebtServiceCoverageRatio, futureValueOfAnnuity, futureValueOfAnnuityDue, ProfitPercentage, LossPercentage, DefensiveIntervalRatio, CashConversionCycle, RateofReturn, financialAssestRatio, PriceElasticity, PolicyPremium, FinancialGoalPlanner
from tasks.financialAssestRatio import financial_assest_ratio
from tasks.PriceElasticity import calculate_price_elasticity
from tasks.Financialgoalplanner import financial_goal_palnner
from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod, capmRequest, DebtServiceCoverageRatio, futureValueOfAnnuity, futureValueOfAnnuityDue, ProfitPercentage, LossPercentage, DefensiveIntervalRatio, CashConversionCycle, RateofReturn, financialAssestRatio, PriceElasticity, PolicyPremium, AveragePaymentPeriod, ModifiedInternalRateOfReturn
from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod, capmRequest, DebtServiceCoverageRatio, futureValueOfAnnuity, futureValueOfAnnuityDue, ProfitPercentage, LossPercentage, DefensiveIntervalRatio, CashConversionCycle, RateofReturn, financialAssestRatio, PriceElasticity, PolicyPremium, AveragePaymentPeriod, ModifiedInternalRateOfReturn, SavingGoal, InterestCoverageRatio
from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod, capmRequest, DebtServiceCoverageRatio, futureValueOfAnnuity, futureValueOfAnnuityDue, ProfitPercentage, LossPercentage, DefensiveIntervalRatio, CashConversionCycle, RateofReturn, financialAssestRatio, PriceElasticity, PolicyPremium, AveragePaymentPeriod, ModifiedInternalRateOfReturn, SavingGoal, InterestCoverageRatio, MarginOfSafety, TaxBracketCalculator
from tasks.financialAssestRatio import financial_assest_ratio
from tasks.PriceElasticity import calculate_price_elasticity
Expand Down Expand Up @@ -1980,6 +1986,18 @@ def price_elasticity(request: PriceElasticity):
request.initial_quantity,
request.final_quantity )

# Endpoint to calculate Financial goal planner

@app.post(
"/financial_goal_palnner",
tags=["financial_goal_palnner"],
description="Calculate Financial goal planner",
)
def financial_goal_palnner(request: FinancialGoalPlanner):
return financial_goal_palnner(request.initial_savings_amount ,
request.monthly_savings_amount ,
request.target_savings_amount,
request.timeframe )
# Endpoint to calculate Average Payment Period
@app.post(
"/average_payment_period",
Expand Down
24 changes: 24 additions & 0 deletions tasks/Financialgoalplanner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
from helpers import functions
from fastapi import HTTPException, status

def financial_goal_palnner(initial_savings_amount: int, monthly_savings_amount: int, target_savings_amount: int,
timeframe: int):
try:
total_savings_goal = target_savings_amount - initial_savings_amount
months = timeframe if isinstance(timeframe, int) else timeframe * 12
monthly_savings_goal = total_savings_goal / months

savings_schedule = []
current_savings = initial_savings_amount

for month in range(1, months + 1):
current_savings += monthly_savings_amount
savings_schedule.append((month, current_savings))
return {
"Tag": "financial goal planner",
"monthly_savings_goal": monthly_savings_goal,
"total_savings_goal": total_savings_goal,
"savings_schedule": savings_schedule
}
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 @@ -644,7 +644,13 @@ class PriceElasticity(BaseModel):
initial_quantity: float
final_quantity: float

class AveragePaymentPeriod(BaseModel):
class FinancialGoalPlanner(BaseModel):
initial_saving_amount: int
monthly_savings_amount: int
target_savings_amount: int
timeframe: int

class AveragePaymentPeriod(BaseModel):
beginning_accounts_payable: float
ending_accounts_payable: float
total_credit_purchases: float
Expand Down
Loading