Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WSFEv1: Agrego los cambios de FCE al branch py3k #65

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from 13 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 55 additions & 55 deletions cot.pyw
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"Aplicativo Visual (Front-end) Remito Electrónico (COT) ARBA"

from __future__ import with_statement

__author__ = "Mariano Reingart ([email protected])"
__copyright__ = "Copyright (C) 2013- Mariano Reingart"
__copyright__ = "Copyright (C) 2013-2019 Mariano Reingart"
__license__ = "LGPL 3.0"

import datetime
Expand All @@ -19,10 +19,11 @@ import sys

# importar gui2py (atajos)

import gui
import gui

# establecer la configuración regional por defecto:
import wx, locale
import wx
import locale
if sys.platform == "win32":
locale.setlocale(locale.LC_ALL, 'Spanish_Argentina.1252')
elif sys.platform == "linux2":
Expand All @@ -38,71 +39,71 @@ from cot import COT

# --- gui2py designer generated code starts ---

with gui.Window(name='mywin', title=u'COT: Remito Electr\xf3nico ARBA',
resizable=True, height='450px', left='180', top='24',
width='550px', bgcolor=u'#E0E0E0', fgcolor=u'#4C4C4C',
with gui.Window(name='mywin', title=u'COT: Remito Electr\xf3nico ARBA',
resizable=True, height='450px', left='180', top='24',
width='550px', bgcolor=u'#E0E0E0', fgcolor=u'#4C4C4C',
image='', ):
gui.StatusBar(name='statusbar', )
with gui.Panel(label=u'', name='panel', image='', ):
gui.TextBox(name='usuario', left='299', top='10', width='105',
gui.TextBox(name='usuario', left='299', top='10', width='105',
value=u'20267565393', )
gui.TextBox(name='clave', password=True, left='455', top='10',
gui.TextBox(name='clave', password=True, left='455', top='10',
width='75', )
gui.Line(name='line_25_556', height='3', left='24', top='390',
gui.Line(name='line_25_556', height='3', left='24', top='390',
width='499', )
gui.Button(label=u'Salir', name='salir', left='440', top='394',
gui.Button(label=u'Salir', name='salir', left='440', top='394',
width='85', onclick='import sys; sys.exit(0)', )
gui.ComboBox(name=u'url',
text=u'http://cot.test.arba.gov.ar/TransporteBienes/SeguridadCliente/presentarRemitos.do',
height='29', left='79', top='42', width='250',
bgcolor=u'#FFFFFF',
data_selection=u'http://cot.test.arba.gov.ar/TransporteBienes/SeguridadCliente/presentarRemitos.do',
fgcolor=u'#4C4C4C',
items=[u'https://cot.arba.gov.ar/TransporteBienes/SeguridadCliente/presentarRemitos.do', u'http://cot.test.arba.gov.ar/TransporteBienes/SeguridadCliente/presentarRemitos.do'],
selection=1,
gui.ComboBox(name=u'url',
text=u'http://cot.test.arba.gov.ar/TransporteBienes/SeguridadCliente/presentarRemitos.do',
height='29', left='79', top='42', width='250',
bgcolor=u'#FFFFFF',
data_selection=u'http://cot.test.arba.gov.ar/TransporteBienes/SeguridadCliente/presentarRemitos.do',
fgcolor=u'#4C4C4C',
items=[u'https://cot.arba.gov.ar/TransporteBienes/SeguridadCliente/presentarRemitos.do', u'http://cot.test.arba.gov.ar/TransporteBienes/SeguridadCliente/presentarRemitos.do'],
selection=1,
string_selection=u'http://cot.test.arba.gov.ar/TransporteBienes/SeguridadCliente/presentarRemitos.do', )
gui.Label(name='lblTest_273_363', height='17', left='234', top='15',
gui.Label(name='lblTest_273_363', height='17', left='234', top='15',
width='58', text=u'Usuario:', )
gui.Label(name='lblTest_273', height='17', left='410', top='14',
gui.Label(name='lblTest_273', height='17', left='410', top='14',
width='58', text=u'Clave:', )
gui.Gauge(name='gauge', height='18', left='20', top='365',
gui.Gauge(name='gauge', height='18', left='20', top='365',
width='507', )
gui.Label(id=228, name='lblTest_228', height='17', left='341',
gui.Label(id=228, name='lblTest_228', height='17', left='341',
top='47', width='32', text=u'Carpeta:', )
with gui.ListView(id=213, name=u'remitos', height='74', left='20',
with gui.ListView(id=213, name=u'remitos', height='74', left='20',
top='180', width='510', item_count=0, sort_column=0, ):
gui.ListColumn(name=u'nro', text=u'N\xb0 \xdanico Remito',
gui.ListColumn(name=u'nro', text=u'N\xb0 \xdanico Remito',
width=250, )
gui.ListColumn(name=u'proc', text=u'Procesado', )
with gui.ListView(name=u'archivos', height='99', left='21', top='77',
with gui.ListView(name=u'archivos', height='99', left='21', top='77',
width='509', item_count=0, sort_column=2, ):
gui.ListColumn(name=u'txt', text='Archivo TXT', width=200, )
gui.ListColumn(name=u'xml', text='Archivo XML', )
gui.ListColumn(name=u'cuit', text='CUIT Empresa', )
gui.ListColumn(name=u'nro', text=u'N\xb0 Comprobante', )
gui.ListColumn(name=u'md5', text=u'C\xf3digo Integridad', )
with gui.ListView(id=309, name=u'errores', height='99', left='20',
with gui.ListView(id=309, name=u'errores', height='99', left='20',
top='259', width='510', item_count=0, sort_column=0, ):
gui.ListColumn(name=u'codigo', text=u'C\xf3digo', width=100, )
gui.ListColumn(name=u'descripcion', text=u'Descripci\xf3n Error',
gui.ListColumn(name=u'descripcion', text=u'Descripci\xf3n Error',
width=400, )
gui.TextBox(id=488, mask='date', name='fecha',
left='101', top='10', width='127', enabled=False,
gui.TextBox(id=488, mask='date', name='fecha',
left='101', top='10', width='127', enabled=False,
value=datetime.date(2014, 4, 5), )
gui.CheckBox(label=u'Fecha:', name=u'filtrar_fecha', height='24',
left='22', top='11', width='73',
gui.CheckBox(label=u'Fecha:', name=u'filtrar_fecha', height='24',
left='22', top='11', width='73',
tooltip=u'filtrar por fecha', )
gui.Label(id=2084, name='lblTest_228_2084', height='17', left='24',
gui.Label(id=2084, name='lblTest_228_2084', height='17', left='24',
top='47', width='32', text=u'URL:', )
gui.ComboBox(id=961, name=u'carpeta', text=u'datos', height='29',
left='412', top='42', width='118', bgcolor=u'#FFFFFF',
data_selection=u'datos', fgcolor=u'#4C4C4C',
items=[u'datos', u'procesados'], selection=0,
gui.ComboBox(id=961, name=u'carpeta', text=u'datos', height='29',
left='412', top='42', width='118', bgcolor=u'#FFFFFF',
data_selection=u'datos', fgcolor=u'#4C4C4C',
items=[u'datos', u'procesados'], selection=0,
string_selection=u'datos', )
gui.Button(label=u'Procesar', name=u'procesar', left='20', top='394',
gui.Button(label=u'Procesar', name=u'procesar', left='20', top='394',
tooltip="Presentar el remito en ARBA",
width='85', default=True, fgcolor=u'#4C4C4C', )
gui.Button(label=u'Mover Procesados', name=u'mover', left='112',
gui.Button(label=u'Mover Procesados', name=u'mover', left='112',
top='394', width='166', fgcolor=u'#4C4C4C', )

# --- gui2py designer generated code ends ---
Expand All @@ -119,7 +120,7 @@ def getpass(username):
password = passwd_db.get(str(username))
if not password:
password = gui.prompt(message=u"Ingrese contraseña",
title="Usuario: %s" % username,
title="Usuario: %s" % username,
password=True) or ""
return password

Expand Down Expand Up @@ -182,9 +183,9 @@ def abrir_archivo(evt):

def procesar_archivo(item, enviar=False):
"Enviar archivo a ARBA y analizar la respuesta"

# establezco credenciales:
cuit = item['txt'][3:14]
cuit = item['txt'][3:14]
cot.Usuario = panel['usuario'].value = cuit
cot.Password = panel['clave'].value = getpass(cuit)
cot.Conectar(panel['url'].text, trace=True)
Expand All @@ -209,11 +210,11 @@ def procesar_archivo(item, enviar=False):

if cot.Excepcion and enviar:
gui.alert(cot.Traceback, cot.Excepcion)

if cot.TipoError and enviar:
gui.alert(cot.MensajeError, "Error %s: %s" % (cot.TipoError, cot.CodigoError))

# actualizo los datos devueltos en el listado
# actualizo los datos devueltos en el listado
item['cuit'] = cot.CuitEmpresa
item['nro'] = cot.NumeroComprobante
item['md5'] = cot.CodigoIntegridad
Expand All @@ -226,15 +227,15 @@ def procesar_archivo(item, enviar=False):
remitos.items = []
i = 0
while cot.LeerValidacionRemito():
print "REMITO", i
print("REMITO", i)
errores = []
remito = {'nro': cot.NumeroUnico, 'proc': cot.Procesado,
'errores': errores}
remitos.items[i] = remito
item['remitos'].append(remito)
i += 1
while cot.LeerErrorValidacion():
print "Error Validacion:", "|", cot.CodigoError, "|", cot.MensajeError
print("Error Validacion:", "|", cot.CodigoError, "|", cot.MensajeError)
errores.append({'codigo': cot.CodigoError,
'descripcion': cot.MensajeError})

Expand All @@ -245,7 +246,7 @@ def cargar_errores(evt):
errores = panel['errores']
errores.items = []
for i, error in enumerate(item['errores']):
print i, error
print(i, error)
errores.items[i] = error

def filtro_fecha(evt):
Expand All @@ -257,11 +258,11 @@ def mover_archivos(evt=None):
carpeta = panel['carpeta'].text
if carpeta != "datos":
gui.alert("No se puede mover archivos de carpeta %s" % carpeta)

i = 0
print panel['archivos'].items
print(panel['archivos'].items)
for item in panel['archivos'].items:
procesado = all([remito.get('proc', 'NO') == 'SI'
procesado = all([remito.get('proc', 'NO') == 'SI'
for remito in item.get('remitos', [])])
if procesado and item.get('remitos'):
for fn in (item['txt'], item['xml']):
Expand All @@ -270,13 +271,13 @@ def mover_archivos(evt=None):
try:
os.rename(fn0, fn1)
i += 1
except Exception, e:
gui.alert(unicode(e), "No se puede mover %s" % fn)
except Exception as e:
gui.alert(e, "No se puede mover %s" % fn)
gui.alert("Se movieron: %s archivos" % i)
listar_archivos()


panel['archivos'].onitemselected = cargar_archivo
panel['archivos'].onitemselected = cargar_archivo
panel['archivos'].onmousedclick = abrir_archivo
panel['remitos'].onitemselected = cargar_errores
panel['filtrar_fecha'].onclick = filtro_fecha
Expand All @@ -290,8 +291,7 @@ panel['clave'].onchange = grabar_clave
if __name__ == "__main__":
mywin.show()
mywin.title = u"%s - %s" % (mywin.title, cot.Version.decode("latin1"))
mywin['statusbar'].text = ""
mywin['statusbar'].text = ""
listar_archivos()
gui.main_loop()
passwd_db.close()

19 changes: 15 additions & 4 deletions padron.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
# http://www.sistemasagiles.com.ar/trac/wiki/PadronContribuyentesAFIP

__author__ = "Mariano Reingart <[email protected]>"
__copyright__ = "Copyright (C) 2014-2016 Mariano Reingart"
__copyright__ = "Copyright (C) 2014-2019 Mariano Reingart"
__license__ = "GPL 3.0"
__version__ = "1.07e"
__version__ = "1.08a"


import csv
Expand All @@ -34,7 +34,7 @@
from email.utils import formatdate
import sys
import warnings
from .utils import leer, escribir, N, A, I, get_install_dir, safe_console, \
from utils import leer, escribir, N, A, I, get_install_dir, safe_console, \
inicializar_y_capturar_excepciones_simple, WebClient, norm, \
exception_info

Expand Down Expand Up @@ -77,7 +77,7 @@ class PadronAFIP():

_public_methods_ = ['Buscar', 'Descargar', 'Procesar', 'Guardar',
'ConsultarDomicilios', 'Consultar', 'Conectar',
'DescargarConstancia', 'MostrarPDF',
'DescargarConstancia', 'MostrarPDF', 'BuscarCUIT',
"ObtenerTablaParametros",
]
_public_attrs_ = ['InstallDir', 'Traceback', 'Excepcion', 'Version',
Expand Down Expand Up @@ -288,6 +288,17 @@ def ConsultarDomicilios(self, nro_doc, tipo_doc=80, cat_iva=None):
self.domicilios = [fila['direccion'] for fila in filas]
return len(filas)

@inicializar_y_capturar_excepciones_simple
def BuscarCUIT(self, denominacion, limite=10):
"Busca por nombre, devuelve una lista con tipo y nro de documento"
sql = ("SELECT tipo_doc, nro_doc, denominacion "
"FROM padron_fts WHERE denominacion MATCH ? "
"LIMIT ?")
denominacion = denominacion.replace(" ", "*")
self.cursor.execute(sql, ["*{}*".format(denominacion), limite])
filas = self.cursor.fetchall()
return [dict(fila) for fila in filas]

@inicializar_y_capturar_excepciones_simple
def Guardar(self, tipo_doc, nro_doc, denominacion, cat_iva, direccion,
email, imp_ganancias='NI', imp_iva='NI', monotributo='NI',
Expand Down
4 changes: 2 additions & 2 deletions plantillas/liquidacion_form_c1116b_wslpg.csv
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@
'tipo_operacion';'T';58.60;32.70;127.90;38.50;'Arial';9;False;False;False;0;16777215;'L';'tipo_operacion';0
'total_deduccion';'T';50.00;250.90;78.40;255.00;'Arial';9;False;False;False;0;16777215;'R';'total_deduccion';0
'total_deduccion.L';'T';19.10;250.80;47.50;254.90;'Arial';9;False;False;False;0;16777215;'L';'Total deducciones:';0
'total_iva_rg_2300_07';'T';111.10;255.80;139.50;259.90;'Arial';9;False;False;False;0;16777215;'R';'total_iva_rg_2300_07';0
'total_iva_rg_2300_07.L';'T';79.30;255.80;107.70;259.90;'Arial';9;False;False;False;0;16777215;'L';'Total IVA RG 2300/07:';0
'total_iva_rg_4310_18';'T';111.10;255.80;139.50;259.90;'Arial';9;False;False;False;0;16777215;'R';'total_iva_rg_4310_18';0
'total_iva_rg_4310_18.L';'T';79.30;255.80;107.70;259.90;'Arial';9;False;False;False;0;16777215;'L';'Total IVA RG 4310/18:';0
'total_neto_a_pagar';'T';50.10;255.80;78.50;259.90;'Arial';9;False;False;False;0;16777215;'R';'total_neto_a_pagar';0
'total_neto_a_pagar.L_copy';'T';19.40;255.90;47.80;260.00;'Arial';9;False;False;False;0;16777215;'L';'Total Neto a Pagar:';0
'total_operacion.L';'T';19.10;246.10;47.50;250.20;'Arial';9;False;False;False;0;16777215;'L';'Total operacion:';0
Expand Down
4 changes: 2 additions & 2 deletions plantillas/liquidacion_wslpg_ajuste_base.csv
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@
'total_deduccion.L_copy_copy_copy';'T';22.40;197.70;50.80;201.80;'Arial';9;False;False;False;0;16777215;'L';'IVA 21%:';0
'total_iva_10_5';'T';53.80;193.70;82.20;197.80;'Arial';9;False;False;False;0;16777215;'R';'total_iva_10_5';0
'total_iva_21';'T';53.80;197.70;82.20;201.80;'Arial';9;False;False;False;0;16777215;'R';'total_iva_21';0
'total_iva_rg_2300_07';'T';53.80;217.70;82.20;221.80;'Arial';9;False;False;False;0;16777215;'R';'total_iva_rg_2300_07';0
'total_iva_rg_2300_07.L';'T';22.40;217.70;50.80;221.80;'Arial';9;False;False;False;0;16777215;'L';'Total IVA RG 2300/07:';0
'total_iva_rg_4310_18';'T';53.80;217.70;82.20;221.80;'Arial';9;False;False;False;0;16777215;'R';'total_iva_rg_4310_18';0
'total_iva_rg_4310_18.L';'T';22.40;217.70;50.80;221.80;'Arial';9;False;False;False;0;16777215;'L';'Total IVA RG 4310/18:';0
'total_neto_a_pagar';'T';53.80;213.70;82.20;217.80;'Arial';9;False;False;False;0;16777215;'R';'total_neto_a_pagar';0
'total_neto_a_pagar.L_copy';'T';22.30;213.80;50.70;217.90;'Arial';9;False;False;False;0;16777215;'L';'Importe Neto:';0
'total_operacion.L';'T';22.40;177.80;50.80;181.90;'Arial';9;False;False;False;0;16777215;'L';'Subtotal general:';0
Expand Down
4 changes: 2 additions & 2 deletions plantillas/liquidacion_wslpg_ajuste_debcred.csv
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@
'tipo_operacion';'T';58.70;32.80;128.00;38.60;'Arial';9;False;False;False;0;16777215;'L';'tipo_operacion';0
'total_deduccion';'T';50.10;251.00;78.50;255.10;'Arial';9;False;False;False;0;16777215;'R';'total_deduccion';0
'total_deduccion.L';'T';19.20;250.90;47.60;255.00;'Arial';9;False;False;False;0;16777215;'L';'Total deducciones:';0
'total_iva_rg_2300_07';'T';111.20;255.90;139.60;260.00;'Arial';9;False;False;False;0;16777215;'R';'total_iva_rg_2300_07';0
'total_iva_rg_2300_07.L';'T';79.40;255.90;107.80;260.00;'Arial';9;False;False;False;0;16777215;'L';'Total IVA RG 2300/07:';0
'total_iva_rg_4310_18';'T';111.20;255.90;139.60;260.00;'Arial';9;False;False;False;0;16777215;'R';'total_iva_rg_4310_18';0
'total_iva_rg_4310_18.L';'T';79.40;255.90;107.80;260.00;'Arial';9;False;False;False;0;16777215;'L';'Total IVA RG 4310/18:';0
'total_neto_a_pagar';'T';50.20;255.90;78.60;260.00;'Arial';9;False;False;False;0;16777215;'R';'total_neto_a_pagar';0
'total_neto_a_pagar.L_copy';'T';19.50;256.00;47.90;260.10;'Arial';9;False;False;False;0;16777215;'L';'Total Neto a Pagar:';0
'total_operacion.L';'T';19.20;246.20;47.60;250.30;'Arial';9;False;False;False;0;16777215;'L';'Total operacion:';0
Expand Down
26 changes: 17 additions & 9 deletions pyfepdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
"M�dulo para generar PDF de facturas electr�nicas"

__author__ = "Mariano Reingart <[email protected]>"
__copyright__ = "Copyright (C) 2011-2018 Mariano Reingart"
__copyright__ = "Copyright (C) 2011-2019 Mariano Reingart"
__license__ = "GPL 3.0"
__version__ = "1.09b"
__version__ = "1.09c"

DEBUG = False
HOMO = False
Expand Down Expand Up @@ -120,16 +120,19 @@ class FEPDF:
(1, 6, 11, 19, 51): 'Factura',
(2, 7, 12, 20, 52): 'Nota de D�bito',
(3, 8, 13, 21, 53): 'Nota de Cr�dito',
(201, 206, 211): 'Factura de Cr�dito MiPyMEs',
(202, 207, 212): 'Nota de D�bito MiPyMEs',
(203, 208, 213): 'Nota de Cr�dito MiPyMEs',
(4, 9, 15, 54): 'Recibo',
(10, 5): 'Nota de Venta al contado',
(60, 61): 'Cuenta de Venta y L�quido producto',
(63, 64): 'Liquidaci�n',
(91, ): 'Remito',
(39, 40): '???? (R.G. N� 3419)'}

letras_fact = {(1, 2, 3, 4, 5, 39, 60, 63): 'A',
(6, 7, 8, 9, 10, 40, 61, 64): 'B',
(11, 12, 13, 15): 'C',
letras_fact = {(1, 2, 3, 4, 5, 39, 60, 63, 201, 202, 203): 'A',
(6, 7, 8, 9, 10, 40, 61, 64, 206, 207, 208): 'B',
(11, 12, 13, 15, 211, 212, 213): 'C',
(51, 52, 53, 54): 'M',
(19, 20, 21): 'E',
(91, ): 'R',
Expand Down Expand Up @@ -299,9 +302,14 @@ def fmt_num(self, i, fmt="%0.2f", monetary=True):
else:
return ''

def fmt_imp(self, i): return self.fmt_num(i, "%0.2f")
def fmt_qty(self, i): return self.fmt_num(i, "%" + self.FmtCantidad + "f", False)
def fmt_pre(self, i): return self.fmt_num(i, "%" + self.FmtPrecio + "f")
def fmt_imp(self, i):
return self.fmt_num(i, "%0.2f")

def fmt_qty(self, i):
return self.fmt_num(i, "%" + self.FmtCantidad + "f", False)

def fmt_pre(self, i):
return self.fmt_num(i, "%" + self.FmtPrecio + "f")

def fmt_iva(self, i):
if int(i) in self.ivas_ds:
Expand Down Expand Up @@ -1028,7 +1036,7 @@ def MostrarPDF(self, archivo, imprimir=False):
HOMO = True

# datos generales del encabezado:
tipo_cbte = 19 if '--expo' in sys.argv else 1
tipo_cbte = 19 if '--expo' in sys.argv else 201
punto_vta = 4000
fecha = datetime.datetime.now().strftime("%Y%m%d")
concepto = 3
Expand Down
Loading