Commit 49d745e1 authored by Gabriel Detraz's avatar Gabriel Detraz Committed by root

Adapte pour les factures

parent 0df56dd5
#!/usr/bin/env python
#-*- coding: utf-8 -*-
PIDFILE = '/var/run/cransticket.pid'
USER='crans_ticket'
GROUP='adm'
PIDFILE = '/var/run/cransticket/cransticket.pid'
USER='cransticket'
GROUP='cranticket'
......@@ -7,10 +7,8 @@ from escpos.printer import Usb
import subprocess, time, socket
import os
import json
from config import DEVICE
import config
#
CODING='cp437'
SAMPLE_MACHINE = {
'host': 'nouille',
......@@ -26,7 +24,7 @@ SAMPLE_ACCOUNT = {
""" Seiko Epson Corp. Receipt Printer (EPSON TM-T88III) """
printer = Usb(0x04b8, 0x0e15, 0)
printer = Usb(config.VENDOR_ID, config.DEVICE_ID, 0)
printer.charcode(code='CA_FRENCH')
def print_carac(text, value):
......@@ -67,7 +65,7 @@ def make_fact_elem(element,nb_car,is_last):
ligne = u''
u_elem = unicode(element)
u_elem = str(element)
if len(u_elem) >= nb_car:
ligne += u_elem[0:nb_car]
else:
......@@ -91,36 +89,34 @@ def make_fact_elem(element,nb_car,is_last):
# ! facture est un dictionnaire, pas un objet LDAP !
def show_facture(facture):
printer.text('\n')
#Impression de l'en-tête
printer.justify('L')
printer.text(facture['recuPaiement'].encode(CODING))
printer.justify('C')
printer.text(u'--------------------------------'.encode(CODING))
printer.boldOn()
printer.text(facture['recuPaiement'] + '\n')
printer.text('--------------------------------\n')
printer.set(align='center', text_type="BU")
fid = u'Facture n°%d' % facture['fid']
printer.text(fid.encode(CODING))
printer.boldOff()
printer.text(u'--------------------------------'.encode(CODING))
printer.text(fid + '\n')
printer.set(align='center', text_type="NORMAL")
printer.text('--------------------------------\n')
#Impression de l'en-tête de la facture
nom_complet = facture['nom'] + u' ' + facture['prenom']
printer.justify('R')
printer.text((u'Adhérent : ' + nom_complet).encode(CODING))
printer.text('Adhérent : ' + nom_complet + '\n')
if facture['chbre'] is u'EXT':
printer.text(u'Externe'.encode(CODING))
printer.text('Externe \n')
else:
printer.text((u'Chambre : ' + facture['chbre']).encode(CODING))
printer.text(('Chambre : ' + facture['chbre'] + '\n'))
if facture['debutAdhesion']:
printer.text((u'Début adhésion : ' + facture['debutAdhesion']).encode(CODING))
printer.text(('Début adhésion : ' + facture['debutAdhesion'] + '\n'))
if facture['finAdhesion']:
printer.text((u'Fin adhésion : ' + facture['finAdhesion']).encode(CODING))
printer.text(('Fin adhésion : ' + facture['finAdhesion']+ '\n'))
if facture['finConnexion']:
printer.text((u'Fin connexion : ' + facture['finConnexion']).encode(CODING))
printer.text(('Fin connexion : ' + facture['finConnexion']+ '\n'))
printer.justify('L')
printer.text(u'--------------------------------'.encode(CODING))
printer.text(u' Code | Désig. |Qté| P.U '.encode(CODING)) #Code(6c. max.),Désignation(11c. max.),Qté(3c. max),PU(8[+1]c.max)
printer.text(u'------|-----------|---|---------'.encode(CODING))
#printer.justify('L')
printer.text('--------------------------------\n')
printer.text(' Code | Désig. |Qté| P.U \n') #Code(6c. max.),Désignation(11c. max.),Qté(3c. max),PU(8[+1]c.max)
printer.text('------|-----------|---|---------\n')
#Impression du corps de la facture + calcul du prix total
total = 0.0
......@@ -132,31 +128,29 @@ def show_facture(facture):
row += make_fact_elem(art['pu']+u'e',9,True)
total += float(art['pu'])
printer.text(row.encode(CODING))
printer.text((row + '\n'))
printer.text(u'--------------------------------'.encode(CODING))
printer.text(u'--------------------------------\n')
#On affiche le total
printer.justify('R')
printer.text((u'---------').encode(CODING))
printer.text((u'Total à régler '+ '|' + make_fact_elem(total,8,True) + u'e').encode(CODING))
printer.text((u'---------').encode(CODING))
printer.justify('L')
printer.text((u'Payé par ' + facture['modePaiement']).encode(CODING))
printer.text(('---------\n'))
printer.text(('Total à régler '+ '|' + make_fact_elem(total,8,True) + u'e' + '\n'))
printer.text(('---------\n'))
printer.text(('Payé par ' + facture['modePaiement'] + '\n'))
#On met une super phrase sur la TVA
printer.feed(1)
printer.text(u'TVA non applicable(art. 293B du CGI)'.encode(CODING))
#Fin de la facture
printer.feed(1)
printer.text('\n')
printer.set(align='center', text_type="BU")
printer.text('TVA non applicable(art. 293B du CGI)\n')
printer.set(align='center', text_type="NORMALE")
printer.text('\n')
printer.text(config.ADDRESS)
# Do print
def print_liste(liste):
printer.set(align='center')
printer.image("/home/pi/cransticket/logo_crans.png", True)
printer.image(os.path.dirname(os.path.realpath(sys.argv[0])) + "/home/pi/cransticket/logo_crans.png", True)
for entry in liste:
show_entry(entry)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment