'Generates the pdf invoice for the given course
and returns the pdf_buffer.'

def generate_pdf_invoice(self, course, course_price, quantity, sale_price):

    discount_per_item = (float(course_price) - (sale_price / quantity))
    list_price = (course_price - discount_per_item)
    items_data = [{'item_description': course.display_name, 'quantity': quantity, 'list_price': list_price, 'discount': discount_per_item, 'item_total': (quantity * list_price)}]
    pdf_buffer = BytesIO()
    PDFInvoice(items_data=items_data, item_id=str(self.id), date=datetime.now(pytz.utc), is_invoice=True, total_cost=float(self.total_amount), payment_received=0, balance=float(self.total_amount)).generate_pdf(pdf_buffer)
    return pdf_buffer
