From b43795255069928e8a7645a572496a49987993dd Mon Sep 17 00:00:00 2001 From: Lukas Winkler Date: Sat, 5 May 2018 13:04:30 +0200 Subject: [PATCH] support bank fees --- main.py | 9 ++++++--- strings.yaml | 4 +++- template.tex | 5 ++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 512cf5a..ad80231 100644 --- a/main.py +++ b/main.py @@ -14,7 +14,7 @@ def create_invoice(): "locale": ask("locale", "set", set=["de", "en"], default="de"), "id": ask("id", "int", default=current_id), "title": ask("title"), - "recipient": ask("recipient", "set", set=get_possible_recipents(), default="innocraft"), + "recipient": ask("recipient", "set", set=get_possible_recipents(), default=config["default_recipient"]), "date": ask("date", "date", default="today"), "mode": ask("Mode", "set", set=["single", "hourly"], default="hourly"), "description": ask("description"), @@ -32,6 +32,7 @@ def create_invoice(): "per_hour": ask("per hour", "money", default=config["default_hourly_rate"]) } invoice.update(hourly) + invoice["bank_fee"] = ask("bank_fee", "boolean") directory = invoice_dir + "/" + str(invoice["id"]) if os.path.exists(directory): if not ask("overwrite", "boolean"): @@ -63,11 +64,13 @@ def compile_invoice(id): loader=jinja2.FileSystemLoader(os.path.abspath('.')) ) if invoice["mode"] == "hourly": - invoice["total"] = invoice["per_hour"] * (invoice["hours"] + invoice["minutes"] / 60) + invoice["hourtotal"] = invoice["per_hour"] * (invoice["hours"] + invoice["minutes"] / 60) + invoice["total"] = invoice["hourtotal"] + config["bank_fee"] data = { "from": load_yaml("from.yaml"), "to": load_yaml("recipients/{id}.yaml".format(id=invoice["recipient"])), - "invoice": invoice + "invoice": invoice, + "config": config } strings = load_yaml("strings.yaml") diff --git a/strings.yaml b/strings.yaml index 2784a8d..ab84018 100644 --- a/strings.yaml +++ b/strings.yaml @@ -22,7 +22,9 @@ taxexception: transfer: de: Ich bitte Sie, den Gesamtbetrag innerhalb der nächsten 10 Werktage auf folgendes Konto zu überweisen en: Please transfer the due invoice amount to the following account - range: de: Leistungszeitraum en: period +bank_fee: + de: Überweisungsgebühr + en: Bank Fees diff --git a/template.tex b/template.tex index 04e0ec2..06f7148 100644 --- a/template.tex +++ b/template.tex @@ -105,8 +105,11 @@ \VAR{invoice.description} & \EUR{\VAR{invoice.per_hour | formatdigit }} & \VAR{invoice.hours}:\VAR{invoice.minutes} & - \EUR{\VAR{invoice.total | formatdigit }} \\ + \EUR{\VAR{invoice.hourtotal | formatdigit }} \\ + \BLOCK{if invoice.bank_fee} + \VAR{"bank_fee"|t} & & & \EUR{\VAR{config.bank_fee| formatdigit}} \\ + \BLOCK{endif} \midrule %\cmidrule{4-4}