Add paid stamp
This commit is contained in:
parent
f1729225f3
commit
4ed136e78c
2 changed files with 5 additions and 4 deletions
|
@ -5,7 +5,7 @@ from reportlab.lib.pagesizes import letter
|
|||
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
||||
from reportlab.lib.units import inch
|
||||
from reportlab.platypus import SimpleDocTemplate, Paragraph
|
||||
from pyinvoice.components import SimpleTable, TableWithHeader
|
||||
from pyinvoice.components import SimpleTable, TableWithHeader, PaidStamp
|
||||
from pyinvoice.models import PDFInfo, Item, Transaction, InvoiceInfo, ServiceProviderInfo, ClientInfo
|
||||
|
||||
|
||||
|
@ -30,6 +30,7 @@ class SimpleInvoice(SimpleDocTemplate):
|
|||
self.invoice_info = None
|
||||
self.service_provider_info = None
|
||||
self.client_info = None
|
||||
self.is_paid = False
|
||||
self._items = []
|
||||
self._transactions = []
|
||||
|
||||
|
@ -56,7 +57,6 @@ class SimpleInvoice(SimpleDocTemplate):
|
|||
for p, v in attribute_verbose_name_list:
|
||||
attr = getattr(instance, p)
|
||||
if attr is not None:
|
||||
# TODO: datetime format
|
||||
if isinstance(attr, datetime):
|
||||
attr = attr.strftime('%Y-%m-%d %H:%M')
|
||||
elif isinstance(attr, date):
|
||||
|
@ -107,4 +107,4 @@ class SimpleInvoice(SimpleDocTemplate):
|
|||
item_data.insert(0, ('Item id', 'Name', 'Description', 'Units', 'Unit Price', 'Subtotal'))
|
||||
story.append(TableWithHeader(item_data, horizontal_align='LEFT'))
|
||||
|
||||
self.build(story)
|
||||
self.build(story, onFirstPage=PaidStamp(7*inch, 5.8*inch) if self.is_paid else None)
|
3
test.py
3
test.py
|
@ -5,6 +5,8 @@ from pyinvoice.templates import SimpleInvoice
|
|||
|
||||
doc = SimpleInvoice('test.pdf')
|
||||
|
||||
doc.is_paid = True
|
||||
|
||||
doc.invoice_info = InvoiceInfo('1024', datetime.now(), datetime.now())
|
||||
|
||||
doc.service_provider_info = ServiceProviderInfo(
|
||||
|
@ -31,5 +33,4 @@ doc.add_item(Item('0000', 'Item 0000', 'Item Description 1 Long-----------------
|
|||
doc.add_item(Item('1111', 'Item 1111', 'Item Description 2', 2, Decimal('2.2')))
|
||||
doc.add_item(Item('2222', 'Item 2222', 'Item Description 3', 3, Decimal('3.3')))
|
||||
|
||||
# doc.build(story, onFirstPage=PaidStamp(7*inch, 5.8*inch))
|
||||
doc.finish()
|
Loading…
Reference in a new issue