diff --git a/facho/fe/form.py b/facho/fe/form.py index 6c9fc53..d01ffda 100644 --- a/facho/fe/form.py +++ b/facho/fe/form.py @@ -10,6 +10,19 @@ from datetime import datetime from .data.dian import codelist from . import fe +@dataclass +class Country: + code: str + name: str + +@dataclass +class Address: + name: str + street: str = '' + city: str = '' + department: str = '' + country: Country = Country('CO', 'COLOMBIA') + @dataclass class Party: name: str @@ -18,7 +31,7 @@ class Party: organization_code: str phone: str = '' - address: str = '' + address: Address= Address('') email: str = '' legal_name: str = '' legal_company_ident: str = '' @@ -210,8 +223,13 @@ class DIANInvoiceXML(fe.FeXML): invoice.invoice_supplier.name) fexml.set_element('/fe:Invoice/fe:AccountingSupplierParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationName', invoice.invoice_supplier.legal_name) + fexml.set_element('/fe:Invoice/fe:AccountingSupplierParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationAddress/cbc:CityName', invoice.invoice_supplier.address.city) + fexml.set_element('/fe:Invoice/fe:AccountingSupplierParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationAddress/cac:AddressLine/cbc:Line', invoice.invoice_supplier.address.street) + fexml.set_element('/fe:Invoice/fe:AccountingSupplierParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationAddress/cac:Country/cbc:IdentificationCode', invoice.invoice_supplier.address.country.code) + fexml.set_element('/fe:Invoice/fe:AccountingSupplierParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationAddress/cac:Country/cbc:name', invoice.invoice_supplier.address.country.name) + fexml.set_element('/fe:Invoice/fe:AccountingSupplierParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationAddress/cac:Country/cac:AddressLine/cbc:Line', invoice.invoice_supplier.address.street) fexml.set_element('/fe:Invoice/fe:AccountingSupplierParty/fe:Party/fe:PhysicalLocation/fe:Address/cac:AddressLine/cbc:Line', - invoice.invoice_supplier.address) + invoice.invoice_supplier.address.street) fexml.set_element('/fe:Invoice/fe:AccountingCustomerParty/fe:Party/cac:PartyIdentification/cbc:ID', invoice.invoice_customer.ident) fexml.set_element('/fe:Invoice/fe:AccountingCustomerParty/fe:Party/fe:PartyTaxScheme/cbc:TaxLevelCode', @@ -224,9 +242,14 @@ class DIANInvoiceXML(fe.FeXML): invoice.invoice_customer.ident) fexml.set_element('/fe:Invoice/fe:AccountingCustomerParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationName', invoice.invoice_customer.legal_name) + fexml.set_element('/fe:Invoice/fe:AccountingCustomerParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationAddress/cbc:CityName', invoice.invoice_customer.address.city) + fexml.set_element('/fe:Invoice/fe:AccountingCustomerParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationAddress/cac:Country/cbc:IdentificationCode', invoice.invoice_customer.address.country.code) + fexml.set_element('/fe:Invoice/fe:AccountingCustomerParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationAddress/cac:Country/cbc:Name', invoice.invoice_customer.address.country.name) + fexml.set_element('/fe:Invoice/fe:AccountingCustomerParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationAddress/cac:AddressLine/cbc:Line', invoice.invoice_customer.address.street) fexml.set_element('/fe:Invoice/fe:AccountingCustomerParty/fe:Party/fe:PhysicalLocation/fe:Address/cac:AddressLine/cbc:Line', - invoice.invoice_customer.address) - + invoice.invoice_customer.address.street) + fexml.set_element('/fe:Invoice/fe:AccountingCustomerParty/fe:Party/fe:PartyLegalEntity/cbc:RegistrationAddress/cac:Country/cac:AddressLine/cbc:Line', invoice.invoice_customer.address.street) + fexml.set_element('/fe:Invoice/fe:LegalMonetaryTotal/cbc:LineExtensionAmount', invoice.invoice_legal_monetary_total.line_extension_amount, currencyID='COP') diff --git a/tests/test_fe_form.py b/tests/test_fe_form.py index e20fb30..8b0ffb8 100644 --- a/tests/test_fe_form.py +++ b/tests/test_fe_form.py @@ -24,13 +24,15 @@ def simple_invoice_without_lines(): name = 'facho-supplier', ident = 123, responsability_code = 'No aplica', - organization_code = 'Persona Natural' + organization_code = 'Persona Natural', + address = form.Address(name='Test Building') )) inv.set_customer(form.Party( name = 'facho-customer', ident = 321, responsability_code = 'No aplica', - organization_code = 'Persona Natural' + organization_code = 'Persona Natural', + address = form.Address(name='Test Building') )) return inv