Fix: Formateado PEP8 se elimina responsabilidad O-07 segun anexo 1.9

This commit is contained in:
sinergia 2024-08-06 14:02:40 -05:00
parent 028cf8b687
commit de99633211
5 changed files with 165 additions and 135 deletions

View File

@ -14,7 +14,7 @@ from facho.fe import fe
from datetime import datetime, date from datetime import datetime, date
# Datos del fomulario del SET de pruebas # Datos del fomulario del SET de pruebas
INVOICE_AUTHORIZATION = '181360000001' #Número suministrado por la Dian en el momento de la creación del SET de Pruebas INVOICE_AUTHORIZATION = '181360000001' # Número suministrado por la Dian en el momento de la creación del SET de Pruebas
ID_SOFTWARE = '57bcb6d1-c591-5a90-b80a-cb030ec91440' #Id suministrado por la Dian en el momento de la creación del SET de Pruebas ID_SOFTWARE = '57bcb6d1-c591-5a90-b80a-cb030ec91440' #Id suministrado por la Dian en el momento de la creación del SET de Pruebas
PIN = '19642' #Número creado por la empresa para poder crear el SET de pruebas PIN = '19642' #Número creado por la empresa para poder crear el SET de pruebas
CLAVE_TECNICA = 'fc9eac422eba16e21ffd8c5f94b3f30a6e38162d' ##Id suministrado por la Dian en el momento de la creación del SET de Pruebas CLAVE_TECNICA = 'fc9eac422eba16e21ffd8c5f94b3f30a6e38162d' ##Id suministrado por la Dian en el momento de la creación del SET de Pruebas
@ -36,6 +36,7 @@ def extensions(inv):
'SETP', 990000000, 995000000)#del SET de pruebas 'SETP', 990000000, 995000000)#del SET de pruebas
return [security_code, authorization_provider, cufe, software_provider, inv_authorization] return [security_code, authorization_provider, cufe, software_provider, inv_authorization]
def invoice(): def invoice():
# factura de venta nacional # factura de venta nacional
inv = form.Invoice('01') inv = form.Invoice('01')
@ -49,16 +50,17 @@ def invoice():
inv.set_operation_type('10') inv.set_operation_type('10')
inv.set_supplier(form.Party( inv.set_supplier(form.Party(
legal_name = 'Nombre registrado de la empresa', legal_name = 'Nombre registrado de la empresa',
name = 'Nombre comercial o él mismo nombre registrado', name='Nombre comercial o él mismo nombre registrado',
ident = form.PartyIdentification('nit_empresa', 'digito_verificación', '31'), ident=form.PartyIdentification(
'nit_empresa', 'digito_verificación', '31'),
# obligaciones del contribuyente ver DIAN:FAK26 # obligaciones del contribuyente ver DIAN:FAK26
responsability_code = form.Responsability(['O-07', 'O-14', 'O-48']), responsability_code=form.Responsability(['ZZ', 'O-14', 'O-48']),
# ver DIAN:FAJ28 # ver DIAN:FAJ28
responsability_regime_code = '48', responsability_regime_code='48',
# tipo de organizacion juridica ver DIAN:6.2.3 # tipo de organizacion juridica ver DIAN:6.2.3
organization_code = '1', organization_code='1',
email = "correoempresa@correoempresa.correo", email="correoempresa@correoempresa.correo",
address = form.Address( address=form.Address(
'', '', form.City('05001', 'Medellín'), '', '', form.City('05001', 'Medellín'),
form.Country('CO', 'Colombia'), form.Country('CO', 'Colombia'),
form.CountrySubentity('05', 'Antioquia')), form.CountrySubentity('05', 'Antioquia')),
@ -76,42 +78,43 @@ def invoice():
'', '', form.City('05001', 'Medellín'), '', '', form.City('05001', 'Medellín'),
form.Country('CO', 'Colombia'), form.Country('CO', 'Colombia'),
form.CountrySubentity('05', 'Antioquia')), form.CountrySubentity('05', 'Antioquia')),
#tax_scheme = form.TaxScheme('01', 'IVA') # tax_scheme = form.TaxScheme('01', 'IVA')
)) ))
# asignar metodo de pago # asignar metodo de pago
inv.set_payment_mean(form.PaymentMean( inv.set_payment_mean(form.PaymentMean(
# metodo de pago ver DIAN:3.4.1 # metodo de pago ver DIAN:3.4.1
id = '1', id='1',
# codigo correspondiente al medio de pago ver DIAN:3.4.2 # codigocorrespondientealmediodepagoverDIAN:3.4.2
code = '20', code='20',
# fecha de vencimiento de la factura # fechadevencimientodelafactura
due_at = datetime.now(), due_at=datetime.now(),
# identificador numerico # identificadornumerico
payment_id = '2' payment_id='2'
)) ))
# adicionar una linea al documento # adicionar una linea al documento
inv.add_invoice_line(form.InvoiceLine( inv.add_invoice_line(
quantity = form.Quantity(int(20.5), '94'), form.InvoiceLine(
# item general de codigo 999 quantity=form.Quantity(int(20.5), '94'),
description = 'productO3', # item general de codigo 999
item = form.StandardItem('test', 9999), description='productO3',
price = form.Price( sitem=form.StandardItem('test', 9999),
# precio base del item (sin iva) price=form.Price(
amount = form.Amount(200.00), # precio base del item (sin iva)
# ver DIAN:6.3.5.1 amount=form.Amount(200.00),
type_code = '01', # ver DIAN:6.3.5.1
type = 'x' type_code='01',
), type='x'
tax = form.TaxTotal( ),
subtotals = [ tax=form.TaxTotal(
form.TaxSubTotal( subtotals=[
percent = 19.00, form.TaxSubTotal(
scheme=form.TaxScheme('01') percent=19.00,
) scheme=form.TaxScheme('01')
] )]
) )
)) ))
return inv return inv
def document_xml(): def document_xml():
return form_xml.DIANInvoiceXML return form_xml.DIANInvoiceXML

View File

@ -1,109 +1,127 @@
# importar libreria de modelos # importar libreria de modelos
from facho import fe, form_xml
import facho.fe.form as form import facho.fe.form as form
import facho.fe.form_xml import datetime
PRIVATE_KEY_PATH = 'ruta a mi llave privada'
PRIVATE_PASSPHRASE = 'clave de la llave privada'
PRIVATE_KEY_PATH='ruta a mi llave privada'
PRIVATE_PASSPHRASE='clave de la llave privada'
# consultar las extensiones necesarias # consultar las extensiones necesarias
def extensions(inv): def extensions(inv):
security_code = fe.DianXMLExtensionSoftwareSecurityCode('id software', 'pin', inv.invoice_ident) security_code = fe.DianXMLExtensionSoftwareSecurityCode(
'id software', 'pin', inv.invoice_ident)
authorization_provider = fe.DianXMLExtensionAuthorizationProvider() authorization_provider = fe.DianXMLExtensionAuthorizationProvider()
cufe = fe.DianXMLExtensionCUFE(inv, fe.DianXMLExtensionCUFE.AMBIENTE_PRUEBAS, cufe = fe.DianXMLExtensionCUFE(
'clave tecnica') inv, fe.DianXMLExtensionCUFE.AMBIENTE_PRUEBAS,
'clave tecnica')
nit = form.PartyIdentification('nit', '5', '31') nit = form.PartyIdentification('nit', '5', '31')
software_provider = fe.DianXMLExtensionSoftwareProvider(nit, nit.dv, 'id software') software_provider = fe.DianXMLExtensionSoftwareProvider(
inv_authorization = fe.DianXMLExtensionInvoiceAuthorization('invoice autorization', nit, nit.dv, 'id software')
datetime(2019, 1, 19), inv_authorization = fe.DianXMLExtensionInvoiceAuthorization(
datetime(2030, 1, 19), 'invoice autorization',
'SETP', 990000001, 995000000) datetime(2019, 1, 19),
return [security_code, authorization_provider, cufe, software_provider, inv_authorization] datetime(2030, 1, 19),
'SETP', 990000001, 995000000)
return [
security_code,
authorization_provider,
cufe, software_provider,
inv_authorization
]
# generar documento desde modelo a ruta indicada # generar documento desde modelo a ruta indicada
def generate_document(invoice, filepath): def generate_document(invoice, filepath):
xml = form_xml.DIANInvoiceXML(invoice) xml = form_xml.DIANInvoiceXML(invoice)
for extension in extensions(invoice): for extension in extensions(invoice):
xml.add_extension(extension) xml.add_extension(extension)
form_xml.utils.DIANWriteSigned(xml, filepath, PRIVATE_KEY_PATH, PRIVATE_PASSPHRASE, True) form_xml.utils.DIANWriteSigned(
xml, filepath, PRIVATE_KEY_PATH, PRIVATE_PASSPHRASE, True)
# Modelars las facturas # Modelars las facturas
# ... # ...
# factura de venta nacional # factura de venta nacional
inv = form.NationalSalesInvoice() inv = form.NationalSalesInvoice()
# asignar periodo de facturacion # asignar periodo de facturacion
inv.set_period(datetime.now(), datetime.now()) inv.set_period(datetime.now(), datetime.now())
# asignar fecha de emision de la factura # asignar fecha de emision de la factura
inv.set_issue(datetime.now()) inv.set_issue(datetime.now())
# asignar prefijo y numero del documento # asignar prefijo y numero del documento
inv.set_ident('SETP990003033') inv.set_ident('SETP990003033')
# asignar tipo de operacion ver DIAN:6.1.5 # asignar tipo de operacion ver DIAN:6.1.5
inv.set_operation_type('10') inv.set_operation_type('10')
# asignar proveedor # asignar proveedor
inv.set_supplier(form.Party( inv.set_supplier(form.Party(
legal_name = 'FACHO SOS', legal_name='FACHOSOS',
name = 'FACHO SOS', name='FACHOSOS',
ident = form.PartyIdentification('900579212', '5', '31'), ident=form.PartyIdentification('900579212', '5', '31'),
# obligaciones del contribuyente ver DIAN:FAK26 # obligaciones del contribuyente ver DIAN:FAK26
responsability_code = form.Responsability(['O-07', 'O-09', 'O-14', 'O-48']), responsability_code=form.Responsability(['ZZ', 'O-09', 'O-14', 'O-48']),
# ver DIAN:FAJ28 # ver DIAN:FAJ28
responsability_regime_code = '48', responsability_regime_code='48',
# tipo de organizacion juridica ver DIAN:6.2.3 # tipo de organizacion juridica ver DIAN:6.2.3
organization_code = '1', organization_code='1',
email = "sdds@sd.com", email="sdds@sd.com",
address = form.Address( address=form.Address(
name = '', name='',
street = '', street='',
city = form.City('05001', 'Medellín'), city=form.City('05001', 'Medellín'),
country = form.Country('CO', 'Colombia'), country=form.Country('CO', 'Colombia'),
countrysubentity = form.CountrySubentity('05', 'Antioquia')) countrysubentity=form.CountrySubentity('05', 'Antioquia'))
)) ))
inv.set_customer(form.Party( inv.set_customer(form.Party(
legal_name = 'facho-customer', legal_name='facho-customer',
name = 'facho-customer', name='facho-customer',
ident = form.PartyIdentification('999999999', '', '13'), ident=form.PartyIdentification('999999999', '', '13'),
responsability_code = form.Responsability(['R-99-PN']), responsability_code=form.Responsability(['R-99-PN']),
responsability_regime_code = '49', responsability_regime_code='49',
organization_code = '2', organization_code='2',
email = "sdds@sd.com", email="sdds@sd.com",
address = form.Address( address=form.Address(
name = '', name='',
street = '', street='',
city = form.City('05001', 'Medellín'), city=form.City('05001', 'Medellín'),
country = form.Country('CO', 'Colombia'), country=form.Country('CO', 'Colombia'),
countrysubentity = form.CountrySubentity('05', 'Antioquia')) countrysubentity=form.CountrySubentity('05', 'Antioquia'))
)) ))
# asignar metodo de pago # asignar metodo de pago
inv.set_payment_mean(form.PaymentMean( inv.set_payment_mean(form.PaymentMean(
# metodo de pago ver DIAN:3.4.1 # metodo de pago ver DIAN:3.4.1
id = '1', id='1',
# codigo correspondiente al medio de pago ver DIAN:3.4.2 # codigo correspondiente al medio de pago ver DIAN:3.4.2
code = '10', code='10',
# fecha de vencimiento de la factura # fecha de vencimiento de la factura
due_at = datetime.now(), due_at=datetime.now(),
# identificador numerico # identificador numerico
payment_id = '1' payment_id='1'
)) ))
# adicionar una linea al documento # adicionar una linea al documento
inv.add_invoice_line(form.InvoiceLine( inv.add_invoice_line(form.InvoiceLine(
quantity = form.Quantity(1, '94'), quantity=form.Quantity(1, '94'),
description = 'producto facho', description='producto facho',
# item general de codigo 999 # item general de codigo 999
item = form.StandardItem('test', 9999), item=form.StandardItem('test', 9999),
price = form.Price( price=form.Price(
# precio base del tiem # precio base del tiem
amount = form.Amount(100.00), amount=form.Amount(100.00),
# ver DIAN:6.3.5.1 # ver DIAN:6.3.5.1
type_code = '01', type_code='01',
type = 'x' type='x'
), ),
tax = form.TaxTotal( tax=form.TaxTotal(
subtotals = [ subtotals=[
form.TaxSubTotal( form.TaxSubTotal(
percent = 19.00, percent=19.00,
) )]
]
) )
)) ))

View File

@ -76,7 +76,7 @@
<cac:PartyTaxScheme> <cac:PartyTaxScheme>
<cbc:RegistrationName>NEUROTEC TECNOLOGIA S.A.S</cbc:RegistrationName> <cbc:RegistrationName>NEUROTEC TECNOLOGIA S.A.S</cbc:RegistrationName>
<cbc:CompanyID schemeAgencyName="CO, DIAN (Dirección de Impuestos y Aduanas Nacionales)" schemeAgencyID="195" schemeID="5" schemeName="31">900579212</cbc:CompanyID> <cbc:CompanyID schemeAgencyName="CO, DIAN (Dirección de Impuestos y Aduanas Nacionales)" schemeAgencyID="195" schemeID="5" schemeName="31">900579212</cbc:CompanyID>
<cbc:TaxLevelCode listName="48">O-07;O-09;O-14;O-48</cbc:TaxLevelCode> <cbc:TaxLevelCode listName="48">ZZ;O-09;O-14;O-48</cbc:TaxLevelCode>
<cac:TaxScheme/> <cac:TaxScheme/>
</cac:PartyTaxScheme> </cac:PartyTaxScheme>
<cac:Contact> <cac:Contact>

View File

@ -4,30 +4,32 @@ from datetime import datetime
@pytest.fixture @pytest.fixture
def simple_debit_note_without_lines(): def simple_debit_note_without_lines():
inv = form.DebitNote(form.InvoiceDocumentReference('1234', 'xx', datetime.now())) inv = form.DebitNote(form.InvoiceDocumentReference(
'1234', 'xx', datetime.now()))
inv.set_period(datetime.now(), datetime.now()) inv.set_period(datetime.now(), datetime.now())
inv.set_issue(datetime.now()) inv.set_issue(datetime.now())
inv.set_ident('ABC123') inv.set_ident('ABC123')
inv.set_operation_type('30') inv.set_operation_type('30')
inv.set_payment_mean(form.PaymentMean(form.PaymentMean.DEBIT, '41', datetime.now(), '1234')) inv.set_payment_mean(form.PaymentMean(
form.PaymentMean.DEBIT, '41', datetime.now(), '1234'))
inv.set_supplier(form.Party( inv.set_supplier(form.Party(
name = 'facho-supplier', name='facho-supplier',
ident = form.PartyIdentification('123','', '31'), ident=form.PartyIdentification('123', '', '31'),
responsability_code = form.Responsability(['O-07']), responsability_code = form.Responsability(['ZZ']),
responsability_regime_code = '48', responsability_regime_code='48',
organization_code = '1', organization_code='1',
address = form.Address( address=form.Address(
'', '', form.City('05001', 'Medellín'), '', '', form.City('05001', 'Medellín'),
form.Country('CO', 'Colombia'), form.Country('CO', 'Colombia'),
form.CountrySubentity('05', 'Antioquia')) form.CountrySubentity('05', 'Antioquia'))
)) ))
inv.set_customer(form.Party( inv.set_customer(form.Party(
name = 'facho-customer', name='facho-customer',
ident = form.PartyIdentification('321', '', '31'), ident=form.PartyIdentification('321', '', '31'),
responsability_code = form.Responsability(['O-07']), responsability_code=form.Responsability(['ZZ']),
responsability_regime_code = '48', responsability_regime_code='48',
organization_code = '1', organization_code='1',
address = form.Address( address=form.Address(
'', '', form.City('05001', 'Medellín'), '', '', form.City('05001', 'Medellín'),
form.Country('CO', 'Colombia'), form.Country('CO', 'Colombia'),
form.CountrySubentity('05', 'Antioquia')) form.CountrySubentity('05', 'Antioquia'))
@ -45,7 +47,7 @@ def simple_credit_note_without_lines():
inv.set_supplier(form.Party( inv.set_supplier(form.Party(
name = 'facho-supplier', name = 'facho-supplier',
ident = form.PartyIdentification('123','', '31'), ident = form.PartyIdentification('123','', '31'),
responsability_code = form.Responsability(['O-07']), responsability_code = form.Responsability(['ZZ']),
responsability_regime_code = '48', responsability_regime_code = '48',
organization_code = '1', organization_code = '1',
address = form.Address( address = form.Address(
@ -56,7 +58,7 @@ def simple_credit_note_without_lines():
inv.set_customer(form.Party( inv.set_customer(form.Party(
name = 'facho-customer', name = 'facho-customer',
ident = form.PartyIdentification('321', '', '31'), ident = form.PartyIdentification('321', '', '31'),
responsability_code = form.Responsability(['O-07']), responsability_code = form.Responsability(['ZZ']),
responsability_regime_code = '48', responsability_regime_code = '48',
organization_code = '1', organization_code = '1',
address = form.Address( address = form.Address(
@ -77,7 +79,7 @@ def simple_invoice_without_lines():
inv.set_supplier(form.Party( inv.set_supplier(form.Party(
name = 'facho-supplier', name = 'facho-supplier',
ident = form.PartyIdentification('123','', '31'), ident = form.PartyIdentification('123','', '31'),
responsability_code = form.Responsability(['O-07']), responsability_code = form.Responsability(['ZZ']),
responsability_regime_code = '48', responsability_regime_code = '48',
organization_code = '1', organization_code = '1',
address = form.Address( address = form.Address(
@ -88,7 +90,7 @@ def simple_invoice_without_lines():
inv.set_customer(form.Party( inv.set_customer(form.Party(
name = 'facho-customer', name = 'facho-customer',
ident = form.PartyIdentification('321', '', '31'), ident = form.PartyIdentification('321', '', '31'),
responsability_code = form.Responsability(['O-07']), responsability_code = form.Responsability(['ZZ']),
responsability_regime_code = '48', responsability_regime_code = '48',
organization_code = '1', organization_code = '1',
address = form.Address( address = form.Address(
@ -109,7 +111,7 @@ def simple_invoice():
inv.set_supplier(form.Party( inv.set_supplier(form.Party(
name = 'facho-supplier', name = 'facho-supplier',
ident = form.PartyIdentification('123','', '31'), ident = form.PartyIdentification('123','', '31'),
responsability_code = form.Responsability(['O-07']), responsability_code = form.Responsability(['ZZ']),
responsability_regime_code = '48', responsability_regime_code = '48',
organization_code = '1', organization_code = '1',
address = form.Address( address = form.Address(
@ -120,7 +122,7 @@ def simple_invoice():
inv.set_customer(form.Party( inv.set_customer(form.Party(
name = 'facho-customer', name = 'facho-customer',
ident = form.PartyIdentification('321','', '31'), ident = form.PartyIdentification('321','', '31'),
responsability_code = form.Responsability(['O-07']), responsability_code = form.Responsability(['ZZ']),
responsability_regime_code = '48', responsability_regime_code = '48',
organization_code = '1', organization_code = '1',
address = form.Address( address = form.Address(

View File

@ -6,42 +6,49 @@
"""Tests for `facho` package.""" """Tests for `facho` package."""
import pytest import pytest
from datetime import datetime # from datetime import datetime
import io # import io
import zipfile # import zipfile
import facho.fe.form as form import facho.fe.form as form
from facho import fe # from facho import fe
def test_invoice_legalmonetary(): def test_invoice_legalmonetary():
inv = form.NationalSalesInvoice() inv = form.NationalSalesInvoice()
inv.add_invoice_line(form.InvoiceLine( inv.add_invoice_line(form.InvoiceLine(
quantity = form.Quantity(1, '94'), quantity=form.Quantity(1, '94'),
description = 'producto facho', description='producto facho',
item = form.StandardItem(9999), item=form.StandardItem(9999),
price = form.Price( price=form.Price(
amount = form.Amount(100.0), amount=form.Amount(100.0),
type_code = '01', type_code='01',
type = 'x' type='x'
), ),
tax = form.TaxTotal( tax=form.TaxTotal(
subtotals = [ subtotals=[
form.TaxSubTotal( form.TaxSubTotal(
percent = 19.0, percent=19.0,
) )]
]
) )
)) ))
inv.calculate() inv.calculate()
assert inv.invoice_legal_monetary_total.line_extension_amount == form.Amount(100.0) assert inv.invoice_legal_monetary_total.line_extension_amount == (
assert inv.invoice_legal_monetary_total.tax_exclusive_amount == form.Amount(100.0) form.Amount(100.0))
assert inv.invoice_legal_monetary_total.tax_inclusive_amount == form.Amount(119.0) assert inv.invoice_legal_monetary_total.tax_exclusive_amount == (
assert inv.invoice_legal_monetary_total.charge_total_amount == form.Amount(0.0) form.Amount(100.0))
assert inv.invoice_legal_monetary_total.tax_inclusive_amount == (
form.Amount(119.0))
assert inv.invoice_legal_monetary_total.charge_total_amount == (
form.Amount(0.0))
def test_allowancecharge_as_discount(): def test_allowancecharge_as_discount():
discount = form.AllowanceChargeAsDiscount(amount=form.Amount(1000.0)) discount = form.AllowanceChargeAsDiscount(amount=form.Amount(1000.0))
assert discount.isDiscount() == True assert discount.isDiscount() == True
def test_FAU10(): def test_FAU10():
inv = form.NationalSalesInvoice() inv = form.NationalSalesInvoice()
inv.add_invoice_line(form.InvoiceLine( inv.add_invoice_line(form.InvoiceLine(