feat: 报销单统计计算出来总的花费金额
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
import decimal
|
||||||
|
from decimal import Decimal
|
||||||
from typing import Optional, List
|
from typing import Optional, List
|
||||||
|
|
||||||
from pydantic import computed_field
|
from pydantic import computed_field
|
||||||
@@ -80,6 +82,20 @@ class ReimburseModel(BasicModel, table=True):
|
|||||||
def other_list(self, value: Optional[List["ReimburseOtherModel"]]) -> None:
|
def other_list(self, value: Optional[List["ReimburseOtherModel"]]) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@computed_field
|
||||||
|
@property
|
||||||
|
def amount(self) -> Decimal:
|
||||||
|
ret = Decimal(0)
|
||||||
|
for other_item in (self.other_list or []):
|
||||||
|
ret = ret + Decimal(other_item.amount)
|
||||||
|
for travel_item in (self.travel_list or []):
|
||||||
|
ret = ret + Decimal(travel_item.amount)
|
||||||
|
return ret
|
||||||
|
|
||||||
|
@amount.setter
|
||||||
|
def amount(self, value: decimal) -> None:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
ReimburseService = create_model_service(
|
ReimburseService = create_model_service(
|
||||||
Cls=ReimburseModel,
|
Cls=ReimburseModel,
|
||||||
|
|||||||
Reference in New Issue
Block a user