WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 1) # -*- coding: utf-8 -*-
src/rechnung/Invoice/InvoiceToZUGFeRD.py 2) # (C) 2011 by Bernd Wurst <bernd@schokokeks.org>
src/rechnung/Invoice/InvoiceToZUGFeRD.py 3)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 4) # This file is part of Bib2011.
src/rechnung/Invoice/InvoiceToZUGFeRD.py 5) #
src/rechnung/Invoice/InvoiceToZUGFeRD.py 6) # Bib2011 is free software: you can redistribute it and/or modify
src/rechnung/Invoice/InvoiceToZUGFeRD.py 7) # it under the terms of the GNU General Public License as published by
src/rechnung/Invoice/InvoiceToZUGFeRD.py 8) # the Free Software Foundation, either version 3 of the License, or
src/rechnung/Invoice/InvoiceToZUGFeRD.py 9) # (at your option) any later version.
src/rechnung/Invoice/InvoiceToZUGFeRD.py 10) #
src/rechnung/Invoice/InvoiceToZUGFeRD.py 11) # Bib2011 is distributed in the hope that it will be useful,
src/rechnung/Invoice/InvoiceToZUGFeRD.py 12) # but WITHOUT ANY WARRANTY; without even the implied warranty of
src/rechnung/Invoice/InvoiceToZUGFeRD.py 13) # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
src/rechnung/Invoice/InvoiceToZUGFeRD.py 14) # GNU General Public License for more details.
src/rechnung/Invoice/InvoiceToZUGFeRD.py 15) #
src/rechnung/Invoice/InvoiceToZUGFeRD.py 16) # You should have received a copy of the GNU General Public License
src/rechnung/Invoice/InvoiceToZUGFeRD.py 17) # along with Bib2011. If not, see <http://www.gnu.org/licenses/>.
src/rechnung/Invoice/InvoiceToZUGFeRD.py 18)
|
Kontoinhaber im XML einsetzen
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 19) import os.path
src/rechnung/Invoice/InvoiceToZUGFeRD.py 20) import sys
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 21) from decimal import Decimal
src/rechnung/Invoice/InvoiceToZUGFeRD.py 22)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 23) # Search for included submodule python-drafthorse
src/rechnung/Invoice/InvoiceToZUGFeRD.py 24) atoms = os.path.abspath(os.path.dirname(__file__)).split('/')
src/rechnung/Invoice/InvoiceToZUGFeRD.py 25) dir = ''
src/rechnung/Invoice/InvoiceToZUGFeRD.py 26) while atoms:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 27) candidate = os.path.join('/'.join(atoms), 'external/python-drafthorse')
src/rechnung/Invoice/InvoiceToZUGFeRD.py 28) if os.path.exists(candidate):
src/rechnung/Invoice/InvoiceToZUGFeRD.py 29) dir = candidate
src/rechnung/Invoice/InvoiceToZUGFeRD.py 30) break
src/rechnung/Invoice/InvoiceToZUGFeRD.py 31) atoms = atoms[:-1]
src/rechnung/Invoice/InvoiceToZUGFeRD.py 32) sys.path.insert(0, dir)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 33) from drafthorse.models.document import Document
src/rechnung/Invoice/InvoiceToZUGFeRD.py 34) from drafthorse.models.accounting import ApplicableTradeTax
src/rechnung/Invoice/InvoiceToZUGFeRD.py 35) from drafthorse.models.tradelines import LineItem
|
Codestyle-Fixes
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 36) from .InvoiceObjects import InvoiceTable, InvoiceText, RECHNUNG, GUTSCHRIFT, KORREKTUR, \
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 37) VAT_REGULAR, VAT_KLEINUNTERNEHMER, VAT_INNERGEM, PAYMENT_UEBERWEISUNG, PAYMENT_LASTSCHRIFT
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 38) from drafthorse.models.party import TaxRegistration, URIUniversalCommunication
src/rechnung/Invoice/InvoiceToZUGFeRD.py 39) from drafthorse.models.payment import PaymentTerms
src/rechnung/Invoice/InvoiceToZUGFeRD.py 40) from drafthorse.models.note import IncludedNote
src/rechnung/Invoice/InvoiceToZUGFeRD.py 41) from drafthorse.pdf import attach_xml
src/rechnung/Invoice/InvoiceToZUGFeRD.py 42)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 43) def InvoiceToXML(invoice):
src/rechnung/Invoice/InvoiceToZUGFeRD.py 44) doc = Document()
|
Falscher ID-String
Bernd Wurst authored 7 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 45) doc.context.guideline_parameter.id = "urn:cen.eu:en16931:2017"
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 46) doc.header.id = invoice.id
src/rechnung/Invoice/InvoiceToZUGFeRD.py 47) # Typecodes:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 48) # 380: Handelsrechnungen
src/rechnung/Invoice/InvoiceToZUGFeRD.py 49) # 381: Gutschrift
src/rechnung/Invoice/InvoiceToZUGFeRD.py 50) # 384: Korrekturrechnung
src/rechnung/Invoice/InvoiceToZUGFeRD.py 51) # 389: Eigenrechnung (vom Käufer im Namen des Lieferanten erstellt).
src/rechnung/Invoice/InvoiceToZUGFeRD.py 52) # 261: Selbstverfasste Gutschrift.
src/rechnung/Invoice/InvoiceToZUGFeRD.py 53) # 386: Vorauszahlungsrechnung
src/rechnung/Invoice/InvoiceToZUGFeRD.py 54) # 326: Teilrechnung
src/rechnung/Invoice/InvoiceToZUGFeRD.py 55) # 751: Rechnungsinformation - KEINE RECHNUNG
src/rechnung/Invoice/InvoiceToZUGFeRD.py 56) if invoice.type == RECHNUNG:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 57) doc.header.type_code = "380"
src/rechnung/Invoice/InvoiceToZUGFeRD.py 58) elif invoice.type == GUTSCHRIFT:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 59) doc.header.type_code = "381"
src/rechnung/Invoice/InvoiceToZUGFeRD.py 60) elif invoice.type == KORREKTUR:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 61) doc.header.type_code = "384"
src/rechnung/Invoice/InvoiceToZUGFeRD.py 62) else:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 63) raise TypeError("Unbekannter Rechnungstyp, kann kein XML erstellen")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 64) doc.header.issue_date_time = invoice.date
src/rechnung/Invoice/InvoiceToZUGFeRD.py 65)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 66) # Seller-Address
src/rechnung/Invoice/InvoiceToZUGFeRD.py 67) if invoice.seller['trade_name']:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 68) pass
src/rechnung/Invoice/InvoiceToZUGFeRD.py 69) # FIXME: specified_legal_organization ist in der Library nicht implementiert, pull request ist vorhanden
|
Kontoinhaber im XML einsetzen
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 70) # doc.trade.agreement.seller.specified_legal_organization.trade_name = invoice.seller['trade_name']
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 71) doc.trade.agreement.seller.name = invoice.seller['name']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 72) doc.trade.agreement.seller.address.country_id = invoice.seller['address']['country_id']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 73) doc.trade.agreement.seller.address.postcode = invoice.seller['address']['postcode']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 74) doc.trade.agreement.seller.address.city_name = invoice.seller['address']['city_name']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 75) doc.trade.agreement.seller.address.line_one = invoice.seller['address']['line1']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 76) doc.trade.agreement.seller.address.line_two = invoice.seller['address']['line2']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 77) doc.trade.agreement.seller.address.line_three = invoice.seller['address']['line3']
|
Telefonnummer
Bernd Wurst authored 7 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 78) if invoice.seller['phone']:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 79) doc.trade.agreement.seller.contact.telephone.number = invoice.seller['phone']
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 80) if invoice.seller_vat_id:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 81) tax_reg = TaxRegistration()
src/rechnung/Invoice/InvoiceToZUGFeRD.py 82) tax_reg.id = ('VA', invoice.seller_vat_id)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 83) doc.trade.agreement.seller.tax_registrations.add(tax_reg)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 84) if invoice.seller['email']:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 85) email = URIUniversalCommunication()
src/rechnung/Invoice/InvoiceToZUGFeRD.py 86) email.uri_ID = ('EM', invoice.seller['email'])
src/rechnung/Invoice/InvoiceToZUGFeRD.py 87) # FIXME: Typo in der Library ("adress")?
src/rechnung/Invoice/InvoiceToZUGFeRD.py 88) doc.trade.agreement.seller.electronic_adress.add(email)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 89)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 90) # Buyer-Address
src/rechnung/Invoice/InvoiceToZUGFeRD.py 91) doc.trade.agreement.buyer.name = invoice.customer['name']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 92) doc.trade.agreement.buyer.address.country_id = invoice.customer['address']['country_id']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 93) doc.trade.agreement.buyer.address.postcode = invoice.customer['address']['postcode']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 94) doc.trade.agreement.buyer.address.city_name = invoice.customer['address']['city_name']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 95) doc.trade.agreement.buyer.address.line_one = invoice.customer['address']['line1']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 96) doc.trade.agreement.buyer.address.line_two = invoice.customer['address']['line2']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 97) doc.trade.agreement.buyer.address.line_three = invoice.customer['address']['line3']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 98)
|
Telefonnummer
Bernd Wurst authored 7 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 99) if invoice.buyer_reference:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 100) # "Leitweg-ID" in XRechnung
src/rechnung/Invoice/InvoiceToZUGFeRD.py 101) doc.trade.agreement.buyer_reference = invoice.buyer_reference
|
Referenznummern auf allen A...
Bernd Wurst authored 7 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 102) if invoice.order_number:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 103) doc.trade.agreement.buyer_order.issuer_assigned_id = invoice.order_number
src/rechnung/Invoice/InvoiceToZUGFeRD.py 104) if invoice.contract_number:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 105) doc.trade.agreement.contract.issuer_assigned_id = invoice.contract_number
|
Telefonnummer
Bernd Wurst authored 7 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 106)
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 107) # Line Items
src/rechnung/Invoice/InvoiceToZUGFeRD.py 108) summe_netto = 0.0
src/rechnung/Invoice/InvoiceToZUGFeRD.py 109) summe_brutto = 0.0
src/rechnung/Invoice/InvoiceToZUGFeRD.py 110) summe_bezahlt = 0.0
src/rechnung/Invoice/InvoiceToZUGFeRD.py 111) summe_ust = 0.0
src/rechnung/Invoice/InvoiceToZUGFeRD.py 112) line_id_count = 0
src/rechnung/Invoice/InvoiceToZUGFeRD.py 113) textparts = []
src/rechnung/Invoice/InvoiceToZUGFeRD.py 114) for part in invoice.parts:
|
Codestyle-Fixes
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 115) if isinstance(part, InvoiceText):
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 116) textparts += part.paragraphs
|
Codestyle-Fixes
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 117) if isinstance(part, InvoiceTable):
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 118) for el in part.entries:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 119) line_id_count += 1
src/rechnung/Invoice/InvoiceToZUGFeRD.py 120) li = LineItem()
src/rechnung/Invoice/InvoiceToZUGFeRD.py 121) li.document.line_id = f"{line_id_count}"
src/rechnung/Invoice/InvoiceToZUGFeRD.py 122) li.product.name = el['subject']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 123) if 'desc' in el and el['desc'] != '':
src/rechnung/Invoice/InvoiceToZUGFeRD.py 124) desc = li.product.description = el['desc']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 125)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 126) if 'period_start' in el and el['period_start']:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 127) if 'period_end' in el and el['period_end']:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 128) li.settlement.period.start = el['period_start']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 129) li.settlement.period.end = el['period_end']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 130) else:
|
Referenznummern auf allen A...
Bernd Wurst authored 7 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 131) #li.delivery.event.occurrence = el['period_start']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 132) # FIXME: Fehler in drafthorse?! Wird nicht akzeptiert.
src/rechnung/Invoice/InvoiceToZUGFeRD.py 133) pass
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 134)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 135) # FIXME: Hier sollte der passende Code benutzt werden (z.B. Monat)
|
Kleine Korrekturen, mache B...
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 136) li.delivery.billed_quantity = (Decimal(el['count']), 'C62')
src/rechnung/Invoice/InvoiceToZUGFeRD.py 137) # C62 = ohne Einheit
src/rechnung/Invoice/InvoiceToZUGFeRD.py 138) # H87 = Stück
src/rechnung/Invoice/InvoiceToZUGFeRD.py 139) # MON = Month
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 140) # LTR = Liter (1 dm3)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 141) # KGM = Kilogram
src/rechnung/Invoice/InvoiceToZUGFeRD.py 142) # MTR = Meter
src/rechnung/Invoice/InvoiceToZUGFeRD.py 143) # TNE = Tonne
src/rechnung/Invoice/InvoiceToZUGFeRD.py 144)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 145) li.settlement.trade_tax.type_code = "VAT"
src/rechnung/Invoice/InvoiceToZUGFeRD.py 146) if invoice.vat_type == VAT_REGULAR:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 147) li.settlement.trade_tax.category_code = "S"
src/rechnung/Invoice/InvoiceToZUGFeRD.py 148) elif invoice.vat_type == VAT_KLEINUNTERNEHMER:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 149) li.settlement.trade_tax.category_code = "E"
src/rechnung/Invoice/InvoiceToZUGFeRD.py 150) elif invoice.vat_type == VAT_INNERGEM:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 151) li.settlement.trade_tax.category_code = "K"
src/rechnung/Invoice/InvoiceToZUGFeRD.py 152) # FIXME: Typ bei uns nur global gesetzt, nicht pro Artikel
src/rechnung/Invoice/InvoiceToZUGFeRD.py 153) # S = Standard VAT rate
src/rechnung/Invoice/InvoiceToZUGFeRD.py 154) # Z = Zero rated goods
src/rechnung/Invoice/InvoiceToZUGFeRD.py 155) # E = VAT exempt
src/rechnung/Invoice/InvoiceToZUGFeRD.py 156) # AE = Reverse charge
src/rechnung/Invoice/InvoiceToZUGFeRD.py 157) # K = Intra-Community supply (specific reverse charge)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 158) # G = Exempt VAT for Export outside EU
src/rechnung/Invoice/InvoiceToZUGFeRD.py 159) # O = Outside VAT scope
|
Kontoinhaber im XML einsetzen
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 160) li.settlement.trade_tax.rate_applicable_percent = Decimal(f"{el['vat'] * 100:.1f}")
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 161)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 162) nettopreis = el['price']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 163) if part.vatType == 'gross':
src/rechnung/Invoice/InvoiceToZUGFeRD.py 164) nettopreis = el['price'] / (1 + el['vat'])
src/rechnung/Invoice/InvoiceToZUGFeRD.py 165) li.agreement.net.amount = Decimal(f"{nettopreis:.2f}")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 166)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 167) nettosumme = el['total']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 168) if part.vatType == 'gross':
src/rechnung/Invoice/InvoiceToZUGFeRD.py 169) nettosumme = el['total'] / (1 + el['vat'])
src/rechnung/Invoice/InvoiceToZUGFeRD.py 170) li.settlement.monetary_summation.total_amount = Decimal(f"{nettosumme:.2f}")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 171)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 172) summe_netto += nettosumme
src/rechnung/Invoice/InvoiceToZUGFeRD.py 173) summe_brutto += el['total']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 174) doc.trade.items.add(li)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 175)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 176) for pay in part.payments:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 177) summe_bezahlt += pay['amount']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 178)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 179) for vat, vatdata in part.vat.items():
src/rechnung/Invoice/InvoiceToZUGFeRD.py 180) trade_tax = ApplicableTradeTax()
src/rechnung/Invoice/InvoiceToZUGFeRD.py 181) # Steuerbetrag dieses Steuersatzes
src/rechnung/Invoice/InvoiceToZUGFeRD.py 182) trade_tax.calculated_amount = Decimal(f"{(vatdata[0] / (vat + 1)) * vat:.2f}")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 183) # Nettosumme dieses Steuersatzes
src/rechnung/Invoice/InvoiceToZUGFeRD.py 184) trade_tax.basis_amount = Decimal(f"{(vatdata[0] / (vat + 1)):.2f}")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 185) trade_tax.type_code = "VAT"
src/rechnung/Invoice/InvoiceToZUGFeRD.py 186) if invoice.vat_type == VAT_REGULAR:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 187) trade_tax.category_code = "S"
src/rechnung/Invoice/InvoiceToZUGFeRD.py 188) elif invoice.vat_type == VAT_KLEINUNTERNEHMER:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 189) trade_tax.category_code = "E"
src/rechnung/Invoice/InvoiceToZUGFeRD.py 190) trade_tax.exemption_reason = 'Als Kleinunternehmer wird gemäß §19 UStG keine USt in Rechnung gestellt.'
src/rechnung/Invoice/InvoiceToZUGFeRD.py 191) elif invoice.vat_type == VAT_INNERGEM:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 192) trade_tax.category_code = "K"
|
Kontoinhaber im XML einsetzen
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 193) trade_tax.rate_applicable_percent = Decimal(f"{vat * 100:.1f}")
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 194) summe_ust += (vatdata[0] / (vat + 1)) * vat
src/rechnung/Invoice/InvoiceToZUGFeRD.py 195) doc.trade.settlement.trade_tax.add(trade_tax)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 196)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 197) for paragraph in textparts:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 198) note = IncludedNote()
src/rechnung/Invoice/InvoiceToZUGFeRD.py 199) note.content.add(paragraph)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 200) doc.header.notes.add(note)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 201)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 202) rest = summe_brutto - summe_bezahlt
src/rechnung/Invoice/InvoiceToZUGFeRD.py 203)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 204) if invoice.creditor_reference_id:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 205) # Gläubiger-ID für SEPA
src/rechnung/Invoice/InvoiceToZUGFeRD.py 206) doc.trade.settlement.creditor_reference_id = invoice.creditor_reference_id
src/rechnung/Invoice/InvoiceToZUGFeRD.py 207) doc.trade.settlement.payment_reference = invoice.id
src/rechnung/Invoice/InvoiceToZUGFeRD.py 208) doc.trade.settlement.currency_code = 'EUR'
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 209) if invoice.payment_type:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 210) doc.trade.settlement.payment_means.type_code = invoice.payment_type
src/rechnung/Invoice/InvoiceToZUGFeRD.py 211)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 212) if invoice.seller_bank_data['iban'] and invoice.payment_type == PAYMENT_UEBERWEISUNG:
|
Kontoinhaber im XML einsetzen
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 213) doc.trade.settlement.payment_means.payee_account.account_name = \
src/rechnung/Invoice/InvoiceToZUGFeRD.py 214) invoice.seller_bank_data['kontoinhaber'] or invoice.seller['trade_name'] or invoice.seller['name']
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 215) doc.trade.settlement.payment_means.payee_account.iban = invoice.seller_bank_data['iban']
|
Kleine Korrekturen, mache B...
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 216) if invoice.seller_bank_data['bic']:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 217) doc.trade.settlement.payment_means.payee_institution.bic = invoice.seller_bank_data['bic']
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 218) if invoice.buyer_bank_data['iban'] and invoice.payment_type == PAYMENT_LASTSCHRIFT:
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 219) # Kunden-Bankverbindung bei Lastschrift
src/rechnung/Invoice/InvoiceToZUGFeRD.py 220) doc.trade.settlement.payment_means.payer_account.iban = invoice.buyer_bank_data['iban']
src/rechnung/Invoice/InvoiceToZUGFeRD.py 221)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 222) terms = PaymentTerms()
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 223) if invoice.due_date and invoice.payment_type == PAYMENT_UEBERWEISUNG:
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 224) terms.description = f"Bitte begleichen Sie den Betrag bis zum {invoice.due_date.strftime('%d.%m.%Y')} ohne Abzüge."
src/rechnung/Invoice/InvoiceToZUGFeRD.py 225) terms.due = invoice.due_date
|
Kleine Korrekturen, mache B...
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 226) if invoice.type in [GUTSCHRIFT, KORREKTUR]:
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 227) terms.description = f"Wir überweisen den Betrag auf Ihr Konto."
src/rechnung/Invoice/InvoiceToZUGFeRD.py 228) elif invoice.debit:
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 229) if invoice.debit_mandate_id:
src/rechnung/Invoice/InvoiceToZUGFeRD.py 230) # Mandatsreferenz für Lastschrift
src/rechnung/Invoice/InvoiceToZUGFeRD.py 231) terms.debit_mandate_id = invoice.debit_mandate_id
src/rechnung/Invoice/InvoiceToZUGFeRD.py 232) terms.description = 'Wir buchen von Ihrem Konto ab.'
src/rechnung/Invoice/InvoiceToZUGFeRD.py 233) doc.trade.settlement.terms.add(terms)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 234)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 235) doc.trade.settlement.monetary_summation.line_total = Decimal(f"{summe_netto:.2f}")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 236) doc.trade.settlement.monetary_summation.charge_total = Decimal("0.00")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 237) doc.trade.settlement.monetary_summation.allowance_total = Decimal("0.00")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 238) doc.trade.settlement.monetary_summation.tax_basis_total = Decimal(f"{summe_netto:.2f}")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 239) doc.trade.settlement.monetary_summation.tax_total = (Decimal(f"{summe_ust:.2f}"), "EUR")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 240) doc.trade.settlement.monetary_summation.prepaid_total = Decimal(f"{summe_bezahlt:.2f}")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 241) doc.trade.settlement.monetary_summation.grand_total = Decimal(f"{summe_brutto:.2f}")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 242) doc.trade.settlement.monetary_summation.due_amount = Decimal(f"{rest:.2f}")
src/rechnung/Invoice/InvoiceToZUGFeRD.py 243)
src/rechnung/Invoice/InvoiceToZUGFeRD.py 244) # Generate XML file
|
WiP
Bernd Wurst authored 8 months ago
|
src/rechnung/Invoice/InvoiceToZUGFeRD.py 245) xml = doc.serialize(schema="FACTUR-X_EN16931")
|