コード例 #1
0
def _create_header(canvas, doc, draw_page_number=True):
    canvas.saveState()
    canvas.setTitle('Invoice')
    canvas.setFont(BOLD_FONTNAME, LARGE_FONTSIZE)

    current_y = PAGE_HEIGHT - HEADER_MARGIN

    dpaw_header_logo = ImageReader(DPAW_HEADER_LOGO)
    dpaw_header_logo_size = dpaw_header_logo.getSize()
    canvas.drawImage(dpaw_header_logo,
                     PAGE_WIDTH / 3,
                     current_y - (dpaw_header_logo_size[1] / 2),
                     width=dpaw_header_logo_size[0] / 2,
                     height=dpaw_header_logo_size[1] / 2,
                     mask='auto')

    current_y -= 70
    canvas.drawCentredString(PAGE_WIDTH / 2, current_y - LARGE_FONTSIZE,
                             'TAX INVOICE')

    current_y -= 20
    canvas.drawCentredString(PAGE_WIDTH / 2, current_y - LARGE_FONTSIZE,
                             'ABN: 38 052 249 024')

    # Invoice address details
    invoice_details_offset = 37
    current_y -= 10

    invoice = doc.invoice
    proposal = doc.proposal
    bi = proposal.bookings.filter(
        invoices__invoice_reference=invoice.reference)
    licence_number = proposal.approval.lodgement_number if proposal.approval else None

    # TODO need to fix, since individual parks can be exempt, Below calculation assumes NO PARK IS exempt
    #is_gst_exempt = proposal.application_type.is_gst_exempt if proposal.fee_invoice_reference == invoice.reference else False

    canvas.setFont(BOLD_FONTNAME, SMALL_FONTSIZE)
    current_x = PAGE_MARGIN + 5
    if proposal.org_applicant:
        canvas.drawString(current_x,
                          current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),
                          proposal.applicant)
    canvas.drawString(current_x,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 2,
                      invoice.owner.get_full_name())
    canvas.drawString(current_x,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3,
                      invoice.owner.email)
    current_x += 435

    #write Invoice details
    canvas.drawString(current_x,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),
                      'Date')
    canvas.drawString(
        current_x + invoice_details_offset,
        current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),
        to_local_tz(invoice.created).strftime(DATE_FORMAT) + ' (AWST)')
    canvas.drawString(current_x,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 2,
                      'Page')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 2,
                      str(canvas.getPageNumber()))

    if licence_number:
        canvas.drawRightString(
            current_x + 20,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3,
            'Licence Number')
        canvas.drawString(
            current_x + invoice_details_offset,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3,
            licence_number)
    else:
        canvas.drawRightString(
            current_x + 20,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3,
            'Proposal Number')
        canvas.drawString(
            current_x + invoice_details_offset,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3,
            proposal.lodgement_number)

    canvas.drawRightString(
        current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 4,
        'Invoice Number')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 4,
                      invoice.reference)
    canvas.drawRightString(
        current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5,
        'Total (AUD)')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5,
                      currency(invoice.amount))
    canvas.drawRightString(
        current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 6,
        'GST included (AUD)')
    canvas.drawString(
        current_x + invoice_details_offset,
        current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 6,
        currency(invoice.amount - calculate_excl_gst(invoice.amount)
                 if not _is_gst_exempt(proposal, invoice) else 0.0))
    canvas.drawRightString(
        current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 7,
        'Paid (AUD)')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 7,
                      currency(invoice.payment_amount))
    canvas.drawRightString(
        current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 8,
        'Outstanding (AUD)')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 8,
                      currency(invoice.balance))

    if bi and bi[0].deferred_payment_date and invoice.payment_method in [
            invoice.PAYMENT_METHOD_MONTHLY_INVOICING,
            invoice.PAYMENT_METHOD_BPAY
    ]:
        canvas.drawRightString(
            current_x + 20,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 9,
            'Payment Due Date')
        canvas.drawString(
            current_x + invoice_details_offset,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 9,
            bi[0].deferred_payment_date.strftime(DATE_FORMAT))

    canvas.restoreState()
コード例 #2
0
def _create_header(canvas, doc, draw_page_number=True):
    canvas.saveState()
    canvas.setTitle('Confirmation')
    canvas.setFont(BOLD_FONTNAME, LARGE_FONTSIZE)

    current_y = PAGE_HEIGHT - HEADER_MARGIN

    dpaw_header_logo = ImageReader(DPAW_HEADER_LOGO)
    dpaw_header_logo_size = dpaw_header_logo.getSize()
    canvas.drawImage(dpaw_header_logo, PAGE_WIDTH / 3, current_y - (dpaw_header_logo_size[1]/2),width=dpaw_header_logo_size[0]/2, height=dpaw_header_logo_size[1]/2, mask='auto')

    current_y -= 100
    #invoice = doc.invoice
    booking = doc.booking
    licence_number = booking.proposal.approval.lodgement_number if booking.proposal.approval else None

    PAGE_TITLE = 'BOOKING CONFIRMATION(S)'
    canvas.drawCentredString(PAGE_WIDTH / 2, current_y - LARGE_FONTSIZE, PAGE_TITLE)

    # Invoice address details
    invoice_details_offset = 37
    current_y -= 25
    canvas.setFont(BOLD_FONTNAME, SMALL_FONTSIZE)
    current_x = PAGE_MARGIN + 5
    canvas.drawString(current_x, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),    booking.proposal.applicant)
    current_x += 435

    #write Invoice details
    canvas.drawString(current_x, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),'Date')
    canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER), to_local_tz(booking.created).strftime(DATE_FORMAT)  + ' (AWST)' )
    canvas.drawString(current_x, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 2, 'Page')
    canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 2, str(canvas.getPageNumber()))
    canvas.drawRightString(current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3, 'Licence Number')
    canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3, licence_number)
    canvas.drawRightString(current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 4, 'Paid (AUD)')
    canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 4, 'Monthly Invoicing')
    if hasattr(booking, 'booking_type'):
        canvas.drawRightString(current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5, 'Booking No.')
        canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5, booking.admission_number)
    canvas.restoreState()
コード例 #3
0
def _create_header(canvas, doc, draw_page_number=True):
    canvas.saveState()
    canvas.setTitle('Confirmation')
    canvas.setFont(BOLD_FONTNAME, LARGE_FONTSIZE)

    current_y = PAGE_HEIGHT - HEADER_MARGIN

    dpaw_header_logo = ImageReader(DPAW_HEADER_LOGO)
    dpaw_header_logo_size = dpaw_header_logo.getSize()
    canvas.drawImage(dpaw_header_logo,
                     PAGE_WIDTH / 3,
                     current_y - (dpaw_header_logo_size[1] / 2),
                     width=dpaw_header_logo_size[0] / 2,
                     height=dpaw_header_logo_size[1] / 2,
                     mask='auto')

    current_y -= 100
    #invoice = doc.invoice
    proposal = doc.proposal
    #licence_number = proposal.approval.lodgement_number if booking.proposal.approval else None

    PAGE_TITLE = 'AWAITING PAYMENT CONFIRMATION'
    canvas.drawCentredString(PAGE_WIDTH / 2, current_y - LARGE_FONTSIZE,
                             PAGE_TITLE)

    # Invoice address details
    invoice_details_offset = 37
    current_y -= 25
    canvas.setFont(BOLD_FONTNAME, SMALL_FONTSIZE)
    current_x = PAGE_MARGIN + 5
    #canvas.drawString(current_x, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),    proposal.applicant)
    canvas.drawString(current_x,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),
                      proposal.applicant)
    if hasattr(proposal.invoice,
               'payment_status') and proposal.invoice.payment_status in [
                   'paid', 'over_paid'
               ]:
        canvas.drawString(
            current_x, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 2,
            proposal.invoice.owner.get_full_name())
        canvas.drawString(
            current_x, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3,
            proposal.invoice.owner.email)
    current_x += 435

    total_amount = 0.0
    filming_fee = proposal.filming_fees.order_by('-id').first()
    if hasattr(proposal.invoice,
               'payment_status') and proposal.invoice.payment_status in [
                   'paid', 'over_paid'
               ]:
        pass
    else:
        # Calc Total Amount
        for item in filming_fee.lines:
            amount = float(item['price_incl_tax']) * item['quantity']
            total_amount += amount

    #write Invoice details
    canvas.drawString(current_x,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),
                      'Date')
    canvas.drawString(
        current_x + invoice_details_offset,
        current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),
        to_local_tz(filming_fee.created).strftime(DATE_FORMAT) + ' (AWST)')
    canvas.drawString(current_x,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 2,
                      'Page')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 2,
                      str(canvas.getPageNumber()))
    canvas.drawRightString(
        current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3,
        'Proposal Number')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3,
                      proposal.lodgement_number)
    #if proposal.fee_invoice_reference:
    if proposal.filming_fee_invoice_reference:
        canvas.drawRightString(
            current_x + 20,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 4, 'Invoice')
        canvas.drawString(
            current_x + invoice_details_offset,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 4,
            proposal.filming_fee_invoice_reference)

    canvas.drawRightString(
        current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5,
        'Payment Due Date')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5,
                      filming_fee.deferred_payment_date.strftime(DATE_FORMAT))
    canvas.drawRightString(
        current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 6,
        'Outstanding (AUD)')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 6,
                      currency(total_amount))
    #    if hasattr(booking, 'booking_type'):
    #        canvas.drawRightString(current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5, 'Booking No.')
    #        canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5, booking.admission_number)
    canvas.restoreState()
コード例 #4
0
def _create_header(canvas, doc, draw_page_number=True):
    canvas.saveState()
    canvas.setTitle('Confirmation')
    canvas.setFont(BOLD_FONTNAME, LARGE_FONTSIZE)

    current_y = PAGE_HEIGHT - HEADER_MARGIN

    dpaw_header_logo = ImageReader(DPAW_HEADER_LOGO)
    dpaw_header_logo_size = dpaw_header_logo.getSize()
    canvas.drawImage(dpaw_header_logo,
                     PAGE_WIDTH / 3,
                     current_y - (dpaw_header_logo_size[1] / 2),
                     width=dpaw_header_logo_size[0] / 2,
                     height=dpaw_header_logo_size[1] / 2,
                     mask='auto')

    current_y -= 70
    invoice = doc.invoice
    booking = doc.booking
    licence_number = booking.proposal.approval.lodgement_number if booking.proposal.approval else None

    if hasattr(booking, 'payment_type'):
        PAGE_TITLE = 'APPLICATION & LICENCE FEE CONFIRMATION'
    else:
        PAGE_TITLE = 'BOOKING CONFIRMATION'
    canvas.drawCentredString(PAGE_WIDTH / 2, current_y - LARGE_FONTSIZE,
                             PAGE_TITLE)

    # Invoice address details
    invoice_details_offset = 37
    current_y -= 25
    canvas.setFont(BOLD_FONTNAME, SMALL_FONTSIZE)
    current_x = PAGE_MARGIN + 5
    if booking.proposal.org_applicant:
        canvas.drawString(current_x,
                          current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),
                          booking.proposal.applicant)
    canvas.drawString(current_x,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 2,
                      invoice.owner.get_full_name())
    canvas.drawString(current_x,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3,
                      invoice.owner.email)
    current_x += 435

    #write Invoice details
    canvas.drawString(current_x,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),
                      'Date')
    canvas.drawString(
        current_x + invoice_details_offset,
        current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),
        to_local_tz(invoice.created).strftime(DATE_FORMAT) + ' (AWST)')
    canvas.drawString(current_x,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 2,
                      'Page')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 2,
                      str(canvas.getPageNumber()))
    canvas.drawRightString(
        current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3,
        'Licence Number')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 3,
                      licence_number)
    canvas.drawRightString(
        current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 4,
        'Invoice Number')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 4,
                      invoice.reference)
    canvas.drawRightString(
        current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5,
        'Paid (AUD)')
    canvas.drawString(current_x + invoice_details_offset,
                      current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5,
                      currency(invoice.payment_amount))
    if hasattr(booking, 'booking_type'):
        canvas.drawRightString(
            current_x + 20,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 6,
            'Booking No.')
        canvas.drawString(
            current_x + invoice_details_offset,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 6,
            booking.booking_number)

    if booking.deferred_payment_date and invoice.payment_method in [
            invoice.PAYMENT_METHOD_MONTHLY_INVOICING,
            invoice.PAYMENT_METHOD_BPAY
    ]:
        canvas.drawRightString(
            current_x + 20,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 7,
            'Payment Due Date')
        canvas.drawString(
            current_x + invoice_details_offset,
            current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 7,
            booking.deferred_payment_date.strftime(DATE_FORMAT))

    canvas.restoreState()