30 lines
619 B
Python
30 lines
619 B
Python
"""
|
||
总债务资本化比率(%)
|
||
"""
|
||
from fastapi import APIRouter
|
||
from pydantic import BaseModel
|
||
|
||
INDEX = "总债务资本化比率(%)"
|
||
|
||
router = APIRouter()
|
||
|
||
|
||
class Params(BaseModel):
|
||
短期借款: float
|
||
长期借款: float
|
||
所有者权益: float
|
||
|
||
|
||
@router.post("/{}".format(INDEX))
|
||
def func(p: Params):
|
||
try:
|
||
m = p.短期借款 + p.长期借款
|
||
d = p.短期借款 + p.长期借款 + p.所有者权益
|
||
result = m / d * 100
|
||
return round(result, 6)
|
||
|
||
except ZeroDivisionError:
|
||
return "算式无意义"
|
||
except Exception:
|
||
return "计算错误"
|