Skip to content

Commit

Permalink
Merge pull request #433 from roberanegussie/cash_conversion_cycle
Browse files Browse the repository at this point in the history
Cash Conversion Cycle
  • Loading branch information
ighoshsubho authored Jul 12, 2023
2 parents 484a4d1 + 81b46c5 commit 1782b0e
Show file tree
Hide file tree
Showing 6 changed files with 139 additions and 20 deletions.
15 changes: 14 additions & 1 deletion DOCUMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,23 @@
| | | - `net_receivables` (float): The amount of net_receivables.|
| | | - `annual_operating_expenses` (float): The amount of annual_operating_expenses.|
| | | - `non_cash_charges` (float): The amount of non cash charges.|
| --------------------------- | ---------------------------------------- | --------------------------------------------------------- |
| GET /financial_assest_ratio | Calculate financial assest ratio | - `current_assets` (float): used up within a short period. |
| | | - `current_liabilities` (float): debts that are due . |
| | | - `total_debt` (float): aggregate amount of money. |
| | | - `total_equity`(float): residual interest in the assets. |
| | | - `net_income` (float): net earnings. |
| | | - `total_revenue` (float): sum of all sales. |
| --------------------------- | ---------------------------------------- | --------------------------------------------------------- |

|----------------------------|----------------------------------------|-------------------------------------------------------------------------------|
| GET /cash_conversion_cycle | Calculate Cash Conversion Cycle | - `beginning_inventory` (float): The amount of inventory beginning the cycle. |
| | | - `ending_inventory` (float): The final amount of inventory ending the cycle. |
| | | - `beginning_receivables` (float): The amount of receivables beginning the cycle. |
| | | - `ending_receivables` (float): The final amount of receivables ending the cycle. |
| | | - `beginning_payable` (float): The amount of payable beginning the cycle. |
| | | - `ending_payable` (float): The final amount of payable ending the cycle. |
| | | - `cost_of_goods_sold` (float): The total cost related to producing goods sold by a business. |
| | | - `net_credit_sales` (float): Sales where the cash is collected at a later date. |
|----------------------------|----------------------------------------|----------------------------------------------------------------------|


71 changes: 53 additions & 18 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2083,7 +2083,16 @@ Sample Output
- Request body : `{
"profit": 1560.8,
"cost_price": 7500.4
=======
}`
```py
{
"Tag": "Profit Percentage",
"Profit": 1560.86,
"Cost Price": 7500.47,
"Profit Percentage": 20.81,
}
```

**POST** `/defensive_interval_ratio`

- Request body : `{
Expand All @@ -2094,15 +2103,19 @@ Sample Output
"non_cash_charges": 25000.00
}`
- Sample output
```py
{
"Tag": "Profit Percentage",
"Profit": 1560.86,
"Cost Price": 7500.47,
"Profit Percentage": 20.81,
"Tag": "Defensive Interval Ratio",
"Cash": 40000.00,
"Marketable Securites": 20000.00,
"Net Receivables": 10000.00,
"Annual Operating Expenses": 300000.00,
"Non Cash Charges": 25000.00,
"Current Assets": 70000.0,
"Daily Operational Expenses": 753.42,
"Defensive Interval Ratio": 92.90
}
```
```

**POST** `/loss_percent`

Expand All @@ -2119,17 +2132,6 @@ Sample Output
"Cost Price": 7500.47,
"Loss Percentage": 6.67,
}
```
"Tag": "Defensive Interval Ratio",
"Cash": 40000.00,
"Marketable Securites": 20000.00,
"Net Receivables": 10000.00,
"Annual Operating Expenses": 300000.00,
"Non Cash Charges": 25000.00,
"Current Assets": 70000.0,
"Daily Operational Expenses": 753.42,
"Defensive Interval Ratio": 92.90
}
```

**POST** `/financial_assest_ratio`
Expand All @@ -2156,4 +2158,37 @@ Sample Output
"net_profit_margin": 0.2,
"price_to_earnings_ratio": 20.5
}
```

**POST** `/cash_conversion_cycle`

- Request body : `{
"beginning_inventory": 1000,
"ending_inventory": 2000,
"beginning_receivables": 100
"ending_receivables": 90,
"beginning_payable": 800,
"ending_payable": 900,
"cost_of_goods_sold": 3000,
"net_credit_sales": 3000
}`
- Sample output

```py
{
"Tag": "Cash Conversion Cycle",
"Beginning Inventory": 1000,
"Ending Inventory": 2000,
"Average Inventory": 1500,
"Beginning Receivables": 100,
"Ending Receivables": 90,
"Average Receivables": 95,
"Beginning Payable": 800,
"Ending Payable": 900,
"Average Payable": 850,
"Days of inventory_outstanding": 182.5,
"Days of Sales Outstanding": 11.56,
"Days of Payables Outstanding": 103.42,
"Cash Conversion Cycle": 90.64 days",
}
```
14 changes: 14 additions & 0 deletions helpers/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2001,3 +2001,17 @@ def calculate_financial_asset_ratios(current_assets, current_liabilities, total_
}

return ratios

# Function to Calculate Cash Conversion Cycle

def cash_conversion_cycle(beginning_inventory: float, ending_inventory: float, beginning_receivables: float,
ending_receivables: float, beginning_payable: float, ending_payable: float, cost_of_goods_sold: float,
net_credit_sales: float):
average_inventory = beginning_inventory - ending_inventory / 2
average_receivables = beginning_receivables - ending_receivables / 2
average_payable = beginning_payable - ending_payable / 2
days_of_inventory_outstanding = (average_inventory / cost_of_goods_sold) * 365
days_of_sales_outstanding = (average_receivables / net_credit_sales) * 365
days_of_payables_outstanding = (average_payable / cost_of_goods_sold / 365)
ccc = days_of_inventory_outstanding + days_of_sales_outstanding - days_of_payables_outstanding
return ccc
16 changes: 15 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@
from tasks.profit_percentage import profit_percentage_task
from tasks.loss_percentage import loss_percentage_task
from tasks.defensive_interval_ratio import defensive_interval_ratio_task
from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod, capmRequest, DebtServiceCoverageRatio, futureValueOfAnnuity, futureValueOfAnnuityDue, ProfitPercentage, LossPercentage, DefensiveIntervalRatio, financialAssestRatio
from tasks.cash_conversion_cycle import cash_conversion_cycle_task
from validators.request_validators import SimpleInterestRateRequest, calculatePension, compoundInterest, futureSip, paybackPeriod, capmRequest, DebtServiceCoverageRatio, futureValueOfAnnuity, futureValueOfAnnuityDue, ProfitPercentage, LossPercentage, DefensiveIntervalRatio, CashConversionCycle, financialAssestRatio
from tasks.financialAssestRatio import financial_assest_ratio

# Creating the app
Expand Down Expand Up @@ -1894,3 +1895,16 @@ def financial_assest_ratio(request: financialAssestRatio):
request.total_equity,
request.net_income,
request.total_revenue)

# Endpoint to calculate Cash Conversion Cycle

@app.post(
"/cash_conversion_cycle",
tags=["cash_conversion_cycle"],
description="Calculate Cash Conversion Cycle",
)
def cash_conversion_cycle(request: CashConversionCycle):
return cash_conversion_cycle_task(request.beginning_inventory , request.ending_inventory ,
request.beginning_receivables, request.ending_receivables , request.beginning_payable,
request.ending_payable , request.net_credit_sales , request.cost_of_goods_sold)

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

def cash_conversion_cycle_task(beginning_inventory: float, ending_inventory: float, beginning_receivables: float,
ending_receivables: float, beginning_payable: float, ending_payable: float, cost_of_goods_sold: float,
net_credit_sales: float):
try:
average_inventory = beginning_inventory - ending_inventory / 2
average_receivables = beginning_receivables - ending_receivables / 2
average_payable = beginning_payable - ending_payable / 2
days_of_inventory_outstanding = (average_inventory / cost_of_goods_sold) * 365
days_of_sales_outstanding = (average_receivables / net_credit_sales) * 365
days_of_payables_outstanding = (average_payable / cost_of_goods_sold / 365)
ccc = functions.cash_conversion_cycle(beginning_inventory, ending_inventory, beginning_receivables,
ending_receivables, beginning_payable, ending_payable, cost_of_goods_sold, net_credit_sales)
return {
"Tag": "Cash Conversion Cycle",
"Beginning Inventory": beginning_inventory,
"Ending Inventory": ending_inventory,
"Average Inventory": average_inventory,
"Beginning Receivables": beginning_receivables,
"Ending Receivables": ending_receivables,
"Average Receivables": average_receivables,
"Beginning Payable": beginning_payable,
"Ending Payable": ending_payable,
"Average Payable": average_payable,
"Days of inventory_outstanding": days_of_inventory_outstanding,
"Days of Sales Outstanding": days_of_sales_outstanding,
"Days of Payables Outstanding": days_of_payables_outstanding,
"Cash Conversion Cycle": f"{ccc} days",
}
except:
return HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR)
10 changes: 10 additions & 0 deletions validators/request_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -611,4 +611,14 @@ class financialAssestRatio(BaseModel):
total_equity: float
net_income: float
total_revenue: float

class CashConversionCycle(BaseModel):
beginning_inventory: float
ending_inventory: float
beginning_receivables: float
ending_receivables: float
beginning_payable: float
ending_payable: float
cost_of_goods_sold: float
net_credit_sales: float

0 comments on commit 1782b0e

Please sign in to comment.