Compare commits
	
		
			20 Commits
		
	
	
		
			machete_no
			...
			master
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 68a21ec355 | |||
|  | b6aa9e08b4 | ||
|  | 2171da658a | ||
|  | b00eadb9e5 | ||
|  | a9625addf8 | ||
|  | 55d611397e | ||
|  | 23322d6ec8 | ||
|  | 6642b118af | ||
|  | 3c8742e330 | ||
|  | 7156102a4a | ||
|  | d5a96ea07d | ||
|  | a59df60fc2 | ||
|  | 19c5a5bca6 | ||
|  | c50f1df1e7 | ||
|  | 2a1f3b6b43 | ||
|  | a208d924dd | ||
|  | c3b0f7cfe8 | ||
|  | 005f90166e | ||
|  | 73bb90b74b | ||
|  | 6bed600dd4 | 
| @@ -57,6 +57,17 @@ If you are proposing a feature: | ||||
| Get Started! | ||||
| ------------ | ||||
|  | ||||
| Using docker | ||||
| ------------ | ||||
|  | ||||
| 1. make -f Makefile.dev dev-setup | ||||
|    1. make -f Makefile.dev dev-shell | ||||
| 2. make -f Makefile.dev test | ||||
| 3. make -f Makefile.dev tox | ||||
|  | ||||
| From Source Code | ||||
| ----------- | ||||
|  | ||||
| Ready to contribute? Here's how to set up `facho` for local development. | ||||
|  | ||||
| 1. Fork the `facho` repo . | ||||
| @@ -94,6 +105,7 @@ Ready to contribute? Here's how to set up `facho` for local development. | ||||
|  | ||||
| 7. Submit a pull request through the GitHub website. | ||||
|  | ||||
|  | ||||
| Pull Request Guidelines | ||||
| ----------------------- | ||||
|  | ||||
|   | ||||
							
								
								
									
										19
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										19
									
								
								Dockerfile
									
									
									
									
									
								
							| @@ -2,16 +2,23 @@ | ||||
| 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 get-pip.py pip==21.3 \ | ||||
|   && python3.7 get-pip.py pip==21.3 \ | ||||
|   && python3.8 get-pip.py pip==21.3 \ | ||||
|   && 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 \ | ||||
|   && rm get-pip.py | ||||
|  | ||||
| RUN apt-get install -y --no-install-recommends \ | ||||
| @@ -20,12 +27,14 @@ 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 | ||||
|   | ||||
| @@ -11,9 +11,6 @@ | ||||
| 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 | ||||
|  | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								docs/DIAN/Anexo_tecnico_vr18_09022021.pdf
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								docs/DIAN/Anexo_tecnico_vr18_09022021.pdf
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -1,7 +1,7 @@ | ||||
| #                                               -*- Autoconf -*- | ||||
| # Process this file with autoconf to produce a configure script. | ||||
|  | ||||
| AC_PREREQ([2.71]) | ||||
| AC_PREREQ([2.69]) | ||||
| AC_INIT([facho-signer], [0.0.1], [bit4bit@riseup.net]) | ||||
| AM_INIT_AUTOMAKE | ||||
| AC_CONFIG_SRCDIR([src/facho_signer.c]) | ||||
|   | ||||
| @@ -181,8 +181,6 @@ class FachoXML: | ||||
|         return etree.QName(self.root).namespace | ||||
|  | ||||
|     def append_element(self, 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): | ||||
|   | ||||
| @@ -21,10 +21,10 @@ __all__ = ['DianClient', | ||||
|  | ||||
| class SOAPService: | ||||
|  | ||||
|     def get_wsdl(self): | ||||
|     def wsdl(self): | ||||
|         raise NotImplementedError() | ||||
|  | ||||
|     def get_service(self): | ||||
|     def service(self): | ||||
|         raise NotImplementedError() | ||||
|  | ||||
|     def build_response(self, as_dict): | ||||
| @@ -63,10 +63,10 @@ class GetNumberingRange(SOAPService): | ||||
|     accountCodeT: str | ||||
|     softwareCode: str | ||||
|  | ||||
|     def get_wsdl(self): | ||||
|     def wsdl(self): | ||||
|         return 'https://vpfe.dian.gov.co/WcfDianCustomerServices.svc?wsdl' | ||||
|  | ||||
|     def get_service(self): | ||||
|     def service(self): | ||||
|         return 'GetNumberingRange' | ||||
|  | ||||
|     def build_response(self, as_dict): | ||||
| @@ -78,10 +78,10 @@ class SendBillAsync(SOAPService): | ||||
|     fileName: str | ||||
|     contentFile: str | ||||
|  | ||||
|     def get_wsdl(self): | ||||
|     def wsdl(self): | ||||
|         return 'https://vpfe.dian.gov.co/WcfDianCustomerServices.svc?wsdl' | ||||
|  | ||||
|     def get_service(self): | ||||
|     def service(self): | ||||
|         return 'SendBillAsync' | ||||
|  | ||||
|     def build_response(self, as_dict): | ||||
| @@ -106,10 +106,10 @@ class SendTestSetAsync(SOAPService): | ||||
|     contentFile: str | ||||
|     testSetId: str = '' | ||||
|  | ||||
|     def get_wsdl(self): | ||||
|     def wsdl(self): | ||||
|         return 'https://vpfe.dian.gov.co/WcfDianCustomerServices.svc?wsdl' | ||||
|  | ||||
|     def get_service(self): | ||||
|     def service(self): | ||||
|         return 'SendTestSetAsync' | ||||
|  | ||||
|     def build_response(self, as_dict): | ||||
| @@ -120,10 +120,10 @@ class SendBillSync(SOAPService): | ||||
|     fileName: str | ||||
|     contentFile: bytes | ||||
|  | ||||
|     def get_wsdl(self): | ||||
|     def wsdl(self): | ||||
|         return 'https://vpfe.dian.gov.co/WcfDianCustomerServices.svc?wsdl' | ||||
|  | ||||
|     def get_service(self): | ||||
|     def service(self): | ||||
|         return 'SendBillSync' | ||||
|  | ||||
|     def build_response(self, as_dict): | ||||
| @@ -153,10 +153,10 @@ class GetStatusResponse: | ||||
| class GetStatus(SOAPService): | ||||
|     trackId: bytes | ||||
|  | ||||
|     def get_wsdl(self): | ||||
|     def wsdl(self): | ||||
|         return 'https://vpfe.dian.gov.co/WcfDianCustomerServices.svc?wsdl' | ||||
|  | ||||
|     def get_service(self): | ||||
|     def service(self): | ||||
|         return 'GetStatus' | ||||
|  | ||||
|     def build_response(self, as_dict): | ||||
| @@ -166,10 +166,10 @@ class GetStatus(SOAPService): | ||||
| class GetStatusZip(SOAPService): | ||||
|     trackId: bytes | ||||
|  | ||||
|     def get_wsdl(self): | ||||
|     def wsdl(self): | ||||
|         return 'https://vpfe.dian.gov.co/WcfDianCustomerServices.svc?wsdl' | ||||
|  | ||||
|     def get_service(self): | ||||
|     def service(self): | ||||
|         return 'GetStatusZip' | ||||
|  | ||||
|     def build_response(self, as_dict): | ||||
| @@ -179,10 +179,10 @@ class GetStatusZip(SOAPService): | ||||
| class SendNominaSync(SOAPService): | ||||
|     contentFile: bytes | ||||
|  | ||||
|     def get_wsdl(self): | ||||
|     def wsdl(self): | ||||
|         return 'https://vpfe.dian.gov.co/WcfDianCustomerServices.svc?wsdl' | ||||
|  | ||||
|     def get_service(self): | ||||
|     def service(self): | ||||
|         return 'SendNominaSync' | ||||
|  | ||||
|     def build_response(self, as_dict): | ||||
| @@ -193,31 +193,31 @@ class Habilitacion: | ||||
|     WSDL = 'https://vpfe-hab.dian.gov.co/WcfDianCustomerServices.svc?wsdl' | ||||
|  | ||||
|     class GetNumberingRange(GetNumberingRange): | ||||
|         def get_wsdl(self): | ||||
|         def wsdl(self): | ||||
|             return Habilitacion.WSDL | ||||
|  | ||||
|     class SendBillAsync(SendBillAsync): | ||||
|         def get_wsdl(self): | ||||
|         def wsdl(self): | ||||
|             return Habilitacion.WSDL | ||||
|  | ||||
|     class SendBillSync(SendBillSync): | ||||
|         def get_wsdl(self): | ||||
|         def wsdl(self): | ||||
|             return Habilitacion.WSDL | ||||
|  | ||||
|     class SendTestSetAsync(SendTestSetAsync): | ||||
|         def get_wsdl(self): | ||||
|         def wsdl(self): | ||||
|             return Habilitacion.WSDL | ||||
|  | ||||
|     class GetStatus(GetStatus): | ||||
|         def get_wsdl(self): | ||||
|         def wsdl(self): | ||||
|             return Habilitacion.WSDL | ||||
|  | ||||
|     class GetStatusZip(GetStatusZip): | ||||
|         def get_wsdl(self): | ||||
|         def wsdl(self): | ||||
|             return Habilitacion.WSDL | ||||
|  | ||||
|     class SendNominaSync(SendNominaSync): | ||||
|         def get_wsdl(self): | ||||
|         def wsdl(self): | ||||
|             return Habilitacion.WSDL | ||||
|  | ||||
| class DianGateway: | ||||
| @@ -226,7 +226,7 @@ class DianGateway: | ||||
|         raise NotImplementedError() | ||||
|  | ||||
|     def _remote_service(self, conn, service): | ||||
|         return conn.service[service.get_service()] | ||||
|         return conn.service[service.service()] | ||||
|  | ||||
|     def _close(self, conn): | ||||
|         return | ||||
| @@ -250,7 +250,7 @@ class DianClient(DianGateway): | ||||
|         self._password = password | ||||
|  | ||||
|     def _open(self, service): | ||||
|         return zeep.Client(service.get_wsdl(), wsse=UsernameToken(self._username, self._password)) | ||||
|         return zeep.Client(service.wsdl(), wsse=UsernameToken(self._username, self._password)) | ||||
|  | ||||
|  | ||||
| class DianSignatureClient(DianGateway): | ||||
| @@ -264,7 +264,7 @@ class DianSignatureClient(DianGateway): | ||||
|         # RESOLUCCION 0004: pagina 756 | ||||
|         from zeep.wsse import utils | ||||
|  | ||||
|         client = zeep.Client(service.get_wsdl(), wsse= | ||||
|         client = zeep.Client(service.wsdl(), wsse= | ||||
|                              BinarySignature( | ||||
|                                  self.private_key_path, self.public_key_path, self.password, | ||||
|                                  signature_method=xmlsec.Transform.RSA_SHA256, | ||||
|   | ||||
| @@ -34,6 +34,7 @@ POLICY_NAME = u'Política de firma para facturas electrónicas de la República | ||||
| 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', | ||||
| @@ -91,7 +92,8 @@ class FeXML(FachoXML): | ||||
|         xmlns_name = {v: k for k, v in NAMESPACES.items()}[root_namespace] | ||||
|         return super().tostring(**kw)\ | ||||
|             .replace(xmlns_name + ':', '')\ | ||||
|             .replace('xmlns:'+xmlns_name, 'xmlns') | ||||
|             .replace('xmlns:'+xmlns_name, 'xmlns')\ | ||||
|             .replace('schemaLocation', 'xsi:schemaLocation') | ||||
|      | ||||
| class DianXMLExtensionCUDFE(FachoXMLExtension): | ||||
|  | ||||
| @@ -120,8 +122,7 @@ class DianXMLExtensionCUDFE(FachoXMLExtension): | ||||
|         fachoxml.set_element('./cbc:UUID', cufe, | ||||
|                              schemeID=self.tipo_ambiente, | ||||
|                              schemeName=self.schemeName()) | ||||
|         #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', | ||||
|   | ||||
| @@ -18,3 +18,6 @@ class DIANCreditNoteXML(DIANInvoiceXML): | ||||
|  | ||||
|     def tag_document_concilied(fexml): | ||||
|         return 'Credited' | ||||
|  | ||||
|     def post_attach_invoice(fexml, invoice): | ||||
|         fexml.set_element('./cbc:ProfileID', 'DIAN 2.1: Nota Crédito de Factura Electrónica de Venta') | ||||
|   | ||||
| @@ -13,6 +13,9 @@ class DIANDebitNoteXML(DIANInvoiceXML): | ||||
|     def __init__(self, invoice): | ||||
|         super().__init__(invoice, 'DebitNote') | ||||
|  | ||||
|     def post_attach_invoice(fexml, invoice): | ||||
|         fexml.set_element('./cbc:ProfileID', 'DIAN 2.1 Nota Débito de Factura Electrónica de Venta') | ||||
|  | ||||
|     def tag_document(fexml): | ||||
|         return 'DebitNote' | ||||
|  | ||||
|   | ||||
| @@ -21,6 +21,7 @@ class DIANInvoiceXML(fe.FeXML): | ||||
|         ublextension = self.fragment('./ext:UBLExtensions/ext:UBLExtension', append=True) | ||||
|         extcontent = ublextension.find_or_create_element('/ext:UBLExtension/ext:ExtensionContent') | ||||
|         self.attach_invoice(invoice) | ||||
|         self.post_attach_invoice(invoice) | ||||
|  | ||||
|     def set_supplier(fexml, invoice): | ||||
|         fexml.placeholder_for('./cac:AccountingSupplierParty') | ||||
| @@ -415,7 +416,6 @@ class DIANInvoiceXML(fe.FeXML): | ||||
|             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) | ||||
|  | ||||
| @@ -439,6 +439,7 @@ class DIANInvoiceXML(fe.FeXML): | ||||
|                 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 | ||||
| @@ -453,10 +454,9 @@ class DIANInvoiceXML(fe.FeXML): | ||||
|          | ||||
|         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) | ||||
|             line = fexml.fragment('./cac:TaxTotal', append=True) | ||||
|             #DIAN 1.7.-2020: FAU06 | ||||
|             tax_amount = amount_of['tax_amount'] | ||||
|             fexml.set_element_amount_for(line, | ||||
| @@ -486,7 +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', | ||||
|                     'IVA') | ||||
|                              amount_of['name']) | ||||
|    | ||||
|     # abstract method | ||||
|     def tag_document(fexml): | ||||
| @@ -567,6 +567,10 @@ class DIANInvoiceXML(fe.FeXML): | ||||
|             fexml.set_element_amount_for(line, './cbc:Amount', charge.amount) | ||||
|             fexml.set_element_amount_for(line, './cbc:BaseAmount', charge.base_amount) | ||||
|  | ||||
|     def post_attach_invoice(fexml, invoice): | ||||
|         #DIAN 1.8.-2021: FAD03 | ||||
|         fexml.set_element('./cbc:ProfileID', 'DIAN 2.1: Factura Electrónica de Venta') | ||||
|  | ||||
|     def attach_invoice(fexml, invoice): | ||||
|         """adiciona etiquetas a FEXML y retorna FEXML | ||||
|         en caso de fallar validacion retorna None""" | ||||
|   | ||||
| @@ -144,13 +144,12 @@ 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.same(ambiente): | ||||
|         if InformacionGeneral.AMBIENTE_PRUEBAS == 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) | ||||
| @@ -183,6 +182,7 @@ 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,6 +190,7 @@ 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 | ||||
| @@ -218,9 +219,8 @@ class InformacionGeneral: | ||||
|     class TIPO_AMBIENTE: | ||||
|         valor: str | ||||
|  | ||||
|         @classmethod | ||||
|         def same(cls, value): | ||||
|             return cls.valor == str(value) | ||||
|         def __eq__(self, other): | ||||
|             return self.valor == str(other) | ||||
|  | ||||
|     # TABLA 5.1.1 | ||||
|     @dataclass | ||||
| @@ -237,11 +237,34 @@ 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): | ||||
| @@ -256,7 +279,7 @@ class InformacionGeneral: | ||||
|                                 # NIE202 | ||||
|                                 # TABLA 5.5.2 | ||||
|                                 # TODO(bit4bit) solo NominaIndividual | ||||
|                                 TipoXML = '102', | ||||
|                                 TipoXML = self.tipo_xml.valor, | ||||
|                                 # NIE024 | ||||
|                                 CUNE = None, | ||||
|                                 # NIE025 | ||||
| @@ -315,14 +338,18 @@ class DianXMLExtensionSigner(fe.DianXMLExtensionSigner): | ||||
|  | ||||
|  | ||||
| class DIANNominaXML: | ||||
|     def __init__(self, tag_document, xpath_ajuste=None,schemaLocation=None): | ||||
|     def __init__(self, tag_document, xpath_ajuste=None, schemaLocation=None, namespace_ajuste=None): | ||||
|         self.informacion_general_version = None | ||||
|  | ||||
|         self.tag_document = tag_document | ||||
|  | ||||
|         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", schemaLocation)             | ||||
|         self.fexml.root.set("SchemaLocation", "") | ||||
|         self.fexml.root.set("schemaLocation", schemaLocation) | ||||
|  | ||||
|         # layout, la dian requiere que los elementos | ||||
|         # esten ordenados segun el anexo tecnico | ||||
| @@ -334,6 +361,7 @@ 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') | ||||
| @@ -347,8 +375,10 @@ 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') | ||||
| @@ -368,6 +398,7 @@ 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): | ||||
| @@ -545,7 +576,7 @@ class DIANNominaXML: | ||||
| class DIANNominaIndividual(DIANNominaXML): | ||||
|  | ||||
|     def __init__(self): | ||||
|         schema = "dian:gov:co:facturaelectronica:NominaIndividual" | ||||
|         schema = "dian:gov:co:facturaelectronica:NominaIndividual NominaIndividualElectronicaXSD.xsd" | ||||
|  | ||||
|         super().__init__('NominaIndividual', schemaLocation=schema) | ||||
|         self.informacion_general_version = 'V1.0: Documento Soporte de Pago de Nómina Electrónica' | ||||
| @@ -561,6 +592,8 @@ 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, | ||||
| @@ -571,9 +604,11 @@ class DIANNominaIndividualDeAjuste(DIANNominaXML): | ||||
|                                      ) | ||||
|  | ||||
|         def __init__(self): | ||||
|             super().__init__('NominaIndividualDeAjuste', './Reemplazar') | ||||
|             # NIAE214 | ||||
|             self.root_fragment.set_element('./TipoNota', '1') | ||||
|             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' | ||||
|  | ||||
|         def asignar_predecesor(self, predecesor): | ||||
|             if not isinstance(predecesor, self.Predecesor): | ||||
| @@ -590,6 +625,7 @@ 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, | ||||
| @@ -600,9 +636,9 @@ class DIANNominaIndividualDeAjuste(DIANNominaXML): | ||||
|                                      ) | ||||
|  | ||||
|         def __init__(self): | ||||
|             super().__init__('NominaIndividualDeAjuste', './Eliminar') | ||||
|             schema = "dian:gov:co:facturaelectronica:NominaIndividualDeAjuste NominaIndividualDeAjusteElectronicaXSD.xsd"             | ||||
|             super().__init__('NominaIndividualDeAjuste', './Eliminar', schemaLocation=schema, namespace_ajuste='dian:gov:co:facturaelectronica:NominaIndividualDeAjuste') | ||||
|  | ||||
|             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): | ||||
|   | ||||
							
								
								
									
										17
									
								
								requirements_dev.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								requirements_dev.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,17 @@ | ||||
| attrs==22.1.0 | ||||
| distlib==0.3.6 | ||||
| filelock==3.8.0 | ||||
| iniconfig==1.1.1 | ||||
| packaging==21.3 | ||||
| platformdirs==2.5.2 | ||||
| pluggy==1.0.0 | ||||
| py==1.11.0 | ||||
| pyparsing==3.0.9 | ||||
| pytest==7.1.3 | ||||
| semantic-version==2.10.0 | ||||
| setuptools-rust==1.5.2 | ||||
| six==1.16.0 | ||||
| tomli==2.0.1 | ||||
| tox==3.26.0 | ||||
| typing_extensions==4.4.0 | ||||
| virtualenv==20.16.5 | ||||
| @@ -33,6 +33,23 @@ def test_invoicesimple_build_with_cufe(simple_invoice): | ||||
|     cufe = xml.get_element_text('/fe:Invoice/cbc:UUID') | ||||
|     assert cufe != '' | ||||
|  | ||||
| def test_invoice_profile_id(simple_invoice): | ||||
|     xml = DIANInvoiceXML(simple_invoice) | ||||
|     cufe_extension = fe.DianXMLExtensionCUFE(simple_invoice) | ||||
|     xml.add_extension(cufe_extension) | ||||
|     assert xml.get_element_text('/fe:Invoice/cbc:ProfileID') == 'DIAN 2.1: Factura Electrónica de Venta' | ||||
|  | ||||
| def test_debit_note_profile_id(simple_invoice): | ||||
|     xml = DIANDebitNoteXML(simple_invoice) | ||||
|     cufe_extension = fe.DianXMLExtensionCUFE(simple_invoice) | ||||
|     xml.add_extension(cufe_extension) | ||||
|     assert xml.get_element_text('/fe:DebitNote/cbc:ProfileID') == 'DIAN 2.1 Nota Débito de Factura Electrónica de Venta' | ||||
|  | ||||
| def test_credit_note_profile_id(simple_invoice): | ||||
|     xml = DIANCreditNoteXML(simple_invoice) | ||||
|     cufe_extension = fe.DianXMLExtensionCUFE(simple_invoice) | ||||
|     xml.add_extension(cufe_extension) | ||||
|     assert xml.get_element_text('/fe:CreditNote/cbc:ProfileID') == 'DIAN 2.1: Nota Crédito de Factura Electrónica de Venta' | ||||
|      | ||||
| def test_invoicesimple_xml_signed(monkeypatch, simple_invoice): | ||||
|     xml = DIANInvoiceXML(simple_invoice) | ||||
|   | ||||
| @@ -156,6 +156,7 @@ 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') | ||||
|     )) | ||||
| @@ -214,6 +215,7 @@ 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' | ||||
| @@ -251,143 +253,6 @@ def test_nomina_xmlsign(monkeypatch): | ||||
|     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('/nomina: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('/nomina:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor/@NumeroPred') == '123456' | ||||
|     assert xml.get_element_text_or_attribute('/nomina:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor/@CUNEPred') == 'ABC123456' | ||||
|     assert xml.get_element_text_or_attribute('/nomina: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('/nomina:NominaIndividualDeAjuste/Reemplazar/ReemplazandoPredecesor') is not None | ||||
|     assert xml.get_element('/nomina: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('/nomina:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor') is not None | ||||
|     assert xml.get_element('/nomina: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('/nomina: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('/nomina:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor/@NumeroPred') == '123456' | ||||
|     assert xml.get_element_text_or_attribute('/nomina:NominaIndividualDeAjuste/Eliminar/EliminandoPredecesor/@CUNEPred') == 'ABC123456' | ||||
|     assert xml.get_element_text_or_attribute('/nomina: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' | ||||
|  | ||||
| def test_nomina_devengado_horas_extras_nocturnas(): | ||||
|     nomina = fe.nomina.DIANNominaIndividual() | ||||
|   | ||||
							
								
								
									
										235
									
								
								tests/test_nomina_ajuste.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										235
									
								
								tests/test_nomina_ajuste.py
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,235 @@ | ||||
| #!/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' | ||||
							
								
								
									
										15
									
								
								tox.ini
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								tox.ini
									
									
									
									
									
								
							| @@ -1,17 +1,12 @@ | ||||
| [tox] | ||||
| envlist = py27, py34, py35, py36, flake8 | ||||
| envlist = py37, py38, py39, py310 | ||||
|  | ||||
| [travis] | ||||
| python = | ||||
|     3.6: py36 | ||||
|     3.5: py35 | ||||
|     3.4: py34 | ||||
|     2.7: py27 | ||||
|  | ||||
| [testenv:flake8] | ||||
| basepython = python | ||||
| deps = flake8 | ||||
| commands = flake8 facho | ||||
|     3.7: py37 | ||||
|     3.8: py38 | ||||
|     3.9: py39 | ||||
|     3.10: py310 | ||||
|  | ||||
| [testenv] | ||||
| setenv = | ||||
|   | ||||
		Reference in New Issue
	
	Block a user