Cambio para fix FAJ08

facho/fe/data/dian/codelist/__init__.py: adiciona listas Municipio
Departamento
facho/fe/form.py: Adiciona clase City

FossilOrigin-Name: a962209128aecc9ebb4991a3beea407b5c3a05b17ee8ca6a6f84ea97a3c98814
This commit is contained in:
monomono@disroot.org 2020-09-10 01:58:24 +00:00
parent e2eb65c7a5
commit 2ac9935bbc
2 changed files with 44 additions and 15 deletions

View File

@ -72,7 +72,9 @@ __all__ = ['TipoOrganizacion',
'TipoDocumento', 'TipoDocumento',
'CodigoPrecioReferencia', 'CodigoPrecioReferencia',
'MediosPago', 'MediosPago',
'RegimenFiscal'] 'RegimenFiscal',
'Municipio',
'Departamento']
def path_for_codelist(name): def path_for_codelist(name):
return os.path.join(DATA_DIR, name) return os.path.join(DATA_DIR, name)
@ -86,3 +88,6 @@ CodigoPrecioReferencia = CodeList(path_for_codelist('CodigoPrecioReferencia-2.1.
MediosPago = CodeList(path_for_codelist('MediosPago-2.1.gc'), 'code', 'name') MediosPago = CodeList(path_for_codelist('MediosPago-2.1.gc'), 'code', 'name')
RegimenFiscal = CodeList(path_for_codelist('RegimenFiscal-2.1.custom.gc'), 'code', 'name') RegimenFiscal = CodeList(path_for_codelist('RegimenFiscal-2.1.custom.gc'), 'code', 'name')
TipoOperacionF = CodeList(path_for_codelist('TipoOperacionF-2.1.gc'), 'code', 'name') TipoOperacionF = CodeList(path_for_codelist('TipoOperacionF-2.1.gc'), 'code', 'name')
Municipio = CodeList(path_for_codelist('Municipio-2.1.gc'), 'code', 'name')
Departamento = CodeList(path_for_codelist('Departamentos-2.1.gc'), 'code', 'name')

View File

@ -33,14 +33,18 @@ class CountrySubentity:
code: str code: str
name: str name: str
@dataclass
class City:
code: str
name: str
@dataclass @dataclass
class Address: class Address:
name: str name: str
street: str = '' street: str = ''
city: str = '' city: City = City('', '')
department: str = ''
country: Country = Country('CO', 'Colombia') country: Country = Country('CO', 'Colombia')
countrysubentity: CountrySubentity = CountrySubentity('05', 'Antioquia') countrysubentity: CountrySubentity = CountrySubentity('', '')
@dataclass @dataclass
class PartyIdentification: class PartyIdentification:
@ -268,6 +272,16 @@ class DianResolucion0001Validator:
except KeyError: except KeyError:
self.errors.append((model, 'organization_code' , self.errors.append((model, 'organization_code' ,
'not found %s' % (party.organization_code))) 'not found %s' % (party.organization_code)))
try:
codelist.Departamento[party.address.countrysubentity.code]
except KeyError:
self.errors.append((model, 'countrysubentity_code',
'not found %s' % (party.address.countrysubentity.code)))
try:
codelist.Municipio[party.address.city.code]
except KeyError:
self.errors.append((model, 'city_code',
'not found %s' % (party.address.city.code)))
def _validate_invoice(self, invoice): def _validate_invoice(self, invoice):
try: try:
@ -332,9 +346,12 @@ class DIANInvoiceXML(fe.FeXML):
invoice.invoice_supplier.name) invoice.invoice_supplier.name)
#DIAN 1.7.-2020: FAJ07 #DIAN 1.7.-2020: FAJ07
fexml.placeholder_for('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address') fexml.placeholder_for('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address')
#DIAN 1.7.-2020: FAJ09 #DIAN 1.7.-2020: FAJ08
fexml.set_element('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:ID', fexml.set_element('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:ID',
invoice.invoice_supplier.address.city) invoice.invoice_supplier.address.city.code)
#DIAN 1.7.-2020: FAJ09
fexml.set_element('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:CityName',
invoice.invoice_supplier.address.city.name)
#DIAN 1.7.-2020: FAJ11 #DIAN 1.7.-2020: FAJ11
fexml.set_element('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:CountrySubentity', fexml.set_element('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:CountrySubentity',
invoice.invoice_supplier.address.countrysubentity.name) invoice.invoice_supplier.address.countrysubentity.name)
@ -376,10 +393,6 @@ class DIANInvoiceXML(fe.FeXML):
invoice.invoice_supplier.legal_name) invoice.invoice_supplier.legal_name)
fexml.set_element('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:Contact/cbc:ElectronicMail', fexml.set_element('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:Contact/cbc:ElectronicMail',
invoice.invoice_supplier.email) invoice.invoice_supplier.email)
fexml.set_element('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cbc:CityName', invoice.invoice_supplier.address.city)
fexml.set_element('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cac:AddressLine/cbc:Line', invoice.invoice_supplier.address.street)
fexml.set_element('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cac:Country/cbc:IdentificationCode', invoice.invoice_supplier.address.country.code)
fexml.set_element('/fe:Invoice/cac:AccountingSupplierParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cac:Country/cbc:Name', invoice.invoice_supplier.address.country.name)
def set_customer(fexml, invoice): def set_customer(fexml, invoice):
@ -420,10 +433,21 @@ class DIANInvoiceXML(fe.FeXML):
fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cbc:RegistrationName', fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cbc:RegistrationName',
invoice.invoice_customer.legal_name) invoice.invoice_customer.legal_name)
fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cbc:CityName', invoice.invoice_customer.address.city) #DIAN 1.7.-2020: FAK07
fexml.placeholder_for('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PhysicalLocation/cac:Address')
#DIAN 1.7.-2020: FAK08
fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:ID',
invoice.invoice_customer.address.city.code)
#DIAN 1.7.-2020: FAK09
fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cbc:CityName', invoice.invoice_customer.address.city.name)
#DIAN 1.7.-2020: FAK11
fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:CountrySubentity',
invoice.invoice_customer.address.countrysubentity.name)
#DIAN 1.7.-2020: FAK12
fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PhysicalLocation/cac:Address/cbc:CountrySubentityCode',
invoice.invoice_customer.address.countrysubentity.code)
fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cac:AddressLine/cbc:Line', invoice.invoice_customer.address.street) fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cac:AddressLine/cbc:Line', invoice.invoice_customer.address.street)
fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cac:AddressLine/cbc:Line', invoice.invoice_customer.address.street)
fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cac:Country/cbc:IdentificationCode', invoice.invoice_customer.address.country.code) fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cac:Country/cbc:IdentificationCode', invoice.invoice_customer.address.country.code)
fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cac:Country/cbc:Name', invoice.invoice_customer.address.country.name) fexml.set_element('/fe:Invoice/cac:AccountingCustomerParty/cac:Party/cac:PartyLegalEntity/cac:RegistrationAddress/cac:Country/cbc:Name', invoice.invoice_customer.address.country.name)