### Install moneyworks with pip Source: https://github.com/ari/moneyworks-cli/blob/master/README.md Install the moneyworks library from PyPI. ```bash pip install moneyworks ``` -------------------------------- ### Basic Moneyworks usage Source: https://github.com/ari/moneyworks-cli/blob/master/README.md Basic usage of the Moneyworks class: connect, print version, get an email address, print a transaction to PDF, and export data with a filter. ```python from moneyworks import Moneyworks mw = Moneyworks() # Print the version of Moneyworks we are talking to print mw.version() # Get the email address of the first person in a company, selected by code print mw.get_email("ACME") # Get a PDF document (which you can save or email) of a transaction pdf = mw.print_transaction('sequencenumber=`9999`', 'my_invoice') # Export some data for all companies with code starting with 'A' and print their names my_data = mw.export("name", "left(code, 1)=`A`") for contact in my_data: print contact['name'] ``` -------------------------------- ### Publish new version with setup.py and twine Source: https://github.com/ari/moneyworks-cli/blob/master/README.md Publish a new version of the module: clean the dist folder, build the source distribution, and upload to PyPI with twine. ```bash rm -fr dist/* python3 setup.py sdist twine upload dist/* ``` -------------------------------- ### Advanced usage: create, post, print, and email a transaction Source: https://github.com/ari/moneyworks-cli/blob/master/README.md Advanced usage: create a transaction with lines, post it, print it to PDF, and email it. Requires a configured mw.ini file and appropriate Moneyworks user rights. ```python from moneyworks import Moneyworks, Transaction, Email mw = Moneyworks('/etc/mw.ini') e = Email() t = Transaction() t.add("type", "DI") t.add("theirref", "1234") t.add("transdate", datetime.date.today().replace(day=1)) # First of the month t.add("NameCode", "ACME") t.add("description", "Monthly services") t.add("tofrom", "Acme Pty Ltd") t.add("duedate") t.add("duedate") t.add("contra") t.add("ourref") l = t.add_line() l.add("detail.account", "4100") l.add("detail.net", 1300.35) l.add("detail.description", "Services") l.add("detail.taxcode") l.add("detail.tax") l.add("detail.gross") invoice_sequence = mw.create_transaction(t.to_xml()) result = mw.post_transaction(invoice_sequence) pdf = mw.print_transaction('sequencenumber=`' + invoice_sequence + "`", 'my_invoice') email = mw.get_email("ACME") e.send_mail(email, "invoice", "Please send us some money.", pdf, "invoice.pdf") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.