diff --git a/drafthorse/models/elements.py b/drafthorse/models/elements.py index 31a0e3d..b6e8782 100644 --- a/drafthorse/models/elements.py +++ b/drafthorse/models/elements.py @@ -236,7 +236,7 @@ def to_etree(self): return node def from_etree(self, root, strict=True): - self._text = Decimal(root.text) + self._text = root.text self._list_id = root.attrib["listID"] self._list_version_id = root.attrib["listVersionID"] self._set_on_input = True diff --git a/tests/test_classification.py b/tests/test_classification.py new file mode 100644 index 0000000..b3928ca --- /dev/null +++ b/tests/test_classification.py @@ -0,0 +1,22 @@ +import xml.etree.ElementTree as ET + +from drafthorse.models.product import ProductClassification + +NS = "urn:un:unece:uncefact:data:standard:ReusableAggregateBusinessInformationEntity:100" + + +def _parse(code, list_id, version): + xml = ( + f'' + f'{code}' + "" + ) + return ProductClassification().from_etree(ET.fromstring(xml)) + + +def test_class_code_keeps_the_original_text(): + horses = _parse("010121", "HS", "2022") + assert str(horses.class_code) == "010121 (HS 2022)" + + service = _parse("SRV", "ZZZ", "1") + assert str(service.class_code) == "SRV (ZZZ 1)"