facho/fe/form.py a modulo.
* facho/fe/form/query.py: utilidades. FossilOrigin-Name: a1486421fcfcf6bda1e3b4901f3fc3fe86b7156852571aad74274d5b7ce3778a
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
from .fe import FeXML
|
||||
from .fe import fe_from_string
|
||||
from .fe import NAMESPACES
|
||||
from .fe import DianXMLExtensionSigner
|
||||
from .fe import DianXMLExtensionSoftwareSecurityCode
|
||||
|
||||
@@ -48,6 +48,10 @@ NAMESPACES = {
|
||||
'sig': 'http://www.w3.org/2000/09/xmldsig#',
|
||||
}
|
||||
|
||||
def fe_from_string(document: str) -> FachoXML:
|
||||
xml = LXMLBuilder.from_string(document)
|
||||
return FachoXML(xml, nsmap=NAMESPACES)
|
||||
|
||||
from contextlib import contextmanager
|
||||
@contextmanager
|
||||
def mock_xades_policy():
|
||||
|
||||
@@ -11,7 +11,7 @@ import decimal
|
||||
from decimal import Decimal
|
||||
import typing
|
||||
|
||||
from .data.dian import codelist
|
||||
from ..data.dian import codelist
|
||||
|
||||
DECIMAL_PRECISION = 6
|
||||
|
||||
23
facho/fe/form/query.py
Normal file
23
facho/fe/form/query.py
Normal file
@@ -0,0 +1,23 @@
|
||||
"""
|
||||
utilidades
|
||||
"""
|
||||
|
||||
from .. import form
|
||||
from ..fe import fe_from_string
|
||||
from datetime import datetime
|
||||
|
||||
def billing_reference(xmldocument: str, klass: form.BillingReference) -> form.BillingReference:
|
||||
"""
|
||||
construye BillingReference desde XMLDOCUMENT
|
||||
usando KLASS como clase.
|
||||
"""
|
||||
if not issubclass(klass, form.BillingReference):
|
||||
raise TypeError('klass expected subclass of BillingReference')
|
||||
|
||||
fachoxml = fe_from_string(xmldocument)
|
||||
|
||||
uid = fachoxml.get_element_text('./cbc:ID')
|
||||
uuid = fachoxml.get_element_text('./cbc:UUID')
|
||||
issue_date = fachoxml.get_element_text('./cbc:IssueDate')
|
||||
date = datetime.strptime(issue_date, '%Y-%m-%d')
|
||||
return klass(ident=uid, uuid=uuid, date=date)
|
||||
Reference in New Issue
Block a user