Skip to content

Commit b90d548

Browse files
committed
Añado getSubtotal
1 parent 3bd793f commit b90d548

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

pyfiscalprinter/epson.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,7 @@ def close(self):
4545
pass
4646

4747
def sendCommand(self, commandNumber, parameters, skipStatusErrors):
48-
##raise RuntimeError("saraza1")
49-
## if commandNumber in EpsonPrinter.CMD_CLOSE_FISCAL_RECEIPT:
50-
## #raise RuntimeError("saraza")
51-
## else:
52-
## pass
48+
5349
return ["00", "00", "", "", str(self.number), "", str(self.number)] + [str(self.number)] * 11
5450

5551

@@ -58,7 +54,7 @@ class EpsonPrinter(PrinterInterface):
5854

5955
CMD_OPEN_FISCAL_RECEIPT = 0x40
6056
CMD_OPEN_BILL_TICKET = 0x60
61-
## CMD_PRINT_TEXT_IN_FISCAL = (0x41, 0x61)
57+
# CMD_PRINT_TEXT_IN_FISCAL = (0x41, 0x61)
6258
CMD_PRINT_TEXT_IN_FISCAL = 0x41
6359
CMD_PRINT_LINE_ITEM = (0x42, 0x62)
6460
CMD_PRINT_SUBTOTAL = (0x43, 0x63)
@@ -91,8 +87,7 @@ def __init__(self, deviceFile=None, speed=9600, host=None, port=None, dummy=Fals
9187
else:
9288
deviceFile = deviceFile or 0
9389
self.driver = driver.EpsonFiscalDriver(deviceFile, speed)
94-
#self.driver = FileDriver( "/home/gnarvaja/Desktop/fiscal.txt" )
95-
except Exception, e:
90+
except Exception as e:
9691
raise FiscalPrinterError("Imposible establecer comunicación.", e)
9792
if not model:
9893
self.model = "tickeadoras"
@@ -355,7 +350,8 @@ def dailyClose(self, type):
355350
def getLastNumber(self, letter):
356351
reply = self._sendCommand(self.CMD_STATUS_REQUEST, ["A"], True)
357352
if len(reply) < 3:
358-
# La respuesta no es válida. Vuelvo a hacer el pedido y si hay algún error que se reporte como excepción
353+
# La respuesta no es válida. Vuelvo a hacer el pedido y si hay
354+
# algún error que se reporte como excepción
359355
reply = self._sendCommand(self.CMD_STATUS_REQUEST, ["A"], False)
360356
if letter == "A":
361357
return int(reply[6])
@@ -365,7 +361,8 @@ def getLastNumber(self, letter):
365361
def getLastCreditNoteNumber(self, letter):
366362
reply = self._sendCommand(self.CMD_STATUS_REQUEST, ["A"], True)
367363
if len(reply) < 3:
368-
# La respuesta no es válida. Vuelvo a hacer el pedido y si hay algún error que se reporte como excepción
364+
# La respuesta no es válida. Vuelvo a hacer el pedido y si hay algún
365+
# error que se reporte como excepción
369366
reply = self._sendCommand(self.CMD_STATUS_REQUEST, ["A"], False)
370367
if letter == "A":
371368
return int(reply[10])
@@ -390,6 +387,15 @@ def cancelAnyDocument(self):
390387
pass
391388
return False
392389

390+
def getSubtotal(self):
391+
reply = self._sendCommand(self.CMD_PRINT_SUBTOTAL, ["P", "0", "0"], True)
392+
393+
if len(reply) < 3:
394+
# La respuesta no es válida. Vuelvo a hacer el pedido y
395+
# si hay algún error que se reporte como excepción
396+
reply = self._sendCommand(self.CMD_PRINT_SUBTOTAL, [], False)
397+
return reply
398+
393399
def getWarnings(self):
394400
ret = []
395401
reply = self._sendCommand(self.CMD_STATUS_REQUEST, ["N"], True)

pyfiscalprinter/generic.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# -*- coding: iso-8859-1 -*-
22

3+
34
class PrinterException(RuntimeError):
45
pass
56

7+
68
class PrinterInterface:
79
"""Interfaz que deben cumplir las impresoras fiscales."""
810

@@ -16,7 +18,7 @@ def printNonFiscalText(self, text):
1618
"""Imprime texto fiscal. Si supera el límite de la linea se trunca."""
1719
raise NotImplementedError
1820

19-
NON_FISCAL_TEXT_MAX_LENGTH = 40 # Redefinir
21+
NON_FISCAL_TEXT_MAX_LENGTH = 40 # Redefinir
2022

2123
def closeDocument(self):
2224
"""Cierra el documento que esté abierto"""
@@ -199,3 +201,7 @@ def getWarnings(self):
199201
def openDrawer(self):
200202
"""Abrir cajón del dinero - No es mandatory implementarlo"""
201203
pass
204+
205+
def getSubtotal(self):
206+
"""Toma el subtotal, usado para obtener la información que fue enviada a la FC"""
207+
raise NotImplementedError

pyfiscalprinter/hasar.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,15 @@ def cancelAnyDocument(self):
481481
pass
482482
return False
483483

484+
def getSubtotal(self):
485+
reply = self._sendCommand(self.CMD_PRINT_SUBTOTAL, ["P", "0", "0"], True)
486+
487+
if len(reply) < 3:
488+
# La respuesta no es válida. Vuelvo a hacer el pedido y
489+
# si hay algún error que se reporte como excepción
490+
reply = self._sendCommand(self.CMD_PRINT_SUBTOTAL, [], False)
491+
return reply
492+
484493
def getWarnings(self):
485494
ret = []
486495
reply = self._sendCommand(self.CMD_STATUS_REQUEST, [], True)

0 commit comments

Comments
 (0)