-
Notifications
You must be signed in to change notification settings - Fork 236
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
Changes from 4 commits
a719340
dd5c4f2
d43408d
752a486
09a9d3a
eb9772d
163957b
f045dfa
56a56eb
acfc582
ac601a9
af9da9b
da580ef
37f6d28
765695d
3528d49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -13,7 +13,7 @@ | |||||
"Módulo de Intefase para archivos de texto (exportación version 1)" | ||||||
|
||||||
__author__ = "Mariano Reingart ([email protected])" | ||||||
__copyright__ = "Copyright (C) 2011 Mariano Reingart" | ||||||
__copyright__ = "Copyright (C) 2019 Mariano Reingart" | ||||||
__license__ = "GPL 3.0" | ||||||
__version__ = "1.27e" | ||||||
|
||||||
|
@@ -23,10 +23,10 @@ | |||||
import time | ||||||
import traceback | ||||||
|
||||||
# revisar la instalación de pyafip.ws: | ||||||
# revisar la instalación de pyafipws: | ||||||
from . import wsfexv1 | ||||||
from .utils import SimpleXMLElement, SoapClient, SoapFault, date | ||||||
from .utils import leer, escribir, leer_dbf, guardar_dbf, N, A, I, abrir_conf | ||||||
from utils import SimpleXMLElement, SoapClient, SoapFault, date | ||||||
from utils import leer, escribir, leer_dbf, guardar_dbf, N, A, I, abrir_conf | ||||||
|
||||||
|
||||||
HOMO = wsfexv1.HOMO | ||||||
|
@@ -465,6 +465,17 @@ def depurar_xml(client): | |||||
print(ws.ErrMsg) | ||||||
sys.exit(0) | ||||||
|
||||||
if '/monctz' in sys.argv: | ||||||
i = sys.argv.index("/monctz") | ||||||
if i+1<len(sys.argv): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. que tal:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. De hecho, habría que correr There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gracias por las sugerencias . |
||||||
fecha = sys.argv[i+1] | ||||||
else: | ||||||
fecha = input("Fecha (AAAAMMDD): ") or None | ||||||
ctz = ws.GetParamMonConCotizacion(fecha) | ||||||
print("\n".join(ctz)) | ||||||
print(ws.ErrMsg) | ||||||
sys.exit(0) | ||||||
|
||||||
f_entrada = f_salida = None | ||||||
try: | ||||||
f_entrada = open(entrada, "r") | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,26 +11,27 @@ | |
# for more details. | ||
|
||
"""M�dulo para obtener CAE/CAEA, c�digo de autorizaci�n electr�nico webservice | ||
WSFEv1 de AFIP (Factura Electr�nica Nacional - Proyecto Version 1 - 2.10) | ||
WSFEv1 de AFIP (Factura Electr�nica Nacional - Proyecto Version 1 - 2.13) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Habría alguna chance que a la versión la saque de algun solo lugar? por ejemplo un version.py? Así de esa manera no hay que estar modificando los archivos There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, esa versión es de AFIP; a veces viene en el WSDL del webservice, pero en general hay que revisar la especificación técnica de cada endpoint: http://www.afip.gov.ar/ws |
||
Seg�n RG 2485/08, RG 2757/2010, RG 2904/2010 y RG2926/10 (CAE anticipado), | ||
RG 3067/2011 (RS - Monotributo), RG 3571/2013 (Responsables inscriptos IVA), | ||
RG 3668/2014 (Factura A IVA F.8001), RG 3749/2015 (R.I. y exentos) | ||
RG 4004-E Alquiler de inmuebles con destino casa habitaci�n). | ||
RG 4109-E Venta de bienes muebles registrables. | ||
RG 4291/2018 R�gimen especial de emisi�n y almacenamiento electr�nico | ||
RG 4367/2018 R�gimen de Facturas de Cr�dito Electr�nicas MiPyMEs Ley 27.440 | ||
M�s info: http://www.sistemasagiles.com.ar/trac/wiki/ProyectoWSFEv1 | ||
""" | ||
|
||
__author__ = "Mariano Reingart <[email protected]>" | ||
__copyright__ = "Copyright (C) 2010-2017 Mariano Reingart" | ||
__copyright__ = "Copyright (C) 2010-2019 Mariano Reingart" | ||
__license__ = "GPL 3.0" | ||
__version__ = "1.21a" | ||
__version__ = "1.22b" | ||
|
||
import datetime | ||
import decimal | ||
import os | ||
import sys | ||
from .utils import verifica, inicializar_y_capturar_excepciones, BaseWS, get_install_dir | ||
from utils import verifica, inicializar_y_capturar_excepciones, BaseWS, get_install_dir | ||
|
||
HOMO = False # solo homologaci�n | ||
TYPELIB = False # usar librer�a de tipos (TLB) | ||
|
@@ -42,7 +43,7 @@ | |
|
||
|
||
class WSFEv1(BaseWS): | ||
"Interfaz para el WebService de Factura Electr�nica Version 1 - 2.10" | ||
"Interfaz para el WebService de Factura Electr�nica Version 1 - 2.13" | ||
_public_methods_ = ['CrearFactura', 'AgregarIva', 'CAESolicitar', | ||
'AgregarTributo', 'AgregarCmpAsoc', 'AgregarOpcional', | ||
'AgregarComprador', | ||
|
@@ -170,11 +171,13 @@ def EstablecerCampoFactura(self, campo, valor): | |
else: | ||
return False | ||
|
||
def AgregarCmpAsoc(self, tipo=1, pto_vta=0, nro=0, cuit=None, **kwarg): | ||
def AgregarCmpAsoc(self, tipo=1, pto_vta=0, nro=0, cuit=None, fecha=None, **kwarg): | ||
"Agrego un comprobante asociado a una factura (interna)" | ||
cmp_asoc = {'tipo': tipo, 'pto_vta': pto_vta, 'nro': nro} | ||
if cuit is not None: | ||
cmp_asoc['cuit'] = cuit | ||
if fecha is not None: | ||
cmp_asoc['fecha'] = fecha | ||
self.factura['cbtes_asoc'].append(cmp_asoc) | ||
return True | ||
|
||
|
@@ -259,6 +262,7 @@ def CAESolicitar(self): | |
'PtoVta': cbte_asoc['pto_vta'], | ||
'Nro': cbte_asoc['nro'], | ||
'Cuit': cbte_asoc.get('cuit'), | ||
'CbteFch': cbte_asoc.get('fecha'), | ||
}} | ||
for cbte_asoc in f['cbtes_asoc']] or None, | ||
'Tributos': f['tributos'] and [ | ||
|
@@ -396,6 +400,7 @@ def CompConsultar(self, tipo_cbte, punto_vta, cbte_nro, reproceso=False): | |
'PtoVta': cbte_asoc['pto_vta'], | ||
'Nro': cbte_asoc['nro'], | ||
'Cuit': cbte_asoc.get('cuit'), | ||
'CbteFch': cbte_asoc.get('fecha') or None, | ||
}} | ||
for cbte_asoc in f['cbtes_asoc']], | ||
'Tributos': [ | ||
|
@@ -457,7 +462,9 @@ def CompConsultar(self, tipo_cbte, punto_vta, cbte_nro, reproceso=False): | |
'tipo': cbte_asoc['CbteAsoc']['Tipo'], | ||
'pto_vta': cbte_asoc['CbteAsoc']['PtoVta'], | ||
'nro': cbte_asoc['CbteAsoc']['Nro'], | ||
'cuit': cbte_asoc['CbteAsoc'].get('Cuit')} | ||
'cuit': cbte_asoc['CbteAsoc'].get('Cuit'), | ||
'fecha': cbte_asoc['CbteAsoc'].get('CbteFch'), | ||
} | ||
for cbte_asoc in resultget.get('CbtesAsoc', [])], | ||
'tributos': [ | ||
{ | ||
|
@@ -578,6 +585,7 @@ def CAESolicitarX(self): | |
'PtoVta': cbte_asoc['pto_vta'], | ||
'Nro': cbte_asoc['nro'], | ||
'Cuit': cbte_asoc.get('cuit'), | ||
'CbteFch': cbte_asoc.get('fecha'), | ||
}} | ||
for cbte_asoc in f['cbtes_asoc']] or None, | ||
'Tributos': [ | ||
|
@@ -769,6 +777,7 @@ def CAEARegInformativo(self): | |
'PtoVta': cbte_asoc['pto_vta'], | ||
'Nro': cbte_asoc['nro'], | ||
'Cuit': cbte_asoc.get('cuit'), | ||
'CbteFch': cbtes_asoc.get('fecha'), | ||
}} | ||
for cbte_asoc in f['cbtes_asoc']] | ||
if f['cbtes_asoc'] else None, | ||
|
@@ -996,19 +1005,26 @@ def main(): | |
sys.exit(0) | ||
|
||
# obteniendo el TA para pruebas | ||
from .wsaa import WSAA | ||
from wsaa import WSAA | ||
ta = WSAA().Autenticar("wsfe", "reingart.crt", "reingart.key", debug=True) | ||
wsfev1.SetTicketAcceso(ta) | ||
wsfev1.Cuit = "20267565393" | ||
|
||
if "--prueba" in sys.argv: | ||
print(wsfev1.client.help("FECAESolicitar").encode("latin1")) | ||
|
||
tipo_cbte = 6 if '--usados' not in sys.argv else 49 | ||
print(wsfev1.client.help("FECAESolicitar").encode('latin1')) | ||
|
||
if '--usados' in sys.argv: | ||
tipo_cbte = 49 | ||
concepto = 1 | ||
elif '--fce' in sys.argv: | ||
tipo_cbte = 203 | ||
concepto = 1 | ||
else: | ||
tipo_cbte = 3 | ||
concepto = 3 if ('--rg4109' not in sys.argv) else 1 | ||
punto_vta = 4001 | ||
cbte_nro = int(wsfev1.CompUltimoAutorizado(tipo_cbte, punto_vta) or 0) | ||
fecha = datetime.datetime.now().strftime("%Y%m%d") | ||
concepto = 2 if ('--usados' not in sys.argv and '--rg4109' not in sys.argv) else 1 | ||
tipo_doc = 80 if '--usados' not in sys.argv else 30 | ||
nro_doc = "30500010912" | ||
cbt_desde = cbte_nro + 1 | ||
|
@@ -1020,13 +1036,16 @@ def main(): | |
imp_trib = "1.00" | ||
imp_op_ex = "0.00" | ||
fecha_cbte = fecha | ||
fecha_venc_pago = fecha_serv_desde = fecha_serv_hasta = None | ||
# Fechas del per�odo del servicio facturado y vencimiento de pago: | ||
if concepto > 1: | ||
fecha_venc_pago = fecha | ||
fecha_serv_desde = fecha | ||
fecha_serv_hasta = fecha | ||
else: | ||
fecha_venc_pago = fecha_serv_desde = fecha_serv_hasta = None | ||
if '--fce' in sys.argv: | ||
# obligatorio en Factura de Cr�dito Electr�nica MiPyMEs (FCE): | ||
fecha_venc_pago = fecha | ||
print(fecha_venc_pago) | ||
moneda_id = 'PES' | ||
moneda_ctz = '1.000' | ||
|
||
|
@@ -1053,12 +1072,14 @@ def main(): | |
wsfev1.EstablecerCampoFactura("caea", caea) | ||
|
||
# comprobantes asociados (notas de cr�dito / d�bito) | ||
if tipo_cbte in (2, 3, 7, 8, 12, 13): | ||
tipo = 3 | ||
pto_vta = 2 | ||
nro = 1234 | ||
if tipo_cbte in (2, 3, 7, 8, 12, 13, 203, 208, 213): | ||
tipo = 201 if tipo_cbte in (203, 208, 213) else 3 | ||
pto_vta = 4001 | ||
nro = 1 | ||
cuit = "20267565393" | ||
wsfev1.AgregarCmpAsoc(tipo, pto_vta, nro, cuit) | ||
# obligatorio en Factura de Cr�dito Electr�nica MiPyMEs (FCE): | ||
fecha_cbte = fecha if tipo_cbte in (203, 208, 213) else None | ||
wsfev1.AgregarCmpAsoc(tipo, pto_vta, nro, cuit, fecha_cbte) | ||
|
||
# otros tributos: | ||
tributo_id = 99 | ||
|
@@ -1098,20 +1119,27 @@ def main(): | |
if '--rg4004' in sys.argv: | ||
wsfev1.AgregarOpcional(17, "1") # Intermediario | ||
wsfev1.AgregarOpcional(1801, "30500010912") # CUIT Propietario | ||
wsfev1.AgregarOpcional(1802, "BNA") # Nombr e Titular | ||
wsfev1.AgregarOpcional(1802, "BNA") # Nombre Titular | ||
# datos de compradores RG 4109-E bienes muebles registrables (%) | ||
if '--rg4109' in sys.argv: | ||
wsfev1.AgregarComprador(80, "30500010912", 99.99) | ||
wsfev1.AgregarComprador(80, "30999032083", 0.01) | ||
|
||
# datos de Factura de Cr�dito Electr�nica MiPyMEs (FCE): | ||
if '--fce' in sys.argv: | ||
wsfev1.AgregarOpcional(2101, "2850590940090418135201") # CBU | ||
wsfev1.AgregarOpcional(2102, "pyafipws") # alias | ||
if tipo_cbte in (203, 208, 213): | ||
wsfev1.AgregarOpcional(22, "S") # Anulaci�n | ||
|
||
# agregar la factura creada internamente para solicitud m�ltiple: | ||
if "--multiple" in sys.argv: | ||
wsfev1.AgregarFacturaX() | ||
|
||
import time | ||
# import time | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Que tal eliminar el comentario? |
||
t0 = time.time() | ||
if not '--caea' in sys.argv: | ||
if not "--multiple" in sys.argv: | ||
if '--caea' not in sys.argv: | ||
if "--multiple" not in sys.argv: | ||
wsfev1.CAESolicitar() | ||
else: | ||
cant = wsfev1.CAESolicitarX() | ||
|
@@ -1139,10 +1167,10 @@ def main(): | |
open("xmlrequest.xml", "wb").write(wsfev1.XmlRequest) | ||
open("xmlresponse.xml", "wb").write(wsfev1.XmlResponse) | ||
|
||
if not "--multiple" in sys.argv: | ||
if "--multiple" not in sys.argv: | ||
wsfev1.AnalizarXml("XmlResponse") | ||
p_assert_eq(wsfev1.ObtenerTagXml('CAE'), str(wsfev1.CAE)) | ||
p_assert_eq(wsfev1.ObtenerTagXml('Concepto'), '2') | ||
p_assert_eq(wsfev1.ObtenerTagXml('Concepto'), '3') | ||
p_assert_eq(wsfev1.ObtenerTagXml('Obs', 0, 'Code'), "10017") | ||
print(wsfev1.ObtenerTagXml('Obs', 0, 'Msg')) | ||
|
||
|
@@ -1206,8 +1234,7 @@ def main(): | |
sys.stdout = codecs.getwriter(locale.getpreferredencoding())(sys.stdout, "replace") | ||
sys.stderr = codecs.getwriter(locale.getpreferredencoding())(sys.stderr, "replace") | ||
|
||
print('\n'.join(wsfev1.ParamGetTiposDoc())) | ||
print("=== Tipos de Comprobante ===") | ||
print("\n=== Tipos de Comprobante ===") | ||
print('\n'.join(wsfev1.ParamGetTiposCbte())) | ||
print("=== Tipos de Concepto ===") | ||
print('\n'.join(wsfev1.ParamGetTiposConcepto())) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No sería bueno pone run xyz - 2019?
xyz = desde que año.
:-)