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

28 lines
713 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 "计算错误"