mirror of
https://github.com/paperless-ngx/paperless-ngx.git
synced 2025-03-31 13:35:08 -05:00
Just some stuff
This commit is contained in:
parent
112b39c4de
commit
198ee6ea09
@ -198,6 +198,12 @@ Docker, this may be the `environment` key of the webserver or a
|
||||
containing the configuration parameters. Be sure to use the correct format
|
||||
and watch out for indentation if editing the YAML file.
|
||||
|
||||
#### [`PAPERLESS_EINVOICE_PARSER_ENABLED=<bool>`](#PAPERLESS_EINVOICE_PARSER_ENABLED) {#PAPERLESS_EINVOICE_PARSER_ENABLED}
|
||||
|
||||
: Enable (or disable) the e-invoice parser. Note that this feature requires Tika to be enabled.
|
||||
|
||||
Defaults to false.
|
||||
|
||||
## Paths and folders
|
||||
|
||||
#### [`PAPERLESS_CONSUMPTION_DIR=<path>`](#PAPERLESS_CONSUMPTION_DIR) {#PAPERLESS_CONSUMPTION_DIR}
|
||||
|
@ -87,6 +87,7 @@
|
||||
#PAPERLESS_TIKA_ENABLED=false
|
||||
#PAPERLESS_TIKA_ENDPOINT=http://localhost:9998
|
||||
#PAPERLESS_TIKA_GOTENBERG_ENDPOINT=http://localhost:3000
|
||||
#PAPERLESS_EINVOICE_PARSER_ENABLED=true
|
||||
|
||||
# Binaries
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from pathlib import Path
|
||||
|
||||
from django.conf import settings
|
||||
from drafthorse.models.document import Document
|
||||
from drafthorse.models.document import Document as InvoiceDocument
|
||||
from gotenberg_client import GotenbergClient
|
||||
from gotenberg_client.options import MarginType
|
||||
from gotenberg_client.options import MarginUnitType
|
||||
@ -22,6 +22,10 @@ class EInvoiceDocumentParser(TikaDocumentParser):
|
||||
"""
|
||||
|
||||
logging_name = "paperless.parsing.einvoice"
|
||||
template_loader = FileSystemLoader(
|
||||
searchpath=Path(__file__).parent / "templates",
|
||||
)
|
||||
template_env = Environment(loader=template_loader)
|
||||
|
||||
def convert_to_pdf(self, document_path: Path, file_name):
|
||||
pdf_path = Path(self.tempdir) / "convert.pdf"
|
||||
@ -29,15 +33,25 @@ class EInvoiceDocumentParser(TikaDocumentParser):
|
||||
|
||||
with document_path.open("r") as f:
|
||||
xml = f.read().encode("utf-8")
|
||||
invoice = Document.parse(xml)
|
||||
invoice = InvoiceDocument.parse(xml)
|
||||
context = {
|
||||
"id": invoice.trade.agreement.seller.name,
|
||||
"id": invoice.header.id,
|
||||
"seller_name": invoice.trade.agreement.seller.name,
|
||||
"seller_address": invoice.trade.agreement.seller.address,
|
||||
"buyer_name": invoice.trade.agreement.buyer.name,
|
||||
"buyer_address": invoice.trade.agreement.buyer.address,
|
||||
"issue_date": invoice.header.issue_date_time,
|
||||
"items": [
|
||||
{
|
||||
"name": item.product.name,
|
||||
"description": item.product.description,
|
||||
# "quantity": item.product.quantity,
|
||||
"subtotal": item.settlement.monetary_summation.total_amount,
|
||||
}
|
||||
for item in invoice.trade.items.children # TODO: Fix this
|
||||
],
|
||||
}
|
||||
templateLoader = FileSystemLoader(
|
||||
searchpath=Path(__file__).parent / "templates",
|
||||
)
|
||||
templateEnv = Environment(loader=templateLoader)
|
||||
template = templateEnv.get_template("invoice.j2.html")
|
||||
template = self.template_env.get_template("invoice.j2.html")
|
||||
html_file = Path(self.tempdir) / "invoice_as_html.html"
|
||||
html_file.write_text(
|
||||
template.render(context),
|
||||
|
@ -10,10 +10,10 @@
|
||||
<h1>Rechnung</h1>
|
||||
|
||||
<p id="fromaddress">
|
||||
<u>westnetz w.V., Karl-Heine-Str. 93, 04229 Leipzig</u>
|
||||
<u>{{ seller_name }}: {{ seller_address }}</u>
|
||||
</p>
|
||||
<p id="toaddress">
|
||||
{{ address | join("<br />") }}
|
||||
{{ buyer_name }}: {{ buyer_address }}
|
||||
</p>
|
||||
|
||||
|
||||
@ -25,8 +25,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="info">{{ id }}</td>
|
||||
<td class="info">{{ period }}</td>
|
||||
<td class="info">{{ date }}</td>
|
||||
<td class="info">{{ issue_date }}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@ -36,16 +35,12 @@
|
||||
<tr>
|
||||
<th id="tablepos">Pos.</th>
|
||||
<th id="tabledesc">Beschreibung</th>
|
||||
<th id="tablesingle">Einzelpreis</th>
|
||||
<th id="tablequantity">Anzahl</th>
|
||||
<th id="tabletotal">Gesamtpreis</th>
|
||||
</tr>
|
||||
{% for item in items %}
|
||||
<tr class="position">
|
||||
<td class="positions">{{ item.item }}</td>
|
||||
<td class="positions">{{ item.name }}</td>
|
||||
<td class="positions">{{ item.description }}</td>
|
||||
<td class="positions">{{ item.price }}</td>
|
||||
<td class="positions">{{ item.quantity }}</td>
|
||||
<td class="positions">{{ item.subtotal }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
@ -74,7 +69,5 @@
|
||||
Diese Rechnung wurde maschinell erstellt und ist auch ohne Unterschrift gültig.
|
||||
</p>
|
||||
|
||||
<embed src="file:///{{ logo_asset_file }}" id="logo" />
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
x
Reference in New Issue
Block a user