Add after-tax amount, and some highlighting
This commit is contained in:
parent
687739acdc
commit
36989f346b
22
taxcalc.py
22
taxcalc.py
@ -52,6 +52,18 @@ locale.setlocale( locale.LC_MONETARY, 'en_ZA.UTF-8' )
|
|||||||
locale._override_localeconv = {'mon_thousands_sep': ' ', 'mon_decimal_point': '.'}
|
locale._override_localeconv = {'mon_thousands_sep': ' ', 'mon_decimal_point': '.'}
|
||||||
currency = locale.localeconv()
|
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:
|
if len(sys.argv) < 2:
|
||||||
error()
|
error()
|
||||||
elif isinstance(sys.argv[1], str):
|
elif isinstance(sys.argv[1], str):
|
||||||
@ -94,11 +106,17 @@ for r in tax_rates:
|
|||||||
if amount < high:
|
if amount < high:
|
||||||
break
|
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):
|
def error(e):
|
||||||
if e:
|
if e:
|
||||||
print(e);
|
print(e);
|
||||||
print("{0}: Please enter the annual or monthly amount before tax".format(sys.argv[0]))
|
print("{0}: Please enter the annual or monthly amount before tax".format(sys.argv[0]))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user