From 84f7abfcad6296d0fc538ee4310fcb4e4cb3614d Mon Sep 17 00:00:00 2001 From: martsforever Date: Sat, 23 Aug 2025 20:32:35 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=8A=A5=E9=94=80=E5=8D=95=E7=BB=9F?= =?UTF-8?q?=E8=AE=A1=E8=AE=A1=E7=AE=97=E5=87=BA=E6=9D=A5=E6=80=BB=E7=9A=84?= =?UTF-8?q?=E8=8A=B1=E8=B4=B9=E9=87=91=E9=A2=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/model/ReimburseModel.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/model/ReimburseModel.py b/app/model/ReimburseModel.py index 870a38e..758726f 100644 --- a/app/model/ReimburseModel.py +++ b/app/model/ReimburseModel.py @@ -1,3 +1,5 @@ +import decimal +from decimal import Decimal from typing import Optional, List from pydantic import computed_field @@ -80,6 +82,20 @@ class ReimburseModel(BasicModel, table=True): def other_list(self, value: Optional[List["ReimburseOtherModel"]]) -> None: 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( Cls=ReimburseModel,