Fix: Se importan fixtures
This commit is contained in:
parent
8765a3d2c8
commit
398d27d049
@ -100,6 +100,7 @@ def simple_invoice_without_lines():
|
|||||||
))
|
))
|
||||||
return inv
|
return inv
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def simple_invoice():
|
def simple_invoice():
|
||||||
inv = form.NationalSalesInvoice()
|
inv = form.NationalSalesInvoice()
|
||||||
@ -130,19 +131,20 @@ def simple_invoice():
|
|||||||
form.Country('CO', 'Colombia'),
|
form.Country('CO', 'Colombia'),
|
||||||
form.CountrySubentity('05', 'Antioquia'))
|
form.CountrySubentity('05', 'Antioquia'))
|
||||||
))
|
))
|
||||||
|
|
||||||
inv.add_invoice_line(form.InvoiceLine(
|
inv.add_invoice_line(form.InvoiceLine(
|
||||||
quantity = form.Quantity(1, '94'),
|
quantity=form.Quantity(1, '94'),
|
||||||
description = 'producto facho',
|
description='productofacho',
|
||||||
item = form.StandardItem( 9999),
|
item=form.StandardItem(9999),
|
||||||
price = form.Price(form.Amount(100.0), '01', ''),
|
price=form.Price(form.Amount(100.0),'01',''),
|
||||||
tax = form.TaxTotal(
|
tax=form.TaxTotal(
|
||||||
tax_amount = form.Amount(0.0),
|
tax_amount=form.Amount(0.0),
|
||||||
taxable_amount = form.Amount(0.0),
|
taxable_amount=form.Amount(0.0),
|
||||||
subtotals = [
|
subtotals=[
|
||||||
form.TaxSubTotal(
|
form.TaxSubTotal(
|
||||||
percent = 19.0,
|
percent=19.0,
|
||||||
)
|
)]),
|
||||||
]
|
withholding=form.WithholdingTaxTotal(
|
||||||
)
|
subtotals=[])
|
||||||
))
|
))
|
||||||
return inv
|
return inv
|
||||||
|
@ -5,24 +5,49 @@
|
|||||||
|
|
||||||
"""Tests for `facho` package."""
|
"""Tests for `facho` package."""
|
||||||
|
|
||||||
import pytest
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
import io
|
import io
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
import facho.fe.form as form
|
import facho.fe.form as form
|
||||||
from facho import fe
|
from facho import fe
|
||||||
from facho.fe.form_xml import DIANInvoiceXML, DIANCreditNoteXML, DIANDebitNoteXML
|
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)
|
||||||
|
|
||||||
|
|
||||||
|
CUDE_ = ('907e4444decc9e59'
|
||||||
|
'160a2fb3b6659b33d'
|
||||||
|
'c5b632a5008922b9a'
|
||||||
|
'62f83f757b1c448e4'
|
||||||
|
'7f5867f2b50dbdb96f48c7681168')
|
||||||
|
|
||||||
|
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 fixtures import *
|
|
||||||
|
|
||||||
def test_invoicesimple_build(simple_invoice):
|
def test_invoicesimple_build(simple_invoice):
|
||||||
xml = DIANInvoiceXML(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
|
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
|
assert customer_name == simple_invoice.invoice_customer.name
|
||||||
|
|
||||||
|
|
||||||
@ -42,9 +67,11 @@ def test_invoicesimple_xml_signed(monkeypatch, simple_invoice):
|
|||||||
print(xml.tostring())
|
print(xml.tostring())
|
||||||
xml.add_extension(signer)
|
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
|
assert elem.text is not None
|
||||||
|
|
||||||
|
|
||||||
def test_invoicesimple_zip(simple_invoice):
|
def test_invoicesimple_zip(simple_invoice):
|
||||||
xml_invoice = DIANInvoiceXML(simple_invoice)
|
xml_invoice = DIANInvoiceXML(simple_invoice)
|
||||||
|
|
||||||
@ -66,26 +93,33 @@ def test_invoicesimple_zip(simple_invoice):
|
|||||||
|
|
||||||
def test_bug_cbcid_empty_on_invoice_line(simple_invoice):
|
def test_bug_cbcid_empty_on_invoice_line(simple_invoice):
|
||||||
xml_invoice = DIANInvoiceXML(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
|
assert cbc_id == 1
|
||||||
|
|
||||||
|
|
||||||
def test_invoice_line_count_numeric(simple_invoice):
|
def test_invoice_line_count_numeric(simple_invoice):
|
||||||
xml_invoice = DIANInvoiceXML(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)
|
assert count == len(simple_invoice.invoice_lines)
|
||||||
|
|
||||||
|
|
||||||
def test_invoice_profileexecutionid(simple_invoice):
|
def test_invoice_profileexecutionid(simple_invoice):
|
||||||
xml_invoice = DIANInvoiceXML(simple_invoice)
|
xml_invoice = DIANInvoiceXML(simple_invoice)
|
||||||
cufe_extension = fe.DianXMLExtensionCUFE(simple_invoice)
|
cufe_extension = fe.DianXMLExtensionCUFE(simple_invoice)
|
||||||
xml_invoice.add_extension(cufe_extension)
|
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
|
assert id_ == 2
|
||||||
|
|
||||||
|
|
||||||
def test_invoice_invoice_type_code(simple_invoice):
|
def test_invoice_invoice_type_code(simple_invoice):
|
||||||
xml_invoice = DIANInvoiceXML(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
|
assert id_ == 1
|
||||||
|
|
||||||
|
|
||||||
def test_invoice_totals(simple_invoice_without_lines):
|
def test_invoice_totals(simple_invoice_without_lines):
|
||||||
simple_invoice = simple_invoice_without_lines
|
simple_invoice = simple_invoice_without_lines
|
||||||
simple_invoice.invoice_ident = '323200000129'
|
simple_invoice.invoice_ident = '323200000129'
|
||||||
@ -171,26 +205,30 @@ def test_invoice_cufe(simple_invoice_without_lines):
|
|||||||
xml_invoice.add_extension(cufe_extension)
|
xml_invoice.add_extension(cufe_extension)
|
||||||
cufe = xml_invoice.get_element_text('/fe:Invoice/cbc:UUID')
|
cufe = xml_invoice.get_element_text('/fe:Invoice/cbc:UUID')
|
||||||
# RESOLUCION 004: pagina 689
|
# RESOLUCION 004: pagina 689
|
||||||
assert cufe == '8bb918b19ba22a694f1da11c643b5e9de39adf60311cf179179e9b33381030bcd4c3c3f156c506ed5908f9276f5bd9b4'
|
assert cufe == CUFE_
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def test_credit_note_cude(simple_credit_note_without_lines):
|
def test_credit_note_cude(simple_credit_note_without_lines):
|
||||||
simple_invoice = simple_credit_note_without_lines
|
simple_invoice = simple_credit_note_without_lines
|
||||||
simple_invoice.invoice_ident = '8110007871'
|
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_issue = datetime.strptime(
|
||||||
simple_invoice.invoice_supplier.ident = form.PartyIdentification('900373076', '5', '31')
|
'2019-01-12 07:00:00-05:00', '%Y-%m-%d %H:%M:%S%z')
|
||||||
simple_invoice.invoice_customer.ident = form.PartyIdentification('8355990', '5', '31')
|
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(
|
simple_invoice.add_invoice_line(form.InvoiceLine(
|
||||||
quantity = form.Quantity(1, '94'),
|
quantity=form.Quantity(
|
||||||
description = 'producto',
|
1, '94'),
|
||||||
item = form.StandardItem(111),
|
description='producto',
|
||||||
price = form.Price(form.Amount(5_000), '01', ''),
|
item=form.StandardItem(111),
|
||||||
tax = form.TaxTotal(
|
price=form.Price(
|
||||||
subtotals = [
|
form.Amount(5_000), '01', ''),
|
||||||
|
tax=form.TaxTotal(
|
||||||
|
subtotals=[
|
||||||
form.TaxSubTotal(
|
form.TaxSubTotal(
|
||||||
scheme = form.TaxScheme('01'),
|
scheme=form.TaxScheme('01'),
|
||||||
percent = 19.0
|
percent=19.0
|
||||||
)])
|
)])
|
||||||
))
|
))
|
||||||
|
|
||||||
@ -200,33 +238,38 @@ def test_credit_note_cude(simple_credit_note_without_lines):
|
|||||||
cude_extension = fe.DianXMLExtensionCUDE(
|
cude_extension = fe.DianXMLExtensionCUDE(
|
||||||
simple_invoice,
|
simple_invoice,
|
||||||
'12301',
|
'12301',
|
||||||
tipo_ambiente = fe.AMBIENTE_PRODUCCION,
|
tipo_ambiente=fe.AMBIENTE_PRODUCCION,
|
||||||
)
|
)
|
||||||
|
|
||||||
xml_invoice.add_extension(cude_extension)
|
xml_invoice.add_extension(cude_extension)
|
||||||
cude = xml_invoice.get_element_text('/fe:CreditNote/cbc:UUID')
|
cude = xml_invoice.get_element_text('/fe:CreditNote/cbc:UUID')
|
||||||
# pag 612
|
# pag 612
|
||||||
assert cude == '907e4444decc9e59c160a2fb3b6659b33dc5b632a5008922b9a62f83f757b1c448e47f5867f2b50dbdb96f48c7681168'
|
assert cude == CUDE_
|
||||||
|
|
||||||
|
|
||||||
# pag 614
|
# pag 614
|
||||||
def test_debit_note_cude(simple_debit_note_without_lines):
|
def test_debit_note_cude(simple_debit_note_without_lines):
|
||||||
simple_invoice = simple_debit_note_without_lines
|
simple_invoice = simple_debit_note_without_lines
|
||||||
simple_invoice.invoice_ident = 'ND1001'
|
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_issue = datetime.strptime(
|
||||||
simple_invoice.invoice_supplier.ident = form.PartyIdentification('900197264', '5', '31')
|
'2019-01-18 10:58:00-05:00', '%Y-%m-%d %H:%M:%S%z')
|
||||||
simple_invoice.invoice_customer.ident = form.PartyIdentification('10254102', '5', '31')
|
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(
|
simple_invoice.add_invoice_line(form.InvoiceLine(
|
||||||
quantity = form.Quantity(1, '94'),
|
quantity=form.Quantity(1, '94'),
|
||||||
description = 'producto',
|
description='producto',
|
||||||
item = form.StandardItem(111),
|
item=form.StandardItem(111),
|
||||||
price = form.Price(form.Amount(30_000), '01', ''),
|
price=form.Price(form.Amount(30_000), '01', ''),
|
||||||
tax = form.TaxTotal(
|
tax=form.TaxTotal(
|
||||||
subtotals = [
|
subtotals=[
|
||||||
form.TaxSubTotal(
|
form.TaxSubTotal(
|
||||||
scheme = form.TaxScheme('04'),
|
scheme=form.TaxScheme('04'),
|
||||||
percent = 8.0
|
percent=8.0
|
||||||
)])
|
)]),
|
||||||
|
withholding=form.WithholdingTaxTotal(
|
||||||
|
subtotals=[])
|
||||||
))
|
))
|
||||||
|
|
||||||
simple_invoice.calculate()
|
simple_invoice.calculate()
|
||||||
@ -235,7 +278,7 @@ def test_debit_note_cude(simple_debit_note_without_lines):
|
|||||||
cude_extension = fe.DianXMLExtensionCUDE(
|
cude_extension = fe.DianXMLExtensionCUDE(
|
||||||
simple_invoice,
|
simple_invoice,
|
||||||
'10201',
|
'10201',
|
||||||
tipo_ambiente = fe.AMBIENTE_PRUEBAS,
|
tipo_ambiente=fe.AMBIENTE_PRUEBAS,
|
||||||
)
|
)
|
||||||
build_vars = cude_extension.buildVars()
|
build_vars = cude_extension.buildVars()
|
||||||
assert build_vars['NumFac'] == 'ND1001'
|
assert build_vars['NumFac'] == 'ND1001'
|
||||||
@ -251,8 +294,7 @@ def test_debit_note_cude(simple_debit_note_without_lines):
|
|||||||
assert build_vars['Software-PIN'] == '10201'
|
assert build_vars['Software-PIN'] == '10201'
|
||||||
assert build_vars['TipoAmb'] == 2
|
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'
|
assert cude_composicion == 'ND10012019-01-1810:58:00-05:0030000.00010.00042400.00030.0032400.0090019726410254102102012'
|
||||||
|
|
||||||
xml_invoice.add_extension(cude_extension)
|
xml_invoice.add_extension(cude_extension)
|
||||||
|
@ -13,6 +13,17 @@ import pytest
|
|||||||
import facho.fe.form as form
|
import facho.fe.form as form
|
||||||
# from facho import fe
|
# 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
|
||||||
|
|
||||||
|
|
||||||
def test_invoice_legalmonetary():
|
def test_invoice_legalmonetary():
|
||||||
inv = form.NationalSalesInvoice()
|
inv = form.NationalSalesInvoice()
|
||||||
|
@ -13,6 +13,17 @@ from facho.fe import form
|
|||||||
from facho.fe import form_xml
|
from facho.fe import form_xml
|
||||||
# from fixtures import *
|
# 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
|
||||||
|
|
||||||
|
|
||||||
def test_import_DIANInvoiceXML():
|
def test_import_DIANInvoiceXML():
|
||||||
try:
|
try:
|
||||||
@ -50,8 +61,7 @@ def test_allowance_charge_in_invoice(simple_invoice_without_lines):
|
|||||||
subtotals=[
|
subtotals=[
|
||||||
form.TaxSubTotal(
|
form.TaxSubTotal(
|
||||||
percent=19.0,
|
percent=19.0,
|
||||||
)]
|
)]),
|
||||||
)
|
|
||||||
))
|
))
|
||||||
|
|
||||||
inv.add_allowance_charge(form.AllowanceCharge(amount=form.Amount(19.0)))
|
inv.add_allowance_charge(form.AllowanceCharge(amount=form.Amount(19.0)))
|
||||||
|
@ -12,13 +12,14 @@ from facho.fe.form_xml import DIANInvoiceXML
|
|||||||
# from facho.fe.form_xml import (
|
# from facho.fe.form_xml import (
|
||||||
# DIANInvoiceXML, DIANCreditNoteXML, DIANDebitNoteXML)
|
# DIANInvoiceXML, DIANCreditNoteXML, DIANDebitNoteXML)
|
||||||
|
|
||||||
# from fixtures import *
|
from fixtures import simple_invoice
|
||||||
|
|
||||||
from facho.fe.form import query
|
from facho.fe.form import query
|
||||||
|
|
||||||
|
simple_invoice = simple_invoice
|
||||||
|
|
||||||
|
|
||||||
def test_query_billing_reference(simple_invoice):
|
def test_query_billing_reference(simple_invoice):
|
||||||
raise Exception(simple_invoice)
|
|
||||||
xml = DIANInvoiceXML(simple_invoice)
|
xml = DIANInvoiceXML(simple_invoice)
|
||||||
cufe_extension = fe.DianXMLExtensionCUFE(simple_invoice)
|
cufe_extension = fe.DianXMLExtensionCUFE(simple_invoice)
|
||||||
xml.add_extension(cufe_extension)
|
xml.add_extension(cufe_extension)
|
||||||
|
Loading…
Reference in New Issue
Block a user