From 7d66444de7eeb71ff4cf09cfe67a7cb5a4cba11a Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 23 Jul 2023 02:21:52 +0530 Subject: [PATCH 01/16] Add files via upload --- tasks/break_even_point.py | 14 ++++++++++++++ tasks/cash_ratio.py | 15 +++++++++++++++ tasks/day_sales_in_inventory_ratio.py | 15 +++++++++++++++ tasks/net_income.py | 13 +++++++++++++ 4 files changed, 57 insertions(+) create mode 100644 tasks/break_even_point.py create mode 100644 tasks/cash_ratio.py create mode 100644 tasks/day_sales_in_inventory_ratio.py create mode 100644 tasks/net_income.py 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 From 4dbdbb5a26d71a3556447325ae3b4e4921ab2ad2 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 23 Jul 2023 02:23:58 +0530 Subject: [PATCH 02/16] Update main.py --- main.py | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 79 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index 6b97957f..6d12734e 100644 --- a/main.py +++ b/main.py @@ -1844,4 +1844,82 @@ 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(revenue: float, expenses: float): + 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) + +# 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(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) + +# 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(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) + +# Endpoint to calculate the Cash Ratio +@app.get( + "/cash_ratio", + tags=["cash_ratio"], + description="Calculating the Cash Ratio", +) +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 Libilites":current_liabilities , + "Cash Ratio": cash_ratio_value, + } + except: + return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) + From ad1031960f3ea7b959c91b4dc4019d7724fa27ef Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 23 Jul 2023 02:28:57 +0530 Subject: [PATCH 03/16] Update main.py --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 6d12734e..0302c73a 100644 --- a/main.py +++ b/main.py @@ -1848,6 +1848,7 @@ def accounts_payable_turnover_ratio(total_supply_purchases: float, + # Endpoint to calculate the net income @app.get( "/net_income", @@ -1922,4 +1923,3 @@ def cash_ratio(cash: float, cash_equivalents:float,current_liabilities:float): } except: return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) - From d93559a9af93a00145e137872393ec45e106afbc Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 23 Jul 2023 02:34:21 +0530 Subject: [PATCH 04/16] Update ENDPOINTS.md --- ENDPOINTS.md | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/ENDPOINTS.md b/ENDPOINTS.md index 0b1bb25f..3b28a75f 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -2048,3 +2048,52 @@ Sample Output "Capitalization Rate": 6.16% } ``` + +**GET** `net_income` +- Required Parameters : `revenue`, `expenses` +- Sample output +```py +{ + "Tag" : "Net Income", + "Revenue" : 30000, + "Expenses": 25000, + "Net Income" : 5000 +} +``` + +**GET** `break_even_point` +- Required Parameters : `fixed_costs`, `sales_price_per_unit`,`variable_price_per_unit` +- 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 +} +``` +**GET** `day_sales_in_inventory_ratio` +- Required Parameters : `avg_inventory`, `cost_of_goods_sold`,`no_of_days` +- Sample output +```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" +} +``` +**GET** `cash_ratio` +- Required Parameters : `cash`,`cash_equivalents`, `current_liabilities` +- Sample output +```py +{ + "Tag": "Cash Ratio", + "Cash": 37.1, + "Cash Equivalents": 26.8, + "Current Liabilities": 123.5, + "Cash Ratio": "0.52" +} +``` From b2245c19f2a1839f1c69a0da97527df334b4bcb5 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 23 Jul 2023 02:41:23 +0530 Subject: [PATCH 05/16] Update DOCUMENTATION.md --- DOCUMENTATION.md | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 4ce85ec1..41a53575 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. | +| GET /net_income | Calculate Net Income | - `revenue` (float): The revenue. | +| | | - `expenses` (float): The revenue. | +| GET/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 | +|GET/day_sales_in_ | Calculate Day Sales in Inventory Ratio | - `avg_inventory` (int): The average inventory. | +|inventory_ratio | | - `cost_of_goods_sold` (int):The cost of goods sold. | +| | | - `no_of_days` (int): The number of days. | +| GET /cash_ratio | Calculate Cash Ratio | - `cash` (float): The Cash Amount | +| | | - `cash_equivalents` (float): The cash equivalents. | +| | | - `current_liabilities` (float):The Current liabilities. | From c29a5712688030f820dc5c5e442d392d2090b543 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 23 Jul 2023 02:42:46 +0530 Subject: [PATCH 06/16] Update request_validators.py --- validators/request_validators.py | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/validators/request_validators.py b/validators/request_validators.py index 8e845f5f..026ef8f8 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 net_income(BaseModel): + revenue: float + expenses: float + +class break_even_point(BaseModel): + fixed_costs: int + sales_price_per_unit: float + variable_price_per_unit: float + +class day_sales_in_inventory_ratio(BaseModel): + avg_inventory : int + no_of_days: int + cost_of_goods_sold: int + +class cash_ratio(BaseModel): + cash :float + cash_equivalents: float + current_liabilities: float From 725cb649bcfa526b3c950229750688739e4dc63e Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 23 Jul 2023 02:44:59 +0530 Subject: [PATCH 07/16] Update functions.py --- helpers/functions.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 From 4d4920453fdbe54bfa32a508ed373b3e7a463f1c Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sat, 29 Jul 2023 21:23:49 +0530 Subject: [PATCH 08/16] Update main.py --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index 0302c73a..f4844216 100644 --- a/main.py +++ b/main.py @@ -1850,7 +1850,7 @@ def accounts_payable_turnover_ratio(total_supply_purchases: float, # Endpoint to calculate the net income -@app.get( +@app.post( "/net_income", tags=["net_income"], description="Calculating the Net Income", @@ -1868,7 +1868,7 @@ def net_income(revenue: float, expenses: float): return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) # Endpoint to calculate the break-even point -@app.get( +@app.post( "/break_even_point", tags=["break_even_point"], description="Calculating the Break-even Point", @@ -1887,7 +1887,7 @@ def break_even_point(fixed_costs: int, sales_price_per_unit: float, variable_pri return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) # Endpoint to calculate the Day Sales in Inventory Ratio -@app.get( +@app.post( "/day_sales_in_inventory_ratio", tags=["day_sales_in_inventory_ratio"], description="Calculating the Day Sales in Inventory Ratio", From 7f3d35692cbebd8ca296adb526db2230e1c32d48 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sat, 29 Jul 2023 21:27:12 +0530 Subject: [PATCH 09/16] Update DOCUMENTATION.md --- DOCUMENTATION.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 41a53575..0c8c8f3c 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -6,14 +6,14 @@ | 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. | -| GET /net_income | Calculate Net Income | - `revenue` (float): The revenue. | +| POST /net_income | Calculate Net Income | - `revenue` (float): The revenue. | | | | - `expenses` (float): The revenue. | -| GET/break_even_point | Calculate Break-even point | - `fixed_costs` (int): The Fixed Cost | +| 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 | -|GET/day_sales_in_ | Calculate Day Sales in Inventory Ratio | - `avg_inventory` (int): The average inventory. | +|POST/day_sales_in_ | Calculate Day Sales in Inventory Ratio | - `avg_inventory` (int): The average inventory. | |inventory_ratio | | - `cost_of_goods_sold` (int):The cost of goods sold. | | | | - `no_of_days` (int): The number of days. | -| GET /cash_ratio | Calculate Cash Ratio | - `cash` (float): The Cash Amount | +| POST /cash_ratio | Calculate Cash Ratio | - `cash` (float): The Cash Amount | | | | - `cash_equivalents` (float): The cash equivalents. | | | | - `current_liabilities` (float):The Current liabilities. | From 394310020dbbb044869f4f37ad93139779da747e Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sat, 29 Jul 2023 21:28:27 +0530 Subject: [PATCH 10/16] Update ENDPOINTS.md --- ENDPOINTS.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ENDPOINTS.md b/ENDPOINTS.md index 3b28a75f..7ab16962 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -2049,7 +2049,7 @@ Sample Output } ``` -**GET** `net_income` +**POST** `net_income` - Required Parameters : `revenue`, `expenses` - Sample output ```py @@ -2061,7 +2061,7 @@ Sample Output } ``` -**GET** `break_even_point` +**POST** `break_even_point` - Required Parameters : `fixed_costs`, `sales_price_per_unit`,`variable_price_per_unit` - Sample output ```py @@ -2073,7 +2073,7 @@ Sample Output "Break-even Point": 1612.9032258064512 } ``` -**GET** `day_sales_in_inventory_ratio` +**POST** `day_sales_in_inventory_ratio` - Required Parameters : `avg_inventory`, `cost_of_goods_sold`,`no_of_days` - Sample output ```py @@ -2085,7 +2085,7 @@ Sample Output "Day Sales in Inventory Ratio": "91.25" } ``` -**GET** `cash_ratio` +**POST** `cash_ratio` - Required Parameters : `cash`,`cash_equivalents`, `current_liabilities` - Sample output ```py From a45276263cfa7c06d449a22023879f8eee7f8c21 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sat, 29 Jul 2023 21:33:30 +0530 Subject: [PATCH 11/16] Update ENDPOINTS.md --- ENDPOINTS.md | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/ENDPOINTS.md b/ENDPOINTS.md index 7ab16962..700fad3f 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -2050,8 +2050,11 @@ Sample Output ``` **POST** `net_income` -- Required Parameters : `revenue`, `expenses` -- Sample output +- Request body : `{ + "Revenue" : 30000, + "Expenses": 25000 + }` + - Sample output ```py { "Tag" : "Net Income", @@ -2062,8 +2065,12 @@ Sample Output ``` **POST** `break_even_point` -- Required Parameters : `fixed_costs`, `sales_price_per_unit`,`variable_price_per_unit` -- Sample output +- Request body : `{ + "Fixed Costs": 2500, + "Sales Price Per Unit": 2.95, + "Variable Price Per Unit": 1.40 + }` + - Sample output ```py { "Tag": "Break-even Point", @@ -2074,8 +2081,12 @@ Sample Output } ``` **POST** `day_sales_in_inventory_ratio` -- Required Parameters : `avg_inventory`, `cost_of_goods_sold`,`no_of_days` -- Sample output +- Request body : `{ + "Average Inventory": 50000, + "Cost of Goods Sold": 200000, + "No of Days": 365 + }` + - Sample outputt ```py { "Tag": "Day Sales in Inventory Ratio", @@ -2086,8 +2097,12 @@ Sample Output } ``` **POST** `cash_ratio` -- Required Parameters : `cash`,`cash_equivalents`, `current_liabilities` -- Sample output +- Request body : `{ + "Cash": 37.1, + "Cash Equivalents": 26.8, + "Current Liabilities": 123.5 + }` + - Sample output ```py { "Tag": "Cash Ratio", @@ -2097,3 +2112,4 @@ Sample Output "Cash Ratio": "0.52" } ``` + From 1b20d7928180976eebe99465407fc7cbfa07bd8a Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sat, 29 Jul 2023 21:37:35 +0530 Subject: [PATCH 12/16] Update main.py --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index f4844216..7130dbb3 100644 --- a/main.py +++ b/main.py @@ -1906,7 +1906,7 @@ def day_sales_in_inventory_ratio(avg_inventory: int, cost_of_goods_sold: int, no return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) # Endpoint to calculate the Cash Ratio -@app.get( +@app.post( "/cash_ratio", tags=["cash_ratio"], description="Calculating the Cash Ratio", From e3ef7e1c0ff0eb554db6453efdee72fd95a81d5f Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Mon, 31 Jul 2023 19:36:41 +0530 Subject: [PATCH 13/16] Update DOCUMENTATION.md --- DOCUMENTATION.md | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/DOCUMENTATION.md b/DOCUMENTATION.md index 0c8c8f3c..a2eb6d1c 100644 --- a/DOCUMENTATION.md +++ b/DOCUMENTATION.md @@ -1,19 +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. | -| 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_ | Calculate Day Sales in Inventory Ratio | - `avg_inventory` (int): The average inventory. | -|inventory_ratio | | - `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. | +| 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. | From 0437cf2b0f1b8797b0d349962487daceb6d72eb0 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 6 Aug 2023 20:17:29 +0530 Subject: [PATCH 14/16] Update ENDPOINTS.md --- ENDPOINTS.md | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/ENDPOINTS.md b/ENDPOINTS.md index 700fad3f..c45fe7db 100644 --- a/ENDPOINTS.md +++ b/ENDPOINTS.md @@ -2049,10 +2049,11 @@ Sample Output } ``` -**POST** `net_income` +**POST** `/net_income` + - Request body : `{ - "Revenue" : 30000, - "Expenses": 25000 + "revenue" : 30000, + "expenses": 25000 }` - Sample output ```py @@ -2064,11 +2065,11 @@ Sample Output } ``` -**POST** `break_even_point` +**POST** `/break_even_point` - Request body : `{ - "Fixed Costs": 2500, - "Sales Price Per Unit": 2.95, - "Variable Price Per Unit": 1.40 + "fixed_costs": 2500, + "sales_price_per_unit": 2.95, + "variable_price_per_unit": 1.40 }` - Sample output ```py @@ -2080,11 +2081,11 @@ Sample Output "Break-even Point": 1612.9032258064512 } ``` -**POST** `day_sales_in_inventory_ratio` +**POST** `/day_sales_in_inventory_ratio` - Request body : `{ - "Average Inventory": 50000, - "Cost of Goods Sold": 200000, - "No of Days": 365 + "avg_inventory": 50000, + "cost_of_goods_sold": 200000, + "no_of_days": 365 }` - Sample outputt ```py @@ -2096,11 +2097,11 @@ Sample Output "Day Sales in Inventory Ratio": "91.25" } ``` -**POST** `cash_ratio` +**POST** `/cash_ratio` - Request body : `{ - "Cash": 37.1, - "Cash Equivalents": 26.8, - "Current Liabilities": 123.5 + "cash": 37.1, + "cash_equivalents": 26.8, + "current_liabilities": 123.5 }` - Sample output ```py From 951ebc0485fb2a9efb3131e1549af30bc448ed38 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 6 Aug 2023 20:19:16 +0530 Subject: [PATCH 15/16] Update request_validators.py --- validators/request_validators.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/validators/request_validators.py b/validators/request_validators.py index 026ef8f8..2b1360e0 100644 --- a/validators/request_validators.py +++ b/validators/request_validators.py @@ -857,21 +857,21 @@ class calculateBvps(BaseModel): total_equity: float number_of_shares: float -class net_income(BaseModel): +class NetIncome(BaseModel): revenue: float expenses: float -class break_even_point(BaseModel): +class BreakevenPoint(BaseModel): fixed_costs: int sales_price_per_unit: float variable_price_per_unit: float -class day_sales_in_inventory_ratio(BaseModel): +class DaySalesinInventoryRatio(BaseModel): avg_inventory : int no_of_days: int cost_of_goods_sold: int -class cash_ratio(BaseModel): +class CashRatio(BaseModel): cash :float cash_equivalents: float current_liabilities: float From 391ca175219606c2b60112edd7eee7052b70a0e2 Mon Sep 17 00:00:00 2001 From: Suvamita Sadhukhan <103322378+suvamita@users.noreply.github.com> Date: Sun, 6 Aug 2023 20:33:33 +0530 Subject: [PATCH 16/16] Update main.py --- main.py | 68 +++++++++++++-------------------------------------------- 1 file changed, 15 insertions(+), 53 deletions(-) diff --git a/main.py b/main.py index 7130dbb3..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( @@ -1847,79 +1849,39 @@ def accounts_payable_turnover_ratio(total_supply_purchases: float, return accounts_payable_turnover_ratio_task(total_supply_purchases, beginning_accounts_payable, ending_accounts_payable) - - # Endpoint to calculate the net income -@app.post( +@app.get( "/net_income", tags=["net_income"], description="Calculating the Net Income", ) -def net_income(revenue: float, expenses: float): - 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) +def net_income(request:NetIncome): + return net_income(request.revenue, request.expenses) # Endpoint to calculate the break-even point -@app.post( +@app.get( "/break_even_point", tags=["break_even_point"], description="Calculating the Break-even Point", ) -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) +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.post( +@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(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) +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.post( +@app.get( "/cash_ratio", tags=["cash_ratio"], description="Calculating the Cash Ratio", ) -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 Libilites":current_liabilities , - "Cash Ratio": cash_ratio_value, - } - except: - return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) +def cash_ratio(request:CashRatio): + return cash_ratio(request.cash, request.cash_equivalents,request.current_liabilities) +