indexcalculation/基本信用评级指标/偿债能力/EBIT利息保障倍数.py

28 lines
713 B
Python
Raw Normal View History

2022-12-30 09:28:54 +08:00
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 "计算错误"