form.AllowanceChargeAsDiscount nueva clase para descuentos
FossilOrigin-Name: 5b11ff93dff3a301628694c2a6e71940915aea8754a9eab3f35644bc669ddf87
This commit is contained in:
parent
48619106c5
commit
e571009945
@ -129,6 +129,11 @@ class FachoXML:
|
|||||||
self.xpath_for = {}
|
self.xpath_for = {}
|
||||||
self.extensions = []
|
self.extensions = []
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_string(cls, document: str, namespaces: dict() = []) -> 'FachoXML':
|
||||||
|
xml = LXMLBuilder.from_string(document)
|
||||||
|
return FachoXML(xml, nsmap=namespaces)
|
||||||
|
|
||||||
def append_element(self, elem, new_elem):
|
def append_element(self, elem, new_elem):
|
||||||
#elem = self.find_or_create_element(xpath, append=append)
|
#elem = self.find_or_create_element(xpath, append=append)
|
||||||
#self.builder.append(elem, new_elem)
|
#self.builder.append(elem, new_elem)
|
||||||
|
@ -49,8 +49,7 @@ NAMESPACES = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
def fe_from_string(document: str) -> FachoXML:
|
def fe_from_string(document: str) -> FachoXML:
|
||||||
xml = LXMLBuilder.from_string(document)
|
return FeXML.from_string(document)
|
||||||
return FachoXML(xml, nsmap=NAMESPACES)
|
|
||||||
|
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
@contextmanager
|
@contextmanager
|
||||||
@ -69,6 +68,7 @@ def mock_xades_policy():
|
|||||||
mock.return_value = UrllibPolicyMock()
|
mock.return_value = UrllibPolicyMock()
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|
||||||
class FeXML(FachoXML):
|
class FeXML(FachoXML):
|
||||||
|
|
||||||
def __init__(self, root, namespace):
|
def __init__(self, root, namespace):
|
||||||
@ -79,6 +79,10 @@ class FeXML(FachoXML):
|
|||||||
self._cn = root.rstrip('/')
|
self._cn = root.rstrip('/')
|
||||||
#self.find_or_create_element(self._cn)
|
#self.find_or_create_element(self._cn)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def from_string(cls, document: str) -> 'FeXML':
|
||||||
|
return super().from_string(document, namespaces=NAMESPACES)
|
||||||
|
|
||||||
def tostring(self, **kw):
|
def tostring(self, **kw):
|
||||||
return super().tostring(**kw)\
|
return super().tostring(**kw)\
|
||||||
.replace("fe:", "")\
|
.replace("fe:", "")\
|
||||||
@ -360,6 +364,7 @@ class DianXMLExtensionSigner:
|
|||||||
extcontent = fachoxml.builder.xpath(fachoxml.root, './ext:UBLExtensions/ext:UBLExtension[2]/ext:ExtensionContent')
|
extcontent = fachoxml.builder.xpath(fachoxml.root, './ext:UBLExtensions/ext:UBLExtension[2]/ext:ExtensionContent')
|
||||||
fachoxml.append_element(extcontent, signature)
|
fachoxml.append_element(extcontent, signature)
|
||||||
|
|
||||||
|
|
||||||
class DianXMLExtensionAuthorizationProvider(FachoXMLExtension):
|
class DianXMLExtensionAuthorizationProvider(FachoXMLExtension):
|
||||||
# RESOLUCION 0004: pagina 176
|
# RESOLUCION 0004: pagina 176
|
||||||
|
|
||||||
|
@ -491,6 +491,11 @@ class AllowanceCharge:
|
|||||||
def hasReason(self):
|
def hasReason(self):
|
||||||
return self.reason is not None
|
return self.reason is not None
|
||||||
|
|
||||||
|
class AllowanceChargeAsDiscount(AllowanceCharge):
|
||||||
|
def __init__(self, amount: Amount = Amount(0.0)):
|
||||||
|
self.charge_indicator = False
|
||||||
|
self.amount = amount
|
||||||
|
|
||||||
class NationalSalesInvoiceDocumentType(str):
|
class NationalSalesInvoiceDocumentType(str):
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
# 6.1.3
|
# 6.1.3
|
||||||
|
@ -38,7 +38,10 @@ def test_invoice_legalmonetary():
|
|||||||
assert inv.invoice_legal_monetary_total.tax_inclusive_amount == form.Amount(119.0)
|
assert inv.invoice_legal_monetary_total.tax_inclusive_amount == form.Amount(119.0)
|
||||||
assert inv.invoice_legal_monetary_total.charge_total_amount == form.Amount(0.0)
|
assert inv.invoice_legal_monetary_total.charge_total_amount == form.Amount(0.0)
|
||||||
|
|
||||||
|
def test_allowancecharge_as_discount():
|
||||||
|
discount = form.AllowanceChargeAsDiscount(amount=form.Amount(1000.0))
|
||||||
|
assert discount.isDiscount() == True
|
||||||
|
|
||||||
def test_FAU10():
|
def test_FAU10():
|
||||||
inv = form.NationalSalesInvoice()
|
inv = form.NationalSalesInvoice()
|
||||||
inv.add_invoice_line(form.InvoiceLine(
|
inv.add_invoice_line(form.InvoiceLine(
|
||||||
|
Loading…
Reference in New Issue
Block a user