Add after-tax amount, and some highlighting

This commit is contained in:
Timothy Allen 2020-11-05 12:52:18 +02:00
parent 687739acdc
commit 36989f346b

View File

@ -52,6 +52,18 @@ locale.setlocale( locale.LC_MONETARY, 'en_ZA.UTF-8' )
locale._override_localeconv = {'mon_thousands_sep': ' ', 'mon_decimal_point': '.'}
currency = locale.localeconv()
class colour:
PURPLE = '\033[95m'
CYAN = '\033[96m'
DARKCYAN = '\033[36m'
BLUE = '\033[94m'
GREEN = '\033[92m'
YELLOW = '\033[93m'
RED = '\033[91m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
END = '\033[0m'
if len(sys.argv) < 2:
error()
elif isinstance(sys.argv[1], str):
@ -94,11 +106,17 @@ for r in tax_rates:
if amount < high:
break
print("\nTotal tax on {} is {}".format(locale.currency(amount, grouping=True), locale.currency(total_tax, grouping=True)))
remainder = amount - total_tax
print("\nTotal tax on {} is {}{}{}, leaving {}".format(
locale.currency(amount, grouping=True),
colour.BOLD,
locale.currency(total_tax, grouping=True),
colour.END,
locale.currency(remainder, grouping=True)
))
def error(e):
if e:
print(e);
print("{0}: Please enter the annual or monthly amount before tax".format(sys.argv[0]))
sys.exit()