7b9d64778623e533afc80685b650a17ec50184b2
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

1) # -* coding: utf8 *-
2) 
3) import datetime
4) 
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

5) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

6) class InvoiceImage(object):
7)     def __init__(self, pilimage, caption=None, dpi=80, alignment="left"):
8)         self.imagedata = pilimage
9)         self.alignment = alignment
10)         self.dpi = dpi
11)         self.caption = caption
12) 
13) 
14) class InvoiceText(object):
Bernd Wurst new feature: indentation fo...

Bernd Wurst authored 4 months ago

15)     def __init__(self, content, urgent=False, headline=None, indent=None):
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

16)         self.paragraphs = [content]
17)         self.urgent = urgent
18)         self.headline = headline
Bernd Wurst new feature: indentation fo...

Bernd Wurst authored 4 months ago

19)         self.indent = indent
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

20)         self.fontsize = 0  # relative Schriftgröße ggü default
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

21) 
22)     def addParagraph(self, content):
23)         self.paragraphs.append(content)
24) 
25) 
26) class InvoiceTable(object):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

27)     def __init__(self, vatType='gross', tender=False, summary=True):
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

28)         self.entries = []
29)         self.vat = {}
30)         self.sum = 0.0
31)         self.payments = []
32)         self.tender = tender
33)         self.summary = summary
34)         if vatType not in ['gross', 'net']:
35)             raise ValueError('vatType must be »gross« or »net«')
36)         self.vatType = vatType
37)     
38)     def validEntry(self, entry):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

39)         """bekommt einen Eintrag und liefert einen Eintrag, wenn ok; wirft ansonsten ValueError.
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

40)         wird benutzt um z.B. die Summe auszurechnen oder ähnliches
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

41)         """
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

42)         k = entry.keys()
43)         e = entry
44)         if not ('count' in k and 'unit' in k and 'subject' in k and 'price' in k and 'vat' in k):
45)             raise ValueError('Some data is missing!')
46)         ret = {'type': 'entry',
47)                'count': e['count'],
48)                'unit': e['unit'],
49)                'subject': e['subject'],
50)                'price': e['price'],
51)                'total': (e['price'] * e['count']),
52)                'vat': e['vat'],
53)                'tender': False,
Bernd Wurst Neuer Parameter 'print_date...

Bernd Wurst authored 1 month ago

54)                'print_date': True,
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

55)                }
56)         if ret['vat'] > 1:
57)             ret['vat'] = float(ret['vat']) / 100
58)             
59)         if 'tender' in e.keys():
60)             ret['tender'] = e['tender']
61)         if 'desc' in k:
62)             ret['desc'] = e['desc']
63)         if 'period_start' in k:
64)             ret['period_start'] = e['period_start']
65)         if 'period_end' in k:
66)             ret['period_end'] = e['period_end']
Bernd Wurst Neuer Parameter 'print_date...

Bernd Wurst authored 1 month ago

67)         if 'print_date' in k:
68)             ret['print_date'] = e['print_date']
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

69) 
70)         return ret
71)     
72)     def addItem(self, data):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

73)         """Fügt eine Zeile ein. data muss ein Dict mit passenden Keys und passenden
74)         Typen sein"""
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

75)         d = self.validEntry(data)
76)         if not d['vat'] in self.vat.keys():
77)             self.vat[d['vat']] = [0, chr(65+len(self.vat))]
78)         if 'tender' not in data or not data['tender']:
79)             self.vat[d['vat']][0] += d['total']
80)             self.sum += d['total']
81)         self.entries.append(d)
82)     
83)     def addTitle(self, title):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

84)         self.entries.append({'type': 'title', 'title': title, })
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

85) 
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

86)     def addPayment(self, payment_type, amount, date):
87)         self.payments.append({"type": payment_type, "amount": amount, "date": date})
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

88) 
89) 
90) RECHNUNG = 380
91) ANGEBOT = 1
92) GUTSCHRIFT = 381
93) KORREKTUR = 384
94) 
95) VAT_REGULAR = 'S'
96) VAT_KLEINUNTERNEHMER = 'E'
97) VAT_INNERGEM = 'K'
98) 
Bernd Wurst WiP

Bernd Wurst authored 4 months ago

99) PAYMENT_LASTSCHRIFT = "59"
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

100) PAYMENT_UEBERWEISUNG = "58"
Bernd Wurst WiP

Bernd Wurst authored 4 months ago

101) PAYMENT_BANKKONTO = "42"
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

102) PAYMENT_ONLINE = "68"
Bernd Wurst WiP

Bernd Wurst authored 4 months ago

103) PAYMENT_BAR = "10"
104) PAYMENT_KARTE = "48"
105) 
Bernd Wurst Einheiten soweit möglich al...

Bernd Wurst authored 3 months ago

106) UNITS = {
107)     # key = XML-Code, value = (Langform Einzahl, Langform Mehrzahl, Kurzform, [mögliche weitere Schreibweisen,...])
108)     'H87': ('Stück', 'Stück', 'Stk', 'pcs'),
109)     'SEC': ('Sekunde', 'Sekunden', 's', 'Sek.', 'Sek'),
110)     'MIN': ('Minute', 'Minuten', 'min', 'Min.', 'Min'),
111)     'HUR': ('Stunde', 'Stunden', 'h', 'Std.', 'Std'),
112)     'DAY': ('Tag', 'Tage', 'Tg', 'd'),
113)     'WEE': ('Woche', 'Wochen', 'Woch.', 'Woch'),
114)     'MON': ('Monat', 'Monate', 'Mon.', 'Mon'),
115)     'ANN': ('Jahr', 'Jahre', 'J.', 'y'),
116)     'LTR': ('Liter', 'Liter', 'l', 'Ltr'),
117)     'MTQ': ('Kubikmeter', 'Kubikmeter', 'm³', 'cbm'),
118)     'GRM': ('Gramm', 'Gramm', 'g', 'Gr', 'gr'),
119)     'KGM': ('Kilogramm', 'Kilogramm', 'kg', 'Kilo'),
120)     'TNE': ('Tonne', 'Tonnen', 't'),
121)     'DTN': ('Dezitonne', 'Dezitonnen', 'dt'),
122)     'MTR': ('Meter', 'Meter', 'm', 'Mtr'),
123)     'MMT': ('Millimeter', 'Millimeter', 'mm'),
124)     'KMT': ('Kilometer', 'Kilometer', 'km'),
125)     'MTK': ('Quadratmeter', 'Quadratmeter', 'm²', 'qm'),
126)     'KWT': ('Kilowatt', 'Kilowatt', 'kW'),
127)     'MAW': ('Megawatt', 'Megawatt', 'MW'),
128)     'KWH': ('Kilowattstunde', 'Kilowattstunden', 'kWh'),
129)     'MWH': ('Megawattstunde', 'Megawattstunden', 'MWh'),
130)     'D97': ('Palette', 'Paletten', 'Pal'),
131)     'AD':  ('Byte', 'Bytes', 'Byte', 'octet', 'octets'),
132)     '2P':  ('Kilobyte', 'Kilobytes', 'KB'),
133)     '4L':  ('Megabyte', 'Megabytes', 'MB'),
134)     'E34': ('Gigabyte', 'Gigabytes', 'GB'),
135)     'E35': ('Terabyte', 'Terabytes', 'TB'),
136)     'E36': ('Petabyte', 'Petabytes', 'PB'),
137)     '1I': ('Pauschal', 'Pauschale', 'Psch.', 'Psch'),
138) }
139) 
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

140) 
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

141) class Invoice(object):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

142)     def __init__(self, tender=False):
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

143)         self.customerno = None
144)         self.customer = {
145)             "id": None,
146)             "name": None,
147)             "address": {
148)                 "postcode": None,
149)                 "city_name": None,
150)                 "line1": None,
151)                 "line2": None,
152)                 "line3": None,
153)                 "country_id": None,
154)             },
Bernd Wurst Telefonnummer

Bernd Wurst authored 4 months ago

155)             "phone": None,
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

156)             "email": None,
157)         }
158)         self.buyer = self.customer
159)         self.seller = {
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

160)             "name": None,  # juristischer Name
Bernd Wurst Das XML validiert jetzt als...

Bernd Wurst authored 1 month ago

161)             "contactPerson": None, # Name der Kontaktperson
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

162)             "trade_name": None,  # Firmenname
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

163)             "address": {
164)                 "postcode": None,
165)                 "city_name": None,
166)                 "line1": None,
167)                 "line2": None,
168)                 "line3": None,
169)                 "country_id": None,
170)             },
171)             "phone": None,
172)             "email": None,
173)             "website": None,
174)         }
175)         self.seller_vat_id = None
176)         self.seller_bank_data = {
177)             'kontoinhaber': None,
178)             'iban': None,
179)             'bic': None,
180)             'bankname': None,
181)         }
182)         self.due_date = None
183)         self.debit = False
Bernd Wurst WiP

Bernd Wurst authored 4 months ago

184)         self.payment_type = PAYMENT_UEBERWEISUNG
Bernd Wurst Referenznummern auf allen A...

Bernd Wurst authored 4 months ago

185)         self.leitweg_id = None
Bernd Wurst Telefonnummer

Bernd Wurst authored 4 months ago

186)         self.buyer_reference = None
187)         self.order_number = None
Bernd Wurst Referenznummern auf allen A...

Bernd Wurst authored 4 months ago

188)         self.contract_number = None
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

189)         self.debit_mandate_id = None
190)         self.creditor_reference_id = None
191)         self.buyer_bank_data = {
192)             'kontoinhaber': None,
193)             'iban': None,
194)             'bic': None,
195)             'bankname': None,
196)         }
197)         self.vat_type = VAT_REGULAR
Bernd Wurst Typo

Bernd Wurst authored 3 months ago

198)         self.salutation = 'Sehr geehrte Damen und Herren,'
Bernd Wurst In eigenes GIT ausgelagert

Bernd Wurst authored 4 months ago

199)         self.id = None
200)         self.cash = True
201)         self.type = RECHNUNG
202)         self.logo_image_file = None
203)         self.tender = tender
204)         self.title = 'Rechnung'
205)         if tender:
206)             self.title = 'Angebot'
207)         self.official = True
208)         self.parts = []
209)         self.pagecount = 0
210)         self.date = datetime.date.today()
211)     
212)     def setDate(self, date):
Bernd Wurst Codestyle-Fixes

Bernd Wurst authored 4 months ago

213)         if not isinstance(date, datetime.date):