From 48c56631ec8f61232c31cb2092831498463545d0 Mon Sep 17 00:00:00 2001 From: bit4bit Date: Sat, 5 Feb 2022 18:37:31 +0000 Subject: [PATCH] inicio AttachedDocument FossilOrigin-Name: 45488436368ceeb9cbe6ed5b1b63b004821b868b1eba6a80aec6db5504a21f07 --- facho/fe/fe.py | 1 + facho/fe/form_xml/__init__.py | 1 + facho/fe/form_xml/attached_document.py | 14 ++++++++++++++ tests/test_attached_document.py | 17 +++++++++++++++++ 4 files changed, 33 insertions(+) create mode 100644 facho/fe/form_xml/attached_document.py create mode 100644 tests/test_attached_document.py diff --git a/facho/fe/fe.py b/facho/fe/fe.py index 6ab90d4..c539c43 100644 --- a/facho/fe/fe.py +++ b/facho/fe/fe.py @@ -34,6 +34,7 @@ POLICY_NAME = u'Política de firma para facturas electrónicas de la República NAMESPACES = { 'facho': 'http://git.disroot.org/Etrivial/facho', + 'atd': 'urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2', 'fe': 'http://www.dian.gov.co/contratos/facturaelectronica/v1', 'cac': 'urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2', 'cbc': 'urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2', diff --git a/facho/fe/form_xml/__init__.py b/facho/fe/form_xml/__init__.py index 72d4c99..b7530fa 100644 --- a/facho/fe/form_xml/__init__.py +++ b/facho/fe/form_xml/__init__.py @@ -2,3 +2,4 @@ from .invoice import * from .credit_note import * from .debit_note import * from .utils import * +from .attached_document import * diff --git a/facho/fe/form_xml/attached_document.py b/facho/fe/form_xml/attached_document.py new file mode 100644 index 0000000..ae3df9b --- /dev/null +++ b/facho/fe/form_xml/attached_document.py @@ -0,0 +1,14 @@ +from .. import fe + +__all__ = ['AttachedDocument'] + +class AttachedDocument(): + + def __init__(self, id): + schema = 'urn:oasis:names:specification:ubl:schema:xsd:AttachedDocument-2' + self.fexml = fe.FeXML('AttachedDocument', schema) + self.fexml.set_element('./cbc:ID', id) + + def toFachoXML(self): + return self.fexml + diff --git a/tests/test_attached_document.py b/tests/test_attached_document.py new file mode 100644 index 0000000..0e58be9 --- /dev/null +++ b/tests/test_attached_document.py @@ -0,0 +1,17 @@ +#!/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 + +import helpers + +def test_xml_with_required_elements(): + doc = form_xml.AttachedDocument(id='123') + + xml = doc.toFachoXML() + assert xml.get_element_text('/atd:AttachedDocument/cbc:ID') == '123' +