Python-bindings for the Collmex import/export API
Project description
Introduction
Collmex is an online ERP system for (small) companies with a focus on simple accounting. <http://www.collmex.de> (Note: Collmex is Germany-based but seems to support English. You’re bound to stumble over German strings, though.)
This package aims to provide pythonic bindings to program against Collmex’ API. It includes transaction management for integration with the ZODB or other databases that can integrate with the transaction package.
Collmex API
Collmex provides a POST- and CSV-based API, which is encapsulated into a utility that provides methods for the various CSV record types. API documentation is available at <http://www.collmex.de/cgi-bin/cgi.exe?1005,1,help,api>.
First we need to clean up the Collmex environment:
>>> import gocept.collmex.testing >>> gocept.collmex.testing.cleanup_collmex()
Invalid login information raises an exception:
>>> import os >>> import gocept.collmex.collmex >>> collmex = gocept.collmex.collmex.Collmex( ... os.environ['collmex_customer'], os.environ['collmex_company'], ... os.environ['collmex_username'], 'invalid') >>> collmex.get_invoices(customer_id='10000') Traceback (most recent call last): APIError: ('204008', 'Fehler in Zeile 1: Benutzer oder Kennwort nicht korrekt')
Invoices
Invoices can be looked up again, however, the invoice was only registered for addition and the transaction needs to be committed first:
>>> import datetime >>> collmex = gocept.collmex.collmex.Collmex( ... os.environ['collmex_customer'], os.environ['collmex_company'], ... os.environ['collmex_username'], os.environ['collmex_password']) >>> start_date = datetime.datetime.now() >>> item = gocept.collmex.collmex.InvoiceItem() >>> item['Kunden-Nr'] = '10000' >>> item['Rechnungsnummer'] = 100000 >>> item['Menge'] = 3 >>> item['Produktnummer'] = 'TRAFFIC' >>> item['Rechnungstext'] = 'item text' >>> item['Positionstyp'] = 0 >>> collmex.create_invoice([item]) >>> collmex.get_invoices(customer_id='10000', start_date=start_date) []
After committing, the invoice is found:
>>> import transaction >>> transaction.commit() >>> collmex.get_invoices(customer_id='10000', start_date=start_date)[0]['Rechnungstext'] 'item text'
Changes
0.2 (unreleased)
0.1 (2008-10-14)
first release. Supports getting and storing invoices.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.