Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from functools import partial
- import locale
- from decimal import Decimal
- def rechnung(produkte, mwst, loc='de_DE.utf-8'):
- locale.setlocale(locale.LC_ALL, loc)
- pos_fmt = '{:<5}{:<15}{:>20}'
- sum_fmt = partial(pos_fmt.format, '')
- print(pos_fmt.format('Pos.', 'Produkt', 'Preis'))
- print('-'*40)
- print()
- summe = 0
- for position, element in enumerate(produkte, start=1):
- produkt, preis = element
- fpreis = locale.currency(preis)
- ausgabe = pos_fmt.format(position * 10, produkt, fpreis)
- summe += preis
- print(ausgabe)
- print()
- print('='*40)
- print()
- smwst = summe / 100 * mwst
- netto = summe / (100 + mwst) * 100
- fsumme = locale.currency(summe)
- fmwst = locale.currency(smwst)
- fnetto = locale.currency(netto)
- print(sum_fmt('Summe', fsumme))
- print(sum_fmt('Mwst.', fmwst))
- print(sum_fmt('Netto', fnetto))
- produkte = [
- ('Fön', Decimal('20.00')),
- ('Gitarre', Decimal('1450.99')),
- ('DLSR', Decimal('599.75'))
- ]
- rechnung(produkte, 19)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement