tests/test_fe_form.py: se implementa prueba cude.
se implementa prueba para cude de nota debito segun ejemplo en pagina 614, pero el sha384 de la composicion difiere del generado tanto de facho como el sitio web que dan para generarlo. FossilOrigin-Name: 51b29990f6eaf4fc4f85dc51873957f41d9ba047889e4e4fe2ea4f0b1285e88c
This commit is contained in:
@@ -13,6 +13,7 @@ import hashlib
|
||||
from contextlib import contextmanager
|
||||
from .data.dian import codelist
|
||||
from . import form
|
||||
from collections import defaultdict
|
||||
|
||||
AMBIENTE_PRUEBAS = codelist.TipoAmbiente.by_name('Pruebas')['code']
|
||||
AMBIENTE_PRODUCCION = codelist.TipoAmbiente.by_name('Producción')['code']
|
||||
@@ -97,7 +98,7 @@ class DianXMLExtensionCUDFE(FachoXMLExtension):
|
||||
raise NotImplementedError()
|
||||
|
||||
def build(self, fachoxml):
|
||||
cufe = self._generate_cufe(fachoxml)
|
||||
cufe = self._generate_cufe()
|
||||
fachoxml.set_element('./cbc:UUID', cufe,
|
||||
schemeID=self.tipo_ambiente,
|
||||
schemeName=self.schemeName())
|
||||
@@ -122,7 +123,7 @@ class DianXMLExtensionCUDFE(FachoXMLExtension):
|
||||
# PAG 601
|
||||
build_vars['ValorBruto'] = invoice.invoice_legal_monetary_total.line_extension_amount
|
||||
build_vars['ValorTotalPagar'] = invoice.invoice_legal_monetary_total.payable_amount
|
||||
ValorImpuestoPara = {}
|
||||
ValorImpuestoPara = defaultdict(lambda: form.Amount(0.0))
|
||||
build_vars['CodImpuesto1'] = 1
|
||||
build_vars['CodImpuesto2'] = 4
|
||||
build_vars['CodImpuesto3'] = 3
|
||||
@@ -139,9 +140,8 @@ class DianXMLExtensionCUDFE(FachoXMLExtension):
|
||||
|
||||
return build_vars
|
||||
|
||||
def _generate_cufe(self, fachoxml):
|
||||
formatVars = self.formatVars()
|
||||
cufe = "".join(formatVars)
|
||||
def _generate_cufe(self):
|
||||
cufe = "".join(self.formatVars())
|
||||
|
||||
# crear hash...
|
||||
h = hashlib.sha384()
|
||||
|
||||
@@ -91,6 +91,7 @@ class Amount:
|
||||
def is_same_currency(self, other):
|
||||
return self.currency == other.currency
|
||||
|
||||
|
||||
@dataclass
|
||||
class Item:
|
||||
description: str
|
||||
@@ -348,12 +349,19 @@ class AllowanceCharge:
|
||||
|
||||
class NationalSalesInvoiceDocumentType(str):
|
||||
def __str__(self):
|
||||
# 6.1.3
|
||||
return '01'
|
||||
|
||||
class CreditNoteDocumentType(str):
|
||||
def __str__(self):
|
||||
# 6.1.3
|
||||
return '91'
|
||||
|
||||
class DebitNoteDocumentType(str):
|
||||
def __str__(self):
|
||||
# 6.1.3
|
||||
return '92'
|
||||
|
||||
class Invoice:
|
||||
def __init__(self, type_code: str):
|
||||
if str(type_code) not in codelist.TipoDocumento:
|
||||
@@ -475,3 +483,12 @@ class CreditNote(Invoice):
|
||||
if not isinstance(invoice_document_reference, BillingReference):
|
||||
raise TypeError('invoice_document_reference invalid type')
|
||||
self.invoice_billing_reference = invoice_document_reference
|
||||
|
||||
|
||||
class DebitNote(Invoice):
|
||||
def __init__(self, invoice_document_reference: BillingReference):
|
||||
super().__init__(DebitNoteDocumentType())
|
||||
|
||||
if not isinstance(invoice_document_reference, BillingReference):
|
||||
raise TypeError('invoice_document_reference invalid type')
|
||||
self.invoice_billing_reference = invoice_document_reference
|
||||
|
||||
@@ -17,7 +17,7 @@ class DIANDebitNoteXML(fe.FeXML):
|
||||
ublextension = self.fragment('/fe:DebitNote/ext:UBLExtensions/ext:UBLExtension', append=True)
|
||||
extcontent = ublextension.find_or_create_element('/ext:UBLExtension/ext:ExtensionContent')
|
||||
self.attach_invoice(invoice)
|
||||
|
||||
|
||||
def set_supplier(fexml, invoice):
|
||||
fexml.placeholder_for('/fe:DebitNote/cac:AccountingSupplierParty')
|
||||
#DIAN 1.7.-2020: DAJ02
|
||||
@@ -101,7 +101,7 @@ class DIANDebitNoteXML(fe.FeXML):
|
||||
invoice.invoice_customer.tax_scheme.code)
|
||||
#DIAN 1.7.-2020: DAJ41
|
||||
fexml.set_element('/fe:DebitNote/cac:AccountingSupplierParty/cac:Party/cac:PartyTaxScheme/cac:TaxScheme/cbc:Name',
|
||||
invoice.invoice_customer.tax_scheme.name)
|
||||
invoice.invoice_customer.tax_scheme.name)
|
||||
#DIAN 1.7.-2020: DAJ42
|
||||
fexml.placeholder_for('/fe:DebitNote/cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity')
|
||||
#DIAN 1.7.-2020: DAJ43
|
||||
@@ -229,7 +229,7 @@ class DIANDebitNoteXML(fe.FeXML):
|
||||
#DIAN 1.7.-2020: CAK51, CAK55
|
||||
fexml.set_element('/fe:DebitNote/cac:AccountingCustomerParty/cac:Party/cac:Contact/cbc:ElectronicMail',
|
||||
invoice.invoice_customer.email)
|
||||
|
||||
|
||||
|
||||
def set_payment_mean(fexml, invoice):
|
||||
payment_mean = invoice.invoice_payment_mean
|
||||
@@ -275,10 +275,10 @@ class DIANDebitNoteXML(fe.FeXML):
|
||||
schemeName='CUFE-SHA384')
|
||||
fexml.set_element('/fe:DebitNote/cac:BillingReference/cac:InvoiceDocumentReference/cbc:IssueDate',
|
||||
invoice.invoice_billing_reference.date)
|
||||
|
||||
|
||||
|
||||
|
||||
def set_invoice_totals(fexml, invoice):
|
||||
tax_amount_for = defaultdict(lambda: defaultdict(lambda: 0.0))
|
||||
tax_amount_for = defaultdict(lambda: defaultdict(lambda: Amount(0.0)))
|
||||
percent_for = defaultdict(lambda: None)
|
||||
|
||||
#requeridos para CUDE
|
||||
|
||||
@@ -416,7 +416,7 @@ class DIANInvoiceXML(fe.FeXML):
|
||||
return fexml._set_invoice_document_reference(reference)
|
||||
|
||||
def set_invoice_totals(fexml, invoice):
|
||||
tax_amount_for = defaultdict(lambda: defaultdict(lambda: 0.0))
|
||||
tax_amount_for = defaultdict(lambda: defaultdict(lambda: Amount(0.0)))
|
||||
percent_for = defaultdict(lambda: None)
|
||||
|
||||
#requeridos para CUFE
|
||||
|
||||
Reference in New Issue
Block a user