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.styles import getSampleStyleSheet, ParagraphStyle
|
||||||
from reportlab.lib.units import inch
|
from reportlab.lib.units import inch
|
||||||
from reportlab.platypus import SimpleDocTemplate, Paragraph
|
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
|
from pyinvoice.models import PDFInfo, Item, Transaction, InvoiceInfo, ServiceProviderInfo, ClientInfo
|
||||||
|
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ class SimpleInvoice(SimpleDocTemplate):
|
||||||
self.invoice_info = None
|
self.invoice_info = None
|
||||||
self.service_provider_info = None
|
self.service_provider_info = None
|
||||||
self.client_info = None
|
self.client_info = None
|
||||||
|
self.is_paid = False
|
||||||
self._items = []
|
self._items = []
|
||||||
self._transactions = []
|
self._transactions = []
|
||||||
|
|
||||||
|
@ -56,7 +57,6 @@ class SimpleInvoice(SimpleDocTemplate):
|
||||||
for p, v in attribute_verbose_name_list:
|
for p, v in attribute_verbose_name_list:
|
||||||
attr = getattr(instance, p)
|
attr = getattr(instance, p)
|
||||||
if attr is not None:
|
if attr is not None:
|
||||||
# TODO: datetime format
|
|
||||||
if isinstance(attr, datetime):
|
if isinstance(attr, datetime):
|
||||||
attr = attr.strftime('%Y-%m-%d %H:%M')
|
attr = attr.strftime('%Y-%m-%d %H:%M')
|
||||||
elif isinstance(attr, date):
|
elif isinstance(attr, date):
|
||||||
|
@ -107,4 +107,4 @@ class SimpleInvoice(SimpleDocTemplate):
|
||||||
item_data.insert(0, ('Item id', 'Name', 'Description', 'Units', 'Unit Price', 'Subtotal'))
|
item_data.insert(0, ('Item id', 'Name', 'Description', 'Units', 'Unit Price', 'Subtotal'))
|
||||||
story.append(TableWithHeader(item_data, horizontal_align='LEFT'))
|
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 = SimpleInvoice('test.pdf')
|
||||||
|
|
||||||
|
doc.is_paid = True
|
||||||
|
|
||||||
doc.invoice_info = InvoiceInfo('1024', datetime.now(), datetime.now())
|
doc.invoice_info = InvoiceInfo('1024', datetime.now(), datetime.now())
|
||||||
|
|
||||||
doc.service_provider_info = ServiceProviderInfo(
|
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('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.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()
|
doc.finish()
|
Loading…
Reference in a new issue