1
0
Fork 0
mirror of https://github.com/Findus23/invoices.git synced 2024-09-19 15:13:47 +02:00

allow locking invoices

This commit is contained in:
Lukas Winkler 2018-03-14 08:53:22 +01:00
parent 0a83710079
commit cd2edbc539
No known key found for this signature in database
GPG key ID: 94AFBE7C2656A5B5

View file

@ -41,6 +41,9 @@ def create_invoice():
def compile_invoice(id):
directory = invoice_dir + "/" + str(id)
if os.path.exists(directory + "/locked"):
print("The invoice has already been locked")
exit()
invoice = load_yaml(directory + "/data.yaml")
env = jinja2.Environment(
block_start_string='\BLOCK{',
@ -85,7 +88,8 @@ def compile_invoice(id):
template = env.get_template('template.tex')
fh.write(template.render(section1='Long Form', section2='Short Form', **data))
os.chdir(directory)
subprocess.check_call(['pdflatex', '{name}.tex'.format(name=translate("invoice"))])
for _ in range(2):
subprocess.check_call(['pdflatex', '{name}.tex'.format(name=translate("invoice"))])
print(directory)
remove_tmp_files(translate("invoice"))