service provider/client info
This commit is contained in:
parent
07b99f7e94
commit
42af588ed9
2 changed files with 14 additions and 9 deletions
|
@ -1,5 +1,6 @@
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date
|
||||||
|
from reportlab.lib import colors
|
||||||
from reportlab.lib.enums import TA_CENTER, TA_RIGHT
|
from reportlab.lib.enums import TA_CENTER, TA_RIGHT
|
||||||
from reportlab.lib.pagesizes import letter
|
from reportlab.lib.pagesizes import letter
|
||||||
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
from reportlab.lib.styles import getSampleStyleSheet, ParagraphStyle
|
||||||
|
@ -33,7 +34,7 @@ class SimpleInvoice(SimpleDocTemplate):
|
||||||
ParagraphStyle('RightHeading1', parent=self._defined_styles.get('Heading1'), alignment=TA_RIGHT)
|
ParagraphStyle('RightHeading1', parent=self._defined_styles.get('Heading1'), alignment=TA_RIGHT)
|
||||||
)
|
)
|
||||||
self._defined_styles.add(
|
self._defined_styles.add(
|
||||||
ParagraphStyle('ItemTableParagraph', parent=self._defined_styles.get('Normal'), alignment=TA_CENTER)
|
ParagraphStyle('TableParagraph', parent=self._defined_styles.get('Normal'), alignment=TA_CENTER)
|
||||||
)
|
)
|
||||||
|
|
||||||
self.invoice_info = None
|
self.invoice_info = None
|
||||||
|
@ -129,11 +130,14 @@ class SimpleInvoice(SimpleDocTemplate):
|
||||||
if isinstance(self.service_provider_info, ServiceProviderInfo) and isinstance(self.client_info, ClientInfo):
|
if isinstance(self.service_provider_info, ServiceProviderInfo) and isinstance(self.client_info, ClientInfo):
|
||||||
# Merge Table
|
# Merge Table
|
||||||
table_data = [
|
table_data = [
|
||||||
[Paragraph('Service Provider', self._defined_styles.get('Heading1')), '', Paragraph('Client', self._defined_styles.get('Heading1')), '']
|
[Paragraph('Service Provider', self._defined_styles.get('Heading1')), '', '', Paragraph('Client', self._defined_styles.get('Heading1')), '']
|
||||||
]
|
]
|
||||||
table_style = [
|
table_style = [
|
||||||
('SPAN', (0, 0), (1, 0)),
|
('SPAN', (0, 0), (1, 0)),
|
||||||
('SPAN', (2, 0), (3, 0)),
|
('SPAN', (3, 0), (4, 0)),
|
||||||
|
('LINEBELOW', (0, 0), (1, 0), 1, colors.gray),
|
||||||
|
('LINEBELOW', (3, 0), (4, 0), 1, colors.gray),
|
||||||
|
('LEFTPADDING', (0, 0), (-1, -1), 0),
|
||||||
]
|
]
|
||||||
client_info_data = self.__client_info_data()
|
client_info_data = self.__client_info_data()
|
||||||
service_provider_data = self.__service_provider_data()
|
service_provider_data = self.__service_provider_data()
|
||||||
|
@ -144,6 +148,7 @@ class SimpleInvoice(SimpleDocTemplate):
|
||||||
else:
|
else:
|
||||||
service_provider_data.extend([["", ""]*diff])
|
service_provider_data.extend([["", ""]*diff])
|
||||||
for d in zip(service_provider_data, client_info_data):
|
for d in zip(service_provider_data, client_info_data):
|
||||||
|
d[0].append('')
|
||||||
d[0].extend(d[1])
|
d[0].extend(d[1])
|
||||||
table_data.append(d[0])
|
table_data.append(d[0])
|
||||||
self._story.append(
|
self._story.append(
|
||||||
|
@ -159,7 +164,7 @@ class SimpleInvoice(SimpleDocTemplate):
|
||||||
(
|
(
|
||||||
item.item_id,
|
item.item_id,
|
||||||
item.name,
|
item.name,
|
||||||
Paragraph(item.description, self._defined_styles.get('ItemTableParagraph')),
|
Paragraph(item.description, self._defined_styles.get('TableParagraph')),
|
||||||
item.units,
|
item.units,
|
||||||
item.unit_price,
|
item.unit_price,
|
||||||
item.subtotal
|
item.subtotal
|
||||||
|
@ -178,9 +183,9 @@ class SimpleInvoice(SimpleDocTemplate):
|
||||||
transaction_table_data = [
|
transaction_table_data = [
|
||||||
(
|
(
|
||||||
t.transaction_id,
|
t.transaction_id,
|
||||||
t.gateway,
|
Paragraph(t.gateway, self._defined_styles.get('TableParagraph')),
|
||||||
self.__format_value(t.transaction_datetime),
|
self.__format_value(t.transaction_datetime),
|
||||||
t.amount
|
t.amount,
|
||||||
) for t in self._transactions if isinstance(t, Transaction)
|
) for t in self._transactions if isinstance(t, Transaction)
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
@ -32,9 +32,9 @@ doc.client_info = ClientInfo(
|
||||||
post_code='222222'
|
post_code='222222'
|
||||||
)
|
)
|
||||||
|
|
||||||
doc.add_item(Item('0000', 'Item 0000', 'Item Description 1', 1, Decimal('1.1')))
|
doc.add_item(Item('0000', 'Item', 'Item', 1, Decimal('1.1')))
|
||||||
doc.add_item(Item('1111', 'Item 1111', 'Item Description 2', 2, Decimal('2.2')))
|
doc.add_item(Item('1111', 'Item', 'Item', 2, Decimal('2.2')))
|
||||||
doc.add_item(Item('2222', 'Item 2222', 'Item Description 3', 3, Decimal('3.3')))
|
doc.add_item(Item('2222', 'Item', 'Item', 3, Decimal('3.3')))
|
||||||
|
|
||||||
doc.add_transaction(Transaction('Paypal', 111, datetime.now(), 1))
|
doc.add_transaction(Transaction('Paypal', 111, datetime.now(), 1))
|
||||||
doc.add_transaction(Transaction('Strip', 222, datetime.now(), 2))
|
doc.add_transaction(Transaction('Strip', 222, datetime.now(), 2))
|
||||||
|
|
Loading…
Reference in a new issue