Skip to content

EndevelCZ/python-fakturoid

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fakturoid.cz Python API

The Python interface to online accounting service Fakturoid.

This library is developed and maintained by Roman Krejcik (farin@farin.cz). It is unoficial and no support from Fakturoid team can be claimed.

Installation

Install from PyPI

pip install fakturoid

or alternatively install development version directly from github

pip install -e git+git://github.com/farin/python-fakturoid#egg=fakturoid

Supported Python versions are 2.6+ and 3.x. Dependencies are requests, python-dateutil

Quickstart

Create context:

from fakturoid import Fakturoid

fa = Fakturoid('yourslug', 'your@email.com', 'apikey038dc73...', 'YourApp (yourname@example.com)')

Print 25 regular invoices in year 2013:

from datetime import date

for invoice in fa.invoices(proforma=False, since=date(2013,1,1))[:25]:
    print(invoice.number, invoice.total)

Delete subject with id 27:

subject = fa.subject(27)
fa.delete(subject)

And finally create new invoice:

from fakturoid import Invoice, InvoiceLine

invoice = Invoice(
    subject_id=28,
    number='2013-0108',
    due=10,
    issued_on=date(2012, 3, 30),
    taxable_fulfillment_due=date(2012, 3, 30),
    lines=[
        # use Decimal or string for floating values
        InvoiceLine(name='Hard work', unit_name='h', unit_price=40000, vat_rate=20),
        InvoiceLine(name='Soft material', quantity=12, unit_name='ks', unit_price="4.60", vat_rate=20),
    ]
)
fa.save(invoice)

print(invoice.due_on)

API

Fakturoid.account()

Returns Account instance. Account is readonly and can't be updated by API.

Fakturoid.subject(id)

Returns Subject instance.

Fakturoid.subjects(since=None)

Loads all subjects. If since (date or datetime) paramter is passed, retuns only subjects created since given date.

Fakturoid.invoce(id)

Returns Invoice instance.

Fakturoid.invoices(proforma=None, subject_id=None, since=None, number=None, status=None)

Use proforma=False/True parameter to load regular or proforma invoices only.

Returns list of invoices. Invoices are lazily loaded according to slicing.

fa.invoices(status='paid')[:100]   # loads 100 paid invoices
fa.invoices()[-1]   # loads first issued invoice (invoices are ordered from latest to first)

Fakturoid.fire_invoice_event(id, event)

Fires basic events on invoice. All events are described in Fakturoid API docs.

Fakturoid.generator(id)

Returns Generator instance.

Fakturoid.generators(recurring=None, subject_id=None, since=None)

Use recurring=False/True parameter to load recurring or simple templates only.

Fakturoid.save(model)

Create or modify Subject, Invoice or Generator.

To modify or delete inoive lines simply edit lines

invoice = fa.invoices(number='2014-0002')[0]
invoice.lines[0].unit_price = 5000 # edit first item
del invoice.lines[-1]  # delete last item
fa.save(invoice)

Fakturoid.delete(model)

Delete Subject, Invoice or Generator.

subj = fa.subject(1234)
fa.delete(subj)            # delete subject

fa.delete(Subject(id=1234))   # or alternativelly delete is possible without object loading

Models

All models fields are named same as Fakturoid API.

Values are mapped to corresponding int, decimal.Decimal, datetime.date and datetime.datetime types.

Fakturoid.Account

http://docs.fakturoid.apiary.io/#reference/account

Fakturoid.Subject

http://docs.fakturoid.apiary.io/#reference/subjects

Fakturoid.Invoice
Fakturoid.InvoiceLine

http://docs.fakturoid.apiary.io/#reference/invoices

Fakturoid.Generator

http://docs.fakturoid.apiary.io/#reference/generators

Use InvoiceLine for generator lines

Fakturoid.Message

http://docs.fakturoid.apiary.io/#reference/messages

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%