my_sale is a dictionary having product_id as key and quantity sold as value.
We have discount and tax rate as variables inside this file.
discount_rate=10 # 10% discount
tax_rate=12 # tax rate in percentage
This is the template file where the blank design of the invoice is available inside the function my_temp(). This function is called inside the main file to show the blank invoice.
This file draws all lines , add text and place the top logo on the canvas. Font family is changed to available default fonts.
This is the main file and by using the template ( temp_invoice.py ) and the data ( invoice_data.py ) it creates the pdf document.
from temp_invoice import my_temp # import the template
from invoice_data import * # get all data required for invoice
By using for loop all sales data are displayed with quanity and price. Here for price and total drawRightString() is used.
for items in my_sale:
c.drawString(0.1*inch,line_y*inch,str(my_prod[items])) # p Name
c.drawRightString(4.5*inch,line_y*inch,str(my_prod[items])) # p Price
c.drawRightString(5.5*inch,line_y*inch,str(my_sale[items])) # p Qunt
c.drawRightString(7*inch,line_y*inch,str(sub_total)) # Sub Total