Fix: Facho para habilitacion de nomina python 3.9
This commit is contained in:
		| @@ -1 +0,0 @@ | ||||
| 907e4444decc9e59c160a2fb3b6659b33dc5b632a5008922b9a62f83f757b1c448e47f5867f2b50dbdb96f48c7681168 | ||||
| @@ -4,32 +4,30 @@ from datetime import datetime | ||||
|  | ||||
| @pytest.fixture | ||||
| def simple_debit_note_without_lines(): | ||||
|     inv = form.DebitNote(form.InvoiceDocumentReference( | ||||
|         '1234', 'xx', datetime.now())) | ||||
|     inv = form.DebitNote(form.InvoiceDocumentReference('1234', 'xx', datetime.now())) | ||||
|     inv.set_period(datetime.now(), datetime.now()) | ||||
|     inv.set_issue(datetime.now()) | ||||
|     inv.set_ident('ABC123') | ||||
|     inv.set_operation_type('30') | ||||
|     inv.set_payment_mean(form.PaymentMean( | ||||
|         form.PaymentMean.DEBIT, '41', datetime.now(), '1234')) | ||||
|     inv.set_payment_mean(form.PaymentMean(form.PaymentMean.DEBIT, '41', datetime.now(), '1234')) | ||||
|     inv.set_supplier(form.Party( | ||||
|         name='facho-supplier', | ||||
|         ident=form.PartyIdentification('123', '', '31'), | ||||
|         responsability_code = form.Responsability(['ZZ']), | ||||
|         responsability_regime_code='48', | ||||
|         organization_code='1', | ||||
|         address=form.Address( | ||||
|         name = 'facho-supplier', | ||||
|         ident = form.PartyIdentification('123','', '31'), | ||||
|         responsability_code = form.Responsability(['O-07']), | ||||
|         responsability_regime_code = '48', | ||||
|         organization_code = '1', | ||||
|         address = form.Address( | ||||
|             '', '', form.City('05001', 'Medellín'), | ||||
|             form.Country('CO', 'Colombia'), | ||||
|             form.CountrySubentity('05', 'Antioquia')) | ||||
|     )) | ||||
|     inv.set_customer(form.Party( | ||||
|         name='facho-customer', | ||||
|         ident=form.PartyIdentification('321', '', '31'), | ||||
|         responsability_code=form.Responsability(['ZZ']), | ||||
|         responsability_regime_code='48', | ||||
|         organization_code='1', | ||||
|         address=form.Address( | ||||
|         name = 'facho-customer', | ||||
|         ident = form.PartyIdentification('321', '', '31'), | ||||
|         responsability_code = form.Responsability(['O-07']), | ||||
|         responsability_regime_code = '48', | ||||
|         organization_code = '1', | ||||
|         address = form.Address( | ||||
|             '', '', form.City('05001', 'Medellín'), | ||||
|             form.Country('CO', 'Colombia'), | ||||
|             form.CountrySubentity('05', 'Antioquia')) | ||||
| @@ -47,7 +45,7 @@ def simple_credit_note_without_lines(): | ||||
|     inv.set_supplier(form.Party( | ||||
|         name = 'facho-supplier', | ||||
|         ident = form.PartyIdentification('123','', '31'), | ||||
|         responsability_code = form.Responsability(['ZZ']), | ||||
|         responsability_code = form.Responsability(['O-07']), | ||||
|         responsability_regime_code = '48', | ||||
|         organization_code = '1', | ||||
|         address = form.Address( | ||||
| @@ -58,7 +56,7 @@ def simple_credit_note_without_lines(): | ||||
|     inv.set_customer(form.Party( | ||||
|         name = 'facho-customer', | ||||
|         ident = form.PartyIdentification('321', '', '31'), | ||||
|         responsability_code = form.Responsability(['ZZ']), | ||||
|         responsability_code = form.Responsability(['O-07']), | ||||
|         responsability_regime_code = '48', | ||||
|         organization_code = '1', | ||||
|         address = form.Address( | ||||
| @@ -79,7 +77,7 @@ def simple_invoice_without_lines(): | ||||
|     inv.set_supplier(form.Party( | ||||
|         name = 'facho-supplier', | ||||
|         ident = form.PartyIdentification('123','', '31'), | ||||
|         responsability_code = form.Responsability(['ZZ']), | ||||
|         responsability_code = form.Responsability(['O-07']), | ||||
|         responsability_regime_code = '48', | ||||
|         organization_code = '1', | ||||
|         address = form.Address( | ||||
| @@ -90,7 +88,7 @@ def simple_invoice_without_lines(): | ||||
|     inv.set_customer(form.Party( | ||||
|         name = 'facho-customer', | ||||
|         ident = form.PartyIdentification('321', '', '31'), | ||||
|         responsability_code = form.Responsability(['ZZ']), | ||||
|         responsability_code = form.Responsability(['O-07']), | ||||
|         responsability_regime_code = '48', | ||||
|         organization_code = '1', | ||||
|         address = form.Address( | ||||
| @@ -100,7 +98,6 @@ def simple_invoice_without_lines(): | ||||
|     )) | ||||
|     return inv | ||||
|  | ||||
|  | ||||
| @pytest.fixture | ||||
| def simple_invoice(): | ||||
|     inv = form.NationalSalesInvoice() | ||||
| @@ -112,7 +109,7 @@ def simple_invoice(): | ||||
|     inv.set_supplier(form.Party( | ||||
|         name = 'facho-supplier', | ||||
|         ident = form.PartyIdentification('123','', '31'), | ||||
|         responsability_code = form.Responsability(['ZZ']), | ||||
|         responsability_code = form.Responsability(['O-07']), | ||||
|         responsability_regime_code = '48', | ||||
|         organization_code = '1', | ||||
|         address = form.Address( | ||||
| @@ -123,7 +120,7 @@ def simple_invoice(): | ||||
|     inv.set_customer(form.Party( | ||||
|         name = 'facho-customer', | ||||
|         ident = form.PartyIdentification('321','', '31'), | ||||
|         responsability_code = form.Responsability(['ZZ']), | ||||
|         responsability_code = form.Responsability(['O-07']), | ||||
|         responsability_regime_code = '48', | ||||
|         organization_code = '1', | ||||
|         address = form.Address( | ||||
| @@ -131,20 +128,19 @@ def simple_invoice(): | ||||
|             form.Country('CO', 'Colombia'), | ||||
|             form.CountrySubentity('05', 'Antioquia')) | ||||
|     )) | ||||
|  | ||||
|     inv.add_invoice_line(form.InvoiceLine( | ||||
|         quantity=form.Quantity(1, '94'), | ||||
|         description='productofacho', | ||||
|         item=form.StandardItem(9999), | ||||
|         price=form.Price(form.Amount(100.0),'01',''), | ||||
|         tax=form.TaxTotal( | ||||
|             tax_amount=form.Amount(0.0), | ||||
|             taxable_amount=form.Amount(0.0), | ||||
|             subtotals=[ | ||||
|         quantity = form.Quantity(1, '94'), | ||||
|         description = 'producto facho', | ||||
|         item = form.StandardItem( 9999), | ||||
|         price = form.Price(form.Amount(100.0), '01', ''), | ||||
|         tax = form.TaxTotal( | ||||
|             tax_amount = form.Amount(0.0), | ||||
|             taxable_amount = form.Amount(0.0), | ||||
|             subtotals = [ | ||||
|                 form.TaxSubTotal( | ||||
|                     percent=19.0, | ||||
|                 )]), | ||||
|         withholding=form.WithholdingTaxTotal( | ||||
|             subtotals=[]) | ||||
|                     percent = 19.0, | ||||
|                 ) | ||||
|             ] | ||||
|         ) | ||||
|     )) | ||||
|     return inv | ||||
|   | ||||
| @@ -1,21 +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. | ||||
| import pytest | ||||
| from facho.fe import form_xml | ||||
| from fixtures import simple_invoice | ||||
|  | ||||
| simple_invoice = simple_invoice | ||||
|  | ||||
|  | ||||
| def test_application_response(simple_invoice): | ||||
|  | ||||
|     doc = form_xml.ApplicationResponse(simple_invoice) | ||||
|     xml = doc.toFachoXML() | ||||
|  | ||||
|     with open("application_response.xml", "w") as fh: | ||||
|         fh.write(xml.tostring()) | ||||
|     # raise Exception(xml.tostring()) | ||||
|     # assert xml.get_element_text( | ||||
|     #     './apr:ApplicationResponse') | ||||
| @@ -2,124 +2,16 @@ | ||||
| # -*- 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. | ||||
| # from datetime import datetime | ||||
| from datetime import datetime | ||||
|  | ||||
| import pytest | ||||
| from facho.fe import form_xml | ||||
| from datetime import datetime | ||||
|  | ||||
| import helpers | ||||
| from fixtures import simple_invoice | ||||
|  | ||||
| simple_invoice = simple_invoice | ||||
|  | ||||
| def test_xml_with_required_elements(simple_invoice): | ||||
|  | ||||
|     xml_header = '<?xml version="1.0" encoding="UTF-8" standalone="no"?>' | ||||
|     DIANInvoiceXML = form_xml.DIANInvoiceXML( | ||||
|         simple_invoice) | ||||
|  | ||||
|     doc = form_xml.AttachedDocument( | ||||
|         simple_invoice, | ||||
|         DIANInvoiceXML, | ||||
|         id='123') | ||||
| def test_xml_with_required_elements(): | ||||
|     doc = form_xml.AttachedDocument(id='123') | ||||
|  | ||||
|     xml = doc.toFachoXML() | ||||
|  | ||||
|     DIANInvoiceXML = form_xml.DIANInvoiceXML( | ||||
|         simple_invoice, 'Invoice').attach_invoice | ||||
|  | ||||
|     ApplicationResponse = xml_header + form_xml.ApplicationResponse(simple_invoice).toFachoXML().tostring() | ||||
|  | ||||
|     attached_document = xml_header + DIANInvoiceXML.tostring() | ||||
|  | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cbc:UBLVersionID') == 'UBL 2.1' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cbc:CustomizationID') == 'Documentos adjuntos' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cbc:ProfileID') == 'Factura Electrónica de Venta' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cbc:ProfileExecutionID') == '1' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cbc:ID') == '123' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cbc:IssueDate') == str(datetime.today().date()) | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cbc:IssueTime') == datetime.today( | ||||
|         ).time().strftime( | ||||
|                 '%H:%M:%S-05:00') | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cbc:DocumentType' | ||||
|     ) == 'Contenedor de Factura Electrónica' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cbc:ParentDocumentID' | ||||
|     ) == 'ABC123' | ||||
|  | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:SenderParty/cac:PartyTaxScheme/cbc:RegistrationName' | ||||
|     ) == 'facho-supplier' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:SenderParty/cac:PartyTaxScheme/cbc:CompanyID' | ||||
|     ) == '123' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:SenderParty/cac:PartyTaxScheme/cbc:TaxLevelCode' | ||||
|     ) == 'ZZ' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:SenderParty/cac:PartyTaxScheme/cac:TaxScheme/cbc:ID' | ||||
|     ) == '01' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:SenderParty/cac:PartyTaxScheme/cac:TaxScheme/cbc:Name' | ||||
|     ) == 'IVA' | ||||
|  | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ReceiverParty/cac:PartyTaxScheme/cbc:RegistrationName' | ||||
|     ) == 'facho-customer' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ReceiverParty/cac:PartyTaxScheme/cbc:CompanyID' | ||||
|     ) == '321' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ReceiverParty/cac:PartyTaxScheme/cbc:TaxLevelCode' | ||||
|     ) == 'ZZ' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ReceiverParty/cac:PartyTaxScheme/cac:TaxScheme/cbc:ID' | ||||
|     ) == '01' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ReceiverParty/cac:PartyTaxScheme/cac:TaxScheme/cbc:Name' | ||||
|     ) == 'IVA' | ||||
|  | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:Attachment/cac:ExternalReference/cbc:MimeCode' | ||||
|     ) == "text/xml" | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:Attachment/cac:ExternalReference/cbc:EncodingCode' | ||||
|     ) == "UTF-8" | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:Attachment/cac:ExternalReference/cbc:Description' | ||||
|     ) == "<![CDATA[{}]]>".format(attached_document) | ||||
|  | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ParentDocumentLineReference/cbc:LineID' | ||||
|     ) == '1' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ParentDocumentLineReference/cac:DocumentReference/cbc:ID' | ||||
|     ) == '1234' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ParentDocumentLineReference/cac:DocumentReference/cbc:UUID' | ||||
|     ) == '1234' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ParentDocumentLineReference/cac:DocumentReference/cbc:IssueDate' | ||||
|     ) == '2024-11-28' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ParentDocumentLineReference/cac:DocumentReference/cbc:DocumentType' | ||||
|     ) == 'ApplicationResponse' | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ParentDocumentLineReference/cac:DocumentReference/cac:Attachment/cac:ExternalReference/cbc:MimeCode' | ||||
|     ) == 'text/xml' | ||||
|  | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ParentDocumentLineReference/cac:DocumentReference/cac:Attachment/cac:ExternalReference/cbc:EncodingCode' | ||||
|     ) == "UTF-8" | ||||
|  | ||||
|     assert xml.get_element_text( | ||||
|         '/atd:AttachedDocument/cac:ParentDocumentLineReference/cac:DocumentReference/cac:Attachment/cac:ExternalReference/cbc:Description' | ||||
|     ) == "<![CDATA[{}]]>".format(ApplicationResponse) | ||||
|     assert xml.get_element_text('/atd:AttachedDocument/cbc:ID') == '123' | ||||
|      | ||||
|   | ||||
| @@ -4,26 +4,21 @@ | ||||
| # this repository contains the full copyright notices and license terms. | ||||
|  | ||||
| """Tests for `facho` package.""" | ||||
| from facho.fe.data.dian import codelist | ||||
|  | ||||
| import pytest | ||||
| from facho.fe.data.dian import codelist | ||||
|  | ||||
| def test_tiporesponsabilidad(): | ||||
|     assert codelist.TipoResponsabilidad.short_name == 'TipoResponsabilidad' | ||||
|     assert codelist.TipoResponsabilidad.by_name( | ||||
|         'Autorretenedor')['name'] == 'Autorretenedor' | ||||
|  | ||||
|     assert codelist.TipoResponsabilidad.by_name('Autorretenedor')['name'] == 'Autorretenedor' | ||||
|  | ||||
| def test_tipoorganizacion(): | ||||
|     assert codelist.TipoOrganizacion.short_name == 'TipoOrganizacion' | ||||
|     assert codelist.TipoOrganizacion.by_name( | ||||
|         'Persona Natural')['name'] == 'Persona Natural' | ||||
|  | ||||
|     assert codelist.TipoOrganizacion.by_name('Persona Natural')['name'] == 'Persona Natural' | ||||
|  | ||||
| def test_tipodocumento(): | ||||
|     assert codelist.TipoDocumento.short_name == 'TipoDocumento' | ||||
|     assert codelist.TipoDocumento.by_name( | ||||
|         'Factura electrónica de Venta')['code'] == '01' | ||||
|  | ||||
|     assert codelist.TipoDocumento.by_name('Factura de Venta Nacional')['code'] == '01' | ||||
|  | ||||
| def test_departamento(): | ||||
|     assert codelist.Departamento['05']['name'] == 'Antioquia' | ||||
|   | ||||
| @@ -5,15 +5,15 @@ | ||||
| from datetime import datetime | ||||
|  | ||||
| import pytest | ||||
|  | ||||
| from facho import fe | ||||
|  | ||||
|  | ||||
| import helpers | ||||
|  | ||||
|  | ||||
| def test_xmlsigned_build(monkeypatch): | ||||
|     # openssl req -x509 -sha256 -nodes -subj "/CN=test" -days 1 -newkey rsa:2048 -keyout example.key -out example.pem | ||||
|     # openssl pkcs12 -export -out example.p12 -inkey example.key -in example.pem | ||||
|     #openssl req -x509 -sha256 -nodes -subj "/CN=test" -days 1 -newkey rsa:2048 -keyout example.key -out example.pem | ||||
|     #openssl pkcs12 -export -out example.p12 -inkey example.key -in example.pem | ||||
|     signer = fe.DianXMLExtensionSigner('./tests/example.p12') | ||||
|  | ||||
|     xml = fe.FeXML('Invoice', | ||||
| @@ -116,17 +116,3 @@ def test_xml_sign_dian_using_bytes(monkeypatch): | ||||
|  | ||||
|     xmlsigned = signer.sign_xml_string(xmlstring) | ||||
|     assert "Signature" in xmlsigned | ||||
|  | ||||
| def test_xml_signature_timestamp(monkeypatch): | ||||
|     xml = fe.FeXML( | ||||
|         'Invoice', | ||||
|         'http://www.dian.gov.co/contratos/facturaelectronica/v1') | ||||
|     xml.find_or_create_element( | ||||
|         '/fe:Invoice/ext:UBLExtensions/ext:UBLExtension/ext:ExtensionContent') | ||||
|     ublextension = xml.fragment( | ||||
|         '/fe:Invoice/ext:UBLExtensions/ext:UBLExtension', append=True) | ||||
|     ublextension.find_or_create_element( | ||||
|         '/ext:UBLExtension/ext:ExtensionContent') | ||||
|     xmlstring = xml.tostring() | ||||
|     signer = fe.DianXMLExtensionSigner('./tests/example.p12') | ||||
|     xmlsigned = signer.sign_xml_string(xmlstring) | ||||
|   | ||||
| @@ -5,47 +5,24 @@ | ||||
|  | ||||
| """Tests for `facho` package.""" | ||||
|  | ||||
| import pytest | ||||
| from datetime import datetime | ||||
| import io | ||||
| import zipfile | ||||
|  | ||||
| import facho.fe.form as form | ||||
| from facho import fe | ||||
| from facho.fe.form_xml import ( | ||||
|     DIANInvoiceXML, DIANCreditNoteXML, DIANDebitNoteXML) | ||||
|  | ||||
| from fixtures import ( | ||||
|     simple_invoice, | ||||
|     simple_invoice_without_lines, | ||||
|     simple_credit_note_without_lines, | ||||
|     simple_debit_note_without_lines) | ||||
|  | ||||
| try: | ||||
|     CUDE_ = open("./tests/cude.txt", 'r').read().strip() | ||||
| except FileNotFoundError: | ||||
|     raise Exception("Archivo Cude No encontrado") | ||||
|  | ||||
| CUFE_ = ( | ||||
|     '8bb918b19ba22a694f1da' | ||||
|     '11c643b5e9de39adf60311c' | ||||
|     'f179179e9b33381030bcd4c3c' | ||||
|     '3f156c506ed5908f9276f5bd9b4') | ||||
|  | ||||
| simple_invoice = simple_invoice | ||||
| simple_invoice_without_lines = simple_invoice_without_lines | ||||
| simple_credit_note_without_lines = simple_credit_note_without_lines | ||||
| simple_debit_note_without_lines = simple_debit_note_without_lines | ||||
| from facho.fe.form_xml import DIANInvoiceXML, DIANCreditNoteXML, DIANDebitNoteXML | ||||
|  | ||||
| from fixtures import * | ||||
|  | ||||
| def test_invoicesimple_build(simple_invoice): | ||||
|     xml = DIANInvoiceXML(simple_invoice) | ||||
|  | ||||
|     supplier_name = xml.get_element_text( | ||||
|         '/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyName/cbc:Name') | ||||
|     supplier_name = xml.get_element_text('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyName/cbc:Name') | ||||
|     assert supplier_name == simple_invoice.invoice_supplier.name | ||||
|  | ||||
|     customer_name = xml.get_element_text( | ||||
|         '/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyName/cbc:Name') | ||||
|     customer_name = xml.get_element_text('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyName/cbc:Name') | ||||
|     assert customer_name == simple_invoice.invoice_customer.name | ||||
|  | ||||
|  | ||||
| @@ -65,11 +42,9 @@ def test_invoicesimple_xml_signed(monkeypatch, simple_invoice): | ||||
|     print(xml.tostring()) | ||||
|     xml.add_extension(signer) | ||||
|  | ||||
|     elem = xml.get_element( | ||||
|         '/fe:Invoice/ext:UBLExtensions/ext:UBLExtension[2]/ext:ExtensionContent/ds:Signature') | ||||
|     elem = xml.get_element('/fe:Invoice/ext:UBLExtensions/ext:UBLExtension[2]/ext:ExtensionContent/ds:Signature') | ||||
|     assert elem.text is not None | ||||
|  | ||||
|  | ||||
| def test_invoicesimple_zip(simple_invoice): | ||||
|     xml_invoice = DIANInvoiceXML(simple_invoice) | ||||
|  | ||||
| @@ -91,34 +66,26 @@ def test_invoicesimple_zip(simple_invoice): | ||||
|  | ||||
| def test_bug_cbcid_empty_on_invoice_line(simple_invoice): | ||||
|     xml_invoice = DIANInvoiceXML(simple_invoice) | ||||
|     cbc_id = xml_invoice.get_element_text( | ||||
|         '/fe:Invoice/cac:InvoiceLine[1]/cbc:ID', format_=int) | ||||
|     cbc_id = xml_invoice.get_element_text('/fe:Invoice/cac:InvoiceLine[1]/cbc:ID', format_=int) | ||||
|     assert cbc_id == 1 | ||||
|  | ||||
|  | ||||
| def test_invoice_line_count_numeric(simple_invoice): | ||||
|     xml_invoice = DIANInvoiceXML(simple_invoice) | ||||
|     count = xml_invoice.get_element_text( | ||||
|         '/fe:Invoice/cbc:LineCountNumeric', format_=int) | ||||
|     count = xml_invoice.get_element_text('/fe:Invoice/cbc:LineCountNumeric', format_=int) | ||||
|     assert count == len(simple_invoice.invoice_lines) | ||||
|  | ||||
|  | ||||
| def test_invoice_profileexecutionid(simple_invoice): | ||||
|     xml_invoice = DIANInvoiceXML(simple_invoice) | ||||
|     cufe_extension = fe.DianXMLExtensionCUFE(simple_invoice) | ||||
|     xml_invoice.add_extension(cufe_extension) | ||||
|     id_ = xml_invoice.get_element_text( | ||||
|         '/fe:Invoice/cbc:ProfileExecutionID', format_=int) | ||||
|     id_ = xml_invoice.get_element_text('/fe:Invoice/cbc:ProfileExecutionID', format_=int) | ||||
|     assert id_ == 2 | ||||
|  | ||||
|  | ||||
| def test_invoice_invoice_type_code(simple_invoice): | ||||
|     xml_invoice = DIANInvoiceXML(simple_invoice) | ||||
|     id_ = xml_invoice.get_element_text( | ||||
|         '/fe:Invoice/cbc:InvoiceTypeCode', format_=int) | ||||
|     id_ = xml_invoice.get_element_text('/fe:Invoice/cbc:InvoiceTypeCode', format_=int) | ||||
|     assert id_ == 1 | ||||
|  | ||||
|  | ||||
| def test_invoice_totals(simple_invoice_without_lines): | ||||
|     simple_invoice = simple_invoice_without_lines | ||||
|     simple_invoice.invoice_ident = '323200000129' | ||||
| @@ -126,50 +93,39 @@ def test_invoice_totals(simple_invoice_without_lines): | ||||
|     simple_invoice.invoice_supplier.ident = '700085371' | ||||
|     simple_invoice.invoice_customer.ident = '800199436' | ||||
|     simple_invoice.add_invoice_line(form.InvoiceLine( | ||||
|         quantity=form.Quantity(1, '94'), | ||||
|         description='producto', | ||||
|         item=form.StandardItem(9999), | ||||
|         price=form.Price(form.Amount(1_500_000), '01', ''), | ||||
|         tax=form.TaxTotal( | ||||
|             subtotals=[ | ||||
|         quantity = form.Quantity(1, '94'), | ||||
|         description = 'producto', | ||||
|         item = form.StandardItem(9999), | ||||
|         price = form.Price(form.Amount(1_500_000), '01', ''), | ||||
|         tax = form.TaxTotal( | ||||
|             subtotals = [ | ||||
|                 form.TaxSubTotal( | ||||
|                     scheme=form.TaxScheme('01'), | ||||
|                     percent=19.0 | ||||
|                 )]), | ||||
|         withholding=form.WithholdingTaxTotal( | ||||
|             subtotals=[]) | ||||
|                     scheme = form.TaxScheme('01'), | ||||
|                     percent = 19.0 | ||||
|                 )]) | ||||
|     )) | ||||
|     simple_invoice.calculate() | ||||
|     assert 1 == len(simple_invoice.invoice_lines) | ||||
|     assert form.Amount(1_500_000) == ( | ||||
|         simple_invoice.invoice_legal_monetary_total.line_extension_amount) | ||||
|     assert form.Amount(1_785_000) == ( | ||||
|         simple_invoice.invoice_legal_monetary_total.payable_amount) | ||||
|  | ||||
|     assert form.Amount(1_500_000) == simple_invoice.invoice_legal_monetary_total.line_extension_amount | ||||
|     assert form.Amount(1_785_000) == simple_invoice.invoice_legal_monetary_total.payable_amount | ||||
|  | ||||
| def test_invoice_cufe(simple_invoice_without_lines): | ||||
|     simple_invoice = simple_invoice_without_lines | ||||
|     simple_invoice.invoice_ident = '323200000129' | ||||
|     simple_invoice.invoice_issue = datetime.strptime( | ||||
|         '2019-01-16 10:53:10-05:00', '%Y-%m-%d %H:%M:%S%z') | ||||
|     simple_invoice.invoice_supplier.ident = form.PartyIdentification( | ||||
|         '700085371', '5', '31') | ||||
|     simple_invoice.invoice_customer.ident = form.PartyIdentification( | ||||
|         '800199436', '5', '31') | ||||
|     simple_invoice.invoice_issue = datetime.strptime('2019-01-16 10:53:10-05:00', '%Y-%m-%d %H:%M:%S%z') | ||||
|     simple_invoice.invoice_supplier.ident = form.PartyIdentification('700085371', '5', '31') | ||||
|     simple_invoice.invoice_customer.ident = form.PartyIdentification('800199436', '5', '31') | ||||
|     simple_invoice.add_invoice_line(form.InvoiceLine( | ||||
|         quantity=form.Quantity( | ||||
|             1.00, '94'), | ||||
|         description='producto', | ||||
|         item=form.StandardItem(111), | ||||
|         price=form.Price(form.Amount(1_500_000), '01', ''), | ||||
|         tax=form.TaxTotal( | ||||
|             subtotals=[ | ||||
|         quantity = form.Quantity(1.00, '94'), | ||||
|         description = 'producto', | ||||
|         item = form.StandardItem(111), | ||||
|         price = form.Price(form.Amount(1_500_000), '01', ''), | ||||
|         tax = form.TaxTotal( | ||||
|             subtotals = [ | ||||
|                 form.TaxSubTotal( | ||||
|                     scheme=form.TaxScheme('01'), | ||||
|                     percent=19.0 | ||||
|                 )]), | ||||
|         withholding=form.WithholdingTaxTotal( | ||||
|             subtotals=[]) | ||||
|                     scheme = form.TaxScheme('01'), | ||||
|                     percent = 19.0 | ||||
|                 )]) | ||||
|     )) | ||||
|  | ||||
|     simple_invoice.calculate() | ||||
| @@ -177,86 +133,65 @@ def test_invoice_cufe(simple_invoice_without_lines): | ||||
|  | ||||
|     cufe_extension = fe.DianXMLExtensionCUFE( | ||||
|         simple_invoice, | ||||
|         tipo_ambiente=fe.AMBIENTE_PRODUCCION, | ||||
|         clave_tecnica='693ff6f2a553c3646a063436fd4dd9ded0311471' | ||||
|         tipo_ambiente = fe.AMBIENTE_PRODUCCION, | ||||
|         clave_tecnica = '693ff6f2a553c3646a063436fd4dd9ded0311471' | ||||
|     ) | ||||
|     formatVars = cufe_extension.formatVars() | ||||
|  | ||||
|     # NumFac | ||||
|     #NumFac | ||||
|     assert formatVars[0] == '323200000129', "NumFac" | ||||
|  | ||||
|     # FecFac | ||||
|     #FecFac | ||||
|     assert formatVars[1] == '2019-01-16', "FecFac" | ||||
|  | ||||
|     # HoraFac | ||||
|     #HoraFac | ||||
|     assert formatVars[2] == '10:53:10-05:00', "HoraFac" | ||||
|  | ||||
|     # ValorBruto | ||||
|     #ValorBruto | ||||
|     assert formatVars[3] == '1500000.00', "ValorBruto" | ||||
|  | ||||
|     # CodImpuesto1 | ||||
|     #CodImpuesto1 | ||||
|     assert formatVars[4] == '01', "CodImpuesto1" | ||||
|  | ||||
|     # ValorImpuesto1 | ||||
|     #ValorImpuesto1 | ||||
|     assert formatVars[5] == '285000.00', "ValorImpuesto1" | ||||
|  | ||||
|     # CodImpuesto2 | ||||
|     #CodImpuesto2 | ||||
|     assert formatVars[6] == '04', "CodImpuesto2" | ||||
|  | ||||
|     # ValorImpuesto2 | ||||
|     #ValorImpuesto2 | ||||
|     assert formatVars[7] == '0.00', "ValorImpuesto2" | ||||
|  | ||||
|     # CodImpuesto3 | ||||
|     #CodImpuesto3 | ||||
|     assert formatVars[8] == '03', "CodImpuesto3" | ||||
|  | ||||
|     # ValorImpuesto3 | ||||
|     #ValorImpuesto3 | ||||
|     assert formatVars[9] == '0.00', "ValorImpuesto3" | ||||
|  | ||||
|     # ValTotFac | ||||
|     #ValTotFac | ||||
|     assert formatVars[10] == '1785000.00', "ValTotFac" | ||||
|  | ||||
|     # NitOFE | ||||
|     #NitOFE | ||||
|     assert formatVars[11] == '700085371', "NitOFE" | ||||
|  | ||||
|     # NumAdq | ||||
|     #NumAdq | ||||
|     assert formatVars[12] == '800199436', "NumAdq" | ||||
|  | ||||
|     # ClTec | ||||
|     #ClTec | ||||
|     assert formatVars[13] == '693ff6f2a553c3646a063436fd4dd9ded0311471', "ClTec" | ||||
|  | ||||
|     # TipoAmbiente | ||||
|     #TipoAmbiente | ||||
|     assert formatVars[14] == '1', "TipoAmbiente" | ||||
|  | ||||
|     xml_invoice.add_extension(cufe_extension) | ||||
|     cufe = xml_invoice.get_element_text('/fe:Invoice/cbc:UUID') | ||||
|     # RESOLUCION 004: pagina 689 | ||||
|     assert cufe == CUFE_ | ||||
|     assert cufe == '8bb918b19ba22a694f1da11c643b5e9de39adf60311cf179179e9b33381030bcd4c3c3f156c506ed5908f9276f5bd9b4' | ||||
|  | ||||
|  | ||||
|  | ||||
| def test_credit_note_cude(simple_credit_note_without_lines): | ||||
|     simple_invoice = simple_credit_note_without_lines | ||||
|     simple_invoice.invoice_ident = '8110007871' | ||||
|     simple_invoice.invoice_issue = datetime.strptime( | ||||
|         '2019-01-12 07:00:00-05:00', '%Y-%m-%d %H:%M:%S%z') | ||||
|     simple_invoice.invoice_supplier.ident = form.PartyIdentification( | ||||
|         '900373076', '5', '31') | ||||
|     simple_invoice.invoice_customer.ident = form.PartyIdentification( | ||||
|         '8355990', '5', '31') | ||||
|     simple_invoice.invoice_issue = datetime.strptime('2019-01-12 07:00:00-05:00', '%Y-%m-%d %H:%M:%S%z') | ||||
|     simple_invoice.invoice_supplier.ident = form.PartyIdentification('900373076', '5', '31') | ||||
|     simple_invoice.invoice_customer.ident = form.PartyIdentification('8355990', '5', '31') | ||||
|     simple_invoice.add_invoice_line(form.InvoiceLine( | ||||
|         quantity=form.Quantity( | ||||
|             1, '94'), | ||||
|         description='producto', | ||||
|         item=form.StandardItem(111), | ||||
|         price=form.Price( | ||||
|             form.Amount(5_000), '01', ''), | ||||
|         tax=form.TaxTotal( | ||||
|             subtotals=[ | ||||
|         quantity = form.Quantity(1, '94'), | ||||
|         description = 'producto', | ||||
|         item = form.StandardItem(111), | ||||
|         price = form.Price(form.Amount(5_000), '01', ''), | ||||
|         tax = form.TaxTotal( | ||||
|             subtotals = [ | ||||
|                 form.TaxSubTotal( | ||||
|                     scheme=form.TaxScheme('01'), | ||||
|                     percent=19.0 | ||||
|                 )]), | ||||
|         withholding=form.WithholdingTaxTotal( | ||||
|             subtotals=[]) | ||||
|                     scheme = form.TaxScheme('01'), | ||||
|                     percent = 19.0 | ||||
|                 )]) | ||||
|     )) | ||||
|  | ||||
|     simple_invoice.calculate() | ||||
| @@ -265,39 +200,33 @@ def test_credit_note_cude(simple_credit_note_without_lines): | ||||
|     cude_extension = fe.DianXMLExtensionCUDE( | ||||
|         simple_invoice, | ||||
|         '12301', | ||||
|         tipo_ambiente=fe.AMBIENTE_PRODUCCION, | ||||
|         tipo_ambiente = fe.AMBIENTE_PRODUCCION, | ||||
|     ) | ||||
|  | ||||
|     xml_invoice.add_extension(cude_extension) | ||||
|     cude = xml_invoice.get_element_text('/fe:CreditNote/cbc:UUID') | ||||
|     # pag 612 | ||||
|  | ||||
|     assert cude == CUDE_ | ||||
|     assert cude == '907e4444decc9e59c160a2fb3b6659b33dc5b632a5008922b9a62f83f757b1c448e47f5867f2b50dbdb96f48c7681168' | ||||
|  | ||||
|  | ||||
| # pag 614 | ||||
| def test_debit_note_cude(simple_debit_note_without_lines): | ||||
|     simple_invoice = simple_debit_note_without_lines | ||||
|     simple_invoice.invoice_ident = 'ND1001' | ||||
|     simple_invoice.invoice_issue = datetime.strptime( | ||||
|         '2019-01-18 10:58:00-05:00', '%Y-%m-%d %H:%M:%S%z') | ||||
|     simple_invoice.invoice_supplier.ident = form.PartyIdentification( | ||||
|         '900197264', '5', '31') | ||||
|     simple_invoice.invoice_customer.ident = form.PartyIdentification( | ||||
|         '10254102', '5', '31') | ||||
|     simple_invoice.invoice_issue = datetime.strptime('2019-01-18 10:58:00-05:00', '%Y-%m-%d %H:%M:%S%z') | ||||
|     simple_invoice.invoice_supplier.ident = form.PartyIdentification('900197264', '5', '31') | ||||
|     simple_invoice.invoice_customer.ident = form.PartyIdentification('10254102', '5', '31') | ||||
|     simple_invoice.add_invoice_line(form.InvoiceLine( | ||||
|         quantity=form.Quantity(1, '94'), | ||||
|         description='producto', | ||||
|         item=form.StandardItem(111), | ||||
|         price=form.Price(form.Amount(30_000), '01', ''), | ||||
|         tax=form.TaxTotal( | ||||
|             subtotals=[ | ||||
|         quantity = form.Quantity(1, '94'), | ||||
|         description = 'producto', | ||||
|         item = form.StandardItem(111), | ||||
|         price = form.Price(form.Amount(30_000), '01', ''), | ||||
|         tax = form.TaxTotal( | ||||
|             subtotals = [ | ||||
|                 form.TaxSubTotal( | ||||
|                     scheme=form.TaxScheme('04'), | ||||
|                     percent=8.0 | ||||
|                 )]), | ||||
|         withholding=form.WithholdingTaxTotal( | ||||
|             subtotals=[]) | ||||
|                     scheme = form.TaxScheme('04'), | ||||
|                     percent = 8.0 | ||||
|                 )]) | ||||
|     )) | ||||
|  | ||||
|     simple_invoice.calculate() | ||||
| @@ -306,7 +235,7 @@ def test_debit_note_cude(simple_debit_note_without_lines): | ||||
|     cude_extension = fe.DianXMLExtensionCUDE( | ||||
|         simple_invoice, | ||||
|         '10201', | ||||
|         tipo_ambiente=fe.AMBIENTE_PRUEBAS, | ||||
|         tipo_ambiente = fe.AMBIENTE_PRUEBAS, | ||||
|     ) | ||||
|     build_vars = cude_extension.buildVars() | ||||
|     assert build_vars['NumFac'] == 'ND1001' | ||||
| @@ -322,7 +251,8 @@ def test_debit_note_cude(simple_debit_note_without_lines): | ||||
|     assert build_vars['Software-PIN'] == '10201' | ||||
|     assert build_vars['TipoAmb'] == 2 | ||||
|  | ||||
|     cude_composicion = "".join(cude_extension.formatVars()) | ||||
|  | ||||
|     cude_composicion =  "".join(cude_extension.formatVars()) | ||||
|     assert cude_composicion == 'ND10012019-01-1810:58:00-05:0030000.00010.00042400.00030.0032400.0090019726410254102102012' | ||||
|  | ||||
|     xml_invoice.add_extension(cude_extension) | ||||
|   | ||||
| @@ -6,117 +6,91 @@ | ||||
| """Tests for `facho` package.""" | ||||
|  | ||||
| import pytest | ||||
| # from datetime import datetime | ||||
| # import io | ||||
| # import zipfile | ||||
| from datetime import datetime | ||||
| import io | ||||
| import zipfile | ||||
|  | ||||
| import facho.fe.form as form | ||||
| # from facho import fe | ||||
|  | ||||
| from fixtures import ( | ||||
|     simple_invoice, | ||||
|     simple_invoice_without_lines, | ||||
|     simple_credit_note_without_lines, | ||||
|     simple_debit_note_without_lines) | ||||
|  | ||||
| simple_invoice = simple_invoice | ||||
| simple_invoice_without_lines = simple_invoice_without_lines | ||||
| simple_credit_note_without_lines = simple_credit_note_without_lines | ||||
| simple_debit_note_without_lines = simple_debit_note_without_lines | ||||
|  | ||||
| from facho import fe | ||||
|  | ||||
| def test_invoice_legalmonetary(): | ||||
|     inv = form.NationalSalesInvoice() | ||||
|     inv.add_invoice_line(form.InvoiceLine( | ||||
|         quantity=form.Quantity(1, '94'), | ||||
|         description='producto facho', | ||||
|         item=form.StandardItem(9999), | ||||
|         price=form.Price( | ||||
|             amount=form.Amount(100.0), | ||||
|             type_code='01', | ||||
|             type='x' | ||||
|         quantity = form.Quantity(1, '94'), | ||||
|         description = 'producto facho', | ||||
|         item = form.StandardItem(9999), | ||||
|         price = form.Price( | ||||
|             amount = form.Amount(100.0), | ||||
|             type_code = '01', | ||||
|             type = 'x' | ||||
|         ), | ||||
|         tax=form.TaxTotal( | ||||
|             subtotals=[ | ||||
|         tax = form.TaxTotal( | ||||
|             subtotals = [ | ||||
|                 form.TaxSubTotal( | ||||
|                     percent=19.0, | ||||
|                 )]), | ||||
|         withholding=form.WithholdingTaxTotal( | ||||
|             subtotals=[]) | ||||
|                     percent = 19.0, | ||||
|                 ) | ||||
|             ] | ||||
|         ) | ||||
|     )) | ||||
|  | ||||
|     inv.calculate() | ||||
|     assert inv.invoice_legal_monetary_total.line_extension_amount == ( | ||||
|         form.Amount(100.0)) | ||||
|     assert inv.invoice_legal_monetary_total.tax_exclusive_amount == ( | ||||
|         form.Amount(100.0)) | ||||
|     assert inv.invoice_legal_monetary_total.tax_inclusive_amount == ( | ||||
|         form.Amount(119.0)) | ||||
|     assert inv.invoice_legal_monetary_total.charge_total_amount == ( | ||||
|         form.Amount(0.0)) | ||||
|  | ||||
|     assert inv.invoice_legal_monetary_total.line_extension_amount == form.Amount(100.0) | ||||
|     assert inv.invoice_legal_monetary_total.tax_exclusive_amount == form.Amount(100.0) | ||||
|     assert inv.invoice_legal_monetary_total.tax_inclusive_amount == form.Amount(119.0) | ||||
|     assert inv.invoice_legal_monetary_total.charge_total_amount == form.Amount(0.0) | ||||
|  | ||||
| def test_allowancecharge_as_discount(): | ||||
|     discount = form.AllowanceChargeAsDiscount(amount=form.Amount(1000.0)) | ||||
|  | ||||
|     assert discount.isDiscount() | ||||
|  | ||||
|  | ||||
|     assert discount.isDiscount() == True | ||||
|      | ||||
| def test_FAU10(): | ||||
|     inv = form.NationalSalesInvoice() | ||||
|     inv.add_invoice_line(form.InvoiceLine( | ||||
|         quantity=form.Quantity(1, '94'), | ||||
|         description='productofacho', | ||||
|         item=form.StandardItem(9999), | ||||
|         price=form.Price( | ||||
|             amount=form.Amount(100.0), | ||||
|             type_code='01', | ||||
|             type='x' | ||||
|         quantity = form.Quantity(1, '94'), | ||||
|         description = 'producto facho', | ||||
|         item = form.StandardItem(9999), | ||||
|         price = form.Price( | ||||
|             amount = form.Amount(100.0), | ||||
|             type_code = '01', | ||||
|             type = 'x' | ||||
|         ), | ||||
|         tax=form.TaxTotal( | ||||
|             subtotals=[ | ||||
|         tax = form.TaxTotal( | ||||
|             subtotals = [ | ||||
|                 form.TaxSubTotal( | ||||
|                     percent=19.0)]), | ||||
|         withholding=form.WithholdingTaxTotal( | ||||
|             subtotals=[]) | ||||
|                     percent = 19.0, | ||||
|                 ) | ||||
|             ] | ||||
|         ) | ||||
|     )) | ||||
|  | ||||
|     inv.add_allowance_charge(form.AllowanceCharge(amount=form.Amount(19.0))) | ||||
|  | ||||
|     inv.calculate() | ||||
|     assert inv.invoice_legal_monetary_total.line_extension_amount == ( | ||||
|         form.Amount(100.0)) | ||||
|     assert inv.invoice_legal_monetary_total.tax_exclusive_amount == ( | ||||
|         form.Amount(100.0)) | ||||
|     assert inv.invoice_legal_monetary_total.tax_inclusive_amount == ( | ||||
|         form.Amount(119.0)) | ||||
|     assert inv.invoice_legal_monetary_total.charge_total_amount == ( | ||||
|         form.Amount(19.0)) | ||||
|     assert inv.invoice_legal_monetary_total.line_extension_amount == form.Amount(100.0) | ||||
|     assert inv.invoice_legal_monetary_total.tax_exclusive_amount == form.Amount(100.0) | ||||
|     assert inv.invoice_legal_monetary_total.tax_inclusive_amount == form.Amount(119.0) | ||||
|     assert inv.invoice_legal_monetary_total.charge_total_amount == form.Amount(19.0) | ||||
|  | ||||
|  | ||||
| def test_FAU14(): | ||||
|     inv = form.NationalSalesInvoice() | ||||
|     inv.add_invoice_line(form.InvoiceLine( | ||||
|         quantity=form.Quantity(1, '94'), | ||||
|         description='productofacho', | ||||
|         item=form.StandardItem(9999), | ||||
|         price=form.Price( | ||||
|             amount=form.Amount(100.0), | ||||
|             type_code='01', | ||||
|             type='x' | ||||
|         quantity = form.Quantity(1, '94'), | ||||
|         description = 'producto facho', | ||||
|         item = form.StandardItem(9999), | ||||
|         price = form.Price( | ||||
|             amount = form.Amount(100.0), | ||||
|             type_code = '01', | ||||
|             type = 'x' | ||||
|         ), | ||||
|         tax=form.TaxTotal( | ||||
|             subtotals=[ | ||||
|         tax = form.TaxTotal( | ||||
|             subtotals = [ | ||||
|                 form.TaxSubTotal( | ||||
|                     percent=19.0, | ||||
|                 )]), | ||||
|         withholding=form.WithholdingTaxTotal( | ||||
|             subtotals=[]) | ||||
|                     percent = 19.0, | ||||
|                 ) | ||||
|             ] | ||||
|         ) | ||||
|     )) | ||||
|     inv.add_allowance_charge(form.AllowanceCharge( | ||||
|         amount=form.Amount(19.0))) | ||||
|     inv.add_prepaid_payment(form.PrePaidPayment( | ||||
|         paid_amount=form.Amount(50.0))) | ||||
|     inv.add_allowance_charge(form.AllowanceCharge(amount=form.Amount(19.0))) | ||||
|     inv.add_prepaid_payment(form.PrePaidPayment(paid_amount = form.Amount(50.0))) | ||||
|     inv.calculate() | ||||
|  | ||||
|     wants = form.Amount(119.0 + 19.0 - 50.0) | ||||
| @@ -126,42 +100,38 @@ def test_FAU14(): | ||||
|  | ||||
| def test_invalid_tipo_operacion_nota_debito(): | ||||
|     reference = form.InvoiceDocumentReference( | ||||
|         ident='11111', | ||||
|         uuid='21312312', | ||||
|         date='2020-05-05' | ||||
|         ident = '11111', | ||||
|         uuid = '21312312', | ||||
|         date = '2020-05-05' | ||||
|     ) | ||||
|     inv = form.DebitNote(reference) | ||||
|     with pytest.raises(ValueError): | ||||
|         inv.set_operation_type(22) | ||||
|  | ||||
|  | ||||
| def test_valid_tipo_operacion_nota_debito(): | ||||
|     reference = form.InvoiceDocumentReference( | ||||
|         ident='11111', | ||||
|         uuid='21312312', | ||||
|         date='2020-05-05' | ||||
|         ident = '11111', | ||||
|         uuid = '21312312', | ||||
|         date = '2020-05-05' | ||||
|     ) | ||||
|     inv = form.DebitNote(reference) | ||||
|     inv.set_operation_type('30') | ||||
|  | ||||
|  | ||||
| def test_invalid_tipo_operacion_nota_credito(): | ||||
|     reference = form.InvoiceDocumentReference( | ||||
|         ident='11111', | ||||
|         uuid='21312312', | ||||
|         date='2020-05-05' | ||||
|         ident = '11111', | ||||
|         uuid = '21312312', | ||||
|         date = '2020-05-05' | ||||
|     ) | ||||
|  | ||||
|     inv = form.DebitNote(reference) | ||||
|     with pytest.raises(ValueError): | ||||
|         inv.set_operation_type('990') | ||||
|  | ||||
|  | ||||
| def test_valid_tipo_operacion_nota_credito(): | ||||
|     reference = form.InvoiceDocumentReference( | ||||
|         ident='11111', | ||||
|         uuid='21312312', | ||||
|         date='2020-05-05' | ||||
|         ident = '11111', | ||||
|         uuid = '21312312', | ||||
|         date = '2020-05-05' | ||||
|     ) | ||||
|     inv = form.CreditNote(reference) | ||||
|     inv.set_operation_type('20') | ||||
| @@ -171,52 +141,41 @@ def test_quantity(): | ||||
|     quantity1 = form.Quantity(10, '94') | ||||
|     assert quantity1 * form.Amount(3) == form.Amount(30) | ||||
|  | ||||
|  | ||||
| def test_invoice_line_quantity_without_taxes(): | ||||
|     line = form.InvoiceLine( | ||||
|         quantity=form.Quantity(10, '94'), | ||||
|         description='', | ||||
|         item=form.StandardItem('test', 9999), | ||||
|         price=form.Price( | ||||
|             amount=form.Amount(30.00), | ||||
|             type_code='01', | ||||
|             type='x'), | ||||
|         tax=form.TaxTotal(subtotals=[]), | ||||
|         withholding=form.WithholdingTaxTotal( | ||||
|             subtotals=[]) | ||||
|     ) | ||||
|         quantity = form.Quantity(10, '94'), | ||||
|         description = '', | ||||
|         item = form.StandardItem('test', 9999), | ||||
|         price = form.Price( | ||||
|             amount = form.Amount(30.00), | ||||
|             type_code = '01', | ||||
|             type = 'x' | ||||
|         ), | ||||
|         tax = form.TaxTotal(subtotals=[])) | ||||
|     line.calculate() | ||||
|     assert line.total_amount == form.Amount(300) | ||||
|     assert line.tax_amount == form.Amount(0) | ||||
|  | ||||
|  | ||||
| def test_invoice_legalmonetary_with_taxes(): | ||||
|     inv = form.NationalSalesInvoice() | ||||
|     inv.add_invoice_line(form.InvoiceLine( | ||||
|         quantity=form.Quantity(1, '94'), | ||||
|         description='productofacho', | ||||
|         item=form.StandardItem(9999), | ||||
|         price=form.Price( | ||||
|             amount=form.Amount(100.0), | ||||
|             type_code='01', | ||||
|             type='x' | ||||
|         quantity = form.Quantity(1, '94'), | ||||
|         description = 'producto facho', | ||||
|         item = form.StandardItem(9999), | ||||
|         price = form.Price( | ||||
|             amount = form.Amount(100.0), | ||||
|             type_code = '01', | ||||
|             type = 'x' | ||||
|         ), | ||||
|         tax=form.TaxTotal(subtotals=[]), | ||||
|         withholding=form.WithholdingTaxTotal( | ||||
|             subtotals=[]) | ||||
|         tax = form.TaxTotal(subtotals=[]) | ||||
|     )) | ||||
|     inv.calculate() | ||||
|  | ||||
|     assert inv.invoice_legal_monetary_total.line_extension_amount == ( | ||||
|         form.Amount(100.0)) | ||||
|     assert inv.invoice_legal_monetary_total.tax_exclusive_amount == ( | ||||
|         form.Amount(100.0)) | ||||
|     assert inv.invoice_legal_monetary_total.tax_inclusive_amount == ( | ||||
|         form.Amount(100.0)) | ||||
|     assert inv.invoice_legal_monetary_total.charge_total_amount == ( | ||||
|         form.Amount(0.0)) | ||||
|     assert inv.invoice_legal_monetary_total.payable_amount == ( | ||||
|         form.Amount(100.0)) | ||||
|     assert inv.invoice_legal_monetary_total.line_extension_amount == form.Amount(100.0) | ||||
|     assert inv.invoice_legal_monetary_total.tax_exclusive_amount == form.Amount(100.0) | ||||
|     assert inv.invoice_legal_monetary_total.tax_inclusive_amount == form.Amount(100.0) | ||||
|     assert inv.invoice_legal_monetary_total.charge_total_amount == form.Amount(0.0) | ||||
|     assert inv.invoice_legal_monetary_total.payable_amount == form.Amount(100.0) | ||||
|  | ||||
|  | ||||
| def test_invoice_ident_prefix_automatic_invalid(): | ||||
| @@ -224,7 +183,6 @@ def test_invoice_ident_prefix_automatic_invalid(): | ||||
|     with pytest.raises(ValueError): | ||||
|         inv.set_ident('SETPQJQJ1234567') | ||||
|  | ||||
|  | ||||
| def test_invoice_ident_prefix_automatic(): | ||||
|     inv = form.NationalSalesInvoice() | ||||
|     inv.set_ident('SETP1234567') | ||||
| @@ -242,15 +200,13 @@ def test_invoice_ident_prefix_automatic(): | ||||
|     inv.set_ident('1234567') | ||||
|     assert inv.invoice_ident_prefix == '' | ||||
|  | ||||
|  | ||||
| def test_invoice_ident_prefix_manual(): | ||||
|     inv = form.NationalSalesInvoice() | ||||
|     inv.set_ident('SETP1234567') | ||||
|     inv.set_ident_prefix('SETA') | ||||
|     assert inv.invoice_ident_prefix == 'SETA' | ||||
|  | ||||
|  | ||||
| def test_invoice_ident_prefix_automatic_debit(): | ||||
|     inv = form.DebitNote(form.BillingReference('', '', '')) | ||||
|     inv = form.DebitNote(form.BillingReference('','','')) | ||||
|     inv.set_ident('ABCDEF1234567') | ||||
|     assert inv.invoice_ident_prefix == 'ABCDEF' | ||||
|   | ||||
| @@ -6,24 +6,13 @@ | ||||
| """Tests for `facho` package.""" | ||||
|  | ||||
| import pytest | ||||
| # from datetime import datetime | ||||
| from datetime import datetime | ||||
| import copy | ||||
|  | ||||
| from facho.fe import form | ||||
| from facho.fe import form_xml | ||||
| # from fixtures import * | ||||
|  | ||||
| from fixtures import ( | ||||
|     simple_invoice, | ||||
|     simple_invoice_without_lines, | ||||
|     simple_credit_note_without_lines, | ||||
|     simple_debit_note_without_lines) | ||||
|  | ||||
| simple_invoice = simple_invoice | ||||
| simple_invoice_without_lines = simple_invoice_without_lines | ||||
| simple_credit_note_without_lines = simple_credit_note_without_lines | ||||
| simple_debit_note_without_lines = simple_debit_note_without_lines | ||||
|  | ||||
| from fixtures import * | ||||
|  | ||||
| def test_import_DIANInvoiceXML(): | ||||
|     try: | ||||
| @@ -38,82 +27,70 @@ def test_import_DIANDebitNoteXML(): | ||||
|     except AttributeError: | ||||
|         pytest.fail("unexpected not found") | ||||
|  | ||||
|  | ||||
| def test_import_DIANCreditNoteXML(): | ||||
|     try: | ||||
|         form_xml.DIANCreditNoteXML | ||||
|     except AttributeError: | ||||
|         pytest.fail("unexpected not found") | ||||
|  | ||||
| def test_allowance_charge_in_invoice(simple_invoice_without_lines): | ||||
|     inv = copy.copy(simple_invoice_without_lines) | ||||
|     inv.add_invoice_line(form.InvoiceLine( | ||||
|         quantity = form.Quantity(1, '94'), | ||||
|         description = 'producto facho', | ||||
|         item = form.StandardItem(9999), | ||||
|         price = form.Price( | ||||
|             amount = form.Amount(100.0), | ||||
|             type_code = '01', | ||||
|             type = 'x' | ||||
|         ), | ||||
|         tax = form.TaxTotal( | ||||
|             subtotals = [ | ||||
|                 form.TaxSubTotal( | ||||
|                     percent = 19.0, | ||||
|                 ) | ||||
|             ] | ||||
|         ) | ||||
|     )) | ||||
|     inv.add_allowance_charge(form.AllowanceCharge(amount=form.Amount(19.0))) | ||||
|     inv.calculate() | ||||
|      | ||||
|     xml = form_xml.DIANInvoiceXML(inv) | ||||
|     assert xml.get_element_text('./cac:AllowanceCharge/cbc:ID') == '1' | ||||
|     assert xml.get_element_text('./cac:AllowanceCharge/cbc:ChargeIndicator') == 'true' | ||||
|     assert xml.get_element_text('./cac:AllowanceCharge/cbc:Amount') == '19.0' | ||||
|     assert xml.get_element_text('./cac:AllowanceCharge/cbc:BaseAmount') == '100.0' | ||||
|  | ||||
| # def test_allowance_charge_in_invoice(simple_invoice_without_lines): | ||||
| #     inv = copy.copy(simple_invoice_without_lines) | ||||
| #     inv.add_invoice_line(form.InvoiceLine( | ||||
| #         quantity=form.Quantity(1, '94'), | ||||
| #         description='productofacho', | ||||
| #         item=form.StandardItem(9999), | ||||
| #         price=form.Price( | ||||
| #             amount=form.Amount(100.0), | ||||
| #             type_code='01', | ||||
| #             type='x' | ||||
| #         ), | ||||
| #         tax=form.TaxTotal( | ||||
| #             subtotals=[ | ||||
| #                 form.TaxSubTotal( | ||||
| #                     percent=19.0, | ||||
| #                 )]), | ||||
| #         withholding=form.WithholdingTaxTotal( | ||||
| #             subtotals=[]) | ||||
| #     )) | ||||
| def test_allowance_charge_in_invoice_line(simple_invoice_without_lines): | ||||
|     inv = copy.copy(simple_invoice_without_lines) | ||||
|     inv.add_invoice_line(form.InvoiceLine( | ||||
|         quantity = form.Quantity(1, '94'), | ||||
|         description = 'producto facho', | ||||
|         item = form.StandardItem(9999), | ||||
|         price = form.Price( | ||||
|             amount = form.Amount(100.0), | ||||
|             type_code = '01', | ||||
|             type = 'x' | ||||
|         ), | ||||
|         tax = form.TaxTotal( | ||||
|             subtotals = [ | ||||
|                 form.TaxSubTotal( | ||||
|                     percent = 19.0, | ||||
|                 ) | ||||
|             ] | ||||
|         ), | ||||
|         allowance_charge = [ | ||||
|             form.AllowanceChargeAsDiscount(amount=form.Amount(10.0)) | ||||
|         ] | ||||
|     )) | ||||
|     inv.calculate() | ||||
|  | ||||
| #     inv.add_allowance_charge(form.AllowanceCharge(amount=form.Amount(19.0))) | ||||
| #     inv.calculate() | ||||
|     # se aplico descuento | ||||
|     assert inv.invoice_legal_monetary_total.line_extension_amount == form.Amount(90.0) | ||||
|      | ||||
|     xml = form_xml.DIANInvoiceXML(inv) | ||||
|  | ||||
| #     xml = form_xml.DIANInvoiceXML(inv) | ||||
| #     assert xml.get_element_text('./cac:AllowanceCharge/cbc:ID') == '1' | ||||
| #     assert xml.get_element_text( | ||||
| #         './cac:AllowanceCharge/cbc:ChargeIndicator') == 'true' | ||||
| #     assert xml.get_element_text( | ||||
| #         './cac:AllowanceCharge/cbc:Amount') == '19.0' | ||||
| #     assert xml.get_element_text( | ||||
| #         './cac:AllowanceCharge/cbc:BaseAmount') == '100.0' | ||||
|  | ||||
|  | ||||
| # def test_allowance_charge_in_invoice_line(simple_invoice_without_lines): | ||||
| #     inv = copy.copy(simple_invoice_without_lines) | ||||
| #     inv.add_invoice_line(form.InvoiceLine( | ||||
| #         quantity=form.Quantity(1, '94'), | ||||
| #         description='producto facho', | ||||
| #         item=form.StandardItem(9999), | ||||
| #         price=form.Price( | ||||
| #             amount=form.Amount(100.0), | ||||
| #             type_code='01', | ||||
| #             type='x' | ||||
| #         ), | ||||
| #         tax=form.TaxTotal( | ||||
| #             subtotals=[ | ||||
| #                 form.TaxSubTotal( | ||||
| #                     percent=19.0, | ||||
| #                 )]), | ||||
| #         withholding=form.WithholdingTaxTotal( | ||||
| #             subtotals=[]), | ||||
| #         allowance_charge=[ | ||||
| #             form.AllowanceChargeAsDiscount(amount=form.Amount(10.0)) | ||||
| #         ] | ||||
| #     )) | ||||
| #     inv.calculate() | ||||
|  | ||||
| #     # se aplico descuento | ||||
| #     assert inv.invoice_legal_monetary_total.line_extension_amount == ( | ||||
| #         form.Amount(90.0)) | ||||
|  | ||||
| #     xml = form_xml.DIANInvoiceXML(inv) | ||||
|  | ||||
| #     with pytest.raises(AttributeError): | ||||
| #         assert xml.get_element_text( | ||||
| #             '/fe:Invoice/cac:AllowanceCharge/cbc:ID') == '1' | ||||
| #     xml.get_element_text( | ||||
| #         '/fe:Invoice/cac:InvoiceLine/cac:AllowanceCharge/cbc:ID') == '1' | ||||
| #     xml.get_element_text( | ||||
| #         '/fe:Invoice/cac:InvoiceLine/cac:AllowanceCharge/cbc:BaseAmount' | ||||
| #     ) == '100.0' | ||||
|     with pytest.raises(AttributeError): | ||||
|         assert xml.get_element_text('/fe:Invoice/cac:AllowanceCharge/cbc:ID') == '1' | ||||
|     xml.get_element_text('/fe:Invoice/cac:InvoiceLine/cac:AllowanceCharge/cbc:ID') == '1' | ||||
|     xml.get_element_text('/fe:Invoice/cac:InvoiceLine/cac:AllowanceCharge/cbc:BaseAmount') == '100.0' | ||||
|   | ||||
							
								
								
									
										1026
									
								
								tests/test_nomina.py
									
									
									
									
									
								
							
							
						
						
									
										1026
									
								
								tests/test_nomina.py
									
									
									
									
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @@ -1,236 +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' | ||||
| @@ -3,28 +3,22 @@ | ||||
| # 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 pytest | ||||
| import pytest | ||||
|  | ||||
| import facho.fe.form as form | ||||
| from facho import fe | ||||
| from facho.fe.form_xml import DIANInvoiceXML, DIANCreditNoteXML, DIANDebitNoteXML | ||||
|  | ||||
| from facho.fe.form_xml import DIANInvoiceXML | ||||
| # from facho.fe.form_xml import ( | ||||
| #    DIANInvoiceXML, DIANCreditNoteXML, DIANDebitNoteXML) | ||||
|  | ||||
| from fixtures import simple_invoice | ||||
| from fixtures import * | ||||
|  | ||||
| from facho.fe.form import query | ||||
|  | ||||
| simple_invoice = simple_invoice | ||||
|  | ||||
|  | ||||
| def test_query_billing_reference(simple_invoice): | ||||
|     xml = DIANInvoiceXML(simple_invoice) | ||||
|     cufe_extension = fe.DianXMLExtensionCUFE(simple_invoice) | ||||
|     xml.add_extension(cufe_extension) | ||||
|     out = xml.tostring() | ||||
|  | ||||
|      | ||||
|     reference = query.billing_reference(out, form.BillingReference) | ||||
|     assert isinstance(reference, form.BillingReference) | ||||
|     assert reference.ident != '' | ||||
|   | ||||
		Reference in New Issue
	
	Block a user