@@ -162,23 +162,43 @@ def __payment_line(self):
162
162
self .current_y = current_y
163
163
164
164
def __footer_line (self ):
165
+ total_cols = 4
166
+ try :
167
+ print (self .invoice .due_date .strftime (DATE_FORMAT ))
168
+ total_cols = 5
169
+
170
+ except Exception as e :
171
+ # if not valid date we keep totals cols at 4
172
+ pass
173
+
165
174
canvas = self .canv
166
175
current_y , current_x = self .current_y , self .current_x
167
176
current_y -= 2 * inch
168
177
total_gst_tax = self .invoice .order .total_incl_tax - self .invoice .order .total_excl_tax
169
178
canvas .setFont (DEFAULT_FONTNAME , LARGE_FONTSIZE )
170
179
canvas .setFillColor (colors .black )
171
180
canvas .drawString (current_x , current_y , 'Invoice Number' )
172
- canvas .drawString (PAGE_WIDTH / 4 , current_y , 'Invoice Date' )
173
- canvas .drawString ((PAGE_WIDTH / 4 ) * 2 , current_y , 'GST included' )
174
- canvas .drawString ((PAGE_WIDTH / 4 ) * 3 , current_y , 'Invoice Total' )
181
+ canvas .drawString (PAGE_WIDTH / total_cols , current_y , 'Invoice Date' )
182
+ nextrow = 2
183
+ if self .invoice .due_date :
184
+ canvas .drawString ((PAGE_WIDTH / total_cols ) * nextrow , current_y , 'Due Date' )
185
+ nextrow = nextrow + 1
186
+ canvas .drawString ((PAGE_WIDTH / total_cols ) * nextrow , current_y , 'GST included' )
187
+ nextrow = nextrow + 1
188
+ canvas .drawString ((PAGE_WIDTH / total_cols ) * nextrow , current_y , 'Invoice Total' )
175
189
current_y -= 20
176
190
canvas .setFont (DEFAULT_FONTNAME , MEDIUM_FONTSIZE )
177
191
canvas .drawString (current_x , current_y , self .invoice .reference )
178
- canvas .drawString (PAGE_WIDTH / 4 , current_y , self .invoice .created .strftime (DATE_FORMAT ))
192
+ canvas .drawString (PAGE_WIDTH / total_cols , current_y , self .invoice .created .strftime (DATE_FORMAT ))
193
+ nextrow = 2
194
+ if self .invoice .due_date :
195
+ canvas .drawString ((PAGE_WIDTH / total_cols ) * nextrow , current_y , self .invoice .due_date .strftime (DATE_FORMAT ))
196
+ nextrow = nextrow + 1
179
197
#canvas.drawString((PAGE_WIDTH/4) * 2, current_y, currency(self.invoice.amount - calculate_excl_gst(self.invoice.amount)))
180
- canvas .drawString ((PAGE_WIDTH / 4 ) * 2 , current_y , currency (total_gst_tax ))
181
- canvas .drawString ((PAGE_WIDTH / 4 ) * 3 , current_y , currency (self .invoice .amount ))
198
+
199
+ canvas .drawString ((PAGE_WIDTH / total_cols ) * nextrow , current_y , currency (total_gst_tax ))
200
+ nextrow = nextrow + 1
201
+ canvas .drawString ((PAGE_WIDTH / total_cols ) * nextrow , current_y , currency (self .invoice .amount ))
182
202
183
203
def draw (self ):
184
204
if settings .BPAY_ALLOWED :
@@ -219,26 +239,42 @@ def _create_header(canvas, doc, draw_page_number=True):
219
239
canvas .drawString (current_x , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ), invoice .order .organisation .name )
220
240
canvas .drawString (current_x , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 2 , invoice .order .organisation .abn )
221
241
222
- canvas .drawString (current_x , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 3 ,invoice .owner .get_full_name ())
242
+ invoice_name = invoice .owner .get_full_name ()
243
+ if invoice .invoice_name :
244
+ if len (invoice .invoice_name ) > 0 :
245
+ invoice_name = invoice .invoice_name
246
+
247
+ canvas .drawString (current_x , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 3 ,invoice_name )
223
248
canvas .drawString (current_x , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 4 ,invoice .owner .username )
224
249
225
250
current_x += 452
226
251
#write Invoice details
252
+ nextrowcount = 2
227
253
canvas .drawString (current_x , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ),'Date' )
228
- canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ),invoice .created .strftime (DATE_FORMAT ))
229
- canvas .drawString (current_x , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 2 , 'Page' )
230
- canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 2 , str (canvas .getPageNumber ()))
231
- canvas .drawRightString (current_x + 20 , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 3 , 'Invoice Number' )
232
- canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 3 , invoice .reference )
233
- canvas .drawRightString (current_x + 20 , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 4 , 'Total (AUD)' )
234
- canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 4 , currency (invoice .amount ))
235
- canvas .drawRightString (current_x + 20 , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 5 , 'GST included (AUD)' )
254
+ canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ),invoice .created .strftime (DATE_FORMAT ))
255
+ canvas .drawString (current_x , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , 'Page' )
256
+ canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , str (canvas .getPageNumber ()))
257
+ nextrowcount = nextrowcount + 1
258
+ canvas .drawRightString (current_x + 20 , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , 'Invoice Number' )
259
+ canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , invoice .reference )
260
+
261
+ if invoice .due_date :
262
+ nextrowcount = nextrowcount + 1
263
+ canvas .drawRightString (current_x + 20 , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , 'Due Date' )
264
+ canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , invoice .due_date .strftime (DATE_FORMAT ))
265
+ nextrowcount = nextrowcount + 1
266
+ canvas .drawRightString (current_x + 20 , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , 'Total (AUD)' )
267
+ canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , currency (invoice .amount ))
268
+ nextrowcount = nextrowcount + 1
269
+ canvas .drawRightString (current_x + 20 , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , 'GST included (AUD)' )
236
270
#canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5, currency(invoice.amount - calculate_excl_gst(invoice.amount)))
237
- canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 5 , currency (total_gst_tax ))
238
- canvas .drawRightString (current_x + 20 , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 6 , 'Paid (AUD)' )
239
- canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 6 , currency (invoice .payment_amount ))
240
- canvas .drawRightString (current_x + 20 , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 7 , 'Outstanding (AUD)' )
241
- canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * 7 , currency (invoice .balance ))
271
+ canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , currency (total_gst_tax ))
272
+ nextrowcount = nextrowcount + 1
273
+ canvas .drawRightString (current_x + 20 , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , 'Paid (AUD)' )
274
+ canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , currency (invoice .payment_amount ))
275
+ nextrowcount = nextrowcount + 1
276
+ canvas .drawRightString (current_x + 20 , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , 'Outstanding (AUD)' )
277
+ canvas .drawString (current_x + invoice_details_offset , current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER ) * nextrowcount , currency (invoice .balance ))
242
278
canvas .restoreState ()
243
279
244
280
def _create_invoice (invoice_buffer , invoice ):
0 commit comments