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