27 lines
587 B
Python
27 lines
587 B
Python
from fastapi import APIRouter
|
||
from pydantic import BaseModel
|
||
|
||
|
||
INDEX = "总债务/EBITDA(倍)"
|
||
|
||
router = APIRouter()
|
||
|
||
|
||
class Params(BaseModel):
|
||
短期借款: float
|
||
长期借款: float
|
||
利润总额: float
|
||
计入财务费用的利息支出: float
|
||
|
||
|
||
@router.post("/{}".format(INDEX))
|
||
def func(p: Params):
|
||
try:
|
||
result = (p.短期借款 + p.长期借款) / (p.利润总额 + p.计入财务费用的利息支出)
|
||
return round(result, 6)
|
||
|
||
except ZeroDivisionError:
|
||
return "算式无意义"
|
||
except Exception:
|
||
return "计算错误"
|