Bernd Wurst commited on 2024-01-26 12:36:35
Zeige 3 geänderte Dateien mit 24 Einfügungen und 12 Löschungen.
... | ... |
@@ -107,6 +107,12 @@ VAT_REGULAR = 'S' |
107 | 107 |
VAT_KLEINUNTERNEHMER = 'E' |
108 | 108 |
VAT_INNERGEM = 'K' |
109 | 109 |
|
110 |
+PAYMENT_LASTSCHRIFT = "59" |
|
111 |
+PAYMENT_UEBERWEISUNG = "30" |
|
112 |
+PAYMENT_BANKKONTO = "42" |
|
113 |
+PAYMENT_BAR = "10" |
|
114 |
+PAYMENT_KARTE = "48" |
|
115 |
+ |
|
110 | 116 |
class Invoice(object): |
111 | 117 |
def __init__(self, tender = False): |
112 | 118 |
self.customerno = None |
... | ... |
@@ -148,6 +154,7 @@ class Invoice(object): |
148 | 154 |
} |
149 | 155 |
self.due_date = None |
150 | 156 |
self.debit = False |
157 |
+ self.payment_type = PAYMENT_UEBERWEISUNG |
|
151 | 158 |
self.debit_mandate_id = None |
152 | 159 |
self.creditor_reference_id = None |
153 | 160 |
self.buyer_bank_data = { |
... | ... |
@@ -21,7 +21,7 @@ import os.path |
21 | 21 |
import reportlab |
22 | 22 |
from reportlab.lib import fonts |
23 | 23 |
|
24 |
-from .InvoiceObjects import InvoiceTable, InvoiceText, InvoiceImage |
|
24 |
+from .InvoiceObjects import InvoiceTable, InvoiceText, InvoiceImage, GUTSCHRIFT |
|
25 | 25 |
import re |
26 | 26 |
|
27 | 27 |
# reportlab imports |
... | ... |
@@ -308,8 +308,10 @@ class PDF(object): |
308 | 308 |
self.canvas.drawString(self.rightcolumn, self.y, line) |
309 | 309 |
self.y -= (self.font_size + 5) |
310 | 310 |
self.y -= 5 |
311 |
+ if self.invoice.seller['phone']: |
|
311 | 312 |
self.canvas.drawString(self.rightcolumn, self.y, f"Tel: {self.invoice.seller['phone']}") |
312 | 313 |
self.y -= (self.font_size + 5) |
314 |
+ if self.invoice.seller['email']: |
|
313 | 315 |
self.canvas.drawString(self.rightcolumn, self.y, f"E-Mail: {self.invoice.seller['email']}") |
314 | 316 |
self.y -= (self.font_size + 10) |
315 | 317 |
self.y = -9.5*cm |
... | ... |
@@ -353,6 +355,8 @@ class PDF(object): |
353 | 355 |
introText = 'hiermit stellen wir Ihnen die nachfolgend genannten Leistungen in Rechnung.' |
354 | 356 |
if self.invoice.tender: |
355 | 357 |
introText = 'hiermit unterbreiten wir Ihnen folgendes Angebot.' |
358 |
+ if self.invoice.type == GUTSCHRIFT: |
|
359 |
+ introText = 'nach unserer Berechnung entsteht für Sie folgende Gutschrift.' |
|
356 | 360 |
intro = self._splitToWidth(introText, self.rightcontent - self.leftcontent, self.font, self.font_size) |
357 | 361 |
for line in intro: |
358 | 362 |
self.canvas.drawString(self.leftcontent, self.y, line) |
... | ... |
@@ -36,7 +36,7 @@ from drafthorse.models.document import Document |
36 | 36 |
from drafthorse.models.accounting import ApplicableTradeTax |
37 | 37 |
from drafthorse.models.tradelines import LineItem |
38 | 38 |
from .InvoiceObjects import InvoiceTable, InvoiceText, InvoiceImage, RECHNUNG, GUTSCHRIFT, KORREKTUR, \ |
39 |
- VAT_REGULAR, VAT_KLEINUNTERNEHMER, VAT_INNERGEM |
|
39 |
+ VAT_REGULAR, VAT_KLEINUNTERNEHMER, VAT_INNERGEM, PAYMENT_UEBERWEISUNG, PAYMENT_LASTSCHRIFT |
|
40 | 40 |
from drafthorse.models.party import TaxRegistration, URIUniversalCommunication |
41 | 41 |
from drafthorse.models.payment import PaymentTerms |
42 | 42 |
from drafthorse.models.note import IncludedNote |
... | ... |
@@ -44,7 +44,7 @@ from drafthorse.pdf import attach_xml |
44 | 44 |
|
45 | 45 |
def InvoiceToXML(invoice): |
46 | 46 |
doc = Document() |
47 |
- doc.context.guideline_parameter.id = "urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:extended" |
|
47 |
+ doc.context.guideline_parameter.id = "urn:cen.eu:en16931:2017#conformant#urn:factur-x.eu:1p0:en16931" |
|
48 | 48 |
doc.header.id = invoice.id |
49 | 49 |
# Typecodes: |
50 | 50 |
# 380: Handelsrechnungen |
... | ... |
@@ -196,23 +196,24 @@ def InvoiceToXML(invoice): |
196 | 196 |
doc.trade.settlement.creditor_reference_id = invoice.creditor_reference_id |
197 | 197 |
doc.trade.settlement.payment_reference = invoice.id |
198 | 198 |
doc.trade.settlement.currency_code = 'EUR' |
199 |
- if invoice.debit: |
|
200 |
- doc.trade.settlement.payment_means.type_code = "59" |
|
201 |
- else: |
|
202 |
- doc.trade.settlement.payment_means.type_code = "30" |
|
203 |
- if invoice.seller_bank_data['iban']: |
|
199 |
+ if invoice.payment_type: |
|
200 |
+ doc.trade.settlement.payment_means.type_code = invoice.payment_type |
|
201 |
+ |
|
202 |
+ if invoice.seller_bank_data['iban'] and invoice.payment_type == PAYMENT_UEBERWEISUNG: |
|
204 | 203 |
doc.trade.settlement.payment_means.payee_account.iban = invoice.seller_bank_data['iban'] |
205 | 204 |
doc.trade.settlement.payment_means.payee_institution.bic = "GENODES1VBK" |
206 | 205 |
# Ist in der Library vorhanden, validiert aber nicht im XML?! |
207 |
- if invoice.buyer_bank_data['iban']: |
|
206 |
+ if invoice.buyer_bank_data['iban'] and invoice.payment_type == PAYMENT_LASTSCHRIFT: |
|
208 | 207 |
# Kunden-Bankverbindung bei Lastschrift |
209 | 208 |
doc.trade.settlement.payment_means.payer_account.iban = invoice.buyer_bank_data['iban'] |
210 | 209 |
|
211 | 210 |
terms = PaymentTerms() |
212 |
- if invoice.due_date: |
|
211 |
+ if invoice.due_date and invoice.payment_type == PAYMENT_UEBERWEISUNG: |
|
213 | 212 |
terms.description = f"Bitte begleichen Sie den Betrag bis zum {invoice.due_date.strftime('%d.%m.%Y')} ohne Abzüge." |
214 | 213 |
terms.due = invoice.due_date |
215 |
- if invoice.debit: |
|
214 |
+ if invoice.type == GUTSCHRIFT: |
|
215 |
+ terms.description = f"Wir überweisen den Betrag auf Ihr Konto." |
|
216 |
+ elif invoice.debit: |
|
216 | 217 |
if invoice.debit_mandate_id: |
217 | 218 |
# Mandatsreferenz für Lastschrift |
218 | 219 |
terms.debit_mandate_id = invoice.debit_mandate_id |
... | ... |
@@ -231,7 +232,7 @@ def InvoiceToXML(invoice): |
231 | 232 |
|
232 | 233 |
|
233 | 234 |
# Generate XML file |
234 |
- xml = doc.serialize(schema="FACTUR-X_EXTENDED") |
|
235 |
+ xml = doc.serialize(schema="FACTUR-X_EN16931") |
|
235 | 236 |
return xml |
236 | 237 |
|
237 | 238 |
|
238 | 239 |