Created
October 17, 2018 23:06
-
-
Save kgriffs/871a9176515b55d94a77c974efef1d2e to your computer and use it in GitHub Desktop.
DB to Decimal Utility Functions
This file contains hidden or 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
def _db_to_decimal(db_number): | |
if db_number is None: | |
return None | |
return Decimal(int(db_number)) / 100 | |
def _decimal_to_db(decimal_number, currency=True): | |
if decimal_number is None: | |
return None | |
if currency: | |
decimal_number = decimal_number.quantize(Decimal('.01'), rounding=ROUND_CEILING) | |
return int(decimal_number * 100) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment