-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Serialize decimal with 2 decimal points (#441)
* chore: Add CustomDecimal_13Digits * chore: Add CustomDecimal_12Digits * chore: 13 digits * chore: Add CustomDecimal_7Digits * chore: Add CustomDecimal_15Digits * chore: update import * chore: Add CustomDecimal_12Digits * chore: Add CustomDecimal_13Digits * chore: Add CustomDecimal_7Digits * chore: Update imports * chore: Update generate_treasury_report with str --------- Co-authored-by: Victor Shia <[email protected]>
- Loading branch information
Showing
4 changed files
with
108 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from typing_extensions import Annotated | ||
from pydantic import BaseModel, Field, PlainSerializer | ||
from decimal import Decimal | ||
|
||
|
||
CustomDecimal_16Digits = Annotated[ | ||
Decimal, Field( | ||
max_digits=16, | ||
decimal_places=2 | ||
), PlainSerializer( | ||
lambda x: f"{float(x):.2f}", | ||
return_type=str, | ||
), | ||
] | ||
|
||
CustomDecimal_15Digits = Annotated[ | ||
Decimal, Field( | ||
max_digits=15, | ||
decimal_places=2 | ||
), PlainSerializer( | ||
lambda x: f"{float(x):.2f}", | ||
return_type=str, | ||
), | ||
] | ||
|
||
CustomDecimal_13Digits = Annotated[ | ||
Decimal, Field( | ||
max_digits=13, | ||
decimal_places=2 | ||
), PlainSerializer( | ||
lambda x: f"{float(x):.2f}", | ||
return_type=str, | ||
), | ||
] | ||
|
||
CustomDecimal_12Digits = Annotated[ | ||
Decimal, Field( | ||
max_digits=12, | ||
decimal_places=2 | ||
), PlainSerializer( | ||
lambda x: f"{float(x):.2f}", | ||
return_type=str, | ||
), | ||
] | ||
|
||
CustomDecimal_7Digits = Annotated[ | ||
Decimal, Field( | ||
max_digits=7, | ||
decimal_places=2 | ||
), PlainSerializer( | ||
lambda x: f"{float(x):.2f}", | ||
return_type=str, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.