improv
FossilOrigin-Name: e2934831f86be6fb90bf9de21e91747825afdc8366304fe539b7cd1bf3edcfd5
This commit is contained in:
		| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user