start writing letter head with kundennummer, rechnungsnummer and rechnungsdatum
This commit is contained in:
14
src/main.py
14
src/main.py
@@ -67,17 +67,16 @@ def main():
|
|||||||
invoice = parse_yaml_file(invoice_file)
|
invoice = parse_yaml_file(invoice_file)
|
||||||
envelope = parse_yaml_file(envelope_file)
|
envelope = parse_yaml_file(envelope_file)
|
||||||
|
|
||||||
print('Invoice data:')
|
|
||||||
print(invoice)
|
|
||||||
|
|
||||||
print(envelope)
|
|
||||||
|
|
||||||
print('Envelope data:')
|
print('Envelope data:')
|
||||||
envelope_data = DataObject(**envelope)
|
envelope_data = DataObject(**envelope)
|
||||||
print(envelope_data.__dict__)
|
print(envelope_data.__dict__)
|
||||||
|
|
||||||
print('Invoice data:')
|
print('Invoice data:')
|
||||||
invoice_data = DataObject(**invoice)
|
invoice_data = DataObject(**invoice)
|
||||||
|
if not hasattr(invoice_data, 'Id'):
|
||||||
|
invoice_data.Id = None
|
||||||
|
|
||||||
|
invoice_data.Id = invoice_data.Id or invoice_file.stem
|
||||||
print(invoice_data.__dict__)
|
print(invoice_data.__dict__)
|
||||||
|
|
||||||
except FileNotFoundError as e:
|
except FileNotFoundError as e:
|
||||||
@@ -94,7 +93,10 @@ def main():
|
|||||||
template = generator.prepare_template(invoice_data, envelope_data)
|
template = generator.prepare_template(invoice_data, envelope_data)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
html_generator.HtmlTemplate.convert_html_to_pdf(template, 'invoice.pdf')
|
print('Generating invoice...')
|
||||||
|
invoice_pdf = Path(invoice_data.Id).with_suffix('.pdf')
|
||||||
|
print(f'Invoice PDF: {invoice_pdf}')
|
||||||
|
html_generator.HtmlTemplate.convert_html_to_pdf(template, invoice_pdf)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f'Error: {e}')
|
print(f'Error: {e}')
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#Id: RG004712
|
||||||
CustomerId: KD01234
|
CustomerId: KD01234
|
||||||
#InvoiceDate: 2023-12-23
|
#InvoiceDate: 2023-12-23
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@
|
|||||||
#letter_head_content {
|
#letter_head_content {
|
||||||
background-color: lightblue;
|
background-color: lightblue;
|
||||||
}
|
}
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
@@ -57,15 +58,30 @@
|
|||||||
</div>
|
</div>
|
||||||
<div id="letter_head_content">
|
<div id="letter_head_content">
|
||||||
{% for address in envelope.AddressContent.Contents %}
|
{% for address in envelope.AddressContent.Contents %}
|
||||||
{% if address.Head %}
|
{% if address.Head %}
|
||||||
<p><strong>{{ address.Head }}</strong></p>
|
<p><strong>{{ address.Head }}</strong></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<p>{{ address.Text | replace('\n', '<br>') }}</p>
|
<p>{{ address.Text | replace('\n', '<br>') }}</p>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<!-- HTML Content -->
|
<!-- HTML Content -->
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Rechnungsnummer:</td>
|
||||||
|
<td>Kundennummer:</td>
|
||||||
|
<td>Rechnungsdatum:</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>{{ invoice.Id }}</td>
|
||||||
|
<td>{{ invoice.CustomerId }}</td>
|
||||||
|
<td>{{ invoice.InvoiceDate }}</td>
|
||||||
|
</tr>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
|
||||||
To PDF or not to PDF
|
To PDF or not to PDF
|
||||||
|
|
||||||
<section>
|
<section>
|
||||||
|
|||||||
Reference in New Issue
Block a user