Fix: At times the report would fail with numbers not in multiples of .01
This commit is contained in:
@ -112,7 +112,7 @@ def build_report(
|
|||||||
schemas.CashFlowItem(
|
schemas.CashFlowItem(
|
||||||
name=account_type.name,
|
name=account_type.name,
|
||||||
url=["/", "cash-flow", str(account_type.id)],
|
url=["/", "cash-flow", str(account_type.id)],
|
||||||
amount=amount * -1,
|
amount=round(amount * -1, 2),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -144,14 +144,14 @@ def build_report(
|
|||||||
schemas.CashFlowItem(
|
schemas.CashFlowItem(
|
||||||
name="Net increase in cash and cash equivalents",
|
name="Net increase in cash and cash equivalents",
|
||||||
url=[],
|
url=[],
|
||||||
amount=total_amount,
|
amount=round(total_amount, 2),
|
||||||
),
|
),
|
||||||
schemas.CashFlowItem(
|
schemas.CashFlowItem(
|
||||||
name="Cash and cash equivalents at beginning of period",
|
name="Cash and cash equivalents at beginning of period",
|
||||||
url=[],
|
url=[],
|
||||||
amount=opening,
|
amount=round(opening, 2),
|
||||||
),
|
),
|
||||||
schemas.CashFlowItem(name="Cash and cash equivalents at end of period", url=[], amount=closing),
|
schemas.CashFlowItem(name="Cash and cash equivalents at end of period", url=[], amount=round(closing, 2)),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -188,8 +188,8 @@ def build_report_id(
|
|||||||
schemas.CashFlowItem(
|
schemas.CashFlowItem(
|
||||||
name=account.name,
|
name=account.name,
|
||||||
url=["/", "ledger", str(account.id)],
|
url=["/", "ledger", str(account.id)],
|
||||||
amount=amount * -1,
|
amount=round(amount * -1, 2),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
return cf, [schemas.CashFlowItem(name="total", url=[], amount=total_amount)]
|
return cf, [schemas.CashFlowItem(name="total", url=[], amount=round(total_amount, 2))]
|
||||||
|
|||||||
@ -2,7 +2,7 @@ from datetime import date, datetime
|
|||||||
from decimal import Decimal
|
from decimal import Decimal
|
||||||
from typing import List, Optional, Union
|
from typing import List, Optional, Union
|
||||||
|
|
||||||
from pydantic import Field, validator
|
from pydantic import validator
|
||||||
from pydantic.main import BaseModel
|
from pydantic.main import BaseModel
|
||||||
|
|
||||||
from . import to_camel
|
from . import to_camel
|
||||||
@ -11,7 +11,7 @@ from . import to_camel
|
|||||||
class CashFlowItem(BaseModel):
|
class CashFlowItem(BaseModel):
|
||||||
name: str
|
name: str
|
||||||
url: Optional[List[str]]
|
url: Optional[List[str]]
|
||||||
amount: Decimal = Field(multiple_of=0.01)
|
amount: Decimal
|
||||||
|
|
||||||
class Config:
|
class Config:
|
||||||
anystr_strip_whitespace = True
|
anystr_strip_whitespace = True
|
||||||
|
|||||||
Reference in New Issue
Block a user