35 Commits

Author SHA1 Message Date
e539f1e0a7 Añade nomina.sh y nomina.csv 2025-03-16 17:27:18 -05:00
7972a3f59c Añade ejemplos de xml funcionales 2025-03-16 17:05:57 -05:00
20d8f4284f Fix: Facho para habilitacion de nomina python 3.9 2025-03-16 17:02:56 -05:00
c49e67b8a6 Fix: Test incluir ApplicationResponse 2025-01-01 18:40:05 -05:00
7672ae4b7f Fix: Delete escribir archivo para ver salida 2025-01-01 18:39:22 -05:00
25c5fda3f0 Fix: Delete archivo para ver salida 2025-01-01 18:37:09 -05:00
a758b8678b Feat: Se agrega ApplicationResponse a AttachedDocument 2025-01-01 16:56:15 -05:00
3a385c63e3 Feat: Attachment, ParentDocumentLine 2024-12-30 19:00:51 -05:00
9b33b4486c Fix: Se elimina simple_invoice arg 2024-12-30 11:01:22 -05:00
612aae1f86 Fix: Se reemplazan datos de prueba por objeto Invoice issue #4 2024-12-27 21:04:35 -05:00
4fe82daac6 AttachedDocument(WIP): Se escribe envoltorio AttachedDocument issue #4 2024-12-27 18:54:56 -05:00
e237d1b45f Fix: Se descomenta test AttachedDocument 2024-12-27 00:10:03 -05:00
8cc6146be2 Merge remote-tracking branch 'origin/documento_soporte' 2024-12-26 23:20:16 -05:00
f98ab98c9c Fix: Se agrega dateutil 2024-08-28 16:48:41 -05:00
d04596ed3a Fix: SigningTime tz='America/Bogota' 2024-08-28 16:35:34 -05:00
9297be22e0 Fix: UPDATE Dependencies 2024-08-28 13:10:49 -05:00
cosmos
30773e042b Add test signartime - timezone America/Bogota 2024-08-23 11:03:38 -05:00
fb44498e53 Fix: Formateo PEP8 2024-08-14 12:50:53 -05:00
9f7349ccee file(requirements_dev): Pruebas Tox 2024-08-07 00:29:48 -05:00
9cc41e1c5d files: cude.txt, cufe.txt 2024-08-07 00:17:58 -05:00
fc75126ca0 FIX: Formateo PEP8, Test OK 2024-08-07 00:17:16 -05:00
d061077b30 fix(WIP): Reemplazando OpenSsl.crypto,pkcs12 2024-08-06 16:41:14 -05:00
a3d2176068 update(test_data): Anexo 1.9 2024-08-06 15:29:47 -05:00
98677bc162 update(TipoDocumento): Anexo 1.9 2024 2024-08-06 15:25:46 -05:00
398d27d049 Fix: Se importan fixtures 2024-08-06 15:21:26 -05:00
8765a3d2c8 Fix(form_xml/invoice): Se agrega defaultdict 2024-08-06 14:38:36 -05:00
1935ed3048 style(test_form.py): Formateo PEP8 se agrega withholding 2024-08-06 14:33:21 -05:00
097cf97fc3 style(test_form_xml): Formateado PEP8 2024-08-06 14:09:52 -05:00
de99633211 Fix: Formateado PEP8 se elimina responsabilidad O-07 segun anexo 1.9 2024-08-06 14:02:40 -05:00
Rodia
028cf8b687 Merge pull request 'FachoStyle' (#3) from FachoStyle into MigrationPython312Test
Reviewed-on: #3
2024-08-06 13:35:10 -05:00
e7a3976b14 style(test_query): Formateado PEP8 2024-08-06 13:30:34 -05:00
f08954ee43 style(__init__): Formateado PEP8 2024-08-06 13:28:59 -05:00
a0321020c7 Fix(TipoResponsabilidad-2.1.gc): UPDATE Anexo 1.9 2024 2024-08-06 13:27:48 -05:00
dde24b9739 Fix: Dependencies 2024-06-12 10:06:59 -05:00
6e5d358c73 Fix: Se actualizan dependencias para python3.12 y primeros pasos con pruebas 2024-06-11 15:59:44 -05:00
40 changed files with 2523 additions and 1697 deletions

1
.gitignore vendored
View File

@@ -215,3 +215,4 @@ tags
pyvenv.cfg
.venv
pip-selfcheck.json
invoice.xml

View File

@@ -94,14 +94,6 @@ Ready to contribute? Here's how to set up `facho` for local development.
7. Submit a pull request through the GitHub website.
Using docker
------------
1. make -f Makefile.dev build
2. make -f Makefile.dev dev-shell
3. make -f Makefile.dev python3.8 setup.py develop
4. make -f Makefile.dev python3.8 setup.py test
Pull Request Guidelines
-----------------------

View File

@@ -1,24 +1,17 @@
# DERIVADO DE https://alextereshenkov.github.io/run-python-tests-with-tox-in-docker.html
FROM ubuntu:24.04
FROM ubuntu:18.04
RUN apt-get -qq update
RUN apt install software-properties-common -y \
&& add-apt-repository ppa:deadsnakes/ppa
RUN apt-get install -y --no-install-recommends \
python3.7 python3.7-distutils python3.7-dev \
python3.8 python3.8-distutils python3.8-dev \
python3.9 python3.9-distutils python3.9-dev \
python3.10 python3.10-distutils python3.10-dev \
wget \
ca-certificates
RUN wget https://bootstrap.pypa.io/get-pip.py \
&& python3.7 get-pip.py pip==22.2.2 \
&& python3.8 get-pip.py pip==22.2.2 \
&& python3.9 get-pip.py pip==22.2.2 \
&& python3.10 get-pip.py pip==22.2.2 \
&& python3 get-pip.py pip==21.3 \
&& python3.7 get-pip.py pip==21.3 \
&& python3.8 get-pip.py pip==21.3 \
&& rm get-pip.py
RUN apt-get install -y --no-install-recommends \
@@ -27,14 +20,12 @@ RUN apt-get install -y --no-install-recommends \
build-essential \
zip
RUN python3.6 --version
RUN python3.7 --version
RUN python3.8 --version
RUN python3.9 --version
RUN python3.10 --version
RUN pip3.6 install setuptools setuptools-rust
RUN pip3.7 install setuptools setuptools-rust
RUN pip3.8 install setuptools setuptools-rust
RUN pip3.9 install setuptools setuptools-rust
RUN pip3.10 install setuptools setuptools-rust
RUN pip3 install tox pytest

View File

@@ -11,6 +11,9 @@
dev-setup:
docker build -t facho .
py-develop:
docker run -t -v $(PWD):/app -w /app facho sh -c 'python3.7 setup.py develop --user'
dev-shell:
docker run --rm -ti -v "$(PWD):/app" -w /app --name facho-cli facho bash

View File

@@ -0,0 +1,123 @@
from facho import fe
SOFTWARE_PIN='20234'
SOFTWARE_ID='100b0d10-0ca0-4ad4-a894-b704a568cbf3'
NIT='901575528'
DV='2'
def extensions(nomina):
return []
def nomina():
nomina = fe.nomina.DIANNominaIndividual()
nomina.asignar_fecha_pago('2024-04-30')
nomina.asignar_metadata(fe.nomina.Metadata(
novedad=fe.nomina.Novedad(value='false'),
secuencia=fe.nomina.NumeroSecuencia(
prefijo='N',
consecutivo='000001'
),
lugar_generacion=fe.nomina.Lugar(
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
),
proveedor=fe.nomina.Proveedor(
razon_social='BICI PIZZA S.A.S',
nit=NIT,
dv=DV,
software_id=SOFTWARE_ID,
software_pin=SOFTWARE_PIN
)
))
nomina.asignar_periodo(fe.nomina.Periodo(
fecha_ingreso= '2022-01-05',
fecha_liquidacion_inicio='2024-04-01',
fecha_liquidacion_fin='2024-04-30',
fecha_generacion='2024-04-30'
))
nomina.asignar_informacion_general(fe.nomina.InformacionGeneral(
fecha_generacion = '2024-04-30',
hora_generacion = '08:01:00-05:00',
tipo_ambiente = fe.nomina.InformacionGeneral.AMBIENTE_PRUEBAS,
software_pin = SOFTWARE_PIN,
periodo_nomina = fe.nomina.PeriodoNomina(code='1'),
tipo_moneda = fe.nomina.TipoMoneda(code='COP')
))
nomina.asignar_pago(fe.nomina.Pago(
forma=fe.nomina.FormaPago(
code='1',
),
metodo=fe.nomina.MetodoPago(
code='10'
)
))
nomina.asignar_empleador(fe.nomina.Empleador(
razon_social='BICI PIZZA S.A.S',
nit = NIT,
dv = DV,
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
direccion = 'calle etrivial'
))
nomina.asignar_trabajador(fe.nomina.Trabajador(
tipo_contrato = fe.nomina.TipoContrato(
code = '1'
),
alto_riesgo = False,
tipo_documento = fe.nomina.TipoDocumento(
code = '11'
),
primer_apellido = 'GONZALEZ',
segundo_apellido = '',
primer_nombre = 'JUAN',
lugar_trabajo = fe.nomina.LugarTrabajo(
pais = fe.nomina.Pais(code='CO'),
departamento = fe.nomina.Departamento(code='05'),
municipio = fe.nomina.Municipio(code='05001'),
direccion = 'CL 35C 102-17 BL 7 AP 101'
),
numero_documento = NIT,
tipo = fe.nomina.TipoTrabajador(
code = '01'
),
salario_integral = False,
sueldo = fe.nomina.Amount(2400000)
))
nomina.adicionar_devengado(fe.nomina.DevengadoBasico(
dias_trabajados = 30,
sueldo_trabajado = fe.nomina.Amount(2400000)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionSalud(
porcentaje = fe.nomina.Amount(4),
deduccion = fe.nomina.Amount(96000)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionFondoPension(
porcentaje=fe.nomina.Amount(4),
deduccion = fe.nomina.Amount(96000)
))
return nomina

View File

@@ -0,0 +1,89 @@
<?xml version='1.0' encoding='UTF-8'?>
<NominaIndividual xmlns:atd="urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2" xmlns="dian:gov:co:facturaelectronica:NominaIndividual" xmlns:fe="http://www.dian.gov.co/contratos/facturaelectronica/v1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cdt="urn:DocumentInformation:names:specification:ubl:colombia:schema:xsd:DocumentInformationAggregateComponents-1" xmlns:clm54217="urn:un:unece:uncefact:codelist:specification:54217:2001" xmlns:clmIANAMIMEMediaType="urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:sts="dian:gov:co:facturaelectronica:Structures-2-1" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" xmlns:xades141="http://uri.etsi.org/01903/v1.4.1#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:sig="http://www.w3.org/2000/09/xmldsig#" SchemaLocation="" xsi:schemaLocation="dian:gov:co:facturaelectronica:NominaIndividual NominaIndividualElectronicaXSD.xsd"><ext:UBLExtensions><ext:UBLExtension><ext:ExtensionContent><ds:Signature Id="xmlsig-2e62ccd5-82d2-4922-90a0-31af30fc44c0">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<ds:Reference Id="xmldsig-2e62ccd5-82d2-4922-90a0-31af30fc44c0-ref0" URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>HS3rmJgPKyCNLNO3TXfP0s1zIGvJTjq40JfMm/muHLA=</ds:DigestValue>
</ds:Reference>
<ds:Reference Id="xmldsig-2e62ccd5-82d2-4922-90a0-31af30fc44c0-ref1" URI="#xmldsig-2e62ccd5-82d2-4922-90a0-31af30fc44c0-KeyInfo">
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>88R+0zjb6NIUiHhT8EE1ale8bO+TR6SSQBtVQUYkZ6c=</ds:DigestValue>
</ds:Reference>
<ds:Reference URI="#xmldsig-2e62ccd5-82d2-4922-90a0-31af30fc44c0-signedprops" Type="http://uri.etsi.org/01903#SignedProperties">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>QF0d+RznylwnbFaGclqPWLndUo35HVDouEYoS1wfVO8=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>0JBFsBhyo4r/9m5vuBXbKirHOgniDNeGW3RNXpCE/sgXvrV3E4K8/M4HeO0VYtM0
G4bHvvkP2NCkdrKgZ9gB+XG8E/rEmJnwKpHm2kaNnpM1pYGoqBNWpqCa5FnUsEk4
c4BmBaKjmBSUrz+2JoOg1RKaaJumqGWm83IjWWJq9b4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w4TAF8N/Pbs
wnrKukFU2acxISwTLu36HC4hshWw8bEGP54szvv1xnwqcOAWNBCxcBuc9k1JD+SI
iqqPwHKh+6EDIooujo0H15w3rAxkHQRvYe6/IrpvH2sqJl1I3dLv0iqy9+d2l891
KBA9Yebdw7m/+ufu+eqs+0zKrwV6QLhRFmceHzEkPMTFepc2COGf80OUNbI6WWns
pvDK97D8YG0MeifPYveIPw==</ds:Modulus>
<ds:Exponent>AQAB</ds:Exponent>
</ds:RSAKeyValue>
</ds:KeyValue>
</ds:KeyInfo>
<ds:Object><xades:QualifyingProperties Target="#xmlsig-2e62ccd5-82d2-4922-90a0-31af30fc44c0" Id="XadesObjects"><xades:SignedProperties Id="xmldsig-2e62ccd5-82d2-4922-90a0-31af30fc44c0-signedprops"><xades:SignedSignatureProperties><xades:SigningTime>2025-03-16T16:49:57.777363</xades:SigningTime><xades:SigningCertificate><xades:Cert><xades:CertDigest><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><ds:DigestValue>YcIPspAVFcNg+B/galYrdCLYvLIEwFI4KWdSzcuupPY=</ds:DigestValue></xades:CertDigest><xades:IssuerSerial><ds:X509IssuerName>C=CO, L=Bogota D.C., O=Andes SCD, OU=Division de certificacion entidad final, CN=CA ANDES SCD S.A. Clase II v3, OID.1.2.840.113549.1.9.1=info@andesscd.com.co</ds:X509IssuerName><ds:X509SerialNumber>4834208642831502931</ds:X509SerialNumber></xades:IssuerSerial></xades:Cert></xades:SigningCertificate><xades:SignaturePolicyIdentifier><xades:SignaturePolicyId><xades:SigPolicyId><xades:Identifier>https://facturaelectronica.dian.gov.co/politicadefirma/v2/politicadefirmav2.pdf</xades:Identifier><xades:Description>Política de firma para facturas electrónicas de la República de Colombia.</xades:Description></xades:SigPolicyId><xades:SigPolicyHash><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><ds:DigestValue>dMoMvtcG5aIzgYo0tIsSQeVJBDnUnfSOfBpxXrmor0Y=</ds:DigestValue></xades:SigPolicyHash></xades:SignaturePolicyId></xades:SignaturePolicyIdentifier><xades:SignerRole><xades:ClaimedRoles><xades:ClaimedRole>supplier</xades:ClaimedRole></xades:ClaimedRoles></xades:SignerRole></xades:SignedSignatureProperties></xades:SignedProperties></xades:QualifyingProperties></ds:Object></ds:Signature></ext:ExtensionContent></ext:UBLExtension></ext:UBLExtensions><Novedad CUNENov="false">false</Novedad><Periodo FechaIngreso="2022-01-05" FechaLiquidacionInicio="2024-04-01" FechaLiquidacionFin="2024-04-30" TiempoLaborado="1" FechaGen="2024-04-30"/><NumeroSecuenciaXML Prefijo="N" Consecutivo="000001" Numero="N000001"/><LugarGeneracionXML Pais="CO" DepartamentoEstado="05" MunicipioCiudad="05001" Idioma="es"/><ProveedorXML NIT="901575528" DV="2" SoftwareID="100b0d10-0ca0-4ad4-a894-b704a568cbf3" RazonSocial="BICI PIZZA S.A.S" SoftwareSC="277c710304542320e15609646371219dc9ac3edd9c73adc0a278a355fbef97609bb7e451b92900b517044443f6ae1838"/><CodigoQR>https://catalogo-vpfe-hab.dian.gov.co/document/searchqr?documentkey=f498037db4d2f7c42224fbdc958d031927f17f0ad4e4c1f4a3e85d6363d68f3f951860873e6899937c080f03b0bd0ceb</CodigoQR><InformacionGeneral Version="V1.0: Documento Soporte de Pago de Nómina Electrónica" Ambiente="2" TipoXML="102" EncripCUNE="CUNE-SHA384" FechaGen="2024-04-30" HoraGen="08:01:00-05:00" PeriodoNomina="1" TipoMoneda="COP" TRM="0" CUNE="f498037db4d2f7c42224fbdc958d031927f17f0ad4e4c1f4a3e85d6363d68f3f951860873e6899937c080f03b0bd0ceb"/><Empleador NIT="901575528" DV="2" Pais="CO" DepartamentoEstado="05" MunicipioCiudad="05001" Direccion="calle etrivial" RazonSocial="BICI PIZZA S.A.S"/><Trabajador TipoTrabajador="01" SubTipoTrabajador="00" AltoRiesgoPension="false" TipoDocumento="11" NumeroDocumento="901575528" PrimerApellido="GONZALEZ" SegundoApellido="" PrimerNombre="JUAN" LugarTrabajoPais="CO" LugarTrabajoDepartamentoEstado="05" LugarTrabajoMunicipioCiudad="05001" LugarTrabajoDireccion="CL 35C 102-17 BL 7 AP 101" SalarioIntegral="false" TipoContrato="1" Sueldo="2400000.0"/><Pago Forma="1" Metodo="10"/><FechasPagos><FechaPago>2024-04-30</FechaPago></FechasPagos><Devengados><Basico DiasTrabajados="30" SueldoTrabajado="2400000.00"/></Devengados><Deducciones><Salud Porcentaje="4.00" Deduccion="96000.0"/><FondoPension Porcentaje="4.00" Deduccion="96000.0"/></Deducciones><Redondeo>0</Redondeo><DevengadosTotal>2400000.00</DevengadosTotal><DeduccionesTotal>192000.00</DeduccionesTotal><ComprobanteTotal>2208000.00</ComprobanteTotal></NominaIndividual>

Binary file not shown.

View File

@@ -0,0 +1,123 @@
from facho import fe
SOFTWARE_PIN='20234'
SOFTWARE_ID='100b0d10-0ca0-4ad4-a894-b704a568cbf3'
NIT='901575528'
DV='2'
def extensions(nomina):
return []
def nomina():
nomina = fe.nomina.DIANNominaIndividual()
nomina.asignar_fecha_pago('2024-04-30')
nomina.asignar_metadata(fe.nomina.Metadata(
novedad=fe.nomina.Novedad(value='false'),
secuencia=fe.nomina.NumeroSecuencia(
prefijo='N',
consecutivo='000002'
),
lugar_generacion=fe.nomina.Lugar(
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
),
proveedor=fe.nomina.Proveedor(
razon_social='BICI PIZZA S.A.S',
nit=NIT,
dv=DV,
software_id=SOFTWARE_ID,
software_pin=SOFTWARE_PIN
)
))
nomina.asignar_periodo(fe.nomina.Periodo(
fecha_ingreso= '2022-09-05',
fecha_liquidacion_inicio='2024-04-01',
fecha_liquidacion_fin='2024-04-30',
fecha_generacion='2024-04-30'
))
nomina.asignar_informacion_general(fe.nomina.InformacionGeneral(
fecha_generacion = '2024-04-30',
hora_generacion = '08:01:00-05:00',
tipo_ambiente = fe.nomina.InformacionGeneral.AMBIENTE_PRUEBAS,
software_pin = SOFTWARE_PIN,
periodo_nomina = fe.nomina.PeriodoNomina(code='1'),
tipo_moneda = fe.nomina.TipoMoneda(code='COP')
))
nomina.asignar_pago(fe.nomina.Pago(
forma=fe.nomina.FormaPago(
code='1',
),
metodo=fe.nomina.MetodoPago(
code='10'
)
))
nomina.asignar_empleador(fe.nomina.Empleador(
razon_social='BICI PIZZA S.A.S',
nit = NIT,
dv = DV,
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
direccion = 'calle etrivial'
))
nomina.asignar_trabajador(fe.nomina.Trabajador(
tipo_contrato = fe.nomina.TipoContrato(
code = '1'
),
alto_riesgo = False,
tipo_documento = fe.nomina.TipoDocumento(
code = '11'
),
primer_apellido = 'GIRALDO',
segundo_apellido = '',
primer_nombre = 'VIVIANA',
lugar_trabajo = fe.nomina.LugarTrabajo(
pais = fe.nomina.Pais(code='CO'),
departamento = fe.nomina.Departamento(code='05'),
municipio = fe.nomina.Municipio(code='05001'),
direccion = 'CL 35C 102-17 BL 7 AP 101'
),
numero_documento = NIT,
tipo = fe.nomina.TipoTrabajador(
code = '01'
),
salario_integral = False,
sueldo = fe.nomina.Amount(1160000)
))
nomina.adicionar_devengado(fe.nomina.DevengadoBasico(
dias_trabajados = 30,
sueldo_trabajado = fe.nomina.Amount(1160000)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionSalud(
porcentaje = fe.nomina.Amount(4),
deduccion = fe.nomina.Amount(46400)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionFondoPension(
porcentaje=fe.nomina.Amount(4),
deduccion = fe.nomina.Amount(46400)
))
return nomina

View File

@@ -0,0 +1,89 @@
<?xml version='1.0' encoding='UTF-8'?>
<NominaIndividual xmlns:atd="urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2" xmlns="dian:gov:co:facturaelectronica:NominaIndividual" xmlns:fe="http://www.dian.gov.co/contratos/facturaelectronica/v1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cdt="urn:DocumentInformation:names:specification:ubl:colombia:schema:xsd:DocumentInformationAggregateComponents-1" xmlns:clm54217="urn:un:unece:uncefact:codelist:specification:54217:2001" xmlns:clmIANAMIMEMediaType="urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:sts="dian:gov:co:facturaelectronica:Structures-2-1" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" xmlns:xades141="http://uri.etsi.org/01903/v1.4.1#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:sig="http://www.w3.org/2000/09/xmldsig#" SchemaLocation="" xsi:schemaLocation="dian:gov:co:facturaelectronica:NominaIndividual NominaIndividualElectronicaXSD.xsd"><ext:UBLExtensions><ext:UBLExtension><ext:ExtensionContent><ds:Signature Id="xmlsig-bd7246f2-0f63-4a0a-822b-f59be349b7df">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<ds:Reference Id="xmldsig-bd7246f2-0f63-4a0a-822b-f59be349b7df-ref0" URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>OZ66ZARE1QPKfYYk+BdiEnO0675e7p00fGwhb/Iyd5s=</ds:DigestValue>
</ds:Reference>
<ds:Reference Id="xmldsig-bd7246f2-0f63-4a0a-822b-f59be349b7df-ref1" URI="#xmldsig-bd7246f2-0f63-4a0a-822b-f59be349b7df-KeyInfo">
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>jZRqaYdQrLDYoqJmrKrLoO2ZHlGX1Xo5IpGFAznaQnI=</ds:DigestValue>
</ds:Reference>
<ds:Reference URI="#xmldsig-bd7246f2-0f63-4a0a-822b-f59be349b7df-signedprops" Type="http://uri.etsi.org/01903#SignedProperties">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>XNMT1fgTLgeuUDfYH//8aY/TqzhsRcScSySL/6nKwxE=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>fHBH/GVqHYi8iFbtTUwLUaVerZjfoj64Toq5jE+qi/HLmwhtDCAK2V/ISn0VDxpJ
3QrAqWw/VjTFEqWmRV7mCxybM98A/+5yeWbvDkG2eY5fUOUHin9+oomysY8cwLjA
joXsvjEJlM1YIndzWG/Dryr14Hcax6ItVSaopA+1BpUoFn/5jWwZXsbmq0jHDjsI
Vyk1WpZzYwmM/aGZg7gj/pR7kZZOnv4d3L/MnFP6vJRdRNtRwO73wBd5lYGU1KaB
iTimrV2gBwg0+o5bqloSaQEtqV87adJG0h3eosSiIhrG9rc9rOpvqqq7tG2nAxRx
NyPM8gwuKoaoU9ogvRsqHQ==</ds:SignatureValue>
<ds:KeyInfo Id="xmldsig-bd7246f2-0f63-4a0a-822b-f59be349b7df-KeyInfo">
<ds:X509Data>
<ds:X509Certificate>MIIH8TCCBdmgAwIBAgIIQxaPJd4YTlMwDQYJKoZIhvcNAQ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kH4/Lp2TSlHaDEb/airCZ3I2G23M9iaZzSwYuOsOaGwp
4ovkXlYwQ7FVNfIIoAq95m9cBAigb06bRIlVBVTQq44hQFQQG6aSIT7SSPtCwPhB
5CJzG09pmgbxizqN/yxdjWdfW6Av79dh6K4uQT++Vtyp5DuAkmfn0ehayrUbDLkH
9jQFF128U5pnOPfKWf22acXqQBapesUSV/HZUZ3PXoWeHWXcMdz0azxOEunS4+px
fs5UzInRAmEcYwJHqJT3irFz+J2RsZ0WnJHrTGqFoXniQQH8QbCHehDTGN7/v/v1
LQBr5PQBnSEWhmrQ9uFrwPyMMg3yd+L75TaHLZ0MTSVezAG52oM9jBiU5tYXkSio
EfPdIsGlG74BybULGSG2OlTINlblj/lj7pL67V+gY9EGN1zzNKL5sW4YXlXewa6K
dTpLmmzWzI8Cm+tOuuJDSHSwMjn525O+Z/oyKLjdQdyfg1KnZYwNZFpMmCwfP5nd
cm4F7Anzb9HX9ciluAxc6as9TsNoDDTSAGPuUr0QvXqXd9ZCgXdNzdFeiaYknLP5
hT4f5CoO2M8qcG+CH7HnkaOHrSuK</ds:X509Certificate>
</ds:X509Data>
<ds:KeyValue>
<ds:RSAKeyValue>
<ds:Modulus>5J1O+4ZedrSBUsb+9tjNPHI9RGeIJcJl3Wc/208OqMYcCwGLUkrYBgH78E7IayD5
/wra04OU57cS1/+/yBUWYR60oqkaH2/8OXkJMqmjisVM/b58m7zyMw4TAF8N/Pbs
wnrKukFU2acxISwTLu36HC4hshWw8bEGP54szvv1xnwqcOAWNBCxcBuc9k1JD+SI
iqqPwHKh+6EDIooujo0H15w3rAxkHQRvYe6/IrpvH2sqJl1I3dLv0iqy9+d2l891
KBA9Yebdw7m/+ufu+eqs+0zKrwV6QLhRFmceHzEkPMTFepc2COGf80OUNbI6WWns
pvDK97D8YG0MeifPYveIPw==</ds:Modulus>
<ds:Exponent>AQAB</ds:Exponent>
</ds:RSAKeyValue>
</ds:KeyValue>
</ds:KeyInfo>
<ds:Object><xades:QualifyingProperties Target="#xmlsig-bd7246f2-0f63-4a0a-822b-f59be349b7df" Id="XadesObjects"><xades:SignedProperties Id="xmldsig-bd7246f2-0f63-4a0a-822b-f59be349b7df-signedprops"><xades:SignedSignatureProperties><xades:SigningTime>2025-03-16T16:50:01.250573</xades:SigningTime><xades:SigningCertificate><xades:Cert><xades:CertDigest><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><ds:DigestValue>YcIPspAVFcNg+B/galYrdCLYvLIEwFI4KWdSzcuupPY=</ds:DigestValue></xades:CertDigest><xades:IssuerSerial><ds:X509IssuerName>C=CO, L=Bogota D.C., O=Andes SCD, OU=Division de certificacion entidad final, CN=CA ANDES SCD S.A. Clase II v3, OID.1.2.840.113549.1.9.1=info@andesscd.com.co</ds:X509IssuerName><ds:X509SerialNumber>4834208642831502931</ds:X509SerialNumber></xades:IssuerSerial></xades:Cert></xades:SigningCertificate><xades:SignaturePolicyIdentifier><xades:SignaturePolicyId><xades:SigPolicyId><xades:Identifier>https://facturaelectronica.dian.gov.co/politicadefirma/v2/politicadefirmav2.pdf</xades:Identifier><xades:Description>Política de firma para facturas electrónicas de la República de Colombia.</xades:Description></xades:SigPolicyId><xades:SigPolicyHash><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><ds:DigestValue>dMoMvtcG5aIzgYo0tIsSQeVJBDnUnfSOfBpxXrmor0Y=</ds:DigestValue></xades:SigPolicyHash></xades:SignaturePolicyId></xades:SignaturePolicyIdentifier><xades:SignerRole><xades:ClaimedRoles><xades:ClaimedRole>supplier</xades:ClaimedRole></xades:ClaimedRoles></xades:SignerRole></xades:SignedSignatureProperties></xades:SignedProperties></xades:QualifyingProperties></ds:Object></ds:Signature></ext:ExtensionContent></ext:UBLExtension></ext:UBLExtensions><Novedad CUNENov="false">false</Novedad><Periodo FechaIngreso="2022-09-05" FechaLiquidacionInicio="2024-04-01" FechaLiquidacionFin="2024-04-30" TiempoLaborado="1" FechaGen="2024-04-30"/><NumeroSecuenciaXML Prefijo="N" Consecutivo="000002" Numero="N000002"/><LugarGeneracionXML Pais="CO" DepartamentoEstado="05" MunicipioCiudad="05001" Idioma="es"/><ProveedorXML NIT="901575528" DV="2" SoftwareID="100b0d10-0ca0-4ad4-a894-b704a568cbf3" RazonSocial="BICI PIZZA S.A.S" SoftwareSC="067c1069842576f1f954d3540d9f75a214e2a63219f36f4f25465e26958c10d2c9e222076635379bd7f61ca0459c87e9"/><CodigoQR>https://catalogo-vpfe-hab.dian.gov.co/document/searchqr?documentkey=cb2e6968a811c661ebdc8b8cd19a323ca05471c2fe3c3b1cfb5275379d7df94d6c22f9405d732295e805095e366a99fa</CodigoQR><InformacionGeneral Version="V1.0: Documento Soporte de Pago de Nómina Electrónica" Ambiente="2" TipoXML="102" EncripCUNE="CUNE-SHA384" FechaGen="2024-04-30" HoraGen="08:01:00-05:00" PeriodoNomina="1" TipoMoneda="COP" TRM="0" CUNE="cb2e6968a811c661ebdc8b8cd19a323ca05471c2fe3c3b1cfb5275379d7df94d6c22f9405d732295e805095e366a99fa"/><Empleador NIT="901575528" DV="2" Pais="CO" DepartamentoEstado="05" MunicipioCiudad="05001" Direccion="calle etrivial" RazonSocial="BICI PIZZA S.A.S"/><Trabajador TipoTrabajador="01" SubTipoTrabajador="00" AltoRiesgoPension="false" TipoDocumento="11" NumeroDocumento="901575528" PrimerApellido="GIRALDO" SegundoApellido="" PrimerNombre="VIVIANA" LugarTrabajoPais="CO" LugarTrabajoDepartamentoEstado="05" LugarTrabajoMunicipioCiudad="05001" LugarTrabajoDireccion="CL 35C 102-17 BL 7 AP 101" SalarioIntegral="false" TipoContrato="1" Sueldo="1160000.0"/><Pago Forma="1" Metodo="10"/><FechasPagos><FechaPago>2024-04-30</FechaPago></FechasPagos><Devengados><Basico DiasTrabajados="30" SueldoTrabajado="1160000.00"/></Devengados><Deducciones><Salud Porcentaje="4.00" Deduccion="46400.0"/><FondoPension Porcentaje="4.00" Deduccion="46400.0"/></Deducciones><Redondeo>0</Redondeo><DevengadosTotal>1160000.00</DevengadosTotal><DeduccionesTotal>92800.00</DeduccionesTotal><ComprobanteTotal>1067200.00</ComprobanteTotal></NominaIndividual>

Binary file not shown.

View File

@@ -0,0 +1,123 @@
from facho import fe
SOFTWARE_PIN='20234'
SOFTWARE_ID='100b0d10-0ca0-4ad4-a894-b704a568cbf3'
NIT='901575528'
DV='2'
def extensions(nomina):
return []
def nomina():
nomina = fe.nomina.DIANNominaIndividual()
nomina.asignar_fecha_pago('2024-04-30')
nomina.asignar_metadata(fe.nomina.Metadata(
novedad=fe.nomina.Novedad(value='false'),
secuencia=fe.nomina.NumeroSecuencia(
prefijo='N',
consecutivo='000003'
),
lugar_generacion=fe.nomina.Lugar(
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
),
proveedor=fe.nomina.Proveedor(
razon_social='BICI PIZZA S.A.S',
nit=NIT,
dv=DV,
software_id=SOFTWARE_ID,
software_pin=SOFTWARE_PIN
)
))
nomina.asignar_periodo(fe.nomina.Periodo(
fecha_ingreso= '2022-01-05',
fecha_liquidacion_inicio='2024-04-01',
fecha_liquidacion_fin='2024-04-30',
fecha_generacion='2024-04-30'
))
nomina.asignar_informacion_general(fe.nomina.InformacionGeneral(
fecha_generacion = '2024-04-30',
hora_generacion = '08:01:00-05:00',
tipo_ambiente = fe.nomina.InformacionGeneral.AMBIENTE_PRUEBAS,
software_pin = SOFTWARE_PIN,
periodo_nomina = fe.nomina.PeriodoNomina(code='1'),
tipo_moneda = fe.nomina.TipoMoneda(code='COP')
))
nomina.asignar_pago(fe.nomina.Pago(
forma=fe.nomina.FormaPago(
code='1',
),
metodo=fe.nomina.MetodoPago(
code='10'
)
))
nomina.asignar_empleador(fe.nomina.Empleador(
razon_social='BICI PIZZA S.A.S',
nit = NIT,
dv = DV,
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
direccion = 'calle etrivial'
))
nomina.asignar_trabajador(fe.nomina.Trabajador(
tipo_contrato = fe.nomina.TipoContrato(
code = '1'
),
alto_riesgo = False,
tipo_documento = fe.nomina.TipoDocumento(
code = '11'
),
primer_apellido = 'GONZALEZ',
segundo_apellido = '',
primer_nombre = 'JUAN',
lugar_trabajo = fe.nomina.LugarTrabajo(
pais = fe.nomina.Pais(code='CO'),
departamento = fe.nomina.Departamento(code='05'),
municipio = fe.nomina.Municipio(code='05001'),
direccion = 'CL 35C 102-17 BL 7 AP 101'
),
numero_documento = NIT,
tipo = fe.nomina.TipoTrabajador(
code = '01'
),
salario_integral = False,
sueldo = fe.nomina.Amount(2400000)
))
nomina.adicionar_devengado(fe.nomina.DevengadoBasico(
dias_trabajados = 30,
sueldo_trabajado = fe.nomina.Amount(2400000)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionSalud(
porcentaje = fe.nomina.Amount(4),
deduccion = fe.nomina.Amount(96000)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionFondoPension(
porcentaje=fe.nomina.Amount(4),
deduccion = fe.nomina.Amount(96000)
))
return nomina

View File

@@ -0,0 +1,89 @@
<?xml version='1.0' encoding='UTF-8'?>
<NominaIndividual xmlns:atd="urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2" xmlns="dian:gov:co:facturaelectronica:NominaIndividual" xmlns:fe="http://www.dian.gov.co/contratos/facturaelectronica/v1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cdt="urn:DocumentInformation:names:specification:ubl:colombia:schema:xsd:DocumentInformationAggregateComponents-1" xmlns:clm54217="urn:un:unece:uncefact:codelist:specification:54217:2001" xmlns:clmIANAMIMEMediaType="urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:sts="dian:gov:co:facturaelectronica:Structures-2-1" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" xmlns:xades141="http://uri.etsi.org/01903/v1.4.1#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:sig="http://www.w3.org/2000/09/xmldsig#" SchemaLocation="" xsi:schemaLocation="dian:gov:co:facturaelectronica:NominaIndividual NominaIndividualElectronicaXSD.xsd"><ext:UBLExtensions><ext:UBLExtension><ext:ExtensionContent><ds:Signature Id="xmlsig-135b3cc1-1d1c-4ddd-a4c0-704a880a352b">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<ds:Reference Id="xmldsig-135b3cc1-1d1c-4ddd-a4c0-704a880a352b-ref0" URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>mf3prH7SIB1Df0Z/nOPdRGG0DKXP8oCra41918zaCyg=</ds:DigestValue>
</ds:Reference>
<ds:Reference Id="xmldsig-135b3cc1-1d1c-4ddd-a4c0-704a880a352b-ref1" URI="#xmldsig-135b3cc1-1d1c-4ddd-a4c0-704a880a352b-KeyInfo">
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>H3dF/siCNdG6iSy15jUQct1k4qswXBZToWJH6tsptpk=</ds:DigestValue>
</ds:Reference>
<ds:Reference URI="#xmldsig-135b3cc1-1d1c-4ddd-a4c0-704a880a352b-signedprops" Type="http://uri.etsi.org/01903#SignedProperties">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>IqiqJKHTI0OAWva1xZ+ZOk9ooGkzEa4hReQCr4/W778=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>Nv0nFvZ4Y3KIaPODEiOFgThDYb+DNKlJrRUAOrIxcNvtotpK7Y91JnYbUgFvl28b
Z5V/catUMyOclGDjPzslTBcHXExleb5eIgUB8URdNvdrB78iXFUOfPc+ESFomru8
jyPX9cZw24ZYBmQqqusvqIkf/tIARFGZ+7AzXkp28dBRFyWtgjESn60DIrFjm9x5
Pthv1K95gytjrrpwvdk77KN4uumlCbGoc2Pizbj+ufijbnxEPDS7fS7RR0Qv9uz/
2X7znR10TK8+gwMz7AVRYQi90ZbhOadxf3j+HVAlHtw+JHbrPSC+7xBOiPPStY6o
6TkQU+ZMpz2IUovjqREXow==</ds:SignatureValue>
<ds:KeyInfo Id="xmldsig-135b3cc1-1d1c-4ddd-a4c0-704a880a352b-KeyInfo">
<ds:X509Data>
<ds:X509Certificate>MIIH8TCCBdmgAwIBAgIIQxaPJd4YTlMwDQYJKoZIhvcNAQELBQAwgbYxIzAhBgkq
hkiG9w0BCQEWFGluZm9AYW5kZXNzY2QuY29tLmNvMSYwJAYDVQQDEx1DQSBBTkRF
UyBTQ0QgUy5BLiBDbGFzZSBJSSB2MzEwMC4GA1UECxMnRGl2aXNpb24gZGUgY2Vy
dGlmaWNhY2lvbiBlbnRpZGFkIGZpbmFsMRIwEAYDVQQKEwlBbmRlcyBTQ0QxFDAS
BgNVBAcTC0JvZ290YSBELkMuMQswCQYDVQQGEwJDTzAeFw0yNDA1MTYwNTAwMDBa
Fw0yNTA1MTYwNDU5MDBaMIIB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mrQ9uFrwPyMMg3yd+L75TaHLZ0MTSVezAG52oM9jBiU5tYXkSio
EfPdIsGlG74BybULGSG2OlTINlblj/lj7pL67V+gY9EGN1zzNKL5sW4YXlXewa6K
dTpLmmzWzI8Cm+tOuuJDSHSwMjn525O+Z/oyKLjdQdyfg1KnZYwNZFpMmCwfP5nd
cm4F7Anzb9HX9ciluAxc6as9TsNoDDTSAGPuUr0QvXqXd9ZCgXdNzdFeiaYknLP5
hT4f5CoO2M8qcG+CH7HnkaOHrSuK</ds:X509Certificate>
</ds:X509Data>
<ds:KeyValue>
<ds:RSAKeyValue>
<ds:Modulus>5J1O+4ZedrSBUsb+9tjNPHI9RGeIJcJl3Wc/208OqMYcCwGLUkrYBgH78E7IayD5
/wra04OU57cS1/+/yBUWYR60oqkaH2/8OXkJMqmjisVM/b58m7zyMw4TAF8N/Pbs
wnrKukFU2acxISwTLu36HC4hshWw8bEGP54szvv1xnwqcOAWNBCxcBuc9k1JD+SI
iqqPwHKh+6EDIooujo0H15w3rAxkHQRvYe6/IrpvH2sqJl1I3dLv0iqy9+d2l891
KBA9Yebdw7m/+ufu+eqs+0zKrwV6QLhRFmceHzEkPMTFepc2COGf80OUNbI6WWns
pvDK97D8YG0MeifPYveIPw==</ds:Modulus>
<ds:Exponent>AQAB</ds:Exponent>
</ds:RSAKeyValue>
</ds:KeyValue>
</ds:KeyInfo>
<ds:Object><xades:QualifyingProperties Target="#xmlsig-135b3cc1-1d1c-4ddd-a4c0-704a880a352b" Id="XadesObjects"><xades:SignedProperties Id="xmldsig-135b3cc1-1d1c-4ddd-a4c0-704a880a352b-signedprops"><xades:SignedSignatureProperties><xades:SigningTime>2025-03-16T16:51:23.354553</xades:SigningTime><xades:SigningCertificate><xades:Cert><xades:CertDigest><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><ds:DigestValue>YcIPspAVFcNg+B/galYrdCLYvLIEwFI4KWdSzcuupPY=</ds:DigestValue></xades:CertDigest><xades:IssuerSerial><ds:X509IssuerName>C=CO, L=Bogota D.C., O=Andes SCD, OU=Division de certificacion entidad final, CN=CA ANDES SCD S.A. Clase II v3, OID.1.2.840.113549.1.9.1=info@andesscd.com.co</ds:X509IssuerName><ds:X509SerialNumber>4834208642831502931</ds:X509SerialNumber></xades:IssuerSerial></xades:Cert></xades:SigningCertificate><xades:SignaturePolicyIdentifier><xades:SignaturePolicyId><xades:SigPolicyId><xades:Identifier>https://facturaelectronica.dian.gov.co/politicadefirma/v2/politicadefirmav2.pdf</xades:Identifier><xades:Description>Política de firma para facturas electrónicas de la República de Colombia.</xades:Description></xades:SigPolicyId><xades:SigPolicyHash><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><ds:DigestValue>dMoMvtcG5aIzgYo0tIsSQeVJBDnUnfSOfBpxXrmor0Y=</ds:DigestValue></xades:SigPolicyHash></xades:SignaturePolicyId></xades:SignaturePolicyIdentifier><xades:SignerRole><xades:ClaimedRoles><xades:ClaimedRole>supplier</xades:ClaimedRole></xades:ClaimedRoles></xades:SignerRole></xades:SignedSignatureProperties></xades:SignedProperties></xades:QualifyingProperties></ds:Object></ds:Signature></ext:ExtensionContent></ext:UBLExtension></ext:UBLExtensions><Novedad CUNENov="false">false</Novedad><Periodo FechaIngreso="2022-01-05" FechaLiquidacionInicio="2024-04-01" FechaLiquidacionFin="2024-04-30" TiempoLaborado="1" FechaGen="2024-04-30"/><NumeroSecuenciaXML Prefijo="N" Consecutivo="000003" Numero="N000003"/><LugarGeneracionXML Pais="CO" DepartamentoEstado="05" MunicipioCiudad="05001" Idioma="es"/><ProveedorXML NIT="901575528" DV="2" SoftwareID="100b0d10-0ca0-4ad4-a894-b704a568cbf3" RazonSocial="BICI PIZZA S.A.S" SoftwareSC="23bd3a3e925c4cdf6c4b99c1eda9e64846526241a263b86f3ffc9673d91020625812ef6abdcf93b4c326b7b65999d6c1"/><CodigoQR>https://catalogo-vpfe-hab.dian.gov.co/document/searchqr?documentkey=beae68d136b80593b01b5cd7594bc86cc2f6ffd17d0238e5842e29ef6dfde62d26cb959764b6bf0943e73149596bfec0</CodigoQR><InformacionGeneral Version="V1.0: Documento Soporte de Pago de Nómina Electrónica" Ambiente="2" TipoXML="102" EncripCUNE="CUNE-SHA384" FechaGen="2024-04-30" HoraGen="08:01:00-05:00" PeriodoNomina="1" TipoMoneda="COP" TRM="0" CUNE="beae68d136b80593b01b5cd7594bc86cc2f6ffd17d0238e5842e29ef6dfde62d26cb959764b6bf0943e73149596bfec0"/><Empleador NIT="901575528" DV="2" Pais="CO" DepartamentoEstado="05" MunicipioCiudad="05001" Direccion="calle etrivial" RazonSocial="BICI PIZZA S.A.S"/><Trabajador TipoTrabajador="01" SubTipoTrabajador="00" AltoRiesgoPension="false" TipoDocumento="11" NumeroDocumento="901575528" PrimerApellido="GONZALEZ" SegundoApellido="" PrimerNombre="JUAN" LugarTrabajoPais="CO" LugarTrabajoDepartamentoEstado="05" LugarTrabajoMunicipioCiudad="05001" LugarTrabajoDireccion="CL 35C 102-17 BL 7 AP 101" SalarioIntegral="false" TipoContrato="1" Sueldo="2400000.0"/><Pago Forma="1" Metodo="10"/><FechasPagos><FechaPago>2024-04-30</FechaPago></FechasPagos><Devengados><Basico DiasTrabajados="30" SueldoTrabajado="2400000.00"/></Devengados><Deducciones><Salud Porcentaje="4.00" Deduccion="96000.0"/><FondoPension Porcentaje="4.00" Deduccion="96000.0"/></Deducciones><Redondeo>0</Redondeo><DevengadosTotal>2400000.00</DevengadosTotal><DeduccionesTotal>192000.00</DeduccionesTotal><ComprobanteTotal>2208000.00</ComprobanteTotal></NominaIndividual>

Binary file not shown.

View File

@@ -0,0 +1,123 @@
from facho import fe
SOFTWARE_PIN='20234'
SOFTWARE_ID='100b0d10-0ca0-4ad4-a894-b704a568cbf3'
NIT='901575528'
DV='2'
def extensions(nomina):
return []
def nomina():
nomina = fe.nomina.DIANNominaIndividual()
nomina.asignar_fecha_pago('2024-04-30')
nomina.asignar_metadata(fe.nomina.Metadata(
novedad=fe.nomina.Novedad(value='false'),
secuencia=fe.nomina.NumeroSecuencia(
prefijo='N',
consecutivo='000004'
),
lugar_generacion=fe.nomina.Lugar(
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
),
proveedor=fe.nomina.Proveedor(
razon_social='BICI PIZZA S.A.S',
nit=NIT,
dv=DV,
software_id=SOFTWARE_ID,
software_pin=SOFTWARE_PIN
)
))
nomina.asignar_periodo(fe.nomina.Periodo(
fecha_ingreso= '2022-09-05',
fecha_liquidacion_inicio='2024-04-01',
fecha_liquidacion_fin='2024-04-30',
fecha_generacion='2024-04-30'
))
nomina.asignar_informacion_general(fe.nomina.InformacionGeneral(
fecha_generacion = '2024-04-30',
hora_generacion = '08:01:00-05:00',
tipo_ambiente = fe.nomina.InformacionGeneral.AMBIENTE_PRUEBAS,
software_pin = SOFTWARE_PIN,
periodo_nomina = fe.nomina.PeriodoNomina(code='1'),
tipo_moneda = fe.nomina.TipoMoneda(code='COP')
))
nomina.asignar_pago(fe.nomina.Pago(
forma=fe.nomina.FormaPago(
code='1',
),
metodo=fe.nomina.MetodoPago(
code='10'
)
))
nomina.asignar_empleador(fe.nomina.Empleador(
razon_social='BICI PIZZA S.A.S',
nit = NIT,
dv = DV,
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
direccion = 'calle etrivial'
))
nomina.asignar_trabajador(fe.nomina.Trabajador(
tipo_contrato = fe.nomina.TipoContrato(
code = '1'
),
alto_riesgo = False,
tipo_documento = fe.nomina.TipoDocumento(
code = '11'
),
primer_apellido = 'GIRALDO',
segundo_apellido = '',
primer_nombre = 'VIVIANA',
lugar_trabajo = fe.nomina.LugarTrabajo(
pais = fe.nomina.Pais(code='CO'),
departamento = fe.nomina.Departamento(code='05'),
municipio = fe.nomina.Municipio(code='05001'),
direccion = 'CL 35C 102-17 BL 7 AP 101'
),
numero_documento = NIT,
tipo = fe.nomina.TipoTrabajador(
code = '01'
),
salario_integral = False,
sueldo = fe.nomina.Amount(1160000)
))
nomina.adicionar_devengado(fe.nomina.DevengadoBasico(
dias_trabajados = 30,
sueldo_trabajado = fe.nomina.Amount(1160000)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionSalud(
porcentaje = fe.nomina.Amount(4),
deduccion = fe.nomina.Amount(46400)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionFondoPension(
porcentaje=fe.nomina.Amount(4),
deduccion = fe.nomina.Amount(46400)
))
return nomina

View File

@@ -0,0 +1,89 @@
<?xml version='1.0' encoding='UTF-8'?>
<NominaIndividual xmlns:atd="urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2" xmlns="dian:gov:co:facturaelectronica:NominaIndividual" xmlns:fe="http://www.dian.gov.co/contratos/facturaelectronica/v1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2" xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2" xmlns:cdt="urn:DocumentInformation:names:specification:ubl:colombia:schema:xsd:DocumentInformationAggregateComponents-1" xmlns:clm54217="urn:un:unece:uncefact:codelist:specification:54217:2001" xmlns:clmIANAMIMEMediaType="urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003" xmlns:ext="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2" xmlns:qdt="urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2" xmlns:sts="dian:gov:co:facturaelectronica:Structures-2-1" xmlns:udt="urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xades="http://uri.etsi.org/01903/v1.3.2#" xmlns:xades141="http://uri.etsi.org/01903/v1.4.1#" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:sig="http://www.w3.org/2000/09/xmldsig#" SchemaLocation="" xsi:schemaLocation="dian:gov:co:facturaelectronica:NominaIndividual NominaIndividualElectronicaXSD.xsd"><ext:UBLExtensions><ext:UBLExtension><ext:ExtensionContent><ds:Signature Id="xmlsig-bf43fedd-6780-438f-afe3-ac062d8b8072">
<ds:SignedInfo>
<ds:CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
<ds:SignatureMethod Algorithm="http://www.w3.org/2001/04/xmldsig-more#rsa-sha256"/>
<ds:Reference Id="xmldsig-bf43fedd-6780-438f-afe3-ac062d8b8072-ref0" URI="">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>ZAE71pLQXXnN5+540pnkxH5ALNBQcecMdLWFKTKby0g=</ds:DigestValue>
</ds:Reference>
<ds:Reference Id="xmldsig-bf43fedd-6780-438f-afe3-ac062d8b8072-ref1" URI="#xmldsig-bf43fedd-6780-438f-afe3-ac062d8b8072-KeyInfo">
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>kNyh65TH4KfF6wqRoy1duEawgkvOlr2rYLCNfdTfK1c=</ds:DigestValue>
</ds:Reference>
<ds:Reference URI="#xmldsig-bf43fedd-6780-438f-afe3-ac062d8b8072-signedprops" Type="http://uri.etsi.org/01903#SignedProperties">
<ds:Transforms>
<ds:Transform Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315"/>
</ds:Transforms>
<ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/>
<ds:DigestValue>BoPBi5C0tXfV04cf74M4jktBxf9eVsXk5IWqGdeOSHw=</ds:DigestValue>
</ds:Reference>
</ds:SignedInfo>
<ds:SignatureValue>pw5WDlbd4GhnSAJKlTEDjsb1+VAVtyyXWA/isv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SAKeyValue>
<ds:Modulus>5J1O+4ZedrSBUsb+9tjNPHI9RGeIJcJl3Wc/208OqMYcCwGLUkrYBgH78E7IayD5
/wra04OU57cS1/+/yBUWYR60oqkaH2/8OXkJMqmjisVM/b58m7zyMw4TAF8N/Pbs
wnrKukFU2acxISwTLu36HC4hshWw8bEGP54szvv1xnwqcOAWNBCxcBuc9k1JD+SI
iqqPwHKh+6EDIooujo0H15w3rAxkHQRvYe6/IrpvH2sqJl1I3dLv0iqy9+d2l891
KBA9Yebdw7m/+ufu+eqs+0zKrwV6QLhRFmceHzEkPMTFepc2COGf80OUNbI6WWns
pvDK97D8YG0MeifPYveIPw==</ds:Modulus>
<ds:Exponent>AQAB</ds:Exponent>
</ds:RSAKeyValue>
</ds:KeyValue>
</ds:KeyInfo>
<ds:Object><xades:QualifyingProperties Target="#xmlsig-bf43fedd-6780-438f-afe3-ac062d8b8072" Id="XadesObjects"><xades:SignedProperties Id="xmldsig-bf43fedd-6780-438f-afe3-ac062d8b8072-signedprops"><xades:SignedSignatureProperties><xades:SigningTime>2025-03-16T16:51:26.699846</xades:SigningTime><xades:SigningCertificate><xades:Cert><xades:CertDigest><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><ds:DigestValue>YcIPspAVFcNg+B/galYrdCLYvLIEwFI4KWdSzcuupPY=</ds:DigestValue></xades:CertDigest><xades:IssuerSerial><ds:X509IssuerName>C=CO, L=Bogota D.C., O=Andes SCD, OU=Division de certificacion entidad final, CN=CA ANDES SCD S.A. Clase II v3, OID.1.2.840.113549.1.9.1=info@andesscd.com.co</ds:X509IssuerName><ds:X509SerialNumber>4834208642831502931</ds:X509SerialNumber></xades:IssuerSerial></xades:Cert></xades:SigningCertificate><xades:SignaturePolicyIdentifier><xades:SignaturePolicyId><xades:SigPolicyId><xades:Identifier>https://facturaelectronica.dian.gov.co/politicadefirma/v2/politicadefirmav2.pdf</xades:Identifier><xades:Description>Política de firma para facturas electrónicas de la República de Colombia.</xades:Description></xades:SigPolicyId><xades:SigPolicyHash><ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/><ds:DigestValue>dMoMvtcG5aIzgYo0tIsSQeVJBDnUnfSOfBpxXrmor0Y=</ds:DigestValue></xades:SigPolicyHash></xades:SignaturePolicyId></xades:SignaturePolicyIdentifier><xades:SignerRole><xades:ClaimedRoles><xades:ClaimedRole>supplier</xades:ClaimedRole></xades:ClaimedRoles></xades:SignerRole></xades:SignedSignatureProperties></xades:SignedProperties></xades:QualifyingProperties></ds:Object></ds:Signature></ext:ExtensionContent></ext:UBLExtension></ext:UBLExtensions><Novedad CUNENov="false">false</Novedad><Periodo FechaIngreso="2022-09-05" FechaLiquidacionInicio="2024-04-01" FechaLiquidacionFin="2024-04-30" TiempoLaborado="1" FechaGen="2024-04-30"/><NumeroSecuenciaXML Prefijo="N" Consecutivo="000004" Numero="N000004"/><LugarGeneracionXML Pais="CO" DepartamentoEstado="05" MunicipioCiudad="05001" Idioma="es"/><ProveedorXML NIT="901575528" DV="2" SoftwareID="100b0d10-0ca0-4ad4-a894-b704a568cbf3" RazonSocial="BICI PIZZA S.A.S" SoftwareSC="61d2d18fc61f70cff4f5c5c2a5e17e5c904bf42179a8118242e994b40c22ef203741568ee51d94b81a7fbde4ea6a79aa"/><CodigoQR>https://catalogo-vpfe-hab.dian.gov.co/document/searchqr?documentkey=40d20d7af2d7ee471909e62fcb4beef7de82494e6c8df4e8349ca33a1246dea601b4cc9035e18972e853ecd435799eaa</CodigoQR><InformacionGeneral Version="V1.0: Documento Soporte de Pago de Nómina Electrónica" Ambiente="2" TipoXML="102" EncripCUNE="CUNE-SHA384" FechaGen="2024-04-30" HoraGen="08:01:00-05:00" PeriodoNomina="1" TipoMoneda="COP" TRM="0" CUNE="40d20d7af2d7ee471909e62fcb4beef7de82494e6c8df4e8349ca33a1246dea601b4cc9035e18972e853ecd435799eaa"/><Empleador NIT="901575528" DV="2" Pais="CO" DepartamentoEstado="05" MunicipioCiudad="05001" Direccion="calle etrivial" RazonSocial="BICI PIZZA S.A.S"/><Trabajador TipoTrabajador="01" SubTipoTrabajador="00" AltoRiesgoPension="false" TipoDocumento="11" NumeroDocumento="901575528" PrimerApellido="GIRALDO" SegundoApellido="" PrimerNombre="VIVIANA" LugarTrabajoPais="CO" LugarTrabajoDepartamentoEstado="05" LugarTrabajoMunicipioCiudad="05001" LugarTrabajoDireccion="CL 35C 102-17 BL 7 AP 101" SalarioIntegral="false" TipoContrato="1" Sueldo="1160000.0"/><Pago Forma="1" Metodo="10"/><FechasPagos><FechaPago>2024-04-30</FechaPago></FechasPagos><Devengados><Basico DiasTrabajados="30" SueldoTrabajado="1160000.00"/></Devengados><Deducciones><Salud Porcentaje="4.00" Deduccion="46400.0"/><FondoPension Porcentaje="4.00" Deduccion="46400.0"/></Deducciones><Redondeo>0</Redondeo><DevengadosTotal>1160000.00</DevengadosTotal><DeduccionesTotal>92800.00</DeduccionesTotal><ComprobanteTotal>1067200.00</ComprobanteTotal></NominaIndividual>

Binary file not shown.

View File

@@ -259,14 +259,14 @@ def generate_invoice(private_key, passphrase, scriptname, generate=False, ssl=Tr
spec.loader.exec_module(module)
import facho.fe.form as form
from facho.fe.form_xml import DIANInvoiceXML, DIANWriteSigned, DIANWrite, DIANSupportDocumentXML
from facho.fe.form_xml import DIANInvoiceXML, DIANWriteSigned,DIANWrite
from facho import fe
try:
invoice_xml = module.document_xml()
except AttributeError:
#invoice_xml = DIANInvoiceXML
invoice_xml = DIANSupportDocumentXML
invoice_xml = DIANInvoiceXML
print("Using document xml:", invoice_xml)
invoice = module.invoice()
invoice.calculate()

View File

@@ -1,11 +1,12 @@
# This file is part of facho. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
from lxml import etree
from lxml.etree import Element, tostring
from lxml.etree import Element, SubElement, tostring
import re
from collections import defaultdict
from copy import deepcopy
from pprint import pprint
class FachoValueInvalid(Exception):
def __init__(self, xpath):
@@ -31,10 +32,7 @@ class LXMLBuilder:
def __init__(self, nsmap):
self.nsmap = nsmap
self._re_node_expr = \
re.compile(
r'^(?P<path>((?P<ns>\w+):)?(?P<tag>[a-zA-Z0-9_-]+))'
r'(?P<attrs>\[.+\])?')
self._re_node_expr = re.compile(r'^(?P<path>((?P<ns>\w+):)?(?P<tag>[a-zA-Z0-9_-]+))(?P<attrs>\[.+\])?')
self._re_attrs = re.compile(r'(\w+)\s*=\s*\"?(\w+)\"?')
def match_expression(self, node_expr):
@@ -123,7 +121,7 @@ class LXMLBuilder:
elem.attrib[key] = value
@classmethod
def remove_attributes(cls, elem, keys, exclude=[]):
def remove_attributes(cls, elem, keys, exclude = []):
for key in keys:
if key in exclude:
continue
@@ -145,8 +143,7 @@ class LXMLBuilder:
self.remove_attributes(el, keys, exclude=['facho_optional'])
is_optional = el.get('facho_optional', 'False') == 'True'
if is_optional and el.getchildren() == [] and el.keys() == [
'facho_optional']:
if is_optional and el.getchildren() == [] and el.keys() == ['facho_optional']:
el.getparent().remove(el)
return tostring(elem, **attrs).decode('utf-8')
@@ -156,8 +153,7 @@ class FachoXML:
"""
Decora XML con funciones de consulta XPATH de un solo elemento
"""
def __init__(self, root, builder=None, nsmap=None, fragment_prefix='',
fragment_root_element=None):
def __init__(self, root, builder=None, nsmap=None, fragment_prefix='',fragment_root_element=None):
if builder is None:
self.builder = LXMLBuilder(nsmap)
else:
@@ -181,22 +177,16 @@ class FachoXML:
xml = LXMLBuilder.from_string(document)
return FachoXML(xml, nsmap=namespaces)
def root_namespace(self):
return etree.QName(self.root).namespace
def root_localname(self):
return etree.QName(self.root).localname
def append_element(self, elem, new_elem):
# elem = self.find_or_create_element(xpath, append=append)
# self.builder.append(elem, new_elem)
#elem = self.find_or_create_element(xpath, append=append)
#self.builder.append(elem, new_elem)
self.builder.append(elem, new_elem)
def add_extension(self, extension):
extension.build(self)
def fragment(
self, xpath, append=False, append_not_exists=False):
def fragment(self, xpath, append=False, append_not_exists=False):
nodes = xpath.split('/')
nodes.pop()
root_prefix = '/'.join(nodes)
@@ -206,9 +196,7 @@ class FachoXML:
if parent is None:
parent = self.find_or_create_element(xpath, append=append)
return FachoXML(
parent, nsmap=self.nsmap, fragment_prefix=root_prefix,
fragment_root_element=self.root)
return FachoXML(parent, nsmap=self.nsmap, fragment_prefix=root_prefix, fragment_root_element=self.root)
def register_alias_xpath(self, alias, xpath):
self.xpath_for[alias] = xpath
@@ -244,8 +232,7 @@ class FachoXML:
"""
xpath = self._path_xpath_for(xpath)
node_paths = xpath.split('/')
# remove empty /
node_paths.pop(0)
node_paths.pop(0) #remove empty /
root_tag = node_paths.pop(0)
root_node = self.builder.build_from_expression(root_tag)
@@ -255,8 +242,8 @@ class FachoXML:
root_node = self.root
if not self.builder.same_tag(root_node.tag, self.root.tag):
raise ValueError('xpath %s must be absolute to /%s' % (
xpath, self.root.tag))
raise ValueError('xpath %s must be absolute to /%s' % (xpath, self.root.tag))
# crea jerarquia segun xpath indicado
parent = None
@@ -266,8 +253,8 @@ class FachoXML:
for node_path in node_paths:
node_expr = self.builder.match_expression(node_path)
node = self.builder.build_from_expression(node_path)
child = self.builder.find_relative(
current_elem, node_expr['path'], self.nsmap)
child = self.builder.find_relative(current_elem, node_expr['path'], self.nsmap)
parent = current_elem
if child is not None:
@@ -278,8 +265,7 @@ class FachoXML:
node_expr = self.builder.match_expression(node_tag)
node = self.builder.build_from_expression(node_tag)
child = self.builder.find_relative(
current_elem, node_expr['path'], self.nsmap)
child = self.builder.find_relative(current_elem, node_expr['path'], self.nsmap)
parent = current_elem
if child is not None:
current_elem = child
@@ -300,8 +286,7 @@ class FachoXML:
self.builder.append(parent, node)
return node
if self.builder.is_attribute(
last_slibing, 'facho_placeholder', 'True'):
if self.builder.is_attribute(last_slibing, 'facho_placeholder', 'True'):
self._remove_facho_attributes(last_slibing)
return last_slibing
self.builder.append_next(last_slibing, node)
@@ -314,8 +299,7 @@ class FachoXML:
self._remove_facho_attributes(current_elem)
return current_elem
def set_element_validator(
self, xpath, validator=False):
def set_element_validator(self, xpath, validator = False):
"""
validador al asignar contenido a xpath indicado
@@ -329,8 +313,7 @@ class FachoXML:
else:
self._validators[key] = validator
def set_element(
self, xpath, content, **attrs):
def set_element(self, xpath, content, **attrs):
"""
asigna contenido ubicado por ruta tipo XPATH.
@param xpath ruta tipo XPATH
@@ -372,8 +355,7 @@ class FachoXML:
self.builder.set_attribute(elem, k, str(v))
return self
def get_element_attribute(
self, xpath, attribute, multiple=False):
def get_element_attribute(self, xpath, attribute, multiple=False):
elem = self.get_element(xpath, multiple=multiple)
if elem is None:
@@ -410,16 +392,14 @@ class FachoXML:
return None
return format_(text)
def get_element_text_or_attribute(
self, xpath, default=None, multiple=False, raise_on_fail=False):
def get_element_text_or_attribute(self, xpath, default=None, multiple=False, raise_on_fail=False):
parts = xpath.split('/')
is_attribute = parts[-1].startswith('@')
if is_attribute:
attribute_name = parts.pop(-1).lstrip('@')
element_path = "/".join(parts)
try:
val = self.get_element_attribute(
element_path, attribute_name, multiple=multiple)
val = self.get_element_attribute(element_path, attribute_name, multiple=multiple)
if val is None:
return default
return val
@@ -452,8 +432,7 @@ class FachoXML:
if isinstance(xpath, tuple):
val = xpath[0]
else:
val = self.get_element_text_or_attribute(
xpath, raise_on_fail=raise_on_fail)
val = self.get_element_text_or_attribute(xpath, raise_on_fail=raise_on_fail)
vals.append(val)
return vals
@@ -475,8 +454,7 @@ class FachoXML:
return True
def _remove_facho_attributes(self, elem):
self.builder.remove_attributes(
elem, ['facho_optional', 'facho_placeholder'])
self.builder.remove_attributes(elem, ['facho_optional', 'facho_placeholder'])
def tostring(self, **kw):
return self.builder.tostring(self.root, **kw)
@@ -494,11 +472,9 @@ class FachoXML:
ns = nsmap[etree.QName(root).namespace] + ':'
if self.fragment_root_element is not None:
new_xpath = '/' + ns + etree.QName(root).localname + '/' + \
etree.QName(self.root).localname + '/' + xpath.lstrip('/')
new_xpath = '/' + ns + etree.QName(root).localname + '/' + etree.QName(self.root).localname + '/' + xpath.lstrip('/')
else:
new_xpath = '/' + ns + etree.QName(root).localname + '/' + \
xpath.lstrip('/')
new_xpath = '/' + ns + etree.QName(root).localname + '/' + xpath.lstrip('/')
return new_xpath
def __str__(self):

View File

@@ -5,7 +5,6 @@ from .fe import DianXMLExtensionSigner
from .fe import DianXMLExtensionSoftwareSecurityCode
from .fe import DianXMLExtensionCUFE
from .fe import DianXMLExtensionCUDE
from .fe import DianXMLExtensionCUDS
from .fe import DianXMLExtensionInvoiceAuthorization
from .fe import DianXMLExtensionSoftwareProvider
from .fe import DianXMLExtensionAuthorizationProvider

View File

@@ -234,10 +234,9 @@ def _append_timestamp(security, expires_dt=None):
if expires_dt is None:
expires_dt = timedelta(seconds=6000)
timestamp = datetime.now()
etimestamp = utils.WSU.Timestamp({'{http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Id': utils.get_unique_id()})
etimestamp.append(utils.WSU.Created(get_timestamp(timestamp=timestamp)))
etimestamp.append(utils.WSU.Expires(get_timestamp(timestamp=timestamp, delta=expires_dt)))
etimestamp.append(utils.WSU.Created(get_timestamp()))
etimestamp.append(utils.WSU.Expires(get_timestamp(delta=expires_dt)))
security.insert(0, etimestamp)
if etree.LXML_VERSION[:2] >= (3, 5):
etree.cleanup_namespaces(security,

View File

@@ -46,16 +46,5 @@
<SimpleValue>ReteIVA</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>100.00</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>ReteIVA</SimpleValue>
</Value>
<Value ColumnRef="description">
<SimpleValue>ReteIVA</SimpleValue>
</Value>
</Row>
</SimpleCodeList>
</gc:CodeList>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- DIAN Genericode listas de valores: Ultima modificación 03-04-2022 - wcbr-->
<!-- DIAN Genericode listas de valores:: Ultima modificación 18-02-2019 - evb-->
<gc:CodeList xmlns:gc="http://docs.oasis-open.org/codelist/ns/genericode/1.0/">
<Identification>
<ShortName>TipoDocumento</ShortName>
@@ -35,10 +35,7 @@
<SimpleValue>01</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Factura electrónica de Venta</SimpleValue>
</Value>
<Value ColumnRef="description">
<SimpleValue>Tipos de factura</SimpleValue>
<SimpleValue>Factura de Venta Nacional</SimpleValue>
</Value>
</Row>
<Row>
@@ -46,10 +43,7 @@
<SimpleValue>02</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Factura electrónica de venta con propósito de exportación</SimpleValue>
</Value>
<Value ColumnRef="description">
<SimpleValue>Tipos de factura</SimpleValue>
<SimpleValue>Factura de Exportación </SimpleValue>
</Value>
</Row>
<Row>
@@ -57,21 +51,7 @@
<SimpleValue>03</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Factura de talonario o papel con numeración de contingencia.</SimpleValue>
</Value>
<Value ColumnRef="description">
<SimpleValue>Tipos de factura</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>04</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Factura electrónica de Venta por Contingencia DIAN</SimpleValue>
</Value>
<Value ColumnRef="description">
<SimpleValue>Tipos de factura</SimpleValue>
<SimpleValue>Factura de Contingencia</SimpleValue>
</Value>
</Row>
<Row>
@@ -81,9 +61,6 @@
<Value ColumnRef="name">
<SimpleValue>Nota Crédito</SimpleValue>
</Value>
<Value ColumnRef="description">
<SimpleValue>Exclusivo en referencias a documentos (elementos DocumentReference)</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
@@ -92,31 +69,6 @@
<Value ColumnRef="name">
<SimpleValue>Nota Débito</SimpleValue>
</Value>
<Value ColumnRef="description">
<SimpleValue>Exclusivo en referencias a documentos (elementos DocumentReference)</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>05</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Documento soporte en adquisiciones efectuadas a sujetos no obligados a expedir factura o documento equivalente</SimpleValue>
</Value>
<Value ColumnRef="description">
<SimpleValue>Tipo de documento</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>95</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Nota de ajuste al documento soporte en adquisiciones efectuadas a sujetos no obligados a expedir factura o documento equivalente</SimpleValue>
</Value>
<Value ColumnRef="description">
<SimpleValue>Exclusivo en referencias a documentos (elementos DocumentReference)</SimpleValue>
</Value>
</Row>
</SimpleCodeList>
</gc:CodeList>

View File

@@ -75,7 +75,7 @@
<SimpleValue>06</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>ReteRenta</SimpleValue>
<SimpleValue>ReteFuente</SimpleValue>
</Value>
</Row>
<Row>
@@ -150,15 +150,6 @@
<SimpleValue>Sordicom</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>30</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Impuesto al Consumo de Datos</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>ZZ</SimpleValue>

View File

@@ -1,47 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<gc:CodeList xmlns:gc="http://docs.oasis-open.org/codelist/ns/genericode/1.0/">
<Identification>
<ShortName>TipoOperacion</ShortName>
<LongName xml:lang="es">Tipo de operacion</LongName>
<Version>1</Version>
<CanonicalUri>urn:dian:names:especificacion:ubl:listacodigos:gc:TipoOperacion</CanonicalUri>
<CanonicalVersionUri>urn:dian:names:especificacion:ubl:listacodigos:gc:TipoOperacion-2.1</CanonicalVersionUri>
<LocationUri>http://dian.gov.co/ubl/os-ubl-2.0/cl/gc/default/TipoOperacion-2.1.gc</LocationUri>
<Agency>
<LongName xml:lang="es">DIAN (Dirección de Impuestos y Aduanas Nacionales)</LongName>
<Identifier>195</Identifier>
</Agency>
</Identification>
<ColumnSet>
<Column Id="code" Use="required">
<ShortName>Code</ShortName>
<Data Type="normalizedString"/>
</Column>
<Column Id="name" Use="required">
<ShortName>Nombre</ShortName>
<Data Type="normalizedString"/>
</Column>
<Key Id="codeKey">
<ShortName>CodeKey</ShortName>
<ColumnRef Ref="code"/>
</Key>
</ColumnSet>
<SimpleCodeList>
<Row>
<Value ColumnRef="code">
<SimpleValue>10</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Residente</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>11</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>No Residente</SimpleValue>
</Value>
</Row>
</SimpleCodeList>
</gc:CodeList>

View File

@@ -30,6 +30,46 @@
</Key>
</ColumnSet>
<SimpleCodeList>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-99</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Otro tipo de obligado</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-06</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Ingresos y patrimonio</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-07</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Retención en la fuente a título de renta</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-08</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Retención timbre nacional</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-09</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Retención en la fuente en el impuesto sobre las ventas</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-13</SimpleValue>
@@ -38,6 +78,14 @@
<SimpleValue>Gran contribuyente</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-14</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Informante de exógena</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-15</SimpleValue>
@@ -46,6 +94,38 @@
<SimpleValue>Autorretenedor</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-16</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Obligación de facturar por ingresos de bienes y/o servicios excluidos</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-17</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Profesionales de compra y venta de divisas</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-19</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Productor y/o exportador de bienes exentos</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-22</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Obligado a cumplir deberes formales a nombre de terceros</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-23</SimpleValue>
@@ -54,6 +134,62 @@
<SimpleValue>Agente de retención en el impuesto sobre las ventas</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-32</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Impuesto Nacional a la Gasolina y al ACPM</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-33</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Impuesto Nacional al consumo</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-34</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Régimen simplificado impuesto nacional consumo rest y bares</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-36</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Establecimiento Permanente</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-37</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Obligado a Facturar Electrónicamente Modelo 2242</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-38</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Facturación Electrónica Voluntaria Modelo 2242</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-39</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Proveedor de Servicios Tecnológicos PST Modelo 2242</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-47</SimpleValue>
@@ -78,6 +214,782 @@
<SimpleValue>No responsable de IVA</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-52</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Facturador electrónico</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-99</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Otro tipo de obligado</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-00-PN</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Clientes del Exterior</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-12-PN</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Factor PN</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-16-PN</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Mandatario</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-25-PN</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Agente Interventor</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-99-PN</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>No responsable</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-06-PJ</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Apoderado especial</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-07-PJ</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Apoderado general</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-12-PJ</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Factor</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-16-PJ</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Mandatario</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-99-PJ</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Otro tipo de responsable</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-01</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Agente de carga internacional</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-02</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Agente marítimo</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-03</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Almacén general de depósito</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-04</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Comercializadora internacional (C.I.)</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-05</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Comerciante de la zona aduanera especial de Inírida, Puerto Carreño, Cumaribo y Primavera</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-06</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Comerciantes de la zona de régimen aduanero especial de Leticia</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-07</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Comerciantes de la zona de régimen aduanero especial de Maicao, Uribia y Manaure</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-08</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Comerciantes de la zona de régimen aduanero especial de Urabá, Tumaco y Guapí</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-09</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Comerciantes del puerto libre de San Andrés, Providencia y Santa Catalina</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-10</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósito público de apoyo logístico internacional</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-11</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósito privado para procesamiento industrial</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-12</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósito privado de transformación o ensamble</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-13</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósito franco</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-14</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósito privado aeronáutico</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-15</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósito privado para distribución internacional</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-16</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósito privado de provisiones de a bordo para consumo y para llevar</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-17</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósito privado para envíos urgentes</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-18</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósito privado</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-19</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósito público</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-20</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósito público para distribución internacional</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-21</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Exportador de café</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-22</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Exportador</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-23</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Importador</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-24</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Intermediario de tráfico postal y envíos urgentes</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-25</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Operador de transporte multimodal</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-26</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Sociedad de intermediación aduanera</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-27</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Titular de puertos y muelles de servicio público o privado</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-28</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Transportador 263nfor régimen de importación y/o exportación</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-29</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Transportista nacional para operaciones del régimen de tránsito aduanero</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-30</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Usuario comercial zona franca</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-32</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Usuario industrial de bienes zona franca</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-34</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Usuario industrial de servicios zona franca</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-36</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Usuario operador de zona franca</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-37</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Usuario aduanero permanente</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-38</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Usuario altamente exportador</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-39</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Usuario de zonas económicas especiales de exportación</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-40</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Deposito privado de instalaciones industriales</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-41</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Beneficiarios de programas especiales de exportación PEX</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-42</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Depósitos privados para mercancías en tránsito San Andrés</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-43</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Observadores de las operaciones de importación</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-44</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Usuarios sistemas especiales Importación exportación</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-46</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Transportador 263nformac régimen de importación y/o exportación</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-47</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Transportador terrestre régimen de importación y/o exportación</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-48</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Aeropuerto de servicio publico o privado</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-49</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Transportador fluvial régimen de importación</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-50</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Usuario industrial zona franca especial</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-53</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Agencias de aduanas 1</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-54</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Usuario Operador Zona Franca Especial</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-55</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Agencias de aduanas 2</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-56</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Agencias de aduanas 3</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-57</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Agencias de aduanas 4</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-58</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Transportador aéreo nacional</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-60</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Transportador aéreo, marítimo o fluvial modalidad Cabotaje</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-61</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Importador de alimentos de consumo humano y animal</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-62</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Importador Ocasional</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-63</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Importador de maquinaría y sus partes Decreto 2261 de 2012</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-64</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Beneficiario Programa de Fomento Industria Automotriz-PROFIA</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>A-99</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Otro tipo de agente aduanero</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-01</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Agencia</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-02</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Establecimiento de comercio</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-03</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Centro de explotación agrícola</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-04</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Centro de explotación animal</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-05</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Centro de explotación minera</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-06</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Centro de explotación de transformación</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-07</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Centro de explotación de servicios</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-08</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Oficina</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-09</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Sede</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-10</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Sucursal</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-11</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Consultorio</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-12</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Administraciones</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-13</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Seccionales</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-14</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Regionales</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-15</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Intendencias</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-16</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Local o negocio</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-17</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Punto de venta</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-18</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Fábrica</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-19</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Taller</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-20</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Cantera</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-21</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Pozo de Petróleo y Gas</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-22</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Otro lug de tipo de extrac explotación de recursos naturales</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>E-99</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Otro tipo de establecimiento</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-13</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Gran contribuyente</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-15</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Autorretenedor</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-23</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Agente de retención IVA</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-47</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Régimen simple de tributación</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-99-PN</SimpleValue>

View File

@@ -61,30 +61,6 @@
<Value ColumnRef="name">
<SimpleValue>Régimen simple de tributación</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-48</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>Impuesto sobre las ventas IVA</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>O-49</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>No responsable de IVA</SimpleValue>
</Value>
</Row>
<Row>
<Value ColumnRef="code">
<SimpleValue>R-99-PN</SimpleValue>
</Value>
<Value ColumnRef="name">
<SimpleValue>No responsable</SimpleValue>
</Value>
</Row>
</SimpleCodeList>
</gc:CodeList>

View File

@@ -82,16 +82,11 @@ TipoAmbiente = CodeList(path_for_codelist('TipoAmbiente-2.1.gc'), 'code', 'name'
TipoDocumento = CodeList(path_for_codelist('TipoDocumento-2.1.gc'), 'code', 'name')
TipoImpuesto = CodeList(path_for_codelist('TipoImpuesto-2.1.gc'), 'code', 'name')\
.update(CodeList(path_for_codelist('TipoImpuesto-2.1.custom.gc'), 'code', 'name'))
TarifaImpuesto = CodeList(path_for_codelist('TarifaImpuestoINC-2.1.gc'), 'code', 'name')\
.update(CodeList(path_for_codelist('TarifaImpuestoIVA-2.1.gc'), 'code', 'name'))\
.update(CodeList(path_for_codelist('TarifaImpuestoReteIVA-2.1.gc'), 'code', 'name'))\
.update(CodeList(path_for_codelist('TarifaImpuestoReteRenta-2.1.gc'), 'code', 'name'))
CodigoPrecioReferencia = CodeList(path_for_codelist('CodigoPrecioReferencia-2.1.gc'), 'code', 'name')
MediosPago = CodeList(path_for_codelist('MediosPago-2.1.gc'), 'code', 'name')
FormasPago = CodeList(path_for_codelist('FormasPago-2.1.gc'), 'code', 'name')
RegimenFiscal = CodeList(path_for_codelist('RegimenFiscal-2.1.custom.gc'), 'code', 'name')
TipoOperacionNC = CodeList(path_for_codelist('TipoOperacionNC-2.1.gc'), 'code', 'name')
TipoOperacionNCDS = CodeList(path_for_codelist('TipoOperacionNCDS-2.1.gc'), 'code', 'name')
TipoOperacionND = CodeList(path_for_codelist('TipoOperacionND-2.1 - copia.gc'), 'code', 'name')
TipoOperacionF = CodeList(path_for_codelist('TipoOperacionF-2.1.gc'), 'code', 'name')\
.update(CodeList(path_for_codelist('TipoOperacionF-2.1.custom.gc'), 'code', 'name'))

View File

@@ -31,44 +31,27 @@ POLICY_ID = 'https://facturaelectronica.dian.gov.co/politicadefirma/v2/politicad
POLICY_NAME = u'Política de firma para facturas electrónicas de la República de Colombia.'
# NAMESPACES = {
# 'atd': 'urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2',
# 'nomina': 'dian:gov:co:facturaelectronica:NominaIndividual',
# 'nominaajuste': 'dian:gov:co:facturaelectronica:NominaIndividualDeAjuste',
# 'fe': 'http://www.dian.gov.co/contratos/facturaelectronica/v1',
# 'xs': 'http://www.w3.org/2001/XMLSchema-instance',
# 'cac': 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2',
# 'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2',
# 'cdt': 'urn:DocumentInformation:names:specification:ubl:colombia:schema:xsd:DocumentInformationAggregateComponents-1',
# 'clm54217': 'urn:un:unece:uncefact:codelist:specification:54217:2001',
# 'clmIANAMIMEMediaType': 'urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003',
# 'ext': 'urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2',
# 'qdt': 'urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2',
# 'sts': 'dian:gov:co:facturaelectronica:Structures-2-1',
# 'udt': 'urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2',
# 'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
# 'xades': 'http://uri.etsi.org/01903/v1.3.2#',
# 'xades141': 'http://uri.etsi.org/01903/v1.4.1#',
# 'ds': 'http://www.w3.org/2000/09/xmldsig#',
# 'sig': 'http://www.w3.org/2000/09/xmldsig#',
# }
NAMESPACES = {
'atd': 'urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2',
'no': 'dian:gov:co:facturaelectronica:NominaIndividual',
'fe': 'http://www.dian.gov.co/contratos/facturaelectronica/v1',
'xs': 'http://www.w3.org/2001/XMLSchema-instance',
'cac': 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2',
'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2',
'cdt': 'urn:DocumentInformation:names:specification:ubl:colombia:schema:xsd:DocumentInformationAggregateComponents-1',
'clm54217': 'urn:un:unece:uncefact:codelist:specification:54217:2001',
'clmIANAMIMEMediaType': 'urn:un:unece:uncefact:codelist:specification:IANAMIMEMediaType:2003',
'ext': 'urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2',
'qdt': 'urn:oasis:names:specification:ubl:schema:xsd:QualifiedDatatypes-2',
'sts': 'dian:gov:co:facturaelectronica:Structures-2-1',
'udt': 'urn:un:unece:uncefact:data:specification:UnqualifiedDataTypesSchemaModule:2',
'xsi': 'http://www.w3.org/2001/XMLSchema-instance',
'ds': 'http://www.w3.org/2000/09/xmldsig#',
'xades': 'http://uri.etsi.org/01903/v1.3.2#',
'xades141': 'http://uri.etsi.org/01903/v1.4.1#',
'ds': 'http://www.w3.org/2000/09/xmldsig#',
'sig': 'http://www.w3.org/2000/09/xmldsig#',
}
def fe_from_string(document: str) -> FachoXML:
return FeXML.from_string(document)
@@ -94,7 +77,7 @@ def mock_xades_policy():
class FeXML(FachoXML):
def __init__(self, root, namespace):
# raise Exception(namespace)
super().__init__("{%s}%s" % (namespace, root),
nsmap=NAMESPACES)
@@ -104,17 +87,10 @@ class FeXML(FachoXML):
def tostring(self, **kw):
# MACHETE(bit4bit) la DIAN espera que la etiqueta raiz no este en un namespace
root_namespace = self.root_namespace()
root_localname = self.root_localname()
xmlns_name = {v: k for k, v in NAMESPACES.items()}[root_namespace]
if root_localname == 'Invoice':
urn_oasis = 'urn:oasis:names:specification:ubl:schema:xsd:Invoice-2'
if root_localname == 'CreditNote':
urn_oasis = 'urn:oasis:names:specification:ubl:schema:xsd:CreditNote-2'
return super().tostring(**kw)\
.replace(xmlns_name + ':', '')\
.replace('xmlns:'+xmlns_name, 'xmlns')\
.replace(root_namespace, urn_oasis)
.replace("fe:", "")\
.replace("xmlns:no", "xmlns")\
.replace("change", "xsi:schemaLocation")
class DianXMLExtensionCUDFE(FachoXMLExtension):
@@ -144,19 +120,8 @@ class DianXMLExtensionCUDFE(FachoXMLExtension):
fachoxml.set_element('./cbc:UUID', cufe,
schemeID=self.tipo_ambiente,
schemeName=self.schemeName())
if self.schemeName() == "CUDS-SHA384":
if fachoxml.tag_document() == 'Invoice':
fachoxml.set_element('./cbc:ProfileID',
'DIAN 2.1: documento soporte en adquisiciones efectuadas a no obligados a facturar.')
else:
fachoxml.set_element('./cbc:ProfileID',
'DIAN 2.1: Nota de ajuste al documento soporte en adquisiciones efectuadas a sujetos no obligados a expedir factura o documento equivalente')
else:
#DIAN 1.8.-2021: FAD03
fachoxml.set_element('./cbc:ProfileID', 'DIAN 2.1: Factura Electrónica de Venta')
# #DIAN 1.8.-2021: FAD03
# fachoxml.set_element('./cbc:ProfileID', 'DIAN 2.1: Factura Electrónica de Venta')
fachoxml.set_element('./cbc:ProfileExecutionID', self._tipo_ambiente_int())
#DIAN 1.7.-2020: FAB36
fachoxml.set_element('./ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sts:DianExtensions/sts:QRCode',
@@ -279,39 +244,6 @@ class DianXMLExtensionCUDE(DianXMLExtensionCUDFE):
'%d' % build_vars['TipoAmb'],
]
class DianXMLExtensionCUDS(DianXMLExtensionCUDFE):
def __init__(self, invoice, software_pin, tipo_ambiente = AMBIENTE_PRUEBAS):
self.tipo_ambiente = tipo_ambiente
self.software_pin = software_pin
self.invoice = invoice
def schemeName(self):
return 'CUDS-SHA384'
def buildVars(self):
build_vars = super().buildVars()
build_vars['Software-PIN'] = str(self.software_pin)
return build_vars
def formatVars(self):
build_vars = self.buildVars()
CodImpuesto1 = build_vars['CodImpuesto1']
CodImpuesto2 = build_vars['CodImpuesto2']
CodImpuesto3 = build_vars['CodImpuesto3']
return [
'%s' % build_vars['NumFac'],
'%s' % build_vars['FecFac'],
'%s' % build_vars['HoraFac'],
form.Amount(build_vars['ValorBruto']).truncate_as_string(2),
CodImpuesto1,
form.Amount(build_vars['ValorImpuestoPara'].get(CodImpuesto1, 0.0)).truncate_as_string(2),
form.Amount(build_vars['ValorTotalPagar']).truncate_as_string(2),
'%s' % build_vars['NitOFE'],
'%s' % build_vars['NumAdq'],
'%s' % build_vars['Software-PIN'],
'%d' % build_vars['TipoAmb'],
]
class DianXMLExtensionSoftwareProvider(FachoXMLExtension):
# RESOLUCION 0004: pagina 108

View File

@@ -1,5 +1,6 @@
# This file is part of facho. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
import hashlib
from functools import reduce
import copy
@@ -10,6 +11,7 @@ from collections import defaultdict
import decimal
from decimal import Decimal
import typing
from ..data.dian import codelist
DECIMAL_PRECISION = 6
@@ -161,10 +163,10 @@ class Item:
class StandardItem(Item):
def __init__(self, id_: str, description: str = '', name: str = ''):
def __init__(self, id_: str, description: str = ''):
super().__init__(id=id_,
description=description,
scheme_name=name,
scheme_name='',
scheme_id='999',
scheme_agency_id='')
@@ -208,10 +210,6 @@ class City:
raise ValueError("code [%s] not found" % (self.code))
self.name = codelist.Municipio[self.code]['name']
@dataclass
class PostalZone:
code: str = ''
@dataclass
class Address:
name: str
@@ -219,7 +217,6 @@ class Address:
city: City = City('05001')
country: Country = Country('CO')
countrysubentity: CountrySubentity = CountrySubentity('05')
postalzone: PostalZone = PostalZone('')
@dataclass
class PartyIdentification:
@@ -264,6 +261,7 @@ class TaxScheme:
code: str
name: str = ''
def __post_init__(self):
if self.code not in codelist.TipoImpuesto:
raise ValueError("code not found")
@@ -322,6 +320,7 @@ class TaxTotal:
def calculate(self, invline):
self.taxable_amount = invline.total_amount
for subtax in self.subtotals:
subtax.calculate(invline)
self.tax_amount += subtax.tax_amount
@@ -334,36 +333,6 @@ class TaxTotalOmit(TaxTotal):
def calculate(self, invline):
pass
@dataclass
class WithholdingTaxSubTotal:
percent: float
scheme: typing.Optional[TaxScheme] = None
tax_amount: Amount = Amount(0.0)
def calculate(self, invline):
if self.percent is not None:
self.tax_amount = invline.total_amount * Amount(self.percent / 100)
@dataclass
class WithholdingTaxTotal:
subtotals: list
tax_amount: Amount = Amount(0.0)
taxable_amount: Amount = Amount(0.0)
def calculate(self, invline):
self.taxable_amount = invline.total_amount
for subtax in self.subtotals:
subtax.calculate(invline)
self.tax_amount += subtax.tax_amount
class WithholdingTaxTotalOmit(WithholdingTaxTotal):
def __init__(self):
super().__init__([])
def calculate(self, invline):
pass
@dataclass
class Price:
amount: Amount
@@ -399,21 +368,6 @@ class PrePaidPayment:
#DIAN 1.7.-2020: FBD03
paid_amount: Amount = Amount(0.0)
@dataclass
class BillingResponse:
id: str
code: str
description: str
class SupportDocumentCreditNoteResponse(BillingResponse):
"""
ReferenceID: Identifica la sección del Documento
Soporte original a la cual se aplica la corrección.
ResponseCode: Código de descripción de la corrección.
Description: Descripción de la naturaleza de la corrección.
"""
@dataclass
class BillingReference:
@@ -428,6 +382,7 @@ class CreditNoteDocumentReference(BillingReference):
date: fecha de emision de la factura relacionada
"""
class DebitNoteDocumentReference(BillingReference):
"""
ident: Prefijo + Numero de la factura relacionada
@@ -500,7 +455,7 @@ class InvoiceLine:
# la factura y el percent es unico por type_code
# de subtotal
tax: typing.Optional[TaxTotal]
withholding: typing.Optional[WithholdingTaxTotal]
allowance_charge: typing.List[AllowanceCharge] = dataclasses.field(default_factory=list)
def add_allowance_charge(self, charge):
@@ -544,17 +499,8 @@ class InvoiceLine:
def taxable_amount(self):
return self.tax.taxable_amount
@property
def withholding_amount(self):
return self.withholding.tax_amount
@property
def withholding_taxable_amount(self):
return self.withholding.taxable_amount
def calculate(self):
self.tax.calculate(self)
self.withholding.calculate(self)
def __post_init__(self):
if not isinstance(self.quantity, Quantity):
@@ -563,9 +509,6 @@ class InvoiceLine:
if self.tax is None:
self.tax = TaxTotalOmit()
if self.withholding is None:
self.withholding = WithholdingTaxTotalOmit()
@dataclass
class LegalMonetaryTotal:
line_extension_amount: Amount = Amount(0.0)
@@ -601,10 +544,6 @@ class DebitNoteDocumentType(str):
# 6.1.3
return '92'
class CreditNoteSupportDocumentType(str):
def __str__(self):
return '95'
class Invoice:
def __init__(self, type_code: str):
if str(type_code) not in codelist.TipoDocumento:
@@ -624,7 +563,6 @@ class Invoice:
self.invoice_allowance_charge = []
self.invoice_prepaid_payment = []
self.invoice_billing_reference = None
self.invoice_discrepancy_response = None
self.invoice_type_code = str(type_code)
self.invoice_ident_prefix = None
@@ -700,10 +638,6 @@ class Invoice:
def set_billing_reference(self, billing_reference: BillingReference):
self.invoice_billing_reference = billing_reference
def set_discrepancy_response(self, billing_response: BillingResponse):
self.invoice_discrepancy_response = billing_response
def accept(self, visitor):
visitor.visit_payment_mean(self.invoice_payment_mean)
visitor.visit_customer(self.invoice_customer)
@@ -801,27 +735,3 @@ class DebitNote(Invoice):
if not self.invoice_ident_prefix:
self.invoice_ident_prefix = self.invoice_ident[0:6]
class SupportDocument(Invoice):
pass
class SupportDocumentCreditNote(SupportDocument):
def __init__(self, invoice_document_reference: BillingReference,
invoice_discrepancy_response: BillingResponse):
super().__init__(CreditNoteSupportDocumentType())
if not isinstance(invoice_document_reference, BillingReference):
raise TypeError('invoice_document_reference invalid type')
self.invoice_billing_reference = invoice_document_reference
self.invoice_discrepancy_response = invoice_discrepancy_response
def _get_codelist_tipo_operacion(self):
return codelist.TipoOperacionNCDS
def _check_ident_prefix(self, prefix):
if len(prefix) != 6:
raise ValueError('prefix must be 6 length')
def _set_ident_prefix_automatic(self):
if not self.invoice_ident_prefix:
self.invoice_ident_prefix = self.invoice_ident[0:6]
pass

View File

@@ -3,5 +3,3 @@ from .credit_note import *
from .debit_note import *
from .utils import *
from .attached_document import *
from .support_document import *
from .support_document_credit_note import *

View File

@@ -147,6 +147,7 @@ class DIANInvoiceXML(fe.FeXML):
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cac:TaxScheme/cbc:ID',
invoice.invoice_customer.tax_scheme.code)
#DIAN 1.7.-2020: CAJ41
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cac:TaxScheme/cbc:Name',
invoice.invoice_customer.tax_scheme.name)
@@ -420,7 +421,6 @@ class DIANInvoiceXML(fe.FeXML):
def set_invoice_totals(fexml, invoice):
tax_amount_for = defaultdict(lambda: defaultdict(lambda: Amount(0.0)))
withholding_amount_for = defaultdict(lambda: defaultdict(lambda: Amount(0.0)))
percent_for = defaultdict(lambda: None)
#requeridos para CUFE
@@ -433,36 +433,24 @@ class DIANInvoiceXML(fe.FeXML):
#tax_amount_for['03']['taxable_amount'] += 0.0
total_tax_amount = Amount(0.0)
total_withholding_amount = Amount(0.0)
for invoice_line in invoice.invoice_lines:
for subtotal in invoice_line.tax.subtotals:
if subtotal.scheme is not None:
tax_amount_for[subtotal.scheme.code]['tax_amount'] += subtotal.tax_amount
tax_amount_for[subtotal.scheme.code]['taxable_amount'] += invoice_line.taxable_amount
tax_amount_for[subtotal.scheme.code]['name'] = subtotal.scheme.name
# MACHETE ojo InvoiceLine.tax pasar a Invoice
percent_for[subtotal.scheme.code] = subtotal.percent
total_tax_amount += subtotal.tax_amount
for subtotal_withholding in invoice_line.withholding.subtotals:
if subtotal_withholding.scheme is not None:
withholding_amount_for[subtotal_withholding.scheme.code]['tax_amount'] += subtotal_withholding.tax_amount
withholding_amount_for[subtotal_withholding.scheme.code]['taxable_amount'] += invoice_line.withholding_taxable_amount
# MACHETE ojo InvoiceLine.tax pasar a Invoice
percent_for[subtotal_withholding.scheme.code] = subtotal_withholding.percent
total_withholding_amount += subtotal_withholding.tax_amount
if total_tax_amount != Amount(0.0):
fexml.placeholder_for('./cac:TaxTotal')
fexml.set_element_amount('./cac:TaxTotal/cbc:TaxAmount',
total_tax_amount)
for index, item in enumerate(tax_amount_for.items()):
cod_impuesto, amount_of = item
next_append = index > 0
@@ -498,44 +486,7 @@ class DIANInvoiceXML(fe.FeXML):
line.set_element('/cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:ID',
cod_impuesto)
line.set_element('/cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:Name',
amount_of['name'])
for index, item in enumerate(withholding_amount_for.items()):
cod_impuesto, amount_of = item
next_append = index > 0
#DIAN 1.7.-2020: FAS01
line = fexml.fragment('./cac:WithholdingTaxTotal', append=next_append)
#DIAN 1.7.-2020: FAU06
tax_amount = amount_of['tax_amount']
fexml.set_element_amount_for(line,
'/cac:WithholdingTaxTotal/cbc:TaxAmount',
tax_amount)
#DIAN 1.7.-2020: FAS05
fexml.set_element_amount_for(line,
'/cac:WithholdingTaxTotal/cac:TaxSubtotal/cbc:TaxableAmount',
amount_of['taxable_amount'])
#DIAN 1.7.-2020: FAU06
fexml.set_element_amount_for(line,
'/cac:WithholdingTaxTotal/cac:TaxSubtotal/cbc:TaxAmount',
amount_of['tax_amount'])
#DIAN 1.7.-2020: FAS07
if percent_for[cod_impuesto]:
line.set_element('/cac:WithholdingTaxTotal/cac:TaxSubtotal/cbc:Percent',
percent_for[cod_impuesto])
if percent_for[cod_impuesto]:
line.set_element('/cac:WithholdingTaxTotal/cac:TaxSubtotal/cac:TaxCategory/cbc:Percent',
percent_for[cod_impuesto])
line.set_element('/cac:WithholdingTaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:ID',
cod_impuesto)
line.set_element('/cac:WithholdingTaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:Name',
'ReteRenta')
'IVA')
# abstract method
def tag_document(fexml):
@@ -565,28 +516,6 @@ class DIANInvoiceXML(fe.FeXML):
line.set_element('./cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:ID', subtotal.scheme.code)
line.set_element('./cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:Name', subtotal.scheme.name)
def set_invoice_line_withholding(fexml, line, invoice_line):
fexml.set_element_amount_for(line,
'./cac:WithholdingTaxTotal/cbc:TaxAmount',
invoice_line.withholding_amount)
#DIAN 1.7.-2020: FAX05
fexml.set_element_amount_for(line,
'./cac:WithholdingTaxTotal/cac:TaxSubtotal/cbc:TaxableAmount',
invoice_line.withholding_taxable_amount)
for subtotal in invoice_line.withholding.subtotals:
line.set_element('./cac:WithholdingTaxTotal/cac:TaxSubtotal/cbc:TaxAmount', subtotal.tax_amount, currencyID='COP')
if subtotal.percent is not None:
line.set_element('./cac:WithholdingTaxTotal/cac:TaxSubtotal/cac:TaxCategory/cbc:Percent', '%0.2f' % round(subtotal.percent, 2))
if subtotal.scheme is not None:
#DIAN 1.7.-2020: FAX15
line.set_element('./cac:WithholdingTaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:ID', subtotal.scheme.code)
line.set_element('./cac:WithholdingTaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:Name', subtotal.scheme.name)
def set_invoice_lines(fexml, invoice):
next_append = False
for index, invoice_line in enumerate(invoice.invoice_lines):
@@ -602,9 +531,6 @@ class DIANInvoiceXML(fe.FeXML):
if not isinstance(invoice_line.tax, TaxTotalOmit):
fexml.set_invoice_line_tax(line, invoice_line)
if not isinstance(invoice_line.withholding, WithholdingTaxTotalOmit):
fexml.set_invoice_line_withholding(line, invoice_line)
line.set_element('./cac:Item/cbc:Description', invoice_line.item.description)
line.set_element('./cac:Item/cac:StandardItemIdentification/cbc:ID',
@@ -652,6 +578,7 @@ class DIANInvoiceXML(fe.FeXML):
fexml.placeholder_for('./cbc:ProfileExecutionID')
fexml.set_element('./cbc:ID', invoice.invoice_ident)
fexml.placeholder_for('./cbc:UUID')
fexml.set_element('./cbc:DocumentCurrencyCode', 'COP')
fexml.set_element('./cbc:IssueDate', invoice.invoice_issue.strftime('%Y-%m-%d'))
#DIAN 1.7.-2020: FAD10
fexml.set_element('./cbc:IssueTime', invoice.invoice_issue.strftime('%H:%M:%S-05:00'))
@@ -660,25 +587,24 @@ class DIANInvoiceXML(fe.FeXML):
listAgencyID='195',
listAgencyName='No matching global declaration available for the validation root',
listURI='http://www.dian.gov.co')
fexml.set_element('./cbc:DocumentCurrencyCode', 'COP')
fexml.set_element('./cbc:LineCountNumeric', len(invoice.invoice_lines))
if fexml.tag_document() == 'Invoice':
fexml.set_element('./cac:%sPeriod/cbc:StartDate' % (
fexml.tag_document()),
fexml.set_element('./cac:%sPeriod/cbc:StartDate' % (fexml.tag_document()),
invoice.invoice_period_start.strftime('%Y-%m-%d'))
fexml.set_element('./cac:%sPeriod/cbc:EndDate' % (
fexml.tag_document()),
fexml.set_element('./cac:%sPeriod/cbc:EndDate' % (fexml.tag_document()),
invoice.invoice_period_end.strftime('%Y-%m-%d'))
fexml.set_billing_reference(invoice)
fexml.customize(invoice)
fexml.set_supplier(invoice)
fexml.set_customer(invoice)
fexml.set_payment_mean(invoice)
fexml.set_invoice_totals(invoice)
fexml.set_legal_monetary(invoice)
fexml.set_invoice_totals(invoice)
fexml.set_invoice_lines(invoice)
fexml.set_payment_mean(invoice)
fexml.set_allowance_charge(invoice)
fexml.set_billing_reference(invoice)
return fexml
def customize(fexml, invoice):

View File

@@ -1,529 +0,0 @@
from .. import fe
from ..form import *
from datetime import datetime, date
from .attached_document import *
__all__ = ['DIANSupportDocumentXML']
class DIANSupportDocumentXML(fe.FeXML):
"""
DianSupportDocumentXML mapea objeto form.Invoice a XML segun
lo indicado para él Documento soporte en adquisiciones efectuadas con sujetos no obligados a expedir factura de venta o documento equivalente.
"""
def __init__(self, invoice, tag_document = 'Invoice'):
super().__init__(tag_document, 'http://www.dian.gov.co/contratos/facturaelectronica/v1')
#DIAN 1.1.-2021: DSAB03
#DIAN 1.1.-2021: NSAB03
self.placeholder_for('./ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sts:DianExtensions/sts:InvoiceControl')
#DIAN 1.1.-2021: DSAB13
#DIAN 1.1.-2021: NSAB13
self.placeholder_for('./ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sts:DianExtensions/sts:InvoiceSource')
#DIAN 1.1.-2021: DSAB18
#DIAN 1.1.-2021: NSAB18
self.placeholder_for('./ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sts:DianExtensions/sts:SoftwareProvider')
#DIAN 1.1.-2021: DSAB27
#DIAN 1.1.-2021: NSAB27
self.placeholder_for('./ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sts:DianExtensions/sts:SoftwareSecurityCode')
#DIAN 1.1.-2021: DSAB30 DSAB31
#DIAN 1.1.-2021: NSAB30 NSAB31
self.placeholder_for('./ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/sts:DianExtensions/sts:AuthorizationProvider/sts:AuthorizationProviderID')
#ZE02 se requiere existencia para firmar
#DIAN 1.1.-2021: DSAA02 DSAB01
#DIAN 1.1.-2021: NSAA02 NSAB01
ublextension = self.fragment('./ext:UBLExtensions/ext:UBLExtension', append=True)
#DIAN 1.1.-2021: DSAB02
#DIAN 1.1.-2021: NSAB02
extcontent = ublextension.find_or_create_element('/ext:UBLExtension/ext:ExtensionContent')
self.attach_invoice(invoice)
def set_supplier(fexml, invoice):
#DIAN 1.1.-2021: DSAJ01
#DIAN 1.1.-2021: NSAB01
fexml.placeholder_for('./cac:AccountingSupplierParty')
#DIAN 1.1.-2021: DSAJ02
#DIAN 1.1.-2021: NSAJ02
fexml.set_element('./cac:AccountingSupplierParty/cbc:AdditionalAccountID',
invoice.invoice_supplier.organization_code)
#DIAN 1.1.-2021: DSAJ07 DSAJ08
#DIAN 1.1.-2021: NSAJ07 NSAJ08
fexml.placeholder_for('./cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address')
#DIAN 1.1.-2021: DSAJ09
#DIAN 1.1.-2021: NSAJ09
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:ID',
invoice.invoice_supplier.address.city.code)
#DIAN 1.1.-2021: DSAJ10
#DIAN 1.1.-2021: NSAJ10
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:CityName',
invoice.invoice_supplier.address.city.name)
#DIAN 1.1.-2021: DSAJ73
#DIAN 1.1.-2021: NSAJ73
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:PostalZone',
invoice.invoice_supplier.address.postalzone.code)
#DIAN 1.1.-2021: DSAJ11
#DIAN 1.1.-2021: NSAJ11
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:CountrySubentity',
invoice.invoice_supplier.address.countrysubentity.name)
#DIAN 1.1.-2021: DSAJ12
#DIAN 1.1.-2021: NSAJ12
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:CountrySubentityCode',
invoice.invoice_supplier.address.countrysubentity.code)
#DIAN 1.1.-2021: NSAJ13 NSAJ14
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cac:AddressLine/cbc:Line',
invoice.invoice_supplier.address.street)
#DIAN 1.1.-2021: DSAJ15 DSAJ16
#DIAN 1.1.-2021: NSAJ15 NSAJ16
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cac:Country/cbc:IdentificationCode',
invoice.invoice_supplier.address.country.code)
#DIAN 1.1.-2021: DSAJ17
#DIAN 1.1.-2021: NSAJ17
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cac:Country/cbc:Name',
invoice.invoice_supplier.address.country.name,
#DIAN 1.1.-2021: DSAJ18
#DIAN 1.1.-2021: NSAJ18
languageID = 'es')
supplier_company_id_attrs = fe.SCHEME_AGENCY_ATTRS.copy()
supplier_company_id_attrs.update({'schemeID': invoice.invoice_supplier.ident.dv,
'schemeName': invoice.invoice_supplier.ident.type_fiscal})
#DIAN 1.1.-2021: DSAJ19
#DIAN 1.1.-2021: NSAJ19
fexml.placeholder_for('./cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme')
#DIAN 1.1.-2021: DSAJ20
#DIAN 1.1.-2021: NSAJ20
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cbc:RegistrationName',
invoice.invoice_supplier.legal_name)
#DIAN 1.1.-2021: DSAJ21
#DIAN 1.1.-2021: NSAJ21
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID',
invoice.invoice_supplier.ident,
#DIAN 1.1.-2021: DSAJ22 DSAJ23 DSAJ24 DSAJ25
#DIAN 1.1.-2021: NSAJ22 NSAJ23 NSAJ24 NSAJ25
**supplier_company_id_attrs)
#DIAN 1.1.-2021: DSAJ26
#DIAN 1.1.-2021: NSAJ26
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cbc:TaxLevelCode',
invoice.invoice_supplier.responsability_code,
listName=invoice.invoice_supplier.responsability_regime_code)
#DIAN 1.1.-2021: DSAJ39
#DIAN 1.1.-2021: NSAJ39
fexml.placeholder_for('./cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cac:TaxScheme')
#DIAN 1.1.-2021: DSAJ40
#DIAN 1.1.-2021: NSAJ40
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cac:TaxScheme/cbc:ID',
invoice.invoice_customer.tax_scheme.code)
#DIAN 1.1.-2021: DSAJ41
#DIAN 1.1.-2021: NSAJ41
fexml.set_element('./cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cac:TaxScheme/cbc:Name',
invoice.invoice_customer.tax_scheme.name)
def set_customer(fexml, invoice):
#DIAN 1.1.-2021: DSAK01
#DIAN 1.1.-2021: NSAK01
fexml.placeholder_for('./cac:AccountingCustomerParty')
#DIAN 1.1.-2021: DSAK02
#DIAN 1.1.-2021: NSAK02
fexml.set_element('./cac:AccountingCustomerParty/cbc:AdditionalAccountID',
invoice.invoice_customer.organization_code)
#DIAN 1.1.-2021: DSAK03
#DIAN 1.1.-2021: NSAK03
fexml.placeholder_for('./cac:AccountingCustomerParty/cac:Party')
#DIAN 1.1.-2021: DSAK19
#DIAN 1.1.-2021: NSAK19
fexml.placeholder_for('./cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme')
#DIAN 1.1.-2021: DSAK20
#DIAN 1.1.-2021: NSAK20
fexml.set_element('./cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:RegistrationName',
invoice.invoice_customer.legal_name)
customer_company_id_attrs = fe.SCHEME_AGENCY_ATTRS.copy()
customer_company_id_attrs.update({'schemeID': invoice.invoice_customer.ident.dv,
'schemeName': invoice.invoice_customer.ident.type_fiscal})
#DIAN 1.1.-2021: DSAK21
#DIAN 1.1.-2021: NSAK21
fexml.set_element('./cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:CompanyID',
invoice.invoice_customer.ident,
#DIAN 1.1.-2021: DSAK22 DSAK23 DSAK24 DSAK25
#DIAN 1.1.-2021: NSAK22 NSAK23 NSAK24 NSAK25
**customer_company_id_attrs)
#DIAN 1.1.-2021: DSAK26
#DIAN 1.1.-2021: NSAK26
fexml.set_element('./cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cbc:TaxLevelCode',
invoice.invoice_customer.responsability_code)
#DIAN 1.1.-2021: DSAK39
#DIAN 1.1.-2021: NSAK39
fexml.placeholder_for('./cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cac:TaxScheme')
#DIAN 1.1.-2021: DSAK40
#DIAN 1.1.-2021: NSAK40
fexml.set_element('./cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cac:TaxScheme/cbc:ID',
invoice.invoice_customer.tax_scheme.code)
#DIAN 1.1.-2021: DSAK41
#DIAN 1.1.-2021: NSAK41
fexml.set_element('./cac:AccountingCustomerParty/cac:Party/cac:PartyTaxScheme/cac:TaxScheme/cbc:Name',
invoice.invoice_customer.tax_scheme.name)
def set_payment_mean(fexml, invoice):
payment_mean = invoice.invoice_payment_mean
#DIAN 1.1.-2021: DSAN01 DSAN02
#DIAN 1.1.-2021: NSAN02 NSAN02
fexml.set_element('./cac:PaymentMeans/cbc:ID', payment_mean.id)
#DIAN 1.1.-2021: DSAN03
#DIAN 1.1.-2021: NSAN03
fexml.set_element('./cac:PaymentMeans/cbc:PaymentMeansCode', payment_mean.code)
#DIAN 1.1.-2021: DSAN04
#DIAN 1.1.-2021: NSAN04
fexml.set_element('./cac:PaymentMeans/cbc:PaymentDueDate', payment_mean.due_at.strftime('%Y-%m-%d'))
#DIAN 1.1.-2021: DSAN05
#DIAN 1.1.-2021: NSAN05
fexml.set_element('./cac:PaymentMeans/cbc:PaymentID', payment_mean.payment_id)
def set_element_amount_for(fexml, xml, xpath, amount):
if not isinstance(amount, Amount):
raise TypeError("amount not is Amount")
xml.set_element(xpath, amount, currencyID=amount.currency.code)
def set_element_amount(fexml, xpath, amount):
if not isinstance(amount, Amount):
raise TypeError("amount not is Amount")
fexml.set_element(xpath, amount, currencyID=amount.currency.code)
def set_legal_monetary(fexml, invoice):
#DIAN 1.1.-2021: DSAU01 DSAU02 DSAU03
#DIAN 1.1.-2021: NSAU01 NSAU02 NSAU03
fexml.set_element_amount('./cac:LegalMonetaryTotal/cbc:LineExtensionAmount',
invoice.invoice_legal_monetary_total.line_extension_amount)
#DIAN 1.1.-2021: DSAU04 DSAU05
#DIAN 1.1.-2021: NSAU04 NSAU05
fexml.set_element_amount('./cac:LegalMonetaryTotal/cbc:TaxExclusiveAmount',
invoice.invoice_legal_monetary_total.tax_exclusive_amount)
#DIAN 1.1.-2021: DSAU06 DSAU07
#DIAN 1.1.-2021: NSAU06 DSAU07
fexml.set_element_amount('./cac:LegalMonetaryTotal/cbc:TaxInclusiveAmount',
invoice.invoice_legal_monetary_total.tax_inclusive_amount)
#DIAN 1.1.-2021: DSAU10 DSAU11
#DIAN 1.1.-2021: NSAU10 DSAU11
fexml.set_element_amount('./cac:LegalMonetaryTotal/cbc:ChargeTotalAmount',
invoice.invoice_legal_monetary_total.charge_total_amount)
#DIAN 1.1.-2021: DSAU14 DSAU15
#DIAN 1.1.-2021: NSAU14 DSAU15
fexml.set_element_amount('./cac:LegalMonetaryTotal/cbc:PayableAmount',
invoice.invoice_legal_monetary_total.payable_amount)
def _set_invoice_document_reference(fexml, reference):
fexml._do_set_billing_reference(reference, 'cac:InvoiceDocumentReference')
def _set_credit_note_document_reference(fexml, reference):
fexml._do_set_billing_reference(reference, 'cac:CreditNoteDocumentReference')
def _set_debit_note_document_reference(fexml, reference):
fexml._do_set_billing_reference(reference, 'cac:DebitNoteDocumentReference')
def _do_set_billing_reference(fexml, reference, tag_document):
if tag_document == 'Invoice':
schemeName = 'CUFE-SHA384'
else:
schemeName = 'CUDS-SHA384'
fexml.set_element('./cac:BillingReference/%s/cbc:ID' %(tag_document),
reference.ident)
fexml.set_element('./cac:BillingReference/cac:InvoiceDocumentReference/cbc:UUID',
reference.uuid,
schemeName=schemeName)
fexml.set_element('./cac:BillingReference/cac:InvoiceDocumentReference/cbc:IssueDate',
reference.date.strftime("%Y-%m-%d"))
def set_billing_reference(fexml, invoice):
reference = invoice.invoice_billing_reference
if reference is None:
return
if isinstance(reference, DebitNoteDocumentReference):
return fexml._set_debit_note_document_reference(reference)
if isinstance(reference, CreditNoteDocumentReference):
return fexml._set_credit_note_document_reference(reference)
if isinstance(reference, InvoiceDocumentReference):
return fexml._set_invoice_document_reference(reference)
def set_discrepancy_response(fexml, invoice):
reference = invoice.invoice_discrepancy_response
if reference is None:
return
if isinstance(reference, DebitNoteDocumentReference):
return fexml._set_debit_note_document_reference(reference)
if isinstance(reference, CreditNoteDocumentReference):
return fexml._set_credit_note_document_reference(reference)
if isinstance(reference, InvoiceDocumentReference):
return fexml._set_invoice_document_reference(reference)
fexml.set_element('./cac:DiscrepancyResponse/cbc:ReferenceID',
reference.id)
fexml.set_element('./cac:DiscrepancyResponse/cbc:ResponseCode',
reference.code)
fexml.set_element('./cac:DiscrepancyResponse/cbc:Description',
reference.description)
def set_invoice_totals(fexml, invoice):
tax_amount_for = defaultdict(lambda: defaultdict(lambda: Amount(0.0)))
percent_for = defaultdict(lambda: None)
total_tax_amount = Amount(0.0)
for invoice_line in invoice.invoice_lines:
for subtotal in invoice_line.tax.subtotals:
if subtotal.scheme is not None:
tax_amount_for[subtotal.scheme.code]['tax_amount'] += subtotal.tax_amount
tax_amount_for[subtotal.scheme.code]['taxable_amount'] += invoice_line.taxable_amount
# MACHETE ojo InvoiceLine.tax pasar a Invoice
percent_for[subtotal.scheme.code] = subtotal.percent
total_tax_amount += subtotal.tax_amount
if total_tax_amount != Amount(0.0):
fexml.placeholder_for('./cac:TaxTotal')
fexml.set_element_amount('./cac:TaxTotal/cbc:TaxAmount',
total_tax_amount)
for index, item in enumerate(tax_amount_for.items()):
cod_impuesto, amount_of = item
next_append = index > 0
#DIAN 1.7.-2020: FAS01
line = fexml.fragment('./cac:TaxTotal', append=next_append)
#DIAN 1.7.-2020: FAU06
tax_amount = amount_of['tax_amount']
fexml.set_element_amount_for(line,
'/cac:TaxTotal/cbc:TaxAmount',
tax_amount)
#DIAN 1.7.-2020: FAS05
fexml.set_element_amount_for(line,
'/cac:TaxTotal/cac:TaxSubtotal/cbc:TaxableAmount',
amount_of['taxable_amount'])
#DIAN 1.7.-2020: FAU06
fexml.set_element_amount_for(line,
'/cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount',
amount_of['tax_amount'])
#DIAN 1.7.-2020: FAS07
if percent_for[cod_impuesto]:
line.set_element('/cac:TaxTotal/cac:TaxSubtotal/cbc:Percent',
percent_for[cod_impuesto])
if percent_for[cod_impuesto]:
line.set_element('/cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cbc:Percent',
percent_for[cod_impuesto])
line.set_element('/cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:ID',
cod_impuesto)
line.set_element('/cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:Name',
'IVA')
# abstract method
def tag_document(fexml):
return 'Invoice'
# abstract method
def tag_document_concilied(fexml):
return 'Invoiced'
def set_invoice_line_withholding(fexml, line, invoice_line):
fexml.set_element_amount_for(line,
'./cac:WithholdingTaxTotal/cbc:TaxAmount',
invoice_line.withholding_amount)
#DIAN 1.7.-2020: FAX05
fexml.set_element_amount_for(line,
'./cac:WithholdingTaxTotal/cac:TaxSubtotal/cbc:TaxableAmount',
invoice_line.withholding_taxable_amount)
for subtotal in invoice_line.withholding.subtotals:
line.set_element('./cac:WithholdingTaxTotal/cac:TaxSubtotal/cbc:TaxAmount', subtotal.tax_amount, currencyID='COP')
if subtotal.percent is not None:
line.set_element('./cac:WithholdingTaxTotal/cac:TaxSubtotal/cac:TaxCategory/cbc:Percent', '%0.2f' % round(subtotal.percent, 2))
if subtotal.scheme is not None:
#DIAN 1.7.-2020: FAX15
line.set_element('./cac:WithholdingTaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:ID', subtotal.scheme.code)
line.set_element('./cac:WithholdingTaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:Name', subtotal.scheme.name)
def set_invoice_line_tax(fexml, line, invoice_line):
fexml.set_element_amount_for(line,
'./cac:TaxTotal/cbc:TaxAmount',
invoice_line.tax_amount)
#DIAN 1.7.-2020: FAX05
fexml.set_element_amount_for(line,
'./cac:TaxTotal/cac:TaxSubtotal/cbc:TaxableAmount',
invoice_line.taxable_amount)
for subtotal in invoice_line.tax.subtotals:
line.set_element('./cac:TaxTotal/cac:TaxSubtotal/cbc:TaxAmount', subtotal.tax_amount, currencyID='COP')
if subtotal.percent is not None:
line.set_element('./cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cbc:Percent', '%0.2f' % round(subtotal.percent, 2))
if subtotal.scheme is not None:
#DIAN 1.7.-2020: FAX15
line.set_element('./cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:ID', subtotal.scheme.code)
line.set_element('./cac:TaxTotal/cac:TaxSubtotal/cac:TaxCategory/cac:TaxScheme/cbc:Name', subtotal.scheme.name)
def set_invoice_lines(fexml, invoice):
next_append = False
for index, invoice_line in enumerate(invoice.invoice_lines):
line = fexml.fragment('./cac:%sLine' % (fexml.tag_document()), append=next_append)
next_append = True
line.set_element('./cbc:ID', index + 1)
line.set_element('./cbc:%sQuantity' % (fexml.tag_document_concilied()), invoice_line.quantity, unitCode = 'NAR')
fexml.set_element_amount_for(line,
'./cbc:LineExtensionAmount',
invoice_line.total_amount)
period = line.fragment('./cac:InvoicePeriod')
period.set_element('./cbc:StartDate',
datetime.now().strftime('%Y-%m-%d'))
period.set_element('./cbc:DescriptionCode',
'1')
period.set_element('./cbc:Description',
'Por operación')
if not isinstance(invoice_line.tax, TaxTotalOmit):
fexml.set_invoice_line_tax(line, invoice_line)
if not isinstance(invoice_line.withholding, WithholdingTaxTotalOmit):
fexml.set_invoice_line_withholding(line, invoice_line)
line.set_element('./cac:Item/cbc:Description', invoice_line.item.description)
line.set_element('./cac:Item/cac:StandardItemIdentification/cbc:ID',
invoice_line.item.id,
schemeID=invoice_line.item.scheme_id,
schemeName=invoice_line.item.scheme_name,
schemeAgencyID=invoice_line.item.scheme_agency_id)
line.set_element('./cac:Price/cbc:PriceAmount', invoice_line.price.amount, currencyID=invoice_line.price.amount.currency.code)
#DIAN 1.7.-2020: FBB04
line.set_element('./cac:Price/cbc:BaseQuantity',
invoice_line.quantity,
unitCode=invoice_line.quantity.code)
for idx, charge in enumerate(invoice_line.allowance_charge):
next_append_charge = idx > 0
fexml.append_allowance_charge(line, index + 1, charge, append=next_append_charge)
def set_allowance_charge(fexml, invoice):
for idx, charge in enumerate(invoice.invoice_allowance_charge):
next_append = idx > 0
fexml.append_allowance_charge(fexml, idx + 1, charge, append=next_append)
def append_allowance_charge(fexml, parent, idx, charge, append=False):
line = parent.fragment('./cac:AllowanceCharge', append=append)
#DIAN 1.7.-2020: FAQ02
line.set_element('./cbc:ID', idx)
#DIAN 1.7.-2020: FAQ03
line.set_element('./cbc:ChargeIndicator', str(charge.charge_indicator).lower())
if charge.reason:
line.set_element('./cbc:AllowanceChargeReasonCode', charge.reason.code)
line.set_element('./cbc:allowanceChargeReason', charge.reason.reason)
line.set_element('./cbc:MultiplierFactorNumeric', str(round(charge.multiplier_factor_numeric, 2)))
fexml.set_element_amount_for(line, './cbc:Amount', charge.amount)
fexml.set_element_amount_for(line, './cbc:BaseAmount', charge.base_amount)
def attach_invoice(fexml, invoice):
"""adiciona etiquetas a FEXML y retorna FEXML
en caso de fallar validacion retorna None"""
fexml.placeholder_for('./ext:UBLExtensions')
fexml.set_element('./cbc:UBLVersionID', 'UBL 2.1')
fexml.set_element('./cbc:CustomizationID', invoice.invoice_operation_type)
fexml.placeholder_for('./cbc:ProfileID')
fexml.placeholder_for('./cbc:ProfileExecutionID')
fexml.set_element('./cbc:ID', invoice.invoice_ident)
fexml.placeholder_for('./cbc:UUID')
fexml.set_element('./cbc:DocumentCurrencyCode', 'COP')
fexml.set_element('./cbc:IssueDate', invoice.invoice_issue.strftime('%Y-%m-%d'))
#DIAN 1.7.-2020: FAD10
fexml.set_element('./cbc:IssueTime', invoice.invoice_issue.strftime('%H:%M:%S-05:00'))
fexml.set_element('./cbc:%sTypeCode' % (fexml.tag_document()),
invoice.invoice_type_code,
listAgencyID='195',
listAgencyName='No matching global declaration available for the validation root',
listURI='http://www.dian.gov.co')
fexml.set_element('./cbc:LineCountNumeric', len(invoice.invoice_lines))
fexml.set_element('./cac:%sPeriod/cbc:StartDate' % (fexml.tag_document()),
invoice.invoice_period_start.strftime('%Y-%m-%d'))
fexml.set_element('./cac:%sPeriod/cbc:EndDate' % (fexml.tag_document()),
invoice.invoice_period_end.strftime('%Y-%m-%d'))
fexml.customize(invoice)
fexml.set_supplier(invoice)
fexml.set_customer(invoice)
fexml.set_legal_monetary(invoice)
fexml.set_invoice_totals(invoice)
fexml.set_invoice_lines(invoice)
fexml.set_payment_mean(invoice)
fexml.set_allowance_charge(invoice)
fexml.set_discrepancy_response(invoice)
fexml.set_billing_reference(invoice)
return fexml
def customize(fexml, invoice):
"""adiciona etiquetas a FEXML y retorna FEXML
en caso de fallar validacion retorna None"""

View File

@@ -1,21 +0,0 @@
from .. import fe
from ..form import *
from .support_document import DIANSupportDocumentXML
__all__ = ['DIANSupportDocumentCreditNoteXML']
class DIANSupportDocumentCreditNoteXML(DIANSupportDocumentXML):
"""
DianInvoiceXML mapea objeto form.Invoice a XML segun
lo indicado para la facturacion electronica.
"""
def __init__(self, invoice):
super(DIANSupportDocumentCreditNoteXML, self).__init__(invoice, 'CreditNote')
def tag_document(fexml):
return 'CreditNote'
def tag_document_concilied(fexml):
return 'Credited'

View File

@@ -53,20 +53,14 @@ class FechaPago(Fecha):
@dataclass
class Novedad:
# cune de nomina a relacionar
# NIE204
cune: str
# NIE199
activa: bool = False
value: False
def apply(self, fragment):
if self.cune != "":
fragment.set_attributes('./Novedad',
CUNENov=self.cune,
CUNENov=self.value,
)
def post_apply(self, fexml, scopexml, fragment):
scopexml.set_element('./Novedad', self.activa)
scopexml.set_element('./Novedad', "false")
@dataclass
@@ -144,12 +138,13 @@ class Proveedor:
ambiente = fexml.get_element_attribute(scopexml.xpath_from_root('/InformacionGeneral'), 'Ambiente')
codigo_qr = f"https://catalogo-vpfe.dian.gov.co/document/searchqr?documentkey={cune}"
if InformacionGeneral.AMBIENTE_PRUEBAS == ambiente:
if InformacionGeneral.AMBIENTE_PRUEBAS.same(ambiente):
codigo_qr = f"https://catalogo-vpfe-hab.dian.gov.co/document/searchqr?documentkey={cune}"
elif ambiente is None:
raise RuntimeError('fail to get InformacionGeneral/@Ambiente')
scopexml.set_element('./CodigoQR', codigo_qr)
scopexml.set_element('./Novedad', "false")
# NIE020
software_code = self._software_security_code(fexml, scopexml)
@@ -182,7 +177,6 @@ class Metadata:
proveedor: Proveedor
def apply(self, novedad, numero_secuencia_xml, lugar_generacion_xml, proveedor_xml):
if novedad:
self.novedad.apply(novedad)
self.secuencia.apply(numero_secuencia_xml)
self.lugar_generacion.apply(lugar_generacion_xml, './LugarGeneracionXML')
@@ -190,7 +184,6 @@ class Metadata:
def post_apply(self, fexml, scopexml, novedad, numero_secuencia_xml, lugar_generacion_xml, proveedor_xml):
self.proveedor.post_apply(fexml, scopexml, proveedor_xml)
if novedad:
self.novedad.post_apply(fexml, scopexml, proveedor_xml)
@dataclass
@@ -219,8 +212,9 @@ class InformacionGeneral:
class TIPO_AMBIENTE:
valor: str
def __eq__(self, other):
return self.valor == str(other)
@classmethod
def same(cls, value):
return cls.valor == str(value)
# TABLA 5.1.1
@dataclass
@@ -237,34 +231,11 @@ class InformacionGeneral:
def __str__(self):
self.valor
# TABLA 5.5.7
@dataclass
class TIPO_XML:
valor: str
def __eq__(self, other):
return self.valor == str(other)
@dataclass
class TIPO_XML_NORMAL(TIPO_XML):
valor: str = '102'
def __str__(self):
self.valor
@dataclass
class TIPO_XML_AJUSTES(TIPO_XML):
valor: str = '103'
def __str__(self):
self.valor
fecha_generacion: typing.Union[str, Fecha]
hora_generacion: str
periodo_nomina: PeriodoNomina
tipo_moneda: TipoMoneda
tipo_ambiente: TIPO_AMBIENTE
tipo_xml: TIPO_XML
software_pin: str
def __post_init__(self):
@@ -279,7 +250,7 @@ class InformacionGeneral:
# NIE202
# TABLA 5.5.2
# TODO(bit4bit) solo NominaIndividual
TipoXML = self.tipo_xml.valor,
TipoXML = '102',
# NIE024
CUNE = None,
# NIE025
@@ -338,18 +309,15 @@ class DianXMLExtensionSigner(fe.DianXMLExtensionSigner):
class DIANNominaXML:
def __init__(self, tag_document, xpath_ajuste=None, schemaLocation=None, namespace_ajuste=None):
def __init__(self, tag_document, xpath_ajuste=None,schemaLocation=None):
self.informacion_general_version = None
self.tag_document = tag_document
self.fexml = fe.FeXML(tag_document, 'http://www.dian.gov.co/contratos/facturaelectronica/v1')
if namespace_ajuste:
self.fexml = fe.FeXML(tag_document, namespace_ajuste)
else:
self.fexml = fe.FeXML(tag_document, 'dian:gov:co:facturaelectronica:NominaIndividual')
if schemaLocation is not None:
self.fexml.root.set("SchemaLocation", "")
self.fexml.root.set("schemaLocation", schemaLocation)
self.fexml.root.set("change", schemaLocation)
# layout, la dian requiere que los elementos
# esten ordenados segun el anexo tecnico
@@ -361,7 +329,6 @@ class DIANNominaXML:
self.root_fragment = self.fexml.fragment(xpath_ajuste)
self.root_fragment.placeholder_for('./ReemplazandoPredecesor', optional=True)
self.root_fragment.placeholder_for('./EliminandoPredecesor', optional=True)
if not namespace_ajuste:
self.root_fragment.placeholder_for('./Novedad', optional=False)
self.root_fragment.placeholder_for('./Periodo')
self.root_fragment.placeholder_for('./NumeroSecuenciaXML')
@@ -375,10 +342,8 @@ class DIANNominaXML:
self.root_fragment.placeholder_for('./FechasPagos')
self.root_fragment.placeholder_for('./Devengados/Basico')
self.root_fragment.placeholder_for('./Devengados/Transporte', optional=True)
if not namespace_ajuste:
self.novedad = self.root_fragment.fragment('./Novedad')
else:
self.novedad = None
self.informacion_general_xml = self.root_fragment.fragment('./InformacionGeneral')
self.periodo_xml = self.root_fragment.fragment('./Periodo')
self.fecha_pagos_xml = self.root_fragment.fragment('./FechasPagos')
@@ -398,7 +363,6 @@ class DIANNominaXML:
if not isinstance(metadata, Metadata):
raise ValueError('se espera tipo Metadata')
self.metadata = metadata
self.metadata.apply(self.novedad, self.numero_secuencia_xml, self.lugar_generacion_xml, self.proveedor_xml)
def asignar_informacion_general(self, general):
@@ -555,8 +519,6 @@ class DIANNominaXML:
devengados_total = Amount(0.0)
for devengado in devengados:
devengados_total += devengado
# TODO(bit4bit) nque valor va redondeado?
# NIE186
self.root_fragment.set_element('./Redondeo', str(round(0,2)))
self.root_fragment.set_element('./DevengadosTotal', str(round(devengados_total,2)))
@@ -592,8 +554,6 @@ class DIANNominaIndividualDeAjuste(DIANNominaXML):
fecha_generacion: str
def apply(self, fragment):
# NIAE214
fragment.set_element('./TipoNota', '1')
fragment.set_element('./Reemplazar/ReemplazandoPredecesor', None,
# NIAE090
NumeroPred = self.numero,
@@ -604,11 +564,9 @@ class DIANNominaIndividualDeAjuste(DIANNominaXML):
)
def __init__(self):
schema = "dian:gov:co:facturaelectronica:NominaIndividualDeAjuste NominaIndividualDeAjusteElectronicaXSD.xsd"
super().__init__('NominaIndividualDeAjuste', './Reemplazar', schemaLocation=schema, namespace_ajuste='dian:gov:co:facturaelectronica:NominaIndividualDeAjuste')
self.informacion_general_version = 'V1.0: Nota de Ajuste de Documento Soporte de Pago de Nómina Electrónica'
super().__init__('NominaIndividualDeAjuste', './Reemplazar')
# NIAE214
self.root_fragment.set_element('./TipoNota', '1')
def asignar_predecesor(self, predecesor):
if not isinstance(predecesor, self.Predecesor):
@@ -625,7 +583,6 @@ class DIANNominaIndividualDeAjuste(DIANNominaXML):
fecha_generacion: str
def apply(self, fragment):
fragment.set_element('./TipoNota', '2')
fragment.set_element('./Eliminar/EliminandoPredecesor', None,
# NIAE090
NumeroPred = self.numero,
@@ -636,9 +593,9 @@ class DIANNominaIndividualDeAjuste(DIANNominaXML):
)
def __init__(self):
schema = "dian:gov:co:facturaelectronica:NominaIndividualDeAjuste NominaIndividualDeAjusteElectronicaXSD.xsd"
super().__init__('NominaIndividualDeAjuste', './Eliminar', schemaLocation=schema, namespace_ajuste='dian:gov:co:facturaelectronica:NominaIndividualDeAjuste')
super().__init__('NominaIndividualDeAjuste', './Eliminar')
self.root_fragment.set_element('./TipoNota', '2')
self.informacion_general_version = "V1.0: Nota de Ajuste de Documento Soporte de Pago de Nómina Electrónica"
def asignar_predecesor(self, predecesor):

3
scrips/nomina.csv Normal file
View File

@@ -0,0 +1,3 @@
P,#,Nombre,P_Apellido,S_Apellido,Cédula,Dirección,Salario,Días,Salud,Pension,Aux Transpo,Sueldo,Fecha_pago,Fecha_Ingreso,Fecha_inicio,Fecha_fin,Fecha_generación,hora_generacion
N,000005,JUAN,GONZALEZ,CARDONA,71380802,CL 35C 102-17 BL 7 AP 101,2400000,30,96000,96000,140606,2400000,2024-04-30,2022-01-05,2024-04-01,2024-04-30,2024-04-30,08:01:00
N,000006,VIVIANA,GIRALDO,VASQUEZ,32257132,CL 35C 102-17 BL 7 AP 101,1160000,30,46400,46400,140606,1160000,2024-04-30,2022-09-05,2024-04-01,2024-04-30,2024-04-30,08:01:00
1 P # Nombre P_Apellido S_Apellido Cédula Dirección Salario Días Salud Pension Aux Transpo Sueldo Fecha_pago Fecha_Ingreso Fecha_inicio Fecha_fin Fecha_generación hora_generacion
2 N 000005 JUAN GONZALEZ CARDONA 71380802 CL 35C 102-17 BL 7 AP 101 2400000 30 96000 96000 140606 2400000 2024-04-30 2022-01-05 2024-04-01 2024-04-30 2024-04-30 08:01:00
3 N 000006 VIVIANA GIRALDO VASQUEZ 32257132 CL 35C 102-17 BL 7 AP 101 1160000 30 46400 46400 140606 1160000 2024-04-30 2022-09-05 2024-04-01 2024-04-30 2024-04-30 08:01:00

177
scrips/nomina.sh Normal file
View File

@@ -0,0 +1,177 @@
#!/bin/bash
SOFTWARE_PIN='20234'
SOFTWARE_ID='100b0d10-0ca0-4ad4-a894-b704a568cbf3'
NIT='901575528'
DV='2'
TIPO_AMBIENTE='AMBIENTE_PRUEBAS'
RAZON_SOCIAL='BICI PIZZA S.A.S'
SET_PRUEBAS='be4d232c-9c7b-4542-b24d-6044c4e316ce'
PASSPHARASE='7U3XbtZ76W'
#La ruta donde se encuentren estos archivos
LLAVE_PRIVADA='privada.pem'
LLAVE_PUBLICA='publica.pem'
CERTIFICADO='Certificado.pfx'
HABILITACION='True'
ARCHIVO_CSV='nomina.csv'
IFS=,
while read line; do
field=( $line )
Prefijo=${field[0]}
Numero=${field[1]}
Nombre=${field[2]}
P_Apellido=${field[3]}
S_Apellifo=${field[4]}
Cedula=${field[5]}
Direccion=${field[6]}
Salario=${field[7]}
Sueldo=${field[12]}
Dias=${field[8]}
Salud=${field[9]}
Pension=${field[10]}
AuxTp=${field[11]}
Pago=${field[13]}
Ingreso=${field[14]}
Inicio=${field[15]}
Fin=${field[16]}
Generacion=${field[17]}
Hora=${field[18]}
echo "
from facho import fe
SOFTWARE_PIN='${SOFTWARE_PIN}'
SOFTWARE_ID='${SOFTWARE_ID}'
NIT='${NIT}'
DV='${DV}'
def extensions(nomina):
return []
def nomina():
nomina = fe.nomina.DIANNominaIndividual()
nomina.asignar_fecha_pago('${Pago}')
nomina.asignar_metadata(fe.nomina.Metadata(
novedad=fe.nomina.Novedad(value='false'),
secuencia=fe.nomina.NumeroSecuencia(
prefijo='${Prefijo}',
consecutivo='${Numero}'
),
lugar_generacion=fe.nomina.Lugar(
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
),
proveedor=fe.nomina.Proveedor(
razon_social='${RAZON_SOCIAL}',
nit=NIT,
dv=DV,
software_id=SOFTWARE_ID,
software_pin=SOFTWARE_PIN
)
))
nomina.asignar_periodo(fe.nomina.Periodo(
fecha_ingreso= '${Ingreso}',
fecha_liquidacion_inicio='${Inicio}',
fecha_liquidacion_fin='${Fin}',
fecha_generacion='${Generacion}'
))
nomina.asignar_informacion_general(fe.nomina.InformacionGeneral(
fecha_generacion = '${Generacion}',
hora_generacion = '${Hora}-05:00',
tipo_ambiente = fe.nomina.InformacionGeneral.${TIPO_AMBIENTE},
software_pin = SOFTWARE_PIN,
periodo_nomina = fe.nomina.PeriodoNomina(code='1'),
tipo_moneda = fe.nomina.TipoMoneda(code='COP')
))
nomina.asignar_pago(fe.nomina.Pago(
forma=fe.nomina.FormaPago(
code='1',
),
metodo=fe.nomina.MetodoPago(
code='10'
)
))
nomina.asignar_empleador(fe.nomina.Empleador(
razon_social='${RAZON_SOCIAL}',
nit = NIT,
dv = DV,
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
direccion = 'calle etrivial'
))
nomina.asignar_trabajador(fe.nomina.Trabajador(
tipo_contrato = fe.nomina.TipoContrato(
code = '1'
),
alto_riesgo = False,
tipo_documento = fe.nomina.TipoDocumento(
code = '11'
),
primer_apellido = '${P_Apellido}',
segundo_apellido = '${S_Apellido}',
primer_nombre = '${Nombre}',
lugar_trabajo = fe.nomina.LugarTrabajo(
pais = fe.nomina.Pais(code='CO'),
departamento = fe.nomina.Departamento(code='05'),
municipio = fe.nomina.Municipio(code='05001'),
direccion = '${Direccion}'
),
numero_documento = NIT,
tipo = fe.nomina.TipoTrabajador(
code = '01'
),
salario_integral = False,
sueldo = fe.nomina.Amount(${Sueldo})
))
nomina.adicionar_devengado(fe.nomina.DevengadoBasico(
dias_trabajados = ${field[8]},
sueldo_trabajado = fe.nomina.Amount(${Salario})
))
nomina.adicionar_deduccion(fe.nomina.DeduccionSalud(
porcentaje = fe.nomina.Amount(4),
deduccion = fe.nomina.Amount(${Salud})
))
nomina.adicionar_deduccion(fe.nomina.DeduccionFondoPension(
porcentaje=fe.nomina.Amount(4),
deduccion = fe.nomina.Amount(${Pension})
))
return nomina
" > "${Prefijo}${Numero}".py
facho generate-nomina --private-key ${CERTIFICADO} --passphrase ${PASSPHARASE} --use-cache-policy --sign "${field[0]}${field[1]}".py "${Prefijo}${Numero}".xml
CUNE=`grep -oP "<CodigoQR>(.*)</CodigoQR>" "${Prefijo}${Numero}".xml | sed -n 's/.*documentkey=\([^<]*\)<\/CodigoQR>.*/\1/p'`
zip "${field[0]}${field[1]}".zip "${field[0]}${field[1]}".xml
if [ "$HABILITACION" == "True" ];then
facho soap-send-test-set-async --private-key ${LLAVE_PRIVADA} --public-key ${LLAVE_PUBLICA} --habilitacion --password ${PASSPHARASE} --test-setid ${SET_PRUEBAS} "${field[0]}${field[1]}".xml "${field[0]}${field[1]}".zip
else
facho soap-send-nomina-sync --private-key ${LLAVE_PRIVADA} --public-key ${LLAVE_PUBLICA} --password ${PASSPHARASE} "${field[0]}${field[1]}".xml "${field[0]}${field[1]}".zip --produccion
fi
done < ${ARCHIVO_CSV}

View File

@@ -13,18 +13,19 @@ with open('README.rst') as readme_file:
with open('HISTORY.rst') as history_file:
history = history_file.read()
requirements = ['Click>=6.0',
'zeep==4.0.0',
'lxml==4.6.3',
requirements = ['Click>=8.1.7',
'zeep==4.2.1',
'lxml==5.2.2',
'cryptography==3.3.2',
'pyOpenSSL==20.0.1',
'xmlsig==0.1.7',
'xades==0.2.2',
'xmlsec==1.3.12',
'xades==1.0.0',
'xmlsec==1.3.14',
'python-dateutil==2.9.0.post0',
# usamos esta dependencia en runtime
# para forzar uso de policy_id de archivo local
'mock>=2.0.0',
'xmlschema>=1.8']
'mock>=5.1.0',
'xmlschema>=3.0.0' ]
setup_requirements = ['pytest-runner', ]

View File

@@ -4,7 +4,6 @@
# this repository contains the full copyright notices and license terms.
"""Tests for `facho` package."""
import re
import pytest
@@ -28,8 +27,8 @@ def test_adicionar_devengado_Basico():
))
xml = nomina.toFachoXML()
assert xml.get_element_attribute('/nomina:NominaIndividual/Devengados/Basico', 'DiasTrabajados') == '30'
assert xml.get_element_attribute('/nomina:NominaIndividual/Devengados/Basico', 'SueldoTrabajado') == '1000000.00'
assert xml.get_element_attribute('/fe:NominaIndividual/Devengados/Basico', 'DiasTrabajados') == '30'
assert xml.get_element_attribute('/fe:NominaIndividual/Devengados/Basico', 'SueldoTrabajado') == '1000000.00'
def test_adicionar_devengado_transporte():
nomina = fe.nomina.DIANNominaIndividual()
@@ -40,7 +39,7 @@ def test_adicionar_devengado_transporte():
xml = nomina.toFachoXML()
assert xml.get_element_attribute('/nomina:NominaIndividual/Devengados/Transporte', 'AuxilioTransporte') == '2000000.0'
assert xml.get_element_attribute('/fe:NominaIndividual/Devengados/Transporte', 'AuxilioTransporte') == '2000000.0'
def test_adicionar_devengado_comprobante_total():
nomina = fe.nomina.DIANNominaIndividual()
@@ -58,7 +57,7 @@ def test_adicionar_devengado_comprobante_total():
xml = nomina.toFachoXML()
assert xml.get_element_text('/nomina:NominaIndividual/ComprobanteTotal') == '1000000.00'
assert xml.get_element_text('/fe:NominaIndividual/ComprobanteTotal') == '1000000.00'
def test_adicionar_devengado_comprobante_total_cero():
nomina = fe.nomina.DIANNominaIndividual()
@@ -75,7 +74,7 @@ def test_adicionar_devengado_comprobante_total_cero():
xml = nomina.toFachoXML()
assert xml.get_element_text('/nomina:NominaIndividual/ComprobanteTotal') == '0.00'
assert xml.get_element_text('/fe:NominaIndividual/ComprobanteTotal') == '0.00'
def test_adicionar_devengado_transporte_muchos():
nomina = fe.nomina.DIANNominaIndividual()
@@ -90,7 +89,7 @@ def test_adicionar_devengado_transporte_muchos():
xml = nomina.toFachoXML()
print(xml)
assert xml.get_element_text('/nomina:NominaIndividual/DevengadosTotal') == '5000000.00'
assert xml.get_element_text('/fe:NominaIndividual/DevengadosTotal') == '5000000.00'
def test_adicionar_deduccion_salud():
nomina = fe.nomina.DIANNominaIndividual()
@@ -107,7 +106,7 @@ def test_adicionar_deduccion_salud():
xml = nomina.toFachoXML()
print(xml)
assert xml.get_element_text('/nomina:NominaIndividual/DeduccionesTotal') == '1000.00'
assert xml.get_element_text('/fe:NominaIndividual/DeduccionesTotal') == '1000.00'
def test_nomina_obligatorios_segun_anexo_tecnico():
nomina = fe.nomina.DIANNominaIndividual()
@@ -123,10 +122,6 @@ def test_nomina_xml():
nomina = fe.nomina.DIANNominaIndividual()
nomina.asignar_metadata(fe.nomina.Metadata(
novedad=fe.nomina.Novedad(
activa = True,
cune = "N0111"
),
secuencia=fe.nomina.NumeroSecuencia(
prefijo = 'N',
consecutivo='00001'
@@ -156,7 +151,6 @@ def test_nomina_xml():
hora_generacion = '1053:10-05:00',
tipo_ambiente = fe.nomina.InformacionGeneral.AMBIENTE_PRODUCCION,
software_pin = '693',
tipo_xml = fe.nomina.InformacionGeneral.TIPO_XML_NORMAL,
periodo_nomina = fe.nomina.PeriodoNomina(code='1'),
tipo_moneda = fe.nomina.TipoMoneda(code='COP')
))
@@ -213,26 +207,25 @@ def test_nomina_xml():
))
xml = nomina.toFachoXML()
expected_cune = 'b8f9b6c24de07ffd92ea5467433a3b69357cfaffa7c19722db94b2e0eca41d057085a54f484b5da15ff585e773b0b0ab'
assert xml.get_element_attribute('/nomina:NominaIndividual/InformacionGeneral', 'CUNE') == expected_cune
assert xml.get_element_attribute('/nomina:NominaIndividual/InformacionGeneral', 'TipoXML') == '102'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/NumeroSecuenciaXML/@Numero') == 'N00001'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/NumeroSecuenciaXML/@Consecutivo') == '00001'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/LugarGeneracionXML/@Pais') == 'CO'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/LugarGeneracionXML/@DepartamentoEstado') == '05'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/LugarGeneracionXML/@MunicipioCiudad') == '05001'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/ProveedorXML/@NIT') == '999999'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/ProveedorXML/@DV') == '2'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/ProveedorXML/@SoftwareID') == 'xx'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/ProveedorXML/@SoftwareSC') is not None
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/CodigoQR') == f"https://catalogo-vpfe.dian.gov.co/document/searchqr?documentkey={expected_cune}"
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/Empleador/@NIT') == '700085371'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/Trabajador/@NumeroDocumento') == '800199436'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/Novedad') == 'True'
assert xml.get_element_text_or_attribute('/nomina:NominaIndividual/Novedad/@CUNENov') == 'N0111'
# TODO(bit4bit) no logro generar cune igual al del anexo tecnico
#assert xml.get_element_attribute('/fe:NominaIndividual/InformacionGeneral', 'CUNE') == '16560dc8956122e84ffb743c817fe7d494e058a44d9ca3fa4c234c268b4f766003253fbee7ea4af9682dd57210f3bac2'
# confirmar el namespace
assert 'xmlns="dian:gov:co:facturaelectronica:NominaIndividual"' in xml.tostring()
expected_cune = 'b8f9b6c24de07ffd92ea5467433a3b69357cfaffa7c19722db94b2e0eca41d057085a54f484b5da15ff585e773b0b0ab'
assert xml.get_element_attribute('/fe:NominaIndividual/InformacionGeneral', 'fachoCUNE') == "N000012020-01-161053:10-05:003500000.001000000.002500000.007000853718001994361026931"
assert xml.get_element_attribute('/fe:NominaIndividual/InformacionGeneral', 'CUNE') == expected_cune
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/NumeroSecuenciaXML/@Numero') == 'N00001'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/NumeroSecuenciaXML/@Consecutivo') == '00001'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/LugarGeneracionXML/@Pais') == 'CO'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/LugarGeneracionXML/@DepartamentoEstado') == '05'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/LugarGeneracionXML/@MunicipioCiudad') == '05001'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/ProveedorXML/@NIT') == '999999'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/ProveedorXML/@DV') == '2'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/ProveedorXML/@SoftwareID') == 'xx'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/ProveedorXML/@fachoSoftwareSC') == 'xx12N00001'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/ProveedorXML/@SoftwareSC') is not None
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/CodigoQR') == f"https://catalogo-vpfe.dian.gov.co/document/searchqr?documentkey={expected_cune}"
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/Empleador/@NIT') == '700085371'
assert xml.get_element_text_or_attribute('/fe:NominaIndividual/Trabajador/@NumeroDocumento') == '800199436'
def test_asignar_pago():
nomina = fe.nomina.DIANNominaIndividual()
@@ -249,10 +242,147 @@ def test_nomina_xmlsign(monkeypatch):
xml.add_extension(signer)
print(xml.tostring())
elem = xml.get_element('/nomina:NominaIndividual/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/ds:Signature')
elem = xml.get_element('/fe:NominaIndividual/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent/ds:Signature')
assert elem is not None
def atest_nomina_ajuste_reemplazar():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar()
xml = nomina.toFachoXML()
print(xml)
assert False
def test_adicionar_reemplazar_devengado_comprobante_total():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar()
nomina.adicionar_devengado(fe.nomina.DevengadoBasico(
dias_trabajados = 60,
sueldo_trabajado = fe.nomina.Amount(2_000_000)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionSalud(
porcentaje = fe.nomina.Amount(19),
deduccion = fe.nomina.Amount(1_000_000)
))
xml = nomina.toFachoXML()
assert xml.get_element_text('/fe:NominaIndividualDeAjuste/Reemplazar/ComprobanteTotal') == '1000000.00'
def test_adicionar_reemplazar_asignar_predecesor():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar()
nomina.asignar_predecesor(fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar.Predecesor(
numero = '123456',
cune = 'ABC123456',
fecha_generacion = '2021-11-16'
))
xml = nomina.toFachoXML()
print(xml.tostring())
assert xml.get_element_text_or_attribute('/fe:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor/@NumeroPred') == '123456'
assert xml.get_element_text_or_attribute('/fe:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor/@CUNEPred') == 'ABC123456'
assert xml.get_element_text_or_attribute('/fe:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor/@FechaGenPred') == '2021-11-16'
def test_adicionar_reemplazar_eliminar_predecesor_opcional():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar()
nomina.asignar_predecesor(fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar.Predecesor(
numero = '123456',
cune = 'ABC123456',
fecha_generacion = '2021-11-16'
))
xml = nomina.toFachoXML()
print(xml.tostring())
assert xml.get_element('/fe:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor') is not None
assert xml.get_element('/fe:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor') is None
def test_adicionar_eliminar_reemplazar_predecesor_opcional():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Eliminar()
nomina.asignar_predecesor(fe.nomina.DIANNominaIndividualDeAjuste.Eliminar.Predecesor(
numero = '123456',
cune = 'ABC123456',
fecha_generacion = '2021-11-16'
))
xml = nomina.toFachoXML()
print(xml.tostring())
assert xml.get_element('/fe:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor') is not None
assert xml.get_element('/fe:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor') is None
def test_adicionar_eliminar_devengado_comprobante_total():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Eliminar()
nomina.adicionar_devengado(fe.nomina.DevengadoBasico(
dias_trabajados = 60,
sueldo_trabajado = fe.nomina.Amount(2_000_000)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionSalud(
porcentaje = fe.nomina.Amount(19),
deduccion = fe.nomina.Amount(1_000_000)
))
xml = nomina.toFachoXML()
assert xml.get_element_text('/fe:NominaIndividualDeAjuste/Eliminar/ComprobanteTotal') == '1000000.00'
def test_adicionar_eliminar_asignar_predecesor():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Eliminar()
nomina.asignar_predecesor(fe.nomina.DIANNominaIndividualDeAjuste.Eliminar.Predecesor(
numero = '123456',
cune = 'ABC123456',
fecha_generacion = '2021-11-16'
))
xml = nomina.toFachoXML()
print(xml.tostring())
assert xml.get_element_text_or_attribute('/fe:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor/@NumeroPred') == '123456'
assert xml.get_element_text_or_attribute('/fe:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor/@CUNEPred') == 'ABC123456'
assert xml.get_element_text_or_attribute('/fe:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor/@FechaGenPred') == '2021-11-16'
def test_nomina_devengado_horas_extras_diarias():
nomina = fe.nomina.DIANNominaIndividual()
nomina.adicionar_devengado(fe.nomina.DevengadoHorasExtrasDiarias(
horas_extras=[
fe.nomina.DevengadoHoraExtra(
hora_inicio='2021-11-30T19:09:55',
hora_fin='2021-11-30T20:09:55',
cantidad=1,
porcentaje=fe.nomina.Amount(1),
pago=fe.nomina.Amount(100)
),
fe.nomina.DevengadoHoraExtra(
hora_inicio='2021-11-30T18:09:55',
hora_fin='2021-11-30T19:09:55',
cantidad=2,
porcentaje=fe.nomina.Amount(2),
pago=fe.nomina.Amount(200)
)
]
))
xml = nomina.toFachoXML()
extras = xml.get_element('/fe:NominaIndividual/Devengados/HEDs/HED', multiple=True)
assert extras[0].get('HoraInicio') == '2021-11-30T19:09:55'
assert extras[0].get('HoraFin') == '2021-11-30T20:09:55'
assert extras[0].get('Cantidad') == '1'
assert extras[0].get('Porcentaje') == '1.00'
assert extras[0].get('Pago') == '100.00'
assert extras[1].get('HoraInicio') == '2021-11-30T18:09:55'
assert extras[1].get('HoraFin') == '2021-11-30T19:09:55'
assert extras[1].get('Cantidad') == '2'
assert extras[1].get('Porcentaje') == '2.00'
assert extras[1].get('Pago') == '200.00'
def test_nomina_devengado_horas_extras_nocturnas():
nomina = fe.nomina.DIANNominaIndividual()
@@ -277,7 +407,7 @@ def test_nomina_devengado_horas_extras_nocturnas():
))
xml = nomina.toFachoXML()
extras = xml.get_element('/nomina:NominaIndividual/Devengados/HENs/HEN', multiple=True)
extras = xml.get_element('/fe:NominaIndividual/Devengados/HENs/HEN', multiple=True)
assert extras[0].get('HoraInicio') == '2021-11-30T19:09:55'
assert extras[0].get('HoraFin') == '2021-11-30T20:09:55'
assert extras[0].get('Cantidad') == '1'
@@ -312,7 +442,7 @@ def test_nomina_devengado_horas_recargo_nocturno():
))
xml = nomina.toFachoXML()
extras = xml.get_element('/nomina:NominaIndividual/Devengados/HRNs/HRN', multiple=True)
extras = xml.get_element('/fe:NominaIndividual/Devengados/HRNs/HRN', multiple=True)
assert extras[0].get('HoraInicio') == '2021-11-30T19:09:55'
assert extras[0].get('HoraFin') == '2021-11-30T20:09:55'
assert extras[0].get('Cantidad') == '1'
@@ -347,7 +477,7 @@ def test_nomina_devengado_horas_extras_diarias_dominicales_y_festivos():
))
xml = nomina.toFachoXML()
extras = xml.get_element('/nomina:NominaIndividual/Devengados/HEDDFs/HEDDF', multiple=True)
extras = xml.get_element('/fe:NominaIndividual/Devengados/HEDDFs/HEDDF', multiple=True)
assert extras[0].get('HoraInicio') == '2021-11-30T19:09:55'
assert extras[0].get('HoraFin') == '2021-11-30T20:09:55'
assert extras[0].get('Cantidad') == '1'
@@ -382,7 +512,7 @@ def test_nomina_devengado_horas_recargo_diarias_dominicales_y_festivos():
))
xml = nomina.toFachoXML()
extras = xml.get_element('/nomina:NominaIndividual/Devengados/HRDDFs/HRDDF', multiple=True)
extras = xml.get_element('/fe:NominaIndividual/Devengados/HRDDFs/HRDDF', multiple=True)
assert extras[0].get('HoraInicio') == '2021-11-30T19:09:55'
assert extras[0].get('HoraFin') == '2021-11-30T20:09:55'
assert extras[0].get('Cantidad') == '1'
@@ -418,7 +548,7 @@ def test_nomina_devengado_horas_extras_nocturnas_dominicales_y_festivos():
))
xml = nomina.toFachoXML()
extras = xml.get_element('/nomina:NominaIndividual/Devengados/HENDFs/HENDF', multiple=True)
extras = xml.get_element('/fe:NominaIndividual/Devengados/HENDFs/HENDF', multiple=True)
assert extras[0].get('HoraInicio') == '2021-11-30T19:09:55'
assert extras[0].get('HoraFin') == '2021-11-30T20:09:55'
assert extras[0].get('Cantidad') == '1'
@@ -453,7 +583,7 @@ def test_nomina_devengado_horas_recargo_nocturno_dominicales_y_festivos():
))
xml = nomina.toFachoXML()
extras = xml.get_element('/nomina:NominaIndividual/Devengados/HRNDFs/HRNDF', multiple=True)
extras = xml.get_element('/fe:NominaIndividual/Devengados/HRNDFs/HRNDF', multiple=True)
assert extras[0].get('HoraInicio') == '2021-11-30T19:09:55'
assert extras[0].get('HoraFin') == '2021-11-30T20:09:55'
assert extras[0].get('Cantidad') == '1'

View File

@@ -1,235 +0,0 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# This file is part of facho. The COPYRIGHT file at the top level of
# this repository contains the full copyright notices and license terms.
"""Tests for `facho` package."""
import re
import pytest
from facho import fe
import helpers
def atest_nomina_ajuste_reemplazar():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar()
xml = nomina.toFachoXML()
print(xml)
assert False
def test_nomina_ajuste_reemplazar_asignacion_tipo_xml():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar()
nomina.asignar_metadata(fe.nomina.Metadata(
novedad=fe.nomina.Novedad(
activa = True,
cune = "N0111"
),
secuencia=fe.nomina.NumeroSecuencia(
prefijo = 'N',
consecutivo='00001'
),
lugar_generacion=fe.nomina.Lugar(
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
),
proveedor=fe.nomina.Proveedor(
nit='999999',
dv=2,
software_id='xx',
software_pin='12',
razon_social='facho'
)
))
nomina.asignar_empleador(fe.nomina.Empleador(
razon_social='facho',
nit = '700085371',
dv = '1',
pais = fe.nomina.Pais(
code = 'CO'
),
departamento = fe.nomina.Departamento(
code = '05'
),
municipio = fe.nomina.Municipio(
code = '05001'
),
direccion = 'calle etrivial'
))
nomina.asignar_trabajador(fe.nomina.Trabajador(
tipo_contrato = fe.nomina.TipoContrato(
code = '1'
),
alto_riesgo = False,
tipo_documento = fe.nomina.TipoDocumento(
code = '11'
),
primer_apellido = 'gnu',
segundo_apellido = 'emacs',
primer_nombre = 'facho',
lugar_trabajo = fe.nomina.LugarTrabajo(
pais = fe.nomina.Pais(code='CO'),
departamento = fe.nomina.Departamento(code='05'),
municipio = fe.nomina.Municipio(code='05001'),
direccion = 'calle facho'
),
numero_documento = '800199436',
tipo = fe.nomina.TipoTrabajador(
code = '01'
),
salario_integral = True,
sueldo = fe.nomina.Amount(1_500_000)
))
nomina.asignar_informacion_general(fe.nomina.InformacionGeneral(
fecha_generacion = '2020-01-16',
hora_generacion = '1053:10-05:00',
tipo_ambiente = fe.nomina.InformacionGeneral.AMBIENTE_PRODUCCION,
software_pin = '693',
tipo_xml = fe.nomina.InformacionGeneral.TIPO_XML_AJUSTES,
periodo_nomina = fe.nomina.PeriodoNomina(code='1'),
tipo_moneda = fe.nomina.TipoMoneda(code='COP')
))
xml = nomina.toFachoXML()
assert xml.get_element_attribute('/nominaajuste:NominaIndividualDeAjuste/Reemplazar/InformacionGeneral', 'TipoXML') == '103'
def test_adicionar_reemplazar_devengado_comprobante_total():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar()
nomina.adicionar_devengado(fe.nomina.DevengadoBasico(
dias_trabajados = 60,
sueldo_trabajado = fe.nomina.Amount(2_000_000)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionSalud(
porcentaje = fe.nomina.Amount(19),
deduccion = fe.nomina.Amount(1_000_000)
))
xml = nomina.toFachoXML()
assert xml.get_element_text('/nominaajuste:NominaIndividualDeAjuste/Reemplazar/ComprobanteTotal') == '1000000.00'
def test_adicionar_reemplazar_asignar_predecesor():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar()
nomina.asignar_predecesor(fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar.Predecesor(
numero = '123456',
cune = 'ABC123456',
fecha_generacion = '2021-11-16'
))
xml = nomina.toFachoXML()
print(xml.tostring())
assert xml.get_element_text_or_attribute('/nominaajuste:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor/@NumeroPred') == '123456'
assert xml.get_element_text_or_attribute('/nominaajuste:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor/@CUNEPred') == 'ABC123456'
assert xml.get_element_text_or_attribute('/nominaajuste:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor/@FechaGenPred') == '2021-11-16'
def test_adicionar_reemplazar_eliminar_predecesor_opcional():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar()
nomina.asignar_predecesor(fe.nomina.DIANNominaIndividualDeAjuste.Reemplazar.Predecesor(
numero = '123456',
cune = 'ABC123456',
fecha_generacion = '2021-11-16'
))
xml = nomina.toFachoXML()
print(xml.tostring())
assert xml.get_element('/nominaajuste:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor') is not None
assert xml.get_element('/nominaajuste:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor') is None
def test_adicionar_eliminar_reemplazar_predecesor_opcional():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Eliminar()
nomina.asignar_predecesor(fe.nomina.DIANNominaIndividualDeAjuste.Eliminar.Predecesor(
numero = '123456',
cune = 'ABC123456',
fecha_generacion = '2021-11-16'
))
xml = nomina.toFachoXML()
print(xml.tostring())
assert xml.get_element('/nominaajuste:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor') is not None
assert xml.get_element('/nominaajuste:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor') is None
def test_adicionar_eliminar_devengado_comprobante_total():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Eliminar()
nomina.adicionar_devengado(fe.nomina.DevengadoBasico(
dias_trabajados = 60,
sueldo_trabajado = fe.nomina.Amount(2_000_000)
))
nomina.adicionar_deduccion(fe.nomina.DeduccionSalud(
porcentaje = fe.nomina.Amount(19),
deduccion = fe.nomina.Amount(1_000_000)
))
xml = nomina.toFachoXML()
assert xml.get_element_text('/nominaajuste:NominaIndividualDeAjuste/Eliminar/ComprobanteTotal') == '1000000.00'
def test_adicionar_eliminar_asignar_predecesor():
nomina = fe.nomina.DIANNominaIndividualDeAjuste.Eliminar()
nomina.asignar_predecesor(fe.nomina.DIANNominaIndividualDeAjuste.Eliminar.Predecesor(
numero = '123456',
cune = 'ABC123456',
fecha_generacion = '2021-11-16'
))
xml = nomina.toFachoXML()
print(xml.tostring())
assert xml.get_element_text_or_attribute('/nominaajuste:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor/@NumeroPred') == '123456'
assert xml.get_element_text_or_attribute('/nominaajuste:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor/@CUNEPred') == 'ABC123456'
assert xml.get_element_text_or_attribute('/nominaajuste:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor/@FechaGenPred') == '2021-11-16'
def test_nomina_devengado_horas_extras_diarias():
nomina = fe.nomina.DIANNominaIndividual()
nomina.adicionar_devengado(fe.nomina.DevengadoHorasExtrasDiarias(
horas_extras=[
fe.nomina.DevengadoHoraExtra(
hora_inicio='2021-11-30T19:09:55',
hora_fin='2021-11-30T20:09:55',
cantidad=1,
porcentaje=fe.nomina.Amount(1),
pago=fe.nomina.Amount(100)
),
fe.nomina.DevengadoHoraExtra(
hora_inicio='2021-11-30T18:09:55',
hora_fin='2021-11-30T19:09:55',
cantidad=2,
porcentaje=fe.nomina.Amount(2),
pago=fe.nomina.Amount(200)
)
]
))
xml = nomina.toFachoXML()
extras = xml.get_element('/nomina:NominaIndividual/Devengados/HEDs/HED', multiple=True)
assert extras[0].get('HoraInicio') == '2021-11-30T19:09:55'
assert extras[0].get('HoraFin') == '2021-11-30T20:09:55'
assert extras[0].get('Cantidad') == '1'
assert extras[0].get('Porcentaje') == '1.00'
assert extras[0].get('Pago') == '100.00'
assert extras[1].get('HoraInicio') == '2021-11-30T18:09:55'
assert extras[1].get('HoraFin') == '2021-11-30T19:09:55'
assert extras[1].get('Cantidad') == '2'
assert extras[1].get('Porcentaje') == '2.00'
assert extras[1].get('Pago') == '200.00'