Spaces:
Sleeping
Sleeping
Create cashflow.py
Browse files- cashflow.py +15 -0
cashflow.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from datetime import datetime, timedelta
|
| 2 |
+
|
| 3 |
+
def time_discounting(cashflow: float, days: int, rate: float) -> float:
|
| 4 |
+
"""
|
| 5 |
+
Discount cashflows by time using cost of capital.
|
| 6 |
+
"""
|
| 7 |
+
return cashflow / ((1 + rate) ** (days / 365))
|
| 8 |
+
|
| 9 |
+
def accelerate_receivable(amount: float, days_late: int, risk_score: float) -> float:
|
| 10 |
+
"""
|
| 11 |
+
Returns an adjusted value (lower risk ↑ higher value).
|
| 12 |
+
"""
|
| 13 |
+
discount_rate = 0.03 + (0.02 * (1 - risk_score))
|
| 14 |
+
adjusted = time_discounting(amount, days_late, discount_rate)
|
| 15 |
+
return round(adjusted, 2)
|