Change invoice Bill
This commit is contained in:
		
							
								
								
									
										32
									
								
								api.py
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								api.py
									
									
									
									
									
								
							| @@ -21,16 +21,16 @@ class Info(BaseModel): | ||||
| def print_bill(data, address): | ||||
|     d = data | ||||
|     # Crea una instancia de la impresora ficticia | ||||
|     #printer = Network(str(address)) | ||||
|     #printer.open() | ||||
|     printer = Dummy() | ||||
|     printer = Network(str(address)) | ||||
|     printer.open() | ||||
|     #printer = Dummy() | ||||
|      | ||||
|     # Imprime el encabezado | ||||
|     printer.set(align='center', bold=False, height=1, width=1) | ||||
|     printer.text(d["shop_name"]+'\n') | ||||
|     printer.text(d["shop_address"]+'\n') | ||||
|     printer.set(align='left', bold=False, height=1, width=1) | ||||
|     printer.textln('=======================================') | ||||
|     printer.textln('===============================================') | ||||
|  | ||||
|     if d['invoice'] and d['invoice']['resolution']: | ||||
|         text = "Resolucion de Facturacion # "+str(d['invoice']['resolution']['resolution_number']) \ | ||||
| @@ -44,7 +44,7 @@ def print_bill(data, address): | ||||
|     printer.text("Cliente: "+d["party"]+'\n') | ||||
|     printer.text("CC/NIT: "+d["tax_identifier_code"]+'\n') | ||||
|     printer.text("Direccion: "+d["address"]+'\n') | ||||
|     printer.textln('=======================================') | ||||
|     printer.textln('===============================================') | ||||
|     printer.ln() | ||||
|     for line in d["lines"]: | ||||
|         if line['type'] != 'title': | ||||
| @@ -55,7 +55,8 @@ def print_bill(data, address): | ||||
|             printer.text(text) | ||||
|  | ||||
|     printer.set(align='right', bold=False, height=1, width=1) | ||||
|     printer.text('========================\n') | ||||
|     printer.textln('================================================') | ||||
|  | ||||
|     text = "Total (sin impuestos): "+str(d["untaxed_amount"])+"\n" | ||||
|     printer.text(text) | ||||
|     text = "Impuestos (INC): "+str(d["tax_amount"])+"\n" | ||||
| @@ -67,13 +68,14 @@ def print_bill(data, address): | ||||
|     #if d['payments']: | ||||
|     if 'payments' in d.keys(): | ||||
|         printer.textln("Pagos: ") | ||||
|         printer.text('------------------------\n') | ||||
|         printer.textln('================================================') | ||||
|  | ||||
|         for payment in d['payments']: | ||||
|             text = str(payment["statement"])+" $"+str(payment["amount"]) | ||||
|             printer.textln(text) | ||||
|          | ||||
|     printer.set(align='center', bold=False, height=1, width=1) | ||||
|     printer.text('------------------------\n\n') | ||||
|     printer.textln('==============================================\n') | ||||
|     printer.text("Sigue nuestras redes sociales\n") | ||||
|     printer.text("@bicipizza\n") | ||||
|     printer.text("Recuerde que la propina es voluntaria.\n") | ||||
| @@ -87,19 +89,19 @@ def print_bill(data, address): | ||||
|     printer.cut() | ||||
|     printer.close() | ||||
|     # Obtiene el contenido del ticket de prueba | ||||
|     ticket_contenido = printer.output | ||||
|     #ticket_contenido = printer.output | ||||
|      | ||||
|     # Imprime el contenido en la consola | ||||
|     sys.stdout.write(ticket_contenido.decode('utf-8')) | ||||
|     # sys.stdout.write(ticket_contenido.decode('utf-8')) | ||||
|  | ||||
|  | ||||
|  | ||||
| def print_customer_order(data, address): | ||||
|     d = data | ||||
|     # Crea una instancia de la impresora ficticia | ||||
|     #printer = Network(str(address)) | ||||
|     #printer.open() | ||||
|     printer = Dummy() | ||||
|     printer = Network(str(address)) | ||||
|     printer.open() | ||||
|     #printer = Dummy() | ||||
|      | ||||
|     # Imprime el encabezado | ||||
|     printer.set(align='center', bold=False, height=1, width=1) | ||||
| @@ -143,10 +145,10 @@ def print_customer_order(data, address): | ||||
|     printer.cut() | ||||
|     printer.close() | ||||
|     # Obtiene el contenido del ticket de prueba | ||||
|     ticket_contenido = printer.output | ||||
|     # ticket_contenido = printer.output | ||||
|  | ||||
|     # Imprime el contenido en la consola | ||||
|     sys.stdout.write(ticket_contenido.decode('utf-8')) | ||||
|     # sys.stdout.write(ticket_contenido.decode('utf-8')) | ||||
|  | ||||
| @app.post("/print_bill") | ||||
| def print_ticket_bill(info: Info): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user