diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 4ce85ec1..a2eb6d1c 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -1,8 +1,19 @@ -| Endpoint | Description | Parameters | -|---------------------------|----------------------------------------|---------------------------------------------------------| -| GET /simple_interest_rate | Calculate simple interest rates | - `amount_paid` (float): The amount paid. | -| | | - `principle_amount` (float): The principle amount. | -| | | - `months` (int): The number of months. | -| GET /future_sip | Calculate Future Value of SIP | - `interval_investment` (float): The interval investment| -| | | - `rate_of_return` (float): The rate of return. | -| | | - `number_of_payments` (int): The number of payments. | +| Endpoint | Description | Parameters | +|----------------------------------|----------------------------------------|----------------------------------------------------------------| +| GET /simple_interest_rate | Calculate simple interest rates | - `amount_paid` (float): The amount paid. | +| | | - `principle_amount` (float): The principle amount. | +| | | - `months` (int): The number of months. | +| GET /future_sip | Calculate Future Value of SIP | - `interval_investment` (float): The interval investment | +| | | - `rate_of_return` (float): The rate of return. | +| | | - `number_of_payments` (int): The number of payments. | +| POST /net_income | Calculate Net Income | - `revenue` (float): The revenue. | +| | | - `expenses` (float): The revenue. | +| POST/break_even_point | Calculate Break-even point | - `fixed_costs` (int): The Fixed Cost | +| | | - `sales_price_per_unit`(float):The sales price per unit | +| | | - `variable_price_per_unit`(float):variable price per unit | +|POST/day_sales_in_inventory_ratio | Calculate Day Sales in Inventory Ratio | - `avg_inventory` (int): The average inventory. | +| | | - `cost_of_goods_sold` (int):The cost of goods sold. | +| | | - `no_of_days` (int): The number of days. | +| POST /cash_ratio | Calculate Cash Ratio | - `cash` (float): The Cash Amount | +| | | - `cash_equivalents` (float): The cash equivalents. | +| | | - `current_liabilities` (float):The Current liabilities. | diff --git a/ENDPOINTS.md b/ENDPOINTS.md index 0b1bb25f..c45fe7db 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -2048,3 +2048,69 @@ Sample Output "Capitalization Rate": 6.16% } ``` + +**POST** `/net_income` + +- Request body : `{ + "revenue" : 30000, + "expenses": 25000 + }` + - Sample output +```py +{ + "Tag" : "Net Income", + "Revenue" : 30000, + "Expenses": 25000, + "Net Income" : 5000 +} +``` + +**POST** `/break_even_point` +- Request body : `{ + "fixed_costs": 2500, + "sales_price_per_unit": 2.95, + "variable_price_per_unit": 1.40 + }` + - Sample output +```py +{ +"Tag": "Break-even Point", +"Fixed Costs": 2500, +"Sales Price Per Unit": 2.95, +"Variable Price Per Unit": 1.40, +"Break-even Point": 1612.9032258064512 +} +``` +**POST** `/day_sales_in_inventory_ratio` +- Request body : `{ + "avg_inventory": 50000, + "cost_of_goods_sold": 200000, + "no_of_days": 365 + }` + - Sample outputt +```py +{ + "Tag": "Day Sales in Inventory Ratio", + "Average Inventory": 50000, + "Cost of Goods Sold": 200000, + "No of Days": 365, + "Day Sales in Inventory Ratio": "91.25" +} +``` +**POST** `/cash_ratio` +- Request body : `{ + "cash": 37.1, + "cash_equivalents": 26.8, + "current_liabilities": 123.5 + }` + - Sample output +```py +{ + "Tag": "Cash Ratio", + "Cash": 37.1, + "Cash Equivalents": 26.8, + "Current Liabilities": 123.5, + "Cash Ratio": "0.52" +} +``` + diff --git a/helpers/functions.py b/helpers/functions.py index 7ba95169..b06fb7ff 100644 --- a/helpers/functions.py +++ b/helpers/functions.py @@ -1998,3 +1998,19 @@ def net_worth_calculation(assets: float, liabilities: float, loans: float, mortg "Liabilities": total_liabilities, "Net Worth": net_worth, } + +# Function to calculate the net income +def net_income(revenue: float, expenses: float): + return float(revenue)-float(expenses) + +# Function to calculate the break-even point +def break_even_point(fixed_costs:int ,sales_price_per_unit: float,variable_price_per_unit:float): + return fixed_costs/(sales_price_per_unit-variable_price_per_unit) + +# Function to calculate the Day Sales in Inventory Ratio +def day_sales_in_inventory_ratio(avg_inventory:int ,cost_of_goods_sold: int,no_of_days:int): + return (avg_inventory/cost_of_goods_sold)*no_of_days + +# Function to calculate the Cash Ratio +def cash_ratio(cash:float ,cash_equivalents:float,current_liabilities:float): + return (cash+cash_equivalents)/current_liabilities diff --git a/main.py b/main.py index 6b97957f..d1955c56 100644 --- a/main.py +++ b/main.py @@ -129,6 +129,8 @@ from tasks.personal_savings import personal_savings_task from tasks.portfolio_return_monte_carlo import portfolio_return_monte_carlo_task from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod +from validators.request_validators import NetIncome, CashRatio, DaySalesinInventoryRatio, BreakevenPoint + # Creating the app app = FastAPI( @@ -1844,4 +1846,42 @@ def capitalization_rate( def accounts_payable_turnover_ratio(total_supply_purchases: float, beginning_accounts_payable: float, ending_accounts_payable: float): - return accounts_payable_turnover_ratio_task(total_supply_purchases, beginning_accounts_payable, ending_accounts_payable) \ No newline at end of file + return accounts_payable_turnover_ratio_task(total_supply_purchases, beginning_accounts_payable, ending_accounts_payable) + + +# Endpoint to calculate the net income +@app.get( + "/net_income", + tags=["net_income"], + description="Calculating the Net Income", +) +def net_income(request:NetIncome): + return net_income(request.revenue, request.expenses) + +# Endpoint to calculate the break-even point +@app.get( + "/break_even_point", + tags=["break_even_point"], + description="Calculating the Break-even Point", +) +def break_even_point(request:BreakevenPoint): + return break_even_point(request.avg_inventory, request.sales_price_per_unit,request.variable_price_per_unit) + +# Endpoint to calculate the Day Sales in Inventory Ratio +@app.get( + "/day_sales_in_inventory_ratio", + tags=["day_sales_in_inventory_ratio"], + description="Calculating the Day Sales in Inventory Ratio", +) +def day_sales_in_inventory_ratio(request:DaySalesinInventoryRatio): + return day_sales_in_inventory_ratio(request.avg_inventory, request.cost_of_goods_sold,request.no_of_days) + +# Endpoint to calculate the Cash Ratio +@app.get( + "/cash_ratio", + tags=["cash_ratio"], + description="Calculating the Cash Ratio", +) +def cash_ratio(request:CashRatio): + return cash_ratio(request.cash, request.cash_equivalents,request.current_liabilities) + diff --git a/tasks/break_even_point.py b/tasks/break_even_point.py new file mode 100644 index 00000000..4752d897 --- /dev/null +++ b/tasks/break_even_point.py @@ -0,0 +1,14 @@ +from helpers import functions +from fastapi import HTTPException, status +def break_even_point(fixed_costs: int, sales_price_per_unit: float, variable_price_per_unit: float): + try: + break_even_point_value = functions.break_even_point(fixed_costs,sales_price_per_unit,variable_price_per_unit) + return { + "Tag": "Break-even Point", + "Fixed Costs": fixed_costs, + "Sales Price Per Unit": sales_price_per_unit, + "Variable Price Per Unit":variable_price_per_unit , + "Break-even Point": break_even_point_value, + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) \ No newline at end of file diff --git a/tasks/cash_ratio.py b/tasks/cash_ratio.py new file mode 100644 index 00000000..0df77de7 --- /dev/null +++ b/tasks/cash_ratio.py @@ -0,0 +1,15 @@ +from helpers import functions +from fastapi import HTTPException, status + +def cash_ratio(cash: float, cash_equivalents: float, current_liabilities: float): + try: + cash_ratio_value = functions.cash_ratio(cash,cash_equivalents,current_liabilities) + return { + "Tag": "Cash Ratio", + "Cash": cash, + "Cash Equivalents": cash_equivalents, + "Current Liabilities":current_liabilities , + "Cash Ratio": cash_ratio_value, + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) diff --git a/tasks/day_sales_in_inventory_ratio.py b/tasks/day_sales_in_inventory_ratio.py new file mode 100644 index 00000000..7a8dcc9f --- /dev/null +++ b/tasks/day_sales_in_inventory_ratio.py @@ -0,0 +1,15 @@ +from helpers import functions +from fastapi import HTTPException, status + +def day_sales_in_inventory_ratio(avg_inventory: int, cost_of_goods_sold: int, no_of_days: int): + try: + day_sales_in_inventory_ratio_value = functions.day_sales_in_inventory_ratio(avg_inventory,cost_of_goods_sold,no_of_days) + return { + "Tag": "Day Sales in Inventory Ratio", + "Average Inventory": avg_inventory, + "Cost Of Goods Sold": cost_of_goods_sold, + "Number Of Days":no_of_days , + "Day Sales in Inventory Ratio": day_sales_in_inventory_ratio_value, + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) diff --git a/tasks/net_income.py b/tasks/net_income.py new file mode 100644 index 00000000..298e8818 --- /dev/null +++ b/tasks/net_income.py @@ -0,0 +1,13 @@ +from helpers import functions +from fastapi import HTTPException, status +def net_income(revenue: float, expenses: int): + try: + net_income_value = functions.net_income(revenue,expenses) + return { + "Tag": "Net Income", + "Revenue": revenue, + "Expenses": expenses, + "Net Income": net_income_value, + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) \ No newline at end of file diff --git a/validators/request_validators.py b/validators/request_validators.py index 8e845f5f..2b1360e0 100644 --- a/validators/request_validators.py +++ b/validators/request_validators.py @@ -855,4 +855,23 @@ class calculateMarketCap(BaseModel): class calculateBvps(BaseModel): total_equity: float - number_of_shares: float \ No newline at end of file + number_of_shares: float + +class NetIncome(BaseModel): + revenue: float + expenses: float + +class BreakevenPoint(BaseModel): + fixed_costs: int + sales_price_per_unit: float + variable_price_per_unit: float + +class DaySalesinInventoryRatio(BaseModel): + avg_inventory : int + no_of_days: int + cost_of_goods_sold: int + +class CashRatio(BaseModel): + cash :float + cash_equivalents: float + current_liabilities: float