def printinvoice():
    head = header(CustomerName.get(), CustomerContact.get())
    pdf = canvas.Canvas("C:\\InvoiceGenerator\\" + str(head.CustomerName) + ".pdf")
    pdfgen.header(head, pdf)
    pdfgen.middle(pdf)
    ycooridinate = 652
    x = 1

    for item in Products:
        currproduct = product(item[0], item[1], item[2], item[5], item[3])
        pdf.drawString(35, ycooridinate, str(x))
        x = x + 1
        pdf.setFont("Courier-Bold", 9)
        ycooridinate = pdfgen.additem(currproduct, pdf, ycooridinate)
    pdf.setFont("Courier-Bold", 11)
    pdfgen.footer(pdf, Products)
    pdf.save()
Exemple #2
0
def printinvoice():
    head = header(CustomerName.get(), CustomerContact.get())
    pdf = canvas.Canvas("/Users/uttam/Desktop/bill/" + str(head.CustomerName) +
                        ".pdf")
    pdfgen.header(head, pdf)
    pdfgen.middle(pdf)
    ycooridinate = 650
    x = 1

    for item in Products:
        currproduct = product(item[0], item[1], item[2], item[5], item[3])
        pdf.drawString(35, ycooridinate, str(x))
        x = x + 1
        pdf.setFont("Courier-Bold", 9)
        ycooridinate = pdfgen.additem(currproduct, pdf, ycooridinate)
    pdf.setFont("Courier-Bold", 11)
    pdfgen.footer(pdf, Products)
    pdf.save()
    webbrowser.open("/Users/uttam/Desktop/bill/" + str(CustomerName) + ".pdf")
Exemple #3
0
    def generateBill(self):
        global customer_Name
        customer_Name = self.customername_LE.text()
        global Customer_contact
        Customer_contact = self.contactnumber_LE.text()
        if (self.customerValidations()):
            global current_bill
            #self.getDetailsToPrint()
            pdf = canvas.Canvas("C:\\InvoiceGenerator\\" + str(current_bill) +
                                ".pdf")
            pdfgen.header(pdf)
            pdfgen.middle(pdf)
            ycooridinate = 650
            x = 1
            Products = []
            global Total
            Total = 0

            connection = sqlite3.connect("db.db")
            result = connection.execute(
                "SELECT * from bill WHERE bill_id = (?)", (current_bill, ))
            result_list = list(result.fetchall())
            print(result_list)

            i = 0
            while i < len(result_list):
                #print("Inside While")
                #print(result_list[i][1],result_list[i][2], result_list[i][3], result_list[i][4],result_list[i][5])
                currproduct = product(result_list[i][1], result_list[i][2],
                                      result_list[i][3], result_list[i][4],
                                      result_list[i][5])

                Total = Total + int(result_list[i][5])
                pdf.drawString(35, ycooridinate, str(x))
                x = x + 1
                pdf.setFont("Courier-Bold", 9)
                ycooridinate = pdfgen.additem(currproduct, pdf, ycooridinate)
                i += 1

            pdf.setFont("Courier-Bold", 11)
            pdfgen.footer(pdf, Products)
            pdf.save()
            webbrowser.open("C:\\InvoiceGenerator\\" + str(current_bill) +
                            ".pdf")

            quantity = connection.execute(
                """SELECT name,quantity FROM bill WHERE bill_id = ?""",
                (current_bill, ))
            quantity_list = list(quantity.fetchall())
            #print(len(resultlist))
            for x in quantity_list:
                a = int(x[1])
                b = x[0]
                try:
                    connection.execute(
                        "UPDATE product SET in_stock = in_stock - (?) WHERE name = (?) ",
                        (
                            a,
                            b,
                        ))
                    connection.commit()
                except Exception as e:
                    print(e)

            self.carttable.clear()

            last_bill = "SELECT MAX(bill_id) from bill"
            result_lastbill = connection.execute(last_bill)
            final_result = list(result_lastbill.fetchall())
            current_bill = int(final_result[0][0]) + 1

            if current_bill < 10:
                current_bill = '0' + str(current_bill)
            self.billno_LE.setText(str(current_bill))
            self.billno_LE.setDisabled(True)
            self.customername_LE.setText("")
            self.contactnumber_LE.setText("")
            self.loadData()
            connection.close()