7d420e1c6392016e5d7379ae47a72c10f0f1f405
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py   1) # -* coding: utf8 *-
src/rechnung/Invoice/InvoiceObjects.py   2) # (C) 2011 by Bernd Wurst <bernd@schokokeks.org>
src/rechnung/Invoice/InvoiceObjects.py   3) 
src/rechnung/Invoice/InvoiceObjects.py   4) # This file is part of Bib2011.
src/rechnung/Invoice/InvoiceObjects.py   5) #
src/rechnung/Invoice/InvoiceObjects.py   6) # Bib2011 is free software: you can redistribute it and/or modify
src/rechnung/Invoice/InvoiceObjects.py   7) # it under the terms of the GNU General Public License as published by
src/rechnung/Invoice/InvoiceObjects.py   8) # the Free Software Foundation, either version 3 of the License, or
src/rechnung/Invoice/InvoiceObjects.py   9) # (at your option) any later version.
src/rechnung/Invoice/InvoiceObjects.py  10) #
src/rechnung/Invoice/InvoiceObjects.py  11) # Bib2011 is distributed in the hope that it will be useful,
src/rechnung/Invoice/InvoiceObjects.py  12) # but WITHOUT ANY WARRANTY; without even the implied warranty of
src/rechnung/Invoice/InvoiceObjects.py  13) # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
src/rechnung/Invoice/InvoiceObjects.py  14) # GNU General Public License for more details.
src/rechnung/Invoice/InvoiceObjects.py  15) #
src/rechnung/Invoice/InvoiceObjects.py  16) # You should have received a copy of the GNU General Public License
src/rechnung/Invoice/InvoiceObjects.py  17) # along with Bib2011.  If not, see <http://www.gnu.org/licenses/>.
src/rechnung/Invoice/InvoiceObjects.py  18) 
src/rechnung/Invoice/InvoiceObjects.py  19) import datetime
src/rechnung/Invoice/InvoiceObjects.py  20) 
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  21) 
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  22) class InvoiceImage(object):
src/rechnung/Invoice/InvoiceObjects.py  23)     def __init__(self, pilimage, caption=None, dpi=80, alignment="left"):
src/rechnung/Invoice/InvoiceObjects.py  24)         self.imagedata = pilimage
src/rechnung/Invoice/InvoiceObjects.py  25)         self.alignment = alignment
src/rechnung/Invoice/InvoiceObjects.py  26)         self.dpi = dpi
src/rechnung/Invoice/InvoiceObjects.py  27)         self.caption = caption
src/rechnung/Invoice/InvoiceObjects.py  28) 
src/rechnung/Invoice/InvoiceObjects.py  29) 
src/rechnung/Invoice/InvoiceObjects.py  30) class InvoiceText(object):
src/rechnung/Invoice/InvoiceObjects.py  31)     def __init__(self, content, urgent=False, headline=None):
src/rechnung/Invoice/InvoiceObjects.py  32)         self.paragraphs = [content]
src/rechnung/Invoice/InvoiceObjects.py  33)         self.urgent = urgent
src/rechnung/Invoice/InvoiceObjects.py  34)         self.headline = headline
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  35)         self.fontsize = 0  # relative Schriftgröße ggü default
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  36) 
src/rechnung/Invoice/InvoiceObjects.py  37)     def addParagraph(self, content):
src/rechnung/Invoice/InvoiceObjects.py  38)         self.paragraphs.append(content)
src/rechnung/Invoice/InvoiceObjects.py  39) 
src/rechnung/Invoice/InvoiceObjects.py  40) 
src/rechnung/Invoice/InvoiceObjects.py  41) class InvoiceTable(object):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  42)     def __init__(self, vatType='gross', tender=False, summary=True):
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  43)         self.entries = []
src/rechnung/Invoice/InvoiceObjects.py  44)         self.vat = {}
src/rechnung/Invoice/InvoiceObjects.py  45)         self.sum = 0.0
src/rechnung/Invoice/InvoiceObjects.py  46)         self.payments = []
src/rechnung/Invoice/InvoiceObjects.py  47)         self.tender = tender
src/rechnung/Invoice/InvoiceObjects.py  48)         self.summary = summary
src/rechnung/Invoice/InvoiceObjects.py  49)         if vatType not in ['gross', 'net']:
src/rechnung/Invoice/InvoiceObjects.py  50)             raise ValueError('vatType must be »gross« or »net«')
src/rechnung/Invoice/InvoiceObjects.py  51)         self.vatType = vatType
src/rechnung/Invoice/InvoiceObjects.py  52)     
src/rechnung/Invoice/InvoiceObjects.py  53)     def validEntry(self, entry):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  54)         """bekommt einen Eintrag und liefert einen Eintrag, wenn ok; wirft ansonsten ValueError.
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  55)         wird benutzt um z.B. die Summe auszurechnen oder ähnliches
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  56)         """
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  57)         k = entry.keys()
src/rechnung/Invoice/InvoiceObjects.py  58)         e = entry
src/rechnung/Invoice/InvoiceObjects.py  59)         if not ('count' in k and 'unit' in k and 'subject' in k and 'price' in k and 'vat' in k):
src/rechnung/Invoice/InvoiceObjects.py  60)             raise ValueError('Some data is missing!')
src/rechnung/Invoice/InvoiceObjects.py  61)         ret = {'type': 'entry',
src/rechnung/Invoice/InvoiceObjects.py  62)                'count': e['count'],
src/rechnung/Invoice/InvoiceObjects.py  63)                'unit': e['unit'],
src/rechnung/Invoice/InvoiceObjects.py  64)                'subject': e['subject'],
src/rechnung/Invoice/InvoiceObjects.py  65)                'price': e['price'],
src/rechnung/Invoice/InvoiceObjects.py  66)                'total': (e['price'] * e['count']),
src/rechnung/Invoice/InvoiceObjects.py  67)                'vat': e['vat'],
src/rechnung/Invoice/InvoiceObjects.py  68)                'tender': False,
src/rechnung/Invoice/InvoiceObjects.py  69)                }
src/rechnung/Invoice/InvoiceObjects.py  70)         if ret['vat'] > 1:
src/rechnung/Invoice/InvoiceObjects.py  71)             ret['vat'] = float(ret['vat']) / 100
src/rechnung/Invoice/InvoiceObjects.py  72)             
src/rechnung/Invoice/InvoiceObjects.py  73)         if 'tender' in e.keys():
src/rechnung/Invoice/InvoiceObjects.py  74)             ret['tender'] = e['tender']
src/rechnung/Invoice/InvoiceObjects.py  75)         if 'desc' in k:
src/rechnung/Invoice/InvoiceObjects.py  76)             ret['desc'] = e['desc']
src/rechnung/Invoice/InvoiceObjects.py  77)         if 'period_start' in k:
src/rechnung/Invoice/InvoiceObjects.py  78)             ret['period_start'] = e['period_start']
src/rechnung/Invoice/InvoiceObjects.py  79)         if 'period_end' in k:
src/rechnung/Invoice/InvoiceObjects.py  80)             ret['period_end'] = e['period_end']
src/rechnung/Invoice/InvoiceObjects.py  81) 
src/rechnung/Invoice/InvoiceObjects.py  82)         return ret
src/rechnung/Invoice/InvoiceObjects.py  83)     
src/rechnung/Invoice/InvoiceObjects.py  84)     def addItem(self, data):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  85)         """Fügt eine Zeile ein. data muss ein Dict mit passenden Keys und passenden
src/rechnung/Invoice/InvoiceObjects.py  86)         Typen sein"""
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  87)         d = self.validEntry(data)
src/rechnung/Invoice/InvoiceObjects.py  88)         if not d['vat'] in self.vat.keys():
src/rechnung/Invoice/InvoiceObjects.py  89)             self.vat[d['vat']] = [0, chr(65+len(self.vat))]
src/rechnung/Invoice/InvoiceObjects.py  90)         if 'tender' not in data or not data['tender']:
src/rechnung/Invoice/InvoiceObjects.py  91)             self.vat[d['vat']][0] += d['total']
src/rechnung/Invoice/InvoiceObjects.py  92)             self.sum += d['total']
src/rechnung/Invoice/InvoiceObjects.py  93)         self.entries.append(d)
src/rechnung/Invoice/InvoiceObjects.py  94)     
src/rechnung/Invoice/InvoiceObjects.py  95)     def addTitle(self, title):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  96)         self.entries.append({'type': 'title', 'title': title, })
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  97) 
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py  98)     def addPayment(self, payment_type, amount, date):
src/rechnung/Invoice/InvoiceObjects.py  99)         self.payments.append({"type": payment_type, "amount": amount, "date": date})
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 100) 
src/rechnung/Invoice/InvoiceObjects.py 101) 
src/rechnung/Invoice/InvoiceObjects.py 102) RECHNUNG = 380
src/rechnung/Invoice/InvoiceObjects.py 103) ANGEBOT = 1
src/rechnung/Invoice/InvoiceObjects.py 104) GUTSCHRIFT = 381
src/rechnung/Invoice/InvoiceObjects.py 105) KORREKTUR = 384
src/rechnung/Invoice/InvoiceObjects.py 106) 
src/rechnung/Invoice/InvoiceObjects.py 107) VAT_REGULAR = 'S'
src/rechnung/Invoice/InvoiceObjects.py 108) VAT_KLEINUNTERNEHMER = 'E'
src/rechnung/Invoice/InvoiceObjects.py 109) VAT_INNERGEM = 'K'
src/rechnung/Invoice/InvoiceObjects.py 110) 
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 111) PAYMENT_LASTSCHRIFT = "59"
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 112) PAYMENT_UEBERWEISUNG = "58"
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 113) PAYMENT_BANKKONTO = "42"
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 114) PAYMENT_ONLINE = "68"
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 115) PAYMENT_BAR = "10"
src/rechnung/Invoice/InvoiceObjects.py 116) PAYMENT_KARTE = "48"
src/rechnung/Invoice/InvoiceObjects.py 117) 
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 118) 
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 119) class Invoice(object):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 120)     def __init__(self, tender=False):
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 121)         self.customerno = None
src/rechnung/Invoice/InvoiceObjects.py 122)         self.customer = {
src/rechnung/Invoice/InvoiceObjects.py 123)             "id": None,
src/rechnung/Invoice/InvoiceObjects.py 124)             "name": None,
src/rechnung/Invoice/InvoiceObjects.py 125)             "address": {
src/rechnung/Invoice/InvoiceObjects.py 126)                 "postcode": None,
src/rechnung/Invoice/InvoiceObjects.py 127)                 "city_name": None,
src/rechnung/Invoice/InvoiceObjects.py 128)                 "line1": None,
src/rechnung/Invoice/InvoiceObjects.py 129)                 "line2": None,
src/rechnung/Invoice/InvoiceObjects.py 130)                 "line3": None,
src/rechnung/Invoice/InvoiceObjects.py 131)                 "country_id": None,
src/rechnung/Invoice/InvoiceObjects.py 132)             },
Bernd Wurst Telefonnummer

Bernd Wurst authored 4 months ago

src/rechnung/Invoice/InvoiceObjects.py 133)             "phone": None,
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 134)             "email": None,
src/rechnung/Invoice/InvoiceObjects.py 135)         }
src/rechnung/Invoice/InvoiceObjects.py 136)         self.buyer = self.customer
src/rechnung/Invoice/InvoiceObjects.py 137)         self.seller = {
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 138)             "name": None,  # juristischer Name
src/rechnung/Invoice/InvoiceObjects.py 139)             "trade_name": None,  # Firmenname
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 140)             "address": {
src/rechnung/Invoice/InvoiceObjects.py 141)                 "postcode": None,
src/rechnung/Invoice/InvoiceObjects.py 142)                 "city_name": None,
src/rechnung/Invoice/InvoiceObjects.py 143)                 "line1": None,
src/rechnung/Invoice/InvoiceObjects.py 144)                 "line2": None,
src/rechnung/Invoice/InvoiceObjects.py 145)                 "line3": None,
src/rechnung/Invoice/InvoiceObjects.py 146)                 "country_id": None,
src/rechnung/Invoice/InvoiceObjects.py 147)             },
src/rechnung/Invoice/InvoiceObjects.py 148)             "phone": None,
src/rechnung/Invoice/InvoiceObjects.py 149)             "email": None,
src/rechnung/Invoice/InvoiceObjects.py 150)             "website": None,
src/rechnung/Invoice/InvoiceObjects.py 151)         }
src/rechnung/Invoice/InvoiceObjects.py 152)         self.seller_vat_id = None
src/rechnung/Invoice/InvoiceObjects.py 153)         self.seller_bank_data = {
src/rechnung/Invoice/InvoiceObjects.py 154)             'kontoinhaber': None,
src/rechnung/Invoice/InvoiceObjects.py 155)             'iban': None,
src/rechnung/Invoice/InvoiceObjects.py 156)             'bic': None,
src/rechnung/Invoice/InvoiceObjects.py 157)             'bankname': None,
src/rechnung/Invoice/InvoiceObjects.py 158)         }
src/rechnung/Invoice/InvoiceObjects.py 159)         self.due_date = None
src/rechnung/Invoice/InvoiceObjects.py 160)         self.debit = False
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 161)         self.payment_type = PAYMENT_UEBERWEISUNG
Bernd Wurst Referenznummern auf allen A...

Bernd Wurst authored 4 months ago

src/rechnung/Invoice/InvoiceObjects.py 162)         self.leitweg_id = None
Bernd Wurst Telefonnummer

Bernd Wurst authored 4 months ago

src/rechnung/Invoice/InvoiceObjects.py 163)         self.buyer_reference = None
src/rechnung/Invoice/InvoiceObjects.py 164)         self.order_number = None
Bernd Wurst Referenznummern auf allen A...

Bernd Wurst authored 4 months ago

src/rechnung/Invoice/InvoiceObjects.py 165)         self.contract_number = None
Bernd Wurst WiP

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 166)         self.debit_mandate_id = None
src/rechnung/Invoice/InvoiceObjects.py 167)         self.creditor_reference_id = None
src/rechnung/Invoice/InvoiceObjects.py 168)         self.buyer_bank_data = {
src/rechnung/Invoice/InvoiceObjects.py 169)             'kontoinhaber': None,
src/rechnung/Invoice/InvoiceObjects.py 170)             'iban': None,
src/rechnung/Invoice/InvoiceObjects.py 171)             'bic': None,
src/rechnung/Invoice/InvoiceObjects.py 172)             'bankname': None,
src/rechnung/Invoice/InvoiceObjects.py 173)         }
src/rechnung/Invoice/InvoiceObjects.py 174)         self.vat_type = VAT_REGULAR
src/rechnung/Invoice/InvoiceObjects.py 175)         self.salutation = 'Sehr geehte Damen und Herren,'
src/rechnung/Invoice/InvoiceObjects.py 176)         self.id = None
src/rechnung/Invoice/InvoiceObjects.py 177)         self.cash = True
src/rechnung/Invoice/InvoiceObjects.py 178)         self.type = RECHNUNG
src/rechnung/Invoice/InvoiceObjects.py 179)         self.logo_image_file = None
src/rechnung/Invoice/InvoiceObjects.py 180)         self.tender = tender
src/rechnung/Invoice/InvoiceObjects.py 181)         self.title = 'Rechnung'
src/rechnung/Invoice/InvoiceObjects.py 182)         if tender:
src/rechnung/Invoice/InvoiceObjects.py 183)             self.title = 'Angebot'
src/rechnung/Invoice/InvoiceObjects.py 184)         self.official = True
src/rechnung/Invoice/InvoiceObjects.py 185)         self.parts = []
src/rechnung/Invoice/InvoiceObjects.py 186)         self.pagecount = 0
src/rechnung/Invoice/InvoiceObjects.py 187)         self.date = datetime.date.today()
src/rechnung/Invoice/InvoiceObjects.py 188)     
src/rechnung/Invoice/InvoiceObjects.py 189)     def setDate(self, date):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 5 months ago

src/rechnung/Invoice/InvoiceObjects.py 190)         if not isinstance(date, datetime.date):