dinbrief /

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from decimal import Decimal

import dinbrief.template

from reportlab.lib.units import mm
from reportlab.platypus import Paragraph
from reportlab.platypus.flowables import KeepTogether
from reportlab.platypus.flowables import Spacer

from dinbrief.constants import CONTENT_WIDTH
from dinbrief.document import Document
from dinbrief.invoice import Invoice, Item, ItemTable, TotalTable
from dinbrief.styles import styles
from dinbrief.template import BriefTemplate

FOOD_VAT = Decimal('0.07')
DEFAULT_VAT = Decimal('0.19')

with file('test.pdf', 'w') as fh:
    invoice = Invoice(
            Item(1, u'Donut', price=Decimal('1.00'), vat_rate=FOOD_VAT, quantity=100),
            Item(2, u'Brezel', price=Decimal('0.50'), vat_rate=FOOD_VAT, quantity=200, discount=Decimal('0.25')),
            Item(3, u'Backautomat miete', price=Decimal('50'), vat_rate=DEFAULT_VAT, quantity=4, unit='Tag', period=u'04.08.2012 - 07.10.2012'),
            Item(4, u'Versicherungspauschale: Personenschäden bis 100.000 EUR, Sachschäden bis 50.000 EUR.', price=Decimal('30'), vat_rate=DEFAULT_VAT),
    document = Document(
            u'Finkengasse 1',
            u'00000 Musterort'
            u'Max Mustermann',
            u'Lärchenweg 22',
            u'00000 Musterort'
            Paragraph(u'Rechnung 2012-0815', styles['Subject']),
            #Paragraph(u'Sehr geehrter Herr Mustermann,', styles['Greeting']),
            #Paragraph(u'Hiermit möchten wir Ihnen nachfolgende Posten in Rechnung stellen:', styles['Message']),
            Spacer(CONTENT_WIDTH, 2*mm),
    template = BriefTemplate(fh, document)
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.