def simple_invoice_without_lines(): inv = form.NationalSalesInvoice() inv.set_period(datetime.now(), datetime.now()) inv.set_issue(datetime.now()) inv.set_ident('ABC123') inv.set_operation_type('10') inv.set_payment_mean(form.PaymentMean(form.PaymentMean.DEBIT, '41', datetime.now(), '1234')) inv.set_supplier(form.Party( name = 'facho-supplier', ident = form.PartyIdentification('123','', '31'), responsability_code = form.Responsability(['O-07']), responsability_regime_code = '48', organization_code = '1', address = form.Address( '', '', form.City('05001', 'Medellín'), form.Country('CO', 'Colombia'), form.CountrySubentity('05', 'Antioquia')) )) inv.set_customer(form.Party( name = 'facho-customer', ident = form.PartyIdentification('321', '', '31'), responsability_code = form.Responsability(['O-07']), responsability_regime_code = '48', organization_code = '1', address = form.Address( '', '', form.City('05001', 'Medellín'), form.Country('CO', 'Colombia'), form.CountrySubentity('05', 'Antioquia')) )) return inv
def simple_invoice(): inv = form.NationalSalesInvoice() inv.set_period(datetime.now(), datetime.now()) inv.set_issue(datetime.now()) inv.set_ident('ABC123') inv.set_operation_type('10') inv.set_payment_mean(form.PaymentMean(form.PaymentMean.DEBIT, '41', datetime.now(), ' 1234')) inv.set_supplier(form.Party( name = 'facho-supplier', ident = form.PartyIdentification('123','', '31'), responsability_code = form.Responsability(['O-07']), responsability_regime_code = '48', organization_code = '1', address = form.Address( '', '', form.City('05001', 'Medellín'), form.Country('CO', 'Colombia'), form.CountrySubentity('05', 'Antioquia')) )) inv.set_customer(form.Party( name = 'facho-customer', ident = form.PartyIdentification('321','', '31'), responsability_code = form.Responsability(['O-07']), responsability_regime_code = '48', organization_code = '1', address = form.Address( '', '', form.City('05001', 'Medellín'), form.Country('CO', 'Colombia'), form.CountrySubentity('05', 'Antioquia')) )) inv.add_invoice_line(form.InvoiceLine( quantity = form.Quantity(1, '94'), description = 'producto facho', item = form.StandardItem( 9999), price = form.Price(form.Amount(100.0), '01', ''), tax = form.TaxTotal( tax_amount = form.Amount(0.0), taxable_amount = form.Amount(0.0), subtotals = [ form.TaxSubTotal( percent = 19.0, ) ] ) )) return inv
def test_debit_note_cude(simple_debit_note_without_lines): simple_invoice = simple_debit_note_without_lines simple_invoice.invoice_ident = 'ND1001' simple_invoice.invoice_issue = datetime.strptime('2019-01-18 10:58:00-05:00', '%Y-%m-%d %H:%M:%S%z') simple_invoice.invoice_supplier.ident = form.PartyIdentification('900197264', '5', '31') simple_invoice.invoice_customer.ident = form.PartyIdentification('10254102', '5', '31') simple_invoice.add_invoice_line(form.InvoiceLine( quantity = form.Quantity(1, '94'), description = 'producto', item = form.StandardItem(111), price = form.Price(form.Amount(30_000), '01', ''), tax = form.TaxTotal( subtotals = [ form.TaxSubTotal( scheme = form.TaxScheme('04'), percent = 8.0 )]) ))
def test_credit_note_cude(simple_credit_note_without_lines): simple_invoice = simple_credit_note_without_lines simple_invoice.invoice_ident = '8110007871' simple_invoice.invoice_issue = datetime.strptime('2019-01-12 07:00:00-05:00', '%Y-%m-%d %H:%M:%S%z') simple_invoice.invoice_supplier.ident = form.PartyIdentification('900373076', '5', '31') simple_invoice.invoice_customer.ident = form.PartyIdentification('8355990', '5', '31') simple_invoice.add_invoice_line(form.InvoiceLine( quantity = form.Quantity(1, '94'), description = 'producto', item = form.StandardItem(111), price = form.Price(form.Amount(5_000), '01', ''), tax = form.TaxTotal( subtotals = [ form.TaxSubTotal( scheme = form.TaxScheme('01'), percent = 19.0 )]) ))
def test_invoice_cufe(simple_invoice_without_lines): simple_invoice = simple_invoice_without_lines simple_invoice.invoice_ident = '323200000129' simple_invoice.invoice_issue = datetime.strptime('2019-01-16 10:53:10-05:00', '%Y-%m-%d %H:%M:%S%z') simple_invoice.invoice_supplier.ident = form.PartyIdentification('700085371', '5', '31') simple_invoice.invoice_customer.ident = form.PartyIdentification('800199436', '5', '31') simple_invoice.add_invoice_line(form.InvoiceLine( quantity = form.Quantity(1.00, '94'), description = 'producto', item = form.StandardItem(111), price = form.Price(form.Amount(1_500_000), '01', ''), tax = form.TaxTotal( subtotals = [ form.TaxSubTotal( scheme = form.TaxScheme('01'), percent = 19.0 )]) ))
def extensions(inv): security_code = fe.DianXMLExtensionSoftwareSecurityCode('id software', 'pin', inv.invoice_ident) authorization_provider = fe.DianXMLExtensionAuthorizationProvider() cufe = fe.DianXMLExtensionCUFE(inv, fe.DianXMLExtensionCUFE.AMBIENTE_PRUEBAS, 'clave tecnica') nit = form.PartyIdentification('nit', '5', '31') software_provider = fe.DianXMLExtensionSoftwareProvider(nit, nit.dv, 'id software') inv_authorization = fe.DianXMLExtensionInvoiceAuthorization('invoice autorization', datetime(2019, 1, 19), datetime(2030, 1, 19), 'SETP', 990000001, 995000000) return [security_code, authorization_provider, cufe, software_provider, inv_authorization]
def invoice(): # factura de venta nacional inv = form.Invoice('01') # asignar periodo de facturacion inv.set_period(datetime.now(), datetime.now()) # asignar fecha de emision de la factura inv.set_issue(datetime.now()) # asignar prefijo y numero del documento inv.set_ident('SETP990000008') # asignar tipo de operacion ver DIAN:6.1.5 inv.set_operation_type('10') inv.set_supplier( form.Party( legal_name='Nombre registrado de la empresa', name='Nombre comercial o él mismo nombre registrado', ident=form.PartyIdentification('nit_empresa', 'digito_verificación', '31'), # obligaciones del contribuyente ver DIAN:FAK26 responsability_code=form.Responsability(['O-07', 'O-14', 'O-48']), # ver DIAN:FAJ28 responsability_regime_code='48', # tipo de organizacion juridica ver DIAN:6.2.3 organization_code='1', email="*****@*****.**", address=form.Address('', '', form.City('05001', 'Medellín'), form.Country('CO', 'Colombia'), form.CountrySubentity('05', 'Antioquia')), )) #Tercero a quien se le factura inv.set_customer( form.Party( legal_name='consumidor final', name='consumidor final', ident=form.PartyIdentification('222222222222', '', '13'), responsability_code=form.Responsability(['R-99-PN']), responsability_regime_code='49', organization_code='2', email="consumidor_final0final.final", address=form.Address('', '', form.City('05001', 'Medellín'), form.Country('CO', 'Colombia'), form.CountrySubentity('05', 'Antioquia')), #tax_scheme = form.TaxScheme('01', 'IVA') )) # asignar metodo de pago inv.set_payment_mean( form.PaymentMean( # metodo de pago ver DIAN:3.4.1 id='1', # codigo correspondiente al medio de pago ver DIAN:3.4.2 code='20', # fecha de vencimiento de la factura due_at=datetime.now(), # identificador numerico payment_id='2')) # adicionar una linea al documento inv.add_invoice_line( form.InvoiceLine( quantity=form.Quantity(int(20.5), '94'), # item general de codigo 999 description='productO3', item=form.StandardItem('test', 9999), price=form.Price( # precio base del item (sin iva) amount=form.Amount(200.00), # ver DIAN:6.3.5.1 type_code='01', type='x'), tax=form.TaxTotal(subtotals=[ form.TaxSubTotal(percent=19.00, scheme=form.TaxScheme('01')) ]))) return inv
# factura de venta nacional inv = form.NationalSalesInvoice() # asignar periodo de facturacion inv.set_period(datetime.now(), datetime.now()) # asignar fecha de emision de la factura inv.set_issue(datetime.now()) # asignar prefijo y numero del documento inv.set_ident('SETP990003033') # asignar tipo de operacion ver DIAN:6.1.5 inv.set_operation_type('10') # asignar proveedor inv.set_supplier(form.Party( legal_name = 'FACHO SOS', name = 'FACHO SOS', ident = form.PartyIdentification('900579212', '5', '31'), # obligaciones del contribuyente ver DIAN:FAK26 responsability_code = form.Responsability(['O-07', 'O-09', 'O-14', 'O-48']), # ver DIAN:FAJ28 responsability_regime_code = '48', # tipo de organizacion juridica ver DIAN:6.2.3 organization_code = '1', email = "*****@*****.**", address = form.Address( name = '', street = '', city = form.City('05001', 'Medellín'), country = form.Country('CO', 'Colombia'), countrysubentity = form.CountrySubentity('05', 'Antioquia')) )) inv.set_customer(form.Party(