示例#1
0
def test_invoice_ident_prefix_automatic():
    inv = form.NationalSalesInvoice()
    inv.set_ident('SETP1234567')
    assert inv.invoice_ident_prefix == 'SETP'
    inv = form.NationalSalesInvoice()
    inv.set_ident('SET1234567')
    assert inv.invoice_ident_prefix == 'SET'
    inv = form.NationalSalesInvoice()
    inv.set_ident('SE1234567')
    assert inv.invoice_ident_prefix == 'SE'
    inv = form.NationalSalesInvoice()
    inv.set_ident('S1234567')
    assert inv.invoice_ident_prefix == 'S'
    inv = form.NationalSalesInvoice()
    inv.set_ident('1234567')
    assert inv.invoice_ident_prefix == ''
示例#2
0
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
示例#3
0
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
示例#4
0
def test_FAU14():
    inv = form.NationalSalesInvoice()
    inv.add_invoice_line(
        form.InvoiceLine(
            quantity=form.Quantity(1, '94'),
            description='producto facho',
            item=form.StandardItem(9999),
            price=form.Price(amount=form.Amount(100.0),
                             type_code='01',
                             type='x'),
            tax=form.TaxTotal(subtotals=[form.TaxSubTotal(percent=19.0, )])))
    inv.add_allowance_charge(form.AllowanceCharge(amount=form.Amount(19.0)))
    inv.add_prepaid_payment(form.PrePaidPayment(paid_amount=form.Amount(50.0)))
    inv.calculate()

    wants = form.Amount(119.0 + 19.0 - 50.0)

    assert inv.invoice_legal_monetary_total.payable_amount == wants, "got %s want %s" % (
        inv.invoice_legal_monetary_total.payable_amount, wants)
示例#5
0
def test_invoice_legalmonetary():
    inv = form.NationalSalesInvoice()
    inv.add_invoice_line(
        form.InvoiceLine(
            quantity=form.Quantity(1, '94'),
            description='producto facho',
            item=form.StandardItem(9999),
            price=form.Price(amount=form.Amount(100.0),
                             type_code='01',
                             type='x'),
            tax=form.TaxTotal(subtotals=[form.TaxSubTotal(percent=19.0, )])))
    inv.calculate()
    assert inv.invoice_legal_monetary_total.line_extension_amount == form.Amount(
        100.0)
    assert inv.invoice_legal_monetary_total.tax_exclusive_amount == 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)
示例#6
0
def test_invoice_ident_prefix_manual():
    inv = form.NationalSalesInvoice()
    inv.set_ident('SETP1234567')
    inv.set_ident_prefix('SETA')
    assert inv.invoice_ident_prefix == 'SETA'
示例#7
0
def test_invoice_ident_prefix_automatic_invalid():
    inv = form.NationalSalesInvoice()
    with pytest.raises(ValueError):
        inv.set_ident('SETPQJQJ1234567')
示例#8
0
                                                                datetime(2030, 1, 19),
                                                                'SETP', 990000001, 995000000)
    return [security_code, authorization_provider, cufe, software_provider, inv_authorization]

# generar documento desde modelo a ruta indicada
def generate_document(invoice, filepath):
    xml = form_xml.DIANInvoiceXML(invoice)
    for extension in extensions(invoice):
        xml.add_extension(extension)
    form_xml.utils.DIANWriteSigned(xml, filepath, PRIVATE_KEY_PATH, PRIVATE_PASSPHRASE, True)

# Modelars las facturas
# ...

# 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']),