Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate Tax from DB tax line items instead of total amount. #806

Merged
merged 1 commit into from
Aug 5, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions ledger/payments/pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ def __footer_line(self):
canvas = self.canv
current_y, current_x = self.current_y, self.current_x
current_y -= 2 * inch
total_gst_tax = self.invoice.order.total_incl_tax - self.invoice.order.total_excl_tax
canvas.setFont(DEFAULT_FONTNAME, LARGE_FONTSIZE)
canvas.setFillColor(colors.black)
canvas.drawString(current_x, current_y, 'Invoice Number')
Expand All @@ -170,7 +171,8 @@ def __footer_line(self):
canvas.setFont(DEFAULT_FONTNAME, MEDIUM_FONTSIZE)
canvas.drawString(current_x, current_y, self.invoice.reference)
canvas.drawString(PAGE_WIDTH/4, current_y, self.invoice.created.strftime(DATE_FORMAT))
canvas.drawString((PAGE_WIDTH/4) * 2, current_y, currency(self.invoice.amount - calculate_excl_gst(self.invoice.amount)))
#canvas.drawString((PAGE_WIDTH/4) * 2, current_y, currency(self.invoice.amount - calculate_excl_gst(self.invoice.amount)))
canvas.drawString((PAGE_WIDTH/4) * 2, current_y, currency(total_gst_tax))
canvas.drawString((PAGE_WIDTH/4) * 3, current_y, currency(self.invoice.amount))

def draw(self):
Expand Down Expand Up @@ -201,6 +203,8 @@ def _create_header(canvas, doc, draw_page_number=True):
invoice_details_offset = 37
current_y -= 20
invoice = doc.invoice
total_gst_tax = invoice.order.total_incl_tax - invoice.order.total_excl_tax

canvas.setFont(BOLD_FONTNAME, SMALL_FONTSIZE)
current_x = PAGE_MARGIN + 5
canvas.drawString(current_x, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER),invoice.owner.get_full_name())
Expand All @@ -216,7 +220,8 @@ def _create_header(canvas, doc, draw_page_number=True):
canvas.drawRightString(current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 4, 'Total (AUD)')
canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 4, currency(invoice.amount))
canvas.drawRightString(current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5, 'GST included (AUD)')
canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5, currency(invoice.amount - calculate_excl_gst(invoice.amount)))
#canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5, currency(invoice.amount - calculate_excl_gst(invoice.amount)))
canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 5, currency(total_gst_tax))
canvas.drawRightString(current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 6, 'Paid (AUD)')
canvas.drawString(current_x + invoice_details_offset, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 6, currency(invoice.payment_amount))
canvas.drawRightString(current_x + 20, current_y - (SMALL_FONTSIZE + HEADER_SMALL_BUFFER) * 7, 'Outstanding (AUD)')
Expand Down