Fedrojesa/ProxyPoS — pull request #6 by tsk (2014-03-14 16:25:07+00:00)
Title: Devinstaller

1.- Installer: you can test it

$ virtualenv env --system-site-packages
$ source env/bin/activate
$ "clone my repository the devinstaller branch"
$ gtk-proxypos.py

This will create on your home

.proxypos/config/config.cfg
.proxypos/tmp

And a systray icon in star form.

To configure your printer right-click on the star icon --> Configure. Go to ESC/POS printer tab (the charSet still not working, I need to fix it), change values and save.

2.- I create the base for templating. Revise the templates path templates.

The basic structure of a Template is

template.tmp <-- Template configurations and descriptio
template/ <-- html and css
$ cat default.tmp
{
"name": "Template name",
"type": "image",
"description":"Description of this template",
"path": "default",
"files": {
"css":"style.css",
"template":"default.html"
},
"width":"420",
"format":"html",
"author" :{
"name":"Author name",
"email": "email",
"web": "some_web"
}
}

$ cat default/default.html

The names that you can use in your template are given in the mapping dict inside the __init__.py

mapping = {"order_name":lambda r: r['name'],
"total_tax": lambda r: r['total_tax'],
"shop_name": lambda r: r['shop']['name'],
"company_name": lambda r: r['company']['name'],
"company_website": lambda r: r['company']['website'],
"company_phone": lambda r: r['company']['phone'],
"company_email": lambda r: r['company']['email'],
"company_address":lambda r: r['company']['contact_address'],
"company_vat": lambda r: r['company']['vat'],
"company_registry": lambda r: r['company']['company_registry'],
"orderlines": lambda r: r['orderlines'],
"cashier": lambda r: r['cashier'],
"client": lambda r: r['client'],
"currency": lambda r: r['currency'],
"total_discount": lambda r: r['total_discount'],
"invoice_id": lambda r: r['invoice_id'],
"date": lambda r: r['date'],
"total_paid": lambda r: r['total_paid'],
"payment_amount": lambda r: r['paymentlines'][0]['amount'],
"payment_journal": lambda r: r['paymentlines'][0]['journal'],
"total_with_tax": lambda r: r["total_with_tax"],
"subtotal": lambda r: r['subtotal'],
"change": lambda r: r['change'],
}

For a simple test

Install imagemagick download from http://wkhtmltopdf.org/downloads.html the precompiled packages. Uncompress and copy wkhtmltoimage (wkhtmltox/bin) to /usr/local/bin, Then go to the templates directory (proxypos/templates)

$ python __init__.py

You will see the results inside of .proxypos/tmp/

pticket.png ticket.html ticket.png

What is missing?
1.- Get templates from .proxypos/templates/ (this is easy to do)
2.- Add the if stament in print_receipt (to allow printing from templates)