Bernd Wurst

Bernd Wurst commited on 2013-05-24 12:06:04
Zeige 2 geänderte Dateien mit 10 Einfügungen und 4 Löschungen.

... ...
@@ -31,7 +31,10 @@ class Table(object):
31 31
     e = entry
32 32
     if not ('count' in k and 'subject' in k and 'price' in k and 'vat' in k):
33 33
       raise ValueError('Some data is missing!')
34
+    if not 'unit' in e.keys():
35
+      e['unit'] = None
34 36
     ret = {'count': e['count'],
37
+           'unit': e['unit'],
35 38
           'subject': e['subject'],
36 39
           'price': e['price'],
37 40
           'total': (e['price'] * e['count']),
... ...
@@ -57,18 +57,21 @@ def InvoiceTableToText(invoiceTable):
57 57
     ret.append(u'-'*72)
58 58
 
59 59
   for el in invoiceTable.entries:
60
+    unit = ''
61
+    if el['unit']:
62
+      unit = ' %s' % el['unit']
60 63
     if len(invoiceTable.vat) < 2:
61
-      subject = _breakLine(el['subject'], width=43)
62
-      ret.append(u'%5.2f %-43s  %10s %10s' % (el['count'], subject[0], format_price(el['price']), format_price(el['total'])))
64
+      subject = _breakLine(el['subject'], width=39)
65
+      ret.append(u'%5.2f %-3s %-39s  %10s %10s' % (el['count'], unit, subject[0], format_price(el['price']), format_price(el['total'])))
63 66
       for i in range(1,len(subject)):
64 67
         ret.append(u'          %s' % subject[i])
65 68
     else:
66 69
       subject = _breakLine(el['subject'], width=41)
67
-      ret.append(u'%5.2f %-41s  %10s %s %10s' % (el['count'], subject[0], format_price(el['price']), invoiceTable.vat[el['vat']][1], format_price(el['total'])))
70
+      ret.append(u'%5.2f %-3s %-37s  %10s %s %10s' % (el['count'], unit, subject[0], format_price(el['price']), invoiceTable.vat[el['vat']][1], format_price(el['total'])))
68 71
       for i in range(1,len(subject)):
69 72
         ret.append(u'          %s' % subject[i])
70 73
     if 'desc' in el and el['desc']:
71
-      desc = _breakLine(el['desc'], 43)
74
+      desc = _breakLine(el['desc'], 39)
72 75
       for line in desc:
73 76
         ret.append(u'          %s' % line)
74 77
   ret.append('-'*72)
75 78