74 lines
2.9 KiB
Python
74 lines
2.9 KiB
Python
#!/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.
|
|
# from datetime import datetime
|
|
|
|
import pytest
|
|
from facho.fe import form_xml
|
|
from datetime import datetime
|
|
import helpers
|
|
|
|
from fixtures import simple_invoice
|
|
|
|
def test_xml_with_required_elements(simple_invoice):
|
|
doc = form_xml.AttachedDocument(simple_invoice, id='123')
|
|
xml = doc.toFachoXML()
|
|
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'
|
|
|
|
with open("output.xml", "w") as fh:
|
|
fh.write(xml.tostring())
|