def RECEIPT() : Billno = Book.Bill_No() cur.execute(f"""insert into purchase values({BookID.get()} , '{iDate.get()}');""") cur.execute(f"""update stock set book_stock = book_stock - 1 where book_id = {BookID.get()}""") db.commit() messagebox.showinfo('Stock Details' , 'Books Sold Successfully!!! Now Printing...') data = txtReceipt.get(4.0 , 'end-320c') SubTotal = str(Tot.get()) index_deci = SubTotal.find('.') + 1 if len(SubTotal[index_deci:]) == 1 : SubTotal += '0' NoS_SubTotal = 12 - len(SubTotal[-3::-1]) roundoff = eval(SubTotal[index_deci:]) NoS_roundoff = 18 - (len(str(roundoff)) + 7) TotalAmt = str(eval(SubTotal) - eval("0." + str(roundoff))) + "0" Total = Book.Ind_System(TotalAmt) NoS_Total = 12 - len(Total[-3::-1]) Total_words = Book.no_to_words(Total) ''' filename = mktemp('.txt') file = open(filename , 'w') ''' file = open("Receipt.txt" , 'w') file.write("\t\t\t\tSainik Book Shop\n\n") file.write("\t\t\tAmaravathinagar, Tiruppur; PIN => 642102\n\n\n") file.write(f"Bill No.: {Billno}\t\t\t\t\t\t Date : {Book.date_mod()}\n\n") file.write(('-'.center(80 , '-') + '\n')) file.write("PARTICULARS\t\t\t\t\tQuantity Rate Net\n") file.write("\t\t\t\t\t\t\t\t\t Amount\n") file.write(('-'.center(80 , '-') + '\n\n')) file.write(f"{data}\n") file.write(('-'.center(80 , '-') + '\n')) file.write((" " * 50) + "Sub Total : " + " " * NoS_SubTotal + f"Rs. {SubTotal}\n") file.write((" " * 50) + "Round Off : " + " " * NoS_roundoff + f"-Rs. 0.{roundoff}\n") file.write(('-'.center(80 , '-') + '\n\n')) file.write((" " * 54) + "Total : " + " " * NoS_Total + f"Rs. {Total}\n\n") file.write(('-'.center(80 , '-') + '\n\n')) file.write(f"Amount in Words : {Total_words}\n") file.write(18 * " " + "_" * (len(Total_words)) + '\n\n') file.write("\t\t\tThank You, Have a Nice Day!!!") ''' doc = dc.Document() doc.add_paragraph("\t\t\t\tSainik Book Shop\n\n") doc.add_paragraph("\t\t\tAmaravathinagar, Tiruppur; PIN => 642102\n\n\n") doc.add_paragraph("Bill No.: {}\t\t\t\t\t\tDate : {}\n\n".format(Billno , Book.date_mod())) doc.add_paragraph(('-'.center(80 , '-') + '\n')) doc.add_paragraph("PARTICULARS\t\t\t\t\tQuantity Rate Net\n") doc.add_paragraph("\t\t\t\t\t\t\t\t\t Amount\n") doc.add_paragraph(('-'.center(80 , '-') + '\n\n')) doc.add_paragraph("{}\n".format(data)) doc.add_paragraph(('-'.center(80 , '-') + '\n')) doc.add_paragraph((" " * NoS_Total) + "Total : Rs. {}\n\n".format(Total)) doc.add_paragraph(NoS_Total_Words * " " + "Amount in Words : {}\n\n".format(Total_words)) doc.add_paragraph("\t\t\tThank You, Have a Nice Day!!!") doc.save("Receipt.docx") ''' #startfile(filename , 'print') txtReceipt.delete('1.0','end') txtReceipt.insert('end' , "PARTICLULARS\t\t\t\tQuantity Rate Net\n") txtReceipt.insert('end' , "\t\t\t\t\t\t Amount\n") txtReceipt.insert('end' , ('-'.center(316 , '-') + '\n\n\n')) txtReceipt.insert('end' , ('-'.center(316 , '-') + '\n\n\n')) iRESET()