28 lines
713 B
Python
28 lines
713 B
Python
|
from fastapi import APIRouter
|
|||
|
from pydantic import BaseModel
|
|||
|
|
|||
|
INDEX = "EBIT利息保障倍数(倍)"
|
|||
|
|
|||
|
router = APIRouter()
|
|||
|
|
|||
|
|
|||
|
class Params(BaseModel):
|
|||
|
净利润: float
|
|||
|
计入财务费用的利息支出: float
|
|||
|
所得税: float
|
|||
|
资本化利息支出: float
|
|||
|
|
|||
|
|
|||
|
@router.post("/{}".format(INDEX))
|
|||
|
def func(p: Params):
|
|||
|
try:
|
|||
|
m = p.净利润 + p.计入财务费用的利息支出 + p.所得税
|
|||
|
d = p.计入财务费用的利息支出 + p.资本化利息支出
|
|||
|
result = m / d
|
|||
|
return round(result, 6)
|
|||
|
|
|||
|
except ZeroDivisionError:
|
|||
|
return "+inf" # 此处本应为算式无意义,特殊处理为正无穷大
|
|||
|
except Exception:
|
|||
|
return "计算错误"
|