improv
FossilOrigin-Name: e2934831f86be6fb90bf9de21e91747825afdc8366304fe539b7cd1bf3edcfd5
This commit is contained in:
parent
65f74bb557
commit
9d924d5cb5
@ -34,32 +34,26 @@ class SOAPService:
|
||||
return asdict(self)
|
||||
|
||||
@dataclass
|
||||
class ConsultaResolucionesFacturacionRespuesta:
|
||||
class GetNumberingRangeResponse:
|
||||
|
||||
@dataclass
|
||||
class RangoFacturacion:
|
||||
NumeroResolucion: str
|
||||
FechaResolucion: datetime
|
||||
Prefijo: str
|
||||
RangoInicial: int
|
||||
RangoFinal: int
|
||||
FechaVigenciaDesde: datetime
|
||||
FechaVigenciaHasta: datetime
|
||||
ClaveTecnica: str
|
||||
|
||||
CodigoOperacion: str
|
||||
DescripcionOperacion: str
|
||||
IdentificadorOperacion: str
|
||||
RangoFacturacion: List[RangoFacturacion]
|
||||
class NumberRangeResponse:
|
||||
ResolutionNumber: str
|
||||
ResolutionDate: str
|
||||
Prefix: str
|
||||
FromNumber: int
|
||||
ToNumber: int
|
||||
ValidateDateFrom: str
|
||||
ValidateDateTo: str
|
||||
TechnicalKey: str
|
||||
|
||||
NumberRangeResponse: List[NumberRangeResponse]
|
||||
|
||||
|
||||
@classmethod
|
||||
def fromdict(cls, data):
|
||||
return cls(
|
||||
data['CodigoOperacion'],
|
||||
data['DescripcionOperacion'],
|
||||
data['IdentificadorOperacion'],
|
||||
data['RangoFacturacion']
|
||||
data['NumberRangeResponse']
|
||||
)
|
||||
|
||||
|
||||
@ -76,7 +70,7 @@ class GetNumberingRange(SOAPService):
|
||||
return 'GetNumberingRange'
|
||||
|
||||
def build_response(self, as_dict):
|
||||
return as_dict
|
||||
return GetNumberingRangeResponse.fromdict(as_dict)
|
||||
|
||||
|
||||
@dataclass
|
||||
|
@ -10,11 +10,24 @@ from datetime import datetime
|
||||
from .data.dian import codelist
|
||||
from . import fe
|
||||
|
||||
|
||||
@dataclass
|
||||
class Item:
|
||||
description: str
|
||||
id: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class StandarItem(Item):
|
||||
pass
|
||||
|
||||
|
||||
@dataclass
|
||||
class Country:
|
||||
code: str
|
||||
name: str
|
||||
|
||||
|
||||
@dataclass
|
||||
class Address:
|
||||
name: str
|
||||
@ -22,6 +35,7 @@ class Address:
|
||||
city: str = ''
|
||||
department: str = ''
|
||||
country: Country = Country('CO', 'COLOMBIA')
|
||||
|
||||
|
||||
@dataclass
|
||||
class Party:
|
||||
@ -38,7 +52,6 @@ class Party:
|
||||
legal_address: str = ''
|
||||
|
||||
|
||||
|
||||
@dataclass
|
||||
class TaxSubTotal:
|
||||
percent: float
|
||||
@ -70,7 +83,7 @@ class InvoiceLine:
|
||||
# RESOLUCION 0004: pagina 155
|
||||
quantity: int
|
||||
description: str
|
||||
item_ident: int
|
||||
item: Item
|
||||
price_amount: float
|
||||
tax: TaxTotal
|
||||
|
||||
@ -157,26 +170,26 @@ class DianResolucion0001Validator:
|
||||
def __init__(self):
|
||||
self.errors = []
|
||||
|
||||
def _validate_party(self, party):
|
||||
def _validate_party(self, model, party):
|
||||
try:
|
||||
codelist.TipoResponsabilidad[party.responsability_code]
|
||||
except KeyError:
|
||||
self.errors.append(('responsability_code', 'not found'))
|
||||
self.errors.append((model, 'responsability_code', 'not found'))
|
||||
|
||||
try:
|
||||
codelist.TipoOrganizacion[party.organization_code]
|
||||
except KeyError:
|
||||
self.errors.append(('organization_code', 'not found'))
|
||||
self.errors.append((model, 'organization_code', 'not found'))
|
||||
|
||||
def validate(self, invoice):
|
||||
invoice.accept(self)
|
||||
return not self.errors
|
||||
|
||||
def visit_customer(self, customer):
|
||||
self._validate_party(customer)
|
||||
self._validate_party('customer', customer)
|
||||
|
||||
def visit_supplier(self, supplier):
|
||||
self._validate_party(supplier)
|
||||
self._validate_party('supplier', supplier)
|
||||
|
||||
def visit_invoice_line(self, line):
|
||||
pass
|
||||
@ -276,7 +289,8 @@ class DIANInvoiceXML(fe.FeXML):
|
||||
line.set_element('/fe:InvoiceLine/cbc:InvoicedQuantity', invoice_line.quantity, unitCode = 'NAR')
|
||||
line.set_element('/fe:InvoiceLine/cbc:LineExtensionAmount', invoice_line.total_amount, currencyID="COP")
|
||||
line.set_element('/fe:InvoiceLine/fe:Price/cbc:PriceAmount', invoice_line.price_amount, currencyID="COP")
|
||||
line.set_element('/fe:InvoiceLine/fe:Item/cbc:Description', invoice_line.description)
|
||||
|
||||
line.set_element('/fe:InvoiceLine/fe:Item/cbc:Description', invoice_line.item.description)
|
||||
# TODO
|
||||
line.set_element('/fe:InvoiceLine/fe:Item/cac:StandardItemIdentification/cbc:ID', invoice_line.item.id)
|
||||
|
||||
return fexml
|
||||
|
@ -57,7 +57,7 @@ def simple_invoice():
|
||||
inv.add_invoice_line(form.InvoiceLine(
|
||||
quantity = 1,
|
||||
description = 'producto facho',
|
||||
item_ident = 9999,
|
||||
item = form.StandarItem('test', 9999),
|
||||
price_amount = 100.0,
|
||||
tax = form.TaxTotal(
|
||||
tax_amount = 0.0,
|
||||
@ -159,7 +159,7 @@ def test_invoice_totals(simple_invoice_without_lines):
|
||||
simple_invoice.add_invoice_line(form.InvoiceLine(
|
||||
quantity = 1,
|
||||
description = 'producto',
|
||||
item_ident = 9999,
|
||||
item = form.StandarItem('test', 9999),
|
||||
price_amount = 1_500_000,
|
||||
tax = form.TaxTotal(
|
||||
subtotals = [
|
||||
@ -182,7 +182,7 @@ def test_invoice_cufe(simple_invoice_without_lines):
|
||||
simple_invoice.add_invoice_line(form.InvoiceLine(
|
||||
quantity = 1,
|
||||
description = 'producto',
|
||||
item_ident = 9999,
|
||||
item = form.StandarItem('test', 111),
|
||||
price_amount = 1_500_000,
|
||||
tax = form.TaxTotal(
|
||||
subtotals = [
|
||||
|
Loading…
Reference in New Issue
Block a user