gnucash master: Multiple changes pushed
Geert Janssens
gjanssens at code.gnucash.org
Sat Nov 29 11:04:36 EST 2014
Updated via https://github.com/Gnucash/gnucash/commit/1b53d7fa (commit)
via https://github.com/Gnucash/gnucash/commit/e219ef22 (commit)
via https://github.com/Gnucash/gnucash/commit/abf78a20 (commit)
via https://github.com/Gnucash/gnucash/commit/e59c3e06 (commit)
via https://github.com/Gnucash/gnucash/commit/22490a37 (commit)
via https://github.com/Gnucash/gnucash/commit/64d9a3b9 (commit)
via https://github.com/Gnucash/gnucash/commit/67b807fb (commit)
via https://github.com/Gnucash/gnucash/commit/de473302 (commit)
via https://github.com/Gnucash/gnucash/commit/c86c69ad (commit)
via https://github.com/Gnucash/gnucash/commit/7d6caa82 (commit)
via https://github.com/Gnucash/gnucash/commit/ea39d653 (commit)
via https://github.com/Gnucash/gnucash/commit/398fb960 (commit)
via https://github.com/Gnucash/gnucash/commit/3818f327 (commit)
via https://github.com/Gnucash/gnucash/commit/66a9ee80 (commit)
via https://github.com/Gnucash/gnucash/commit/415b8c7b (commit)
via https://github.com/Gnucash/gnucash/commit/eb957864 (commit)
via https://github.com/Gnucash/gnucash/commit/a53f615f (commit)
via https://github.com/Gnucash/gnucash/commit/765d73f9 (commit)
via https://github.com/Gnucash/gnucash/commit/9595062e (commit)
via https://github.com/Gnucash/gnucash/commit/7de700d5 (commit)
via https://github.com/Gnucash/gnucash/commit/15a69f12 (commit)
via https://github.com/Gnucash/gnucash/commit/d2ed3734 (commit)
via https://github.com/Gnucash/gnucash/commit/3fc62395 (commit)
from https://github.com/Gnucash/gnucash/commit/19f08da5 (commit)
commit 1b53d7fa2ea99cb5d1ee92b884202ec7e599311c
Merge: e219ef2 67b807f
Author: Geert Janssens <janssens-geert at telenet.be>
Date: Sat Nov 29 16:32:50 2014 +0100
Merge branch 'master' of https://github.com/c-holtermann/gnucash
commit e219ef22ea86d9c126893d782bafa27f24ec2174
Merge: 19f08da abf78a2
Author: Geert Janssens <janssens-geert at telenet.be>
Date: Sat Nov 29 14:26:27 2014 +0100
Merge branch 'maint'
commit abf78a202c4898f970ef24159f1a6cecabe0ed00
Author: Geert Janssens <janssens-geert at telenet.be>
Date: Mon Nov 24 11:51:33 2014 +0100
Python bindings - fix creation of new xml files
diff --git a/src/optional/python-bindings/gnucash_core.py b/src/optional/python-bindings/gnucash_core.py
index 9d80a36..578e800 100644
--- a/src/optional/python-bindings/gnucash_core.py
+++ b/src/optional/python-bindings/gnucash_core.py
@@ -102,7 +102,13 @@ class Session(GnuCashCoreClass):
if book_uri is not None:
try:
self.begin(book_uri, ignore_lock, is_new, force_new)
- self.load()
+ # Take care of backend inconsistency
+ # New xml file can't be loaded, new sql store
+ # has to be loaded before it can be altered
+ # Any existing store obviously has to be loaded
+ # More background: https://bugzilla.gnome.org/show_bug.cgi?id=726891
+ if book_uri[:3] != "xml" or not is_new:
+ self.load()
except GnuCashBackendException, backend_exception:
self.end()
self.destroy()
commit e59c3e0639470bcdca39970ef8f7ff00849ec4e0
Author: Geert Janssens <janssens-geert at telenet.be>
Date: Mon Nov 17 17:45:40 2014 +0100
Fix a few typos in python example scripts and align them with the latest api changes
diff --git a/src/optional/python-bindings/example_scripts/simple_business_create.py b/src/optional/python-bindings/example_scripts/simple_business_create.py
index adeb97a..40a2c3a 100644
--- a/src/optional/python-bindings/example_scripts/simple_business_create.py
+++ b/src/optional/python-bindings/example_scripts/simple_business_create.py
@@ -163,10 +163,10 @@ try:
invoice_entry.SetDateEntered(datetime.datetime.now())
invoice_customer.PostToAccount(a2, datetime.date.today(), datetime.date.today(),
- "the memo", True)
+ "the memo", True, False)
new_customer.ApplyPayment(None, None, a2, a6, GncNumeric(100,100),
- GncNumeric(1), datetime.date.today(), "", "")
+ GncNumeric(1), datetime.date.today(), "", "", True)
invoice_customer.ApplyPayment(None, a6, GncNumeric(7,100),
GncNumeric(1), datetime.date.today(), "", "")
diff --git a/src/optional/python-bindings/example_scripts/simple_invoice_insert.py b/src/optional/python-bindings/example_scripts/simple_invoice_insert.py
index ace1f57..cab1769 100644
--- a/src/optional/python-bindings/example_scripts/simple_invoice_insert.py
+++ b/src/optional/python-bindings/example_scripts/simple_invoice_insert.py
@@ -22,11 +22,12 @@
# @author Mark Jenkins, ParIT Worker Co-operative <mark at parit.ca>
# Opens a GnuCash book file and adds an invoice to it for a particular
-# customer (by GUID) with a specific ID and value
+# customer (by ID) with a specific ID and value
+# Optionally also adds a payment for the invoice as well
#
# The account tree and tax tables are assumed to be the same as the ones
# created in simple_business_create.py, but you can edit that to adapt
-# this to become an invoice imported for your own books
+# this to become an invoice importer for your own books
#
# Syntax:
# gnucash-env python simple_invoice_insert.py \
@@ -86,20 +87,18 @@ def gnc_numeric_from_decimal(decimal_value):
s = Session(argv[1], is_new=False)
-# this seems to make a difference in more complex cases
-s.save()
book = s.book
root = book.get_root_account()
commod_table = book.get_table()
CAD = commod_table.lookup('CURRENCY', 'CAD')
-my_customer = book.LookupByID(arg[2])
+my_customer = book.CustomerLookupByID(argv[2])
assert( my_customer != None )
assert( isinstance(my_customer, Customer) )
assets = root.lookup_by_name("Assets")
-recievables = assets.lookup_by_name("Recievables")
+receivables = assets.lookup_by_name("Receivables")
income = root.lookup_by_name("Income")
invoice = Invoice(book, argv[3], CAD, my_customer )
@@ -114,8 +113,8 @@ invoice_entry.SetQuantity( GncNumeric(1) )
invoice_entry.SetInvAccount(income)
invoice_entry.SetInvPrice(invoice_value)
-invoice.PostToAccount(recievables, datetime.date.today(), datetime.date.today(),
- "", True)
+invoice.PostToAccount(receivables, datetime.date.today(), datetime.date.today(),
+ "", True, False)
s.save()
s.end()
commit 22490a37abcef966b5523cc60b184be0e6459c94
Author: Geert Janssens <janssens-geert at telenet.be>
Date: Mon Nov 17 14:01:07 2014 +0100
Fix build-time hard-coded path introduced by the guile2 compile changes
These changes hardcoded the standards-reports path at build time.
On Windows and OS X the final path is only known at installation time.
So after installation the build-time hard-coded path would be invalid and
the standard-reports directory could no longer be found.
diff --git a/src/core-utils/gnc-path.c b/src/core-utils/gnc-path.c
index d8f92fd..9b06259 100644
--- a/src/core-utils/gnc-path.c
+++ b/src/core-utils/gnc-path.c
@@ -162,8 +162,18 @@ gchar *gnc_path_get_reportdir()
}
else
{
+ /* Careful: if the autoconf macro GNC_SCM_INSTALL_DIR gets changed
+ * in configure.ac, this path should probably change as well.
+ * Currently this code assumes GNC_SCM_INSTALL_DIR is set to
+ * pkgdatadir/scm
+ * We can't use the AC_MACRO GNC_SCM_INSTALL_DIR here directly
+ * because that's expanded at build time. On Windows and OS X
+ * the final path may get installed in a different location
+ * than assumed during build, invalidating the build path at
+ * runtime.
+ */
gchar *pkgdatadir = gnc_path_get_pkgdatadir ();
- result = g_build_filename (GNC_SCM_INSTALL_DIR,
+ result = g_build_filename (pkgdatadir, "scm",
"gnucash", "report", (char*)NULL);
g_free (pkgdatadir);
}
commit 64d9a3b99e6f6b8ac7b70d63a442c60975e6e603
Author: Geert Janssens <janssens-geert at telenet.be>
Date: Mon Nov 17 15:43:16 2014 +0100
Prevent crash when standards-report dir doesn't exist
diff --git a/src/report/standard-reports/standard-reports.scm b/src/report/standard-reports/standard-reports.scm
index 85d0c38..8497b09 100644
--- a/src/report/standard-reports/standard-reports.scm
+++ b/src/report/standard-reports/standard-reports.scm
@@ -74,24 +74,29 @@
;; list of files in the directory
(define (directory-files dir)
- (let ((fname-regexp (make-regexp "\\.scm$")) ;; Regexp that matches the desired filenames
- (dir-stream (opendir dir)))
- (let loop ((fname (readdir dir-stream))
- (acc '())
- )
- (if (eof-object? fname)
- (begin
- (closedir dir-stream)
- acc
- )
- (loop (readdir dir-stream)
- (if (regexp-exec fname-regexp fname)
- (cons fname acc)
- acc
- )
- )
- )
- )
+ (if (file-exists? dir)
+ (let ((fname-regexp (make-regexp "\\.scm$")) ;; Regexp that matches the desired filenames
+ (dir-stream (opendir dir)))
+
+ (let loop ((fname (readdir dir-stream))
+ (acc '()))
+ (if (eof-object? fname)
+ (begin
+ (closedir dir-stream)
+ acc
+ )
+ (loop (readdir dir-stream)
+ (if (regexp-exec fname-regexp fname)
+ (cons fname acc)
+ acc
+ )
+ )
+ )
+ ))
+ (begin
+ (gnc:warn "Can't access " dir ".\nEmpty list will be returned.")
+ '() ;; return empty list
+ )
)
)
@@ -113,9 +118,8 @@
;; Return value:
;; List of symbols for reports
(define (get-report-list)
- (map (lambda (s) (string->symbol s))
- (process-file-list (directory-files (gnc-path-get-stdreportsdir)))
- )
+ (map (lambda (s) (string->symbol s))
+ (process-file-list (directory-files (gnc-path-get-stdreportsdir))))
)
(gnc:debug "stdrpt-dir=" (gnc-path-get-stdreportsdir))
commit 67b807fbf1981fc5c42c3c141b18cff132e5efbf
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Wed Nov 12 16:50:00 2014 +0100
Small doc changes
diff --git a/src/optional/python-bindings/example_scripts/latex_invoices.py b/src/optional/python-bindings/example_scripts/latex_invoices.py
index ee1283f..4b755d8 100644
--- a/src/optional/python-bindings/example_scripts/latex_invoices.py
+++ b/src/optional/python-bindings/example_scripts/latex_invoices.py
@@ -20,7 +20,7 @@
# For an example where to get it see section credits below.
#
# Usage :
-# \code latex_invoice file://testfile \endcode
+# \code latex_invoice -l -f -n INVOICE_NUMBER file://testfile \endcode
# will create file data.lco.
# \code latex --output-format=pdf Invoice.tex \endcode
# should run latex on file Invoice.tex and result in Invoice.pdf. Invoice.tex includes data.lco.
@@ -214,7 +214,7 @@ def main(argv=None):
print >>sys.stderr, "for help use --help"
retcode=2
- print "Prints out all invoices that have corresponding lots."
+ print "Generate a LaTeX invoice or print out all invoices."
print
print "Usage:"
print
commit de47330288de8fe93b696996d430293517a97aaf
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Wed Nov 12 16:45:53 2014 +0100
Change latex_invoices.py to query for all invoices
Before invoices were catched by going through lots
and getting associated invoices.
diff --git a/src/optional/python-bindings/example_scripts/latex_invoices.py b/src/optional/python-bindings/example_scripts/latex_invoices.py
index 3c765f0..ee1283f 100644
--- a/src/optional/python-bindings/example_scripts/latex_invoices.py
+++ b/src/optional/python-bindings/example_scripts/latex_invoices.py
@@ -246,7 +246,7 @@ def main(argv=None):
comm_table = book.get_table()
EUR = comm_table.lookup("CURRENCY", "EUR")
- invoice_list=get_all_invoices_from_lots(root_account)
+ invoice_list=get_all_invoices(book)
if list_invoices:
for number,invoice in enumerate(invoice_list):
commit c86c69ad05a52992ce762d038337675e288ca0cc
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Wed Nov 12 16:39:08 2014 +0100
Additional doxygen doc
diff --git a/src/optional/python-bindings/example_scripts/gncinvoicefkt.py b/src/optional/python-bindings/example_scripts/gncinvoicefkt.py
index 9b909c7..fff5aed 100644
--- a/src/optional/python-bindings/example_scripts/gncinvoicefkt.py
+++ b/src/optional/python-bindings/example_scripts/gncinvoicefkt.py
@@ -1,17 +1,17 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
-# ##@file
+##@file
# @ingroup python_bindings_examples
# @author Christoph Holtermann (c.holtermann (at) gmx.de)
# @date 2014-11
-# @brief some help for working with invoices
+# @brief some help for working with invoices, used in \ref py_invoice_export
#
# Credits to Tom Loft for the query to get_all_invoices
# as used in his REST-Api
#
# Issues:
-# - get_all_invoices could be added to class book
+# - get_all_invoices could be added as a method to book Class
# - get_all_customers should be a query like get_all_invoices
try:
diff --git a/src/optional/python-bindings/example_scripts/invoice_export_doxygen.txt b/src/optional/python-bindings/example_scripts/invoice_export_doxygen.txt
index 53c1524..ca72c9c 100644
--- a/src/optional/python-bindings/example_scripts/invoice_export_doxygen.txt
+++ b/src/optional/python-bindings/example_scripts/invoice_export_doxygen.txt
@@ -27,10 +27,16 @@ LaTeX or other output formats as desired.
LaTeX template using a table to fill in the invoices values. No rechnung.sty required.
+- gncinvoicefkt.py
+
+ Some helping functions. Included by latex_invoices.py and gncinvoice_jinja.py.
+
\par Goals / Issues:
-- How much logic in the template, how much preprocessing in this file ?
+- How much logic in the template, how much preprocessing in the python script ?
- Internationalization - currencies, formatting of numbers, templates
-- Providing data of gnucash owner. At the moment this has to be put into the invoices (template/final file) by hand.
+- Providing data of gnucash owner.
+
+ At the moment this has to be put into the invoices (template/final file) by hand. Access of this data is in KVPs. No support in python-bindings at the moment. c-API to access these values is work in progress. A fork to access these is https://github.com/c-holtermann/gnucash/tree/python-kvp. This is very much work in progress. A discussion can be found in thread http://lists.gnucash.org/pipermail/gnucash-devel/2014-June/037768.html.
- A jinja2 template mimicking the original html invoices
\par See also:
commit 7d6caa82323c72e1f0d4a832c265cef5cd37bea1
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Wed Nov 12 15:30:13 2014 +0100
latex_invoices.py includes gncinvoicefkt.py
diff --git a/src/optional/python-bindings/example_scripts/latex_invoices.py b/src/optional/python-bindings/example_scripts/latex_invoices.py
index e69bdc3..3c765f0 100644
--- a/src/optional/python-bindings/example_scripts/latex_invoices.py
+++ b/src/optional/python-bindings/example_scripts/latex_invoices.py
@@ -54,6 +54,7 @@ try:
import getopt
import gnucash
import str_methods
+ from gncinvoicefkt import *
from IPython import version_info as IPython_version_info
if IPython_version_info[0]>=1:
from IPython.terminal.ipapp import TerminalIPythonApp
@@ -72,32 +73,6 @@ class Usage(Exception):
def __init__(self, msg):
self.msg = msg
-def get_all_lots(account):
- """Return all lots in account and descendants"""
- ltotal=[]
- descs = account.get_descendants()
- for desc in descs:
- if type(desc).__name__ == 'SwigPyObject':
- desc = gnucash.Account(instance=desc)
- ll=desc.GetLotList()
- ltotal+=ll
- return ltotal
-
-def get_all_invoices_from_lots(account):
- """Return all invoices in account and descendants
-
- This is based on lots. So invoices without lots will be missed."""
-
- lot_list=get_all_lots(account)
- invoice_list=[]
- for lot in lot_list:
- if type(lot).__name__ == 'SwigPyObject':
- lot = gnucash.GncLot(instance=lot)
- invoice=gnucash.gnucash_core_c.gncInvoiceGetInvoiceFromLot(lot.instance)
- if invoice:
- invoice_list.append(Invoice(instance=invoice))
- return invoice_list
-
def invoice_to_lco(invoice):
"""returns a string which forms a lco-file for use with LaTeX"""
commit ea39d6537283145bf82729400f2d1aca829a5c12
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Wed Nov 12 15:08:57 2014 +0100
Some doc for gncinvoicefkt.py
diff --git a/src/optional/python-bindings/example_scripts/gncinvoicefkt.py b/src/optional/python-bindings/example_scripts/gncinvoicefkt.py
index c63fc8d..9b909c7 100644
--- a/src/optional/python-bindings/example_scripts/gncinvoicefkt.py
+++ b/src/optional/python-bindings/example_scripts/gncinvoicefkt.py
@@ -1,6 +1,19 @@
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
+# ##@file
+# @ingroup python_bindings_examples
+# @author Christoph Holtermann (c.holtermann (at) gmx.de)
+# @date 2014-11
+# @brief some help for working with invoices
+#
+# Credits to Tom Loft for the query to get_all_invoices
+# as used in his REST-Api
+#
+# Issues:
+# - get_all_invoices could be added to class book
+# - get_all_customers should be a query like get_all_invoices
+
try:
import gnucash
from gnucash.gnucash_business import Customer, Employee, Vendor, Job, \
@@ -85,7 +98,10 @@ def get_all_invoices(book, is_paid=None, is_active=None):
return invoice_list
def get_all_customers(book):
- """Returns all customers in book."""
+ """Returns all customers in book.
+
+ Counts IDs upwards. May miss customers with irregular IDs.
+ Should be replaced by query as in get_all_invoices."""
customer_list = []
customer = True
commit 398fb96065ee357e2e888ffbfc6de11845944719
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Wed Nov 12 14:54:56 2014 +0100
Doxygen doc extended for python invoice export
diff --git a/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
index 48bf65b..3b7c2da 100644
--- a/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
+++ b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
@@ -5,7 +5,7 @@
# @ingroup python_bindings_examples
# @author Christoph Holtermann (c.holtermann (at) gmx.de)
# @date 2014-11
-# @brief exports an invoice from gnucash using a template file
+# @brief exports an invoice from gnucash using a template file, see \ref py_invoice_export
#
# Input is a template file that will be filled with information from
# gnucash Invoices. Jinja2 templating engine ist used. Templates can
@@ -20,6 +20,8 @@
# The approach used here is not as dependent on external files and
# more modular as it allows to use arbitrary templates
#
+# Doxygen: see page \ref py_invoice_export
+#
# Questions / Issues:
# - How much logic in the template, how much preprocessing in this file ?
# - Internationalization - currencies, formatting of numbers
diff --git a/src/optional/python-bindings/example_scripts/invoice_export_doxygen.txt b/src/optional/python-bindings/example_scripts/invoice_export_doxygen.txt
new file mode 100644
index 0000000..53c1524
--- /dev/null
+++ b/src/optional/python-bindings/example_scripts/invoice_export_doxygen.txt
@@ -0,0 +1,42 @@
+/**
+\page py_invoice_export Python invoice export
+The goal of these example scripts is to export invoices to
+LaTeX or other output formats as desired.
+
+\par Files:
+- latex_invoices.py
+
+ A first approach which exports invoice data to an .lco file which is subsequently included into the template
+ - Templates:
+ - Invoice.tex
+
+ File derived vom scrlttr2.tex v0.3. by Juergen Fenn.
+
+ rechnung.sty is used to create the table of entries
+
+- gncinvoice_jinja.py
+
+ A second step. Imports jinja2 templates and fills in the invoices values. More flexibility in creating the output files. Output can be anything: LaTeX, HTML, CSV, XML, ...
+
+ - Templates:
+ - Invoice.tex.tmpl
+
+ LaTeX template using rechnung.sty, close to the one used by latex_invoices.py.
+
+ - Invoice_2.tex.tmpl
+
+ LaTeX template using a table to fill in the invoices values. No rechnung.sty required.
+
+\par Goals / Issues:
+- How much logic in the template, how much preprocessing in this file ?
+- Internationalization - currencies, formatting of numbers, templates
+- Providing data of gnucash owner. At the moment this has to be put into the invoices (template/final file) by hand.
+- A jinja2 template mimicking the original html invoices
+
+\par See also:
+- Modules
+ - \ref python_bindings_examples
+ - \ref python_bindings
+- Pages
+ - \ref python_bindings_page
+*/
diff --git a/src/optional/python-bindings/example_scripts/latex_invoices.py b/src/optional/python-bindings/example_scripts/latex_invoices.py
index b250684..e69bdc3 100644
--- a/src/optional/python-bindings/example_scripts/latex_invoices.py
+++ b/src/optional/python-bindings/example_scripts/latex_invoices.py
@@ -5,7 +5,7 @@
# @ingroup python_bindings_examples
# @author Christoph Holtermann (c.holtermann (at) gmx.de)
# @date May 2011
-# @brief Exports an invoice to lco-file for use with LaTeX
+# @brief Exports an invoice to lco-file for use with LaTeX, see \ref py_invoice_export
#
# The output file can be imported into KOMA-Script-letters.
# This works primarily for germany. Internationalization welcome!
@@ -27,6 +27,7 @@
#
# Additional information :
#
+# - Doxygen: see page \ref py_invoice_export
# - http://www.uweziegenhagen.de/latex/documents/rechnung/rechnungen.pdf (german)
#
# Credits to and ideas from
commit 3818f3272ec53315c40d5225cf44c8fc128051a5
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Wed Nov 12 13:28:25 2014 +0100
small fixes for doxygen
diff --git a/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
index 6937c72..48bf65b 100644
--- a/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
+++ b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
@@ -11,13 +11,19 @@
# gnucash Invoices. Jinja2 templating engine ist used. Templates can
# be Latex, Html or anything.
#
+# Example templates for german invoices:
+# - Invoice.tex.tmpl
+# - Invoice_2.tex.tmpl
+#
# This is a sequel to latex_invoices.py that exported to a lco file
# to be imported into a LaTeX letter.
# The approach used here is not as dependent on external files and
# more modular as it allows to use arbitrary templates
#
# Questions / Issues:
-# * How much logic in the template, how much preprocessing in this file ?
+# - How much logic in the template, how much preprocessing in this file ?
+# - Internationalization - currencies, formatting of numbers
+# - Providing data of gnucash owner
try:
import locale
commit 66a9ee80ce6e44e965ef2bbe73d48e3c32af56c7
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Wed Nov 12 13:27:46 2014 +0100
polishing the template
diff --git a/src/optional/python-bindings/example_scripts/Invoice_2.tex.tmpl b/src/optional/python-bindings/example_scripts/Invoice_2.tex.tmpl
index 3131ec0..e9123f7 100644
--- a/src/optional/python-bindings/example_scripts/Invoice_2.tex.tmpl
+++ b/src/optional/python-bindings/example_scripts/Invoice_2.tex.tmpl
@@ -180,7 +180,7 @@ Ich erlaube mir, Ihnen folgende Beträge in Rechnung zu stellen:
\end{tabular}
\\[\baselineskip]
-Bitte zahlen Sie den Betrag von \Gesamtsumme \, bis zum {% endraw %} {{ invoice.GetDateDue().strftime("%d.%m.%Y") }} {% raw %} auf mein unten angegebenes Konto.
+Bitte zahlen Sie den Betrag von \EUR{\GesamtSumme{}} bis zum {% endraw %} {{ invoice.GetDateDue().strftime("%d.%m.%Y") }} {% raw %} auf mein unten angegebenes Konto.
\closing{Mit bestem Dank und freundlichen GrüÃen,}
%---------------------------------------------------------------------------
commit 415b8c7b97ea5ce892aef1ab8bf606ada81d822e
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Tue Nov 11 21:57:21 2014 +0100
Invoice templates
diff --git a/src/optional/python-bindings/example_scripts/Invoice.tex b/src/optional/python-bindings/example_scripts/Invoice.tex
new file mode 100644
index 0000000..1c0701f
--- /dev/null
+++ b/src/optional/python-bindings/example_scripts/Invoice.tex
@@ -0,0 +1,154 @@
+%---------------------------------------------------------------------------
+% Invoice.tex v0.1 by Christoph Holtermann (c.holtermann at gmx.de)
+%
+% modified from
+% scrlttr2.tex v0.3. (c) by Juergen Fenn <juergen.fenn at gmx.de>
+% Template for a letter to be typeset with scrlttr2.cls from KOMA-Script.
+% Latest version of the LaTeX Project Public License is applicable.
+% File may not be modified and redistributed under the same name
+% without the author's prior consent.
+%---------------------------------------------------------------------------
+\documentclass%%
+%---------------------------------------------------------------------------
+ [fontsize=12pt,%% Schriftgroesse
+%---------------------------------------------------------------------------
+% Satzspiegel
+ paper=a4,%% Papierformat
+ enlargefirstpage=off,%% Erste Seite anders
+ pagenumber=headright,%% Seitenzahl oben mittig
+%---------------------------------------------------------------------------
+% Layout
+ headsepline=on,%% Linie unter der Seitenzahl
+ parskip=half,%% Abstand zwischen Absaetzen
+%---------------------------------------------------------------------------
+% Briefkopf und Anschrift
+ fromalign=right,%% Platzierung des Briefkopfs
+ fromphone=on,%% Telefonnummer im Absender
+ fromrule=off,%% Linie im Absender (aftername, afteraddress)
+ fromfax=on,%% Faxnummer
+ fromemail=on,%% Emailadresse
+ fromurl=off,%% Homepage
+ fromlogo=off,%% Firmenlogo
+ addrfield=on,%% Adressfeld fuer Fensterkuverts
+ backaddress=on,%% ...und Absender im Fenster
+ subject=beforeopening,%% Plazierung der Betreffzeile
+ locfield=narrow,%% zusaetzliches Feld fuer Absender
+ foldmarks=on,%% Faltmarken setzen
+ numericaldate=off,%% Datum numerisch ausgeben
+ refline=narrow,%% Geschaeftszeile im Satzspiegel
+%---------------------------------------------------------------------------
+% Formatierung
+ draft=off,%% Entwurfsmodus
+ version=last,
+ data%% data.lco ist die Datei aus der die Rechnungsdaten gelesen werden ( invoice-data to be read from data.lco )
+]{scrlttr2}
+%---------------------------------------------------------------------------
+\usepackage[ngerman]{babel}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{url}
+\usepackage{eurosym}
+\usepackage{rechnung}
+\usepackage{textcomp}
+%---------------------------------------------------------------------------
+% Fonts
+\setkomafont{fromname}{\sffamily \LARGE}
+\setkomafont{fromaddress}{\sffamily}%% statt \small
+\setkomafont{pagenumber}{\sffamily}
+\setkomafont{subject}{\mdseries}
+\setkomafont{backaddress}{\mdseries}
+\usepackage{mathptmx}%% Schrift Times
+%\usepackage{mathpazo}%% Schrift Palatino
+%\setkomafont{fromname}{\LARGE}
+%---------------------------------------------------------------------------
+\begin{document}
+%---------------------------------------------------------------------------
+% Briefstil und Position des Briefkopfs
+\LoadLetterOption{DIN} %% oder: DINmtext, SN, SNleft, KOMAold.
+\makeatletter
+\@setplength{firstheadvpos}{20mm}
+\@setplength{firstheadwidth}{\paperwidth}
+\ifdim \useplength{toaddrhpos}>\z@
+ \@addtoplength[-2]{firstheadwidth}{\useplength{toaddrhpos}}
+\else
+ \@addtoplength[2]{firstheadwidth}{\useplength{toaddrhpos}}
+\fi
+\@setplength{foldmarkhpos}{6.5mm}
+%\setlength{\footskip}{1cm}
+\makeatother
+%---------------------------------------------------------------------------
+% Absender
+\setkomavar{fromname}{fromname}
+\setkomavar{fromaddress}{fromaddress}
+\setkomavar{fromphone}{fromphone}
+\renewcommand{\phonename}{Telefon}
+\setkomavar{fromfax}{fromfax}
+\setkomavar{fromemail}{fromemail}
+\setkomavar{backaddressseparator}{. }
+\setkomavar{signature}{(signature)}
+\setkomavar{frombank}{---NAME --- BANK ACCOUNT --- BANK NUMBER --- BANK NAME ---}
+\setkomavar{location}{\\[8ex]\raggedleft{\footnotesize{\usekomavar{fromaddress}\\
+ Telefon: \usekomavar{fromphone}\\Mobil: mobile-number\\Fax: \usekomavar{fromfax}\\\usekomavar{fromemail}}}}%% Neben dem Adressfenster
+%---------------------------------------------------------------------------
+\firsthead{}
+%---------------------------------------------------------------------------
+% FuÃzeile
+\firstfoot{%
+ \parbox[b]{\linewidth}{%
+ \centering\def\\{, }\footnotesize\usekomavar{frombank}%
+ }%
+}%
+%---------------------------------------------------------------------------
+% Geschaeftszeilenfelder
+%\setkomavar{place}{Stadel}
+%\setkomavar{placeseparator}{, den }
+%\setkomavar{date}{\today}
+%\setkomavar{yourmail}{1. 1. 2003}%% 'Ihr Schreiben...'
+%\setkomavar{yourref} {abcdefg}%% 'Ihr Zeichen...'
+%\setkomavar{myref}{}%% Unser Zeichen
+\setkomavar{invoice}{\usekomavar{rechnungsnummer}}%% Rechnungsnummer
+%\setkomavar{phoneseparator}{}
+
+%---------------------------------------------------------------------------
+% Versendungsart
+%\setkomavar{specialmail}{Einschreiben mit R�ckschein}
+%---------------------------------------------------------------------------
+% Anlage neu definieren
+\renewcommand{\enclname}{Anlage}
+\setkomavar{enclseparator}{: }
+%---------------------------------------------------------------------------
+% Seitenstil
+\pagestyle{plain}%% keine Header in der Kopfzeile
+%---------------------------------------------------------------------------
+% Rechnungsoptionen
+\Euro
+%---------------------------------------------------------------------------
+\begin{letter}{\usekomavar{toaddress2}}
+%---------------------------------------------------------------------------
+% Weitere Optionen
+\KOMAoptions{%%
+}
+%---------------------------------------------------------------------------
+%\setkomavar{subject}{Rechnungsnummer \usekomavar{rechnungsnummer}}
+%---------------------------------------------------------------------------
+\opening{Sehr geehrte Damen und Herren,}
+
+Ich erlaube mir, Ihnen folgende Beträge in Rechnung zu stellen:
+
+\begin{Rechnung}[N] %oder [N]
+\Steuersatz{0}{0}
+\usekomavar{entries}
+\end{Rechnung}
+
+Bitte zahlen Sie den Betrag von \Gesamtsumme \, bis zum \usekomavar{date_due} auf mein unten angegebenes Konto.
+
+\closing{Mit bestem Dank und freundlichen GrüÃen,}
+%---------------------------------------------------------------------------
+%\ps{PS:}
+%\encl{}
+%\cc{}
+%---------------------------------------------------------------------------
+\end{letter}
+%---------------------------------------------------------------------------
+\end{document}
+%---------------------------------------------------------------------------
diff --git a/src/optional/python-bindings/example_scripts/Invoice.tex.tmpl b/src/optional/python-bindings/example_scripts/Invoice.tex.tmpl
new file mode 100644
index 0000000..b69f3f8
--- /dev/null
+++ b/src/optional/python-bindings/example_scripts/Invoice.tex.tmpl
@@ -0,0 +1,178 @@
+%---------------------------------------------------------------------------
+% Invoice.tex v0.1 by Christoph Holtermann (c.holtermann at gmx.de)
+% modified for use with jinja2 templating system to export from gnucash
+%
+% modified from
+% scrlttr2.tex v0.3. (c) by Juergen Fenn <juergen.fenn at gmx.de>
+% Template for a letter to be typeset with scrlttr2.cls from KOMA-Script.
+% Latest version of the LaTeX Project Public License is applicable.
+% File may not be modified and redistributed under the same name
+% without the author's prior consent.
+%---------------------------------------------------------------------------
+% {% raw %}
+
+\documentclass%%
+%---------------------------------------------------------------------------
+ [fontsize=12pt,%% Schriftgroesse
+%---------------------------------------------------------------------------
+% Satzspiegel
+ paper=a4,%% Papierformat
+ enlargefirstpage=off,%% Erste Seite anders
+ pagenumber=headright,%% Seitenzahl oben mittig
+%---------------------------------------------------------------------------
+% Layout
+ headsepline=on,%% Linie unter der Seitenzahl
+ parskip=half,%% Abstand zwischen Absaetzen
+%---------------------------------------------------------------------------
+% Briefkopf und Anschrift
+ fromalign=right,%% Platzierung des Briefkopfs
+ fromphone=on,%% Telefonnummer im Absender
+ fromrule=off,%% Linie im Absender (aftername, afteraddress)
+ fromfax=on,%% Faxnummer
+ fromemail=on,%% Emailadresse
+ fromurl=off,%% Homepage
+ fromlogo=off,%% Firmenlogo
+ addrfield=on,%% Adressfeld fuer Fensterkuverts
+ backaddress=on,%% ...und Absender im Fenster
+ subject=beforeopening,%% Plazierung der Betreffzeile
+ locfield=narrow,%% zusaetzliches Feld fuer Absender
+ foldmarks=on,%% Faltmarken setzen
+ numericaldate=off,%% Datum numerisch ausgeben
+ refline=narrow,%% Geschaeftszeile im Satzspiegel
+%---------------------------------------------------------------------------
+% Formatierung
+ draft=off,%% Entwurfsmodus
+ version=last
+]{scrlttr2}
+%---------------------------------------------------------------------------
+\usepackage[ngerman]{babel}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{url}
+\usepackage{eurosym}
+\usepackage{rechnung}
+\usepackage{textcomp}
+%---------------------------------------------------------------------------
+% Fonts
+\setkomafont{fromname}{\sffamily \LARGE}
+\setkomafont{fromaddress}{\sffamily}%% statt \small
+\setkomafont{pagenumber}{\sffamily}
+\setkomafont{subject}{\mdseries}
+\setkomafont{backaddress}{\mdseries}
+\usepackage{mathptmx}%% Schrift Times
+%\usepackage{mathpazo}%% Schrift Palatino
+%\setkomafont{fromname}{\LARGE}
+%---------------------------------------------------------------------------
+\begin{document}
+%---------------------------------------------------------------------------
+% Briefstil und Position des Briefkopfs
+\LoadLetterOption{DIN} %% oder: DINmtext, SN, SNleft, KOMAold.
+\makeatletter
+\@setplength{firstheadvpos}{20mm}
+\@setplength{firstheadwidth}{\paperwidth}
+\ifdim \useplength{toaddrhpos}>\z@
+ \@addtoplength[-2]{firstheadwidth}{\useplength{toaddrhpos}}
+\else
+ \@addtoplength[2]{firstheadwidth}{\useplength{toaddrhpos}}
+\fi
+\@setplength{foldmarkhpos}{6.5mm}
+%\setlength{\footskip}{1cm}
+\makeatother
+%---------------------------------------------------------------------------
+% Absender
+\setkomavar{fromname}{fromname}
+\setkomavar{fromaddress}{fromaddress}
+\setkomavar{fromphone}{fromphone}
+\renewcommand{\phonename}{Telefon}
+\setkomavar{fromfax}{fromfax}
+\setkomavar{fromemail}{fromemail}
+\setkomavar{backaddressseparator}{. }
+\setkomavar{signature}{(signature)}
+\setkomavar{frombank}{---NAME --- BANK ACCOUNT --- BANK NUMBER --- BANK NAME ---}
+\setkomavar{location}{\\[8ex]\raggedleft{\footnotesize{\usekomavar{fromaddress}\\
+ Telefon: \usekomavar{fromphone}\\Mobil: mobile-number\\Fax: \usekomavar{fromfax}
+%---------------------------------------------------------------------------
+\firsthead{}
+%---------------------------------------------------------------------------
+% FuÃzeile
+\firstfoot{%
+ \parbox[b]{\linewidth}{%
+ \centering\def\\{, }\footnotesize\usekomavar{frombank}%
+ }%
+}%
+%---------------------------------------------------------------------------
+% Geschaeftszeilenfelder
+%\setkomavar{place}{Stadel}
+%\setkomavar{placeseparator}{, den }
+%\setkomavar{date}{\today}
+%\setkomavar{yourmail}{1. 1. 2003}%% 'Ihr Schreiben...'
+%\setkomavar{yourref} {abcdefg}%% 'Ihr Zeichen...'
+%\setkomavar{myref}{}%% Unser Zeichen
+\setkomavar{invoice}{
+ {% endraw %}
+ {{ invoice.GetID() }}
+ {% raw %}
+}%% Rechnungsnummer
+%\setkomavar{phoneseparator}{}
+
+%---------------------------------------------------------------------------
+% Versendungsart
+%\setkomavar{specialmail}{Einschreiben mit R�ckschein}
+%---------------------------------------------------------------------------
+% Anlage neu definieren
+\renewcommand{\enclname}{Anlage}
+\setkomavar{enclseparator}{: }
+%---------------------------------------------------------------------------
+% Seitenstil
+\pagestyle{plain}%% keine Header in der Kopfzeile
+%---------------------------------------------------------------------------
+% Rechnungsoptionen
+\Euro
+%---------------------------------------------------------------------------
+\begin{letter}{% {% endraw %}
+{{ invoice.GetOwner().GetName().decode("UTF-8") }} \\
+{{ invoice.GetOwner().GetAddr().GetAddr1().decode("UTF-8") }} \\
+{{ invoice.GetOwner().GetAddr().GetAddr2().decode("UTF-8") }} \\
+{{ invoice.GetOwner().GetAddr().GetAddr3().decode("UTF-8") }}
+{# if Addr4 is declared put a linebreak here #}
+{% if invoice.GetOwner().GetAddr().GetAddr4() %} \\ {% endif %}
+{{ invoice.GetOwner().GetAddr().GetAddr4().decode("UTF-8") }} {% raw %}
+}
+%---------------------------------------------------------------------------
+% Weitere Optionen
+\KOMAoptions{%%
+}
+%---------------------------------------------------------------------------
+%\setkomavar{subject}{Rechnungsnummer \usekomavar{rechnungsnummer}}
+%---------------------------------------------------------------------------
+\opening{Sehr geehrte Damen und Herren,}
+
+Ich erlaube mir, Ihnen folgende Beträge in Rechnung zu stellen:
+
+\begin{Rechnung}[N] %oder [N]
+\Steuersatz{0}{0}
+{%- endraw -%}
+{#- **************** JINJA2 Entries BEGIN ********************** -#}
+{%- for ent in invoice.GetEntries() -%}
+ {{- '\Artikel' -}}
+ {{- '{' -}} {{- ent.GetQuantity() -}} {{- '}' -}}
+ {{- '{' -}} {{- ent.GetDescription().decode("UTF-8") -}} {{- '}' -}}
+ {{- '{' -}} {{- ent.GetInvPrice().to_double() -}} {{- '}' -}}
+{%- endfor -%}
+{#- **************** JINJA2 Entries END ********************** -#}
+{%- raw -%}
+\end{Rechnung}
+
+Bitte zahlen Sie den Betrag von \Gesamtsumme \, bis zum \usekomavar{date_due} auf mein unten angegebenes Konto.
+
+\closing{Mit bestem Dank und freundlichen GrüÃen,}
+%---------------------------------------------------------------------------
+%\ps{PS:}
+%\encl{}
+%\cc{}
+%---------------------------------------------------------------------------
+\end{letter}
+%---------------------------------------------------------------------------
+\end{document}
+%---------------------------------------------------------------------------
+%{% endraw %}
diff --git a/src/optional/python-bindings/example_scripts/Invoice_2.tex.tmpl b/src/optional/python-bindings/example_scripts/Invoice_2.tex.tmpl
new file mode 100644
index 0000000..3131ec0
--- /dev/null
+++ b/src/optional/python-bindings/example_scripts/Invoice_2.tex.tmpl
@@ -0,0 +1,195 @@
+%---------------------------------------------------------------------------
+% Invoice_2.tex v0.1 by Christoph Holtermann (c.holtermann at gmx.de)
+% modified for use with jinja2 templating system to export from gnucash
+% Version without rechnung.sty
+%
+% modified from
+% scrlttr2.tex v0.3. (c) by Juergen Fenn <juergen.fenn at gmx.de>
+% Template for a letter to be typeset with scrlttr2.cls from KOMA-Script.
+% Latest version of the LaTeX Project Public License is applicable.
+% File may not be modified and redistributed under the same name
+% without the author's prior consent.
+%---------------------------------------------------------------------------
+%
+% Issues:
+% - Internationalization (currencies)
+
+{%- raw %}
+
+\documentclass%%
+%---------------------------------------------------------------------------
+ [fontsize=12pt,%% Schriftgroesse
+%---------------------------------------------------------------------------
+% Satzspiegel
+ paper=a4,%% Papierformat
+ enlargefirstpage=off,%% Erste Seite anders
+ pagenumber=headright,%% Seitenzahl oben mittig
+%---------------------------------------------------------------------------
+% Layout
+ headsepline=on,%% Linie unter der Seitenzahl
+ parskip=half,%% Abstand zwischen Absaetzen
+%---------------------------------------------------------------------------
+% Briefkopf und Anschrift
+ fromalign=right,%% Platzierung des Briefkopfs
+ fromphone=on,%% Telefonnummer im Absender
+ fromrule=off,%% Linie im Absender (aftername, afteraddress)
+ fromfax=on,%% Faxnummer
+ fromemail=on,%% Emailadresse
+ fromurl=off,%% Homepage
+ fromlogo=off,%% Firmenlogo
+ addrfield=on,%% Adressfeld fuer Fensterkuverts
+ backaddress=on,%% ...und Absender im Fenster
+ subject=beforeopening,%% Plazierung der Betreffzeile
+ locfield=narrow,%% zusaetzliches Feld fuer Absender
+ foldmarks=on,%% Faltmarken setzen
+ numericaldate=off,%% Datum numerisch ausgeben
+ refline=narrow,%% Geschaeftszeile im Satzspiegel
+%---------------------------------------------------------------------------
+% Formatierung
+ draft=off,%% Entwurfsmodus
+ version=last
+]{scrlttr2}
+%---------------------------------------------------------------------------
+\usepackage[ngerman]{babel}
+\usepackage[T1]{fontenc}
+\usepackage[utf8]{inputenc}
+\usepackage{url}
+\usepackage{eurosym}
+\usepackage{rechnung}
+\usepackage{textcomp}
+%---------------------------------------------------------------------------
+% Fonts
+\setkomafont{fromname}{\sffamily \LARGE}
+\setkomafont{fromaddress}{\sffamily}%% statt \small
+\setkomafont{pagenumber}{\sffamily}
+\setkomafont{subject}{\mdseries}
+\setkomafont{backaddress}{\mdseries}
+\usepackage{mathptmx}%% Schrift Times
+%\usepackage{mathpazo}%% Schrift Palatino
+%\setkomafont{fromname}{\LARGE}
+%---------------------------------------------------------------------------
+\begin{document}
+%---------------------------------------------------------------------------
+% Briefstil und Position des Briefkopfs
+\LoadLetterOption{DIN} %% oder: DINmtext, SN, SNleft, KOMAold.
+\makeatletter
+\@setplength{firstheadvpos}{20mm}
+\@setplength{firstheadwidth}{\paperwidth}
+\ifdim \useplength{toaddrhpos}>\z@
+ \@addtoplength[-2]{firstheadwidth}{\useplength{toaddrhpos}}
+\else
+ \@addtoplength[2]{firstheadwidth}{\useplength{toaddrhpos}}
+\fi
+\@setplength{foldmarkhpos}{6.5mm}
+%\setlength{\footskip}{1cm}
+\makeatother
+%---------------------------------------------------------------------------
+% Absender
+\setkomavar{fromname}{fromname}
+\setkomavar{fromaddress}{fromaddress}
+\setkomavar{fromphone}{fromphone}
+\renewcommand{\phonename}{Telefon}
+\setkomavar{fromfax}{fromfax}
+\setkomavar{fromemail}{fromemail}
+\setkomavar{backaddressseparator}{. }
+\setkomavar{signature}{(signature)}
+\setkomavar{frombank}{---NAME --- BANK ACCOUNT --- BANK NUMBER --- BANK NAME ---}
+\setkomavar{location}{\\[8ex]\raggedleft{\footnotesize{\usekomavar{fromaddress}\\
+ Telefon: \usekomavar{fromphone}\\Mobil: mobile-number\\Fax: \usekomavar{fromfax}\\\usekomavar{fromemail}}}}%% Neben dem Adressfenster
+%---------------------------------------------------------------------------
+\firsthead{}
+%---------------------------------------------------------------------------
+% FuÃzeile
+\firstfoot{%
+ \parbox[b]{\linewidth}{
+ \centering\def\\{, }\footnotesize\usekomavar{frombank}%
+ }%
+}%
+%---------------------------------------------------------------------------
+% Geschaeftszeilenfelder
+%\setkomavar{place}{Stadel}
+%\setkomavar{placeseparator}{, den }
+%\setkomavar{date}{\today}
+%\setkomavar{yourmail}{1. 1. 2003}%% 'Ihr Schreiben...'
+%\setkomavar{yourref} {abcdefg}%% 'Ihr Zeichen...'
+%\setkomavar{myref}{}%% Unser Zeichen
+\setkomavar{invoice}{
+ {% endraw %}
+ {{ invoice.GetID() }}
+ {% raw %}
+}%% Rechnungsnummer
+%\setkomavar{phoneseparator}{}
+
+%---------------------------------------------------------------------------
+% Versendungsart
+%\setkomavar{specialmail}{Einschreiben mit R�ckschein}
+%---------------------------------------------------------------------------
+% Anlage neu definieren
+\renewcommand{\enclname}{Anlage}
+\setkomavar{enclseparator}{: }
+%---------------------------------------------------------------------------
+% Seitenstil
+\pagestyle{plain}%% keine Header in der Kopfzeile
+%---------------------------------------------------------------------------
+% Rechnungsoptionen
+\Euro
+%---------------------------------------------------------------------------
+\begin{letter}{ {%- endraw -%}
+{{- invoice.GetOwner().GetName().decode("UTF-8") -}} \\
+{{- invoice.GetOwner().GetAddr().GetAddr1().decode("UTF-8") -}} \\
+{{- invoice.GetOwner().GetAddr().GetAddr2().decode("UTF-8") -}} \\
+{{- invoice.GetOwner().GetAddr().GetAddr3().decode("UTF-8") -}}
+{# if Addr4 is declared put a linebreak here #}
+{%- if invoice.GetOwner().GetAddr().GetAddr4() -%} \\ {%- endif -%}
+{{- invoice.GetOwner().GetAddr().GetAddr4().decode("UTF-8") -}} {%- raw -%}
+}
+%---------------------------------------------------------------------------
+% Weitere Optionen
+\KOMAoptions{%%
+}
+%---------------------------------------------------------------------------
+%\setkomavar{subject}{Rechnungsnummer \usekomavar{rechnungsnummer}}
+%---------------------------------------------------------------------------
+\opening{Sehr geehrte Damen und Herren,}
+
+{%- endraw -%}
+
+Ich erlaube mir, Ihnen folgende Beträge in Rechnung zu stellen:
+
+\newcommand{\GesamtSumme}{ {{- locale.format("%.2f", invoice.GetTotal().to_double()) -}} }
+
+\renewcommand{\arraystretch}{1.3}
+\begin{tabular}{|c|c|p{0.48\textwidth}|r|r|}
+ \hline
+ \textbf{Pos} & \textbf{Menge} & \textbf{Bezeichnung} & \textbf{Einzelpreis} & \textbf{Gesamtpreis} \\
+ \hline
+% 1 & 1 & Musterdienstleistung \newline vom 11.02.2012 bis 14.03.2012 & \EUR{49,94} & \EUR{49,94} \\ \hline
+ {#- **************** JINJA2 Entries BEGIN ********************** -#}
+ {%- for ent in invoice.GetEntries() %}
+ {{ loop.index }} &
+ {{- locale.format("%.2f", ent.GetQuantity().to_double()) -}} &
+ {{- ent.GetDescription().decode("UTF-8") -}} &
+ \EUR{ {{- locale.format("%.2f", ent.GetInvPrice().to_double()) -}} } &
+ \EUR{ {{- locale.format("%.2f", ent.GetInvPrice().to_double() * ent.GetQuantity().to_double()) -}} } \\ \hline
+ {%- endfor -%}
+ {#- **************** JINJA2 Entries END ********************** -#}
+
+ {%- raw %}
+
+ \multicolumn{4}{r}{\textbf{Gesamtbetrag(brutto)} } & \multicolumn{1}{r}{\EUR{\GesamtSumme{}}}\\
+ \end{tabular}
+\\[\baselineskip]
+
+Bitte zahlen Sie den Betrag von \Gesamtsumme \, bis zum {% endraw %} {{ invoice.GetDateDue().strftime("%d.%m.%Y") }} {% raw %} auf mein unten angegebenes Konto.
+
+\closing{Mit bestem Dank und freundlichen GrüÃen,}
+%---------------------------------------------------------------------------
+%\ps{PS:}
+%\encl{}
+%\cc{}
+%---------------------------------------------------------------------------
+\end{letter}
+%---------------------------------------------------------------------------
+\end{document}
+%---------------------------------------------------------------------------
+%{% endraw %}
commit eb9578648e63ac4393ed82cf616f6ceef52adde0
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Tue Nov 11 21:35:15 2014 +0100
locale formatting added
diff --git a/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
index 93ea8e6..6937c72 100644
--- a/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
+++ b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
@@ -20,6 +20,7 @@
# * How much logic in the template, how much preprocessing in this file ?
try:
+ import locale
import sys
import getopt
import gnucash
@@ -160,7 +161,7 @@ def main(argv=None):
#import IPython
#IPython.embed()
- output = template.render(invoice=invoice)
+ output = template.render(invoice=invoice, locale=locale)
print "Writing output", filename_output, "."
with open(filename_output, 'w') as f:
commit a53f615f806936a6a5a416ccf43d95a6a9b39701
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Tue Nov 11 17:08:57 2014 +0100
This question has been solved
diff --git a/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
index fe2f939..93ea8e6 100644
--- a/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
+++ b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
@@ -17,7 +17,6 @@
# more modular as it allows to use arbitrary templates
#
# Questions / Issues:
-# * How to print a list of all invoices ? ( Or to post a search via python )
# * How much logic in the template, how much preprocessing in this file ?
try:
commit 765d73f9037adb69fd4bfa7ae229d8e2fb876336
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Tue Nov 11 16:59:45 2014 +0100
Querying and listing all invoices now possible
diff --git a/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
index 714c4fe..fe2f939 100644
--- a/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
+++ b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
@@ -46,12 +46,12 @@ def main(argv=None):
filename_template = None
filename_output = None
no_output = False
- list_invoices = True
+ list_invoices = False
invoice_number = None
invoice_id = None
try:
- opts, args = getopt.getopt(argv[1:], "fhI:t:o:", ["help"])
+ opts, args = getopt.getopt(argv[1:], "fhlI:t:o:", ["help"])
except getopt.error, msg:
raise Usage(msg)
@@ -70,6 +70,9 @@ def main(argv=None):
if opt[0] in ["-t"]:
filename_template = opt[1]
print "using template file", filename_template
+ if opt[0] in ["-l"]:
+ list_invoices = True
+ print "listing invoices"
# Check for correct input
if len(args)>1:
@@ -81,11 +84,15 @@ def main(argv=None):
# Check for correct template
if not filename_template:
- raise Usage("No template given !")
+ no_output = True
+ if not list_invoices:
+ raise Usage("No template given !")
# Check for output file
if not filename_output:
- filename_output = filename_template + ".out"
+ if filename_template:
+ filename_output = filename_template + ".out"
+ print "no output filename given, will be:", filename_output
except Usage, err:
if err.msg == "Help:":
@@ -105,8 +112,9 @@ def main(argv=None):
print "or mysql://user:password@host/databasename"
print
print "-f force open = ignore lock"
+ print "-l list all invoices"
print "-h or --help for this help"
- print "-I ID invoice with this ID"
+ print "-I ID use invoice ID"
print "-t filename use filename as template file"
print "-o filename use filename as output file"
@@ -126,12 +134,12 @@ def main(argv=None):
comm_table = book.get_table()
EUR = comm_table.lookup("CURRENCY", "EUR")
- # invoice_list = get_all_invoices(book)
+ invoice_list = get_all_invoices(book)
- # if list_invoices:
- # for number,invoice in enumerate(invoice_list):
- # print str(number)+")"
- # print invoice
+ if list_invoices:
+ for number,invoice in enumerate(invoice_list):
+ print str(number)+")"
+ print invoice
if not (no_output):
diff --git a/src/optional/python-bindings/example_scripts/gncinvoicefkt.py b/src/optional/python-bindings/example_scripts/gncinvoicefkt.py
index f01ea64..c63fc8d 100644
--- a/src/optional/python-bindings/example_scripts/gncinvoicefkt.py
+++ b/src/optional/python-bindings/example_scripts/gncinvoicefkt.py
@@ -39,17 +39,48 @@ def get_all_invoices_from_lots(account):
invoice_list.append(Invoice(instance=invoice))
return invoice_list
-def get_all_invoices(book):
- """Returns all invoices in the book."""
+def get_all_invoices(book, is_paid=None, is_active=None):
+ """Returns a list of all invoices in the book.
+
+ posts a query to search for all invoices.
+
+ arguments:
+ book the gnucash book to work with
+ keyword-arguments:
+ is_paid int 1 to search for invoices having been paid, 0 for not, None to ignore.
+ is_active int 1 to search for active invoices
+ """
+
+ query = gnucash.Query()
+ query.search_for('gncInvoice')
+ query.set_book(book)
+
+ if is_paid == 0:
+ query.add_boolean_match([gnucash.INVOICE_IS_PAID], False, gnucash.QOF_QUERY_AND)
+ elif is_paid == 1:
+ query.add_boolean_match([gnucash.INVOICE_IS_PAID], True, gnucash.QOF_QUERY_AND)
+ elif is_paid == None:
+ pass
+
+ # active = JOB_IS_ACTIVE
+ if is_active == 0:
+ query.add_boolean_match(['active'], False, gnucash.QOF_QUERY_AND)
+ elif is_active == 1:
+ query.add_boolean_match(['active'], True, gnucash.QOF_QUERY_AND)
+ elif is_active == None:
+ pass
+
+ # return only invoices (1 = invoices)
+ pred_data = gnucash.gnucash_core.QueryInt32Predicate(gnucash.QOF_COMPARE_EQUAL, 1)
+ query.add_term([gnucash.INVOICE_TYPE], pred_data, gnucash.QOF_QUERY_AND)
invoice_list = []
- invoice = True
- invoice_id = 0
- while invoice:
- invoice_id += 1
- invoice = book.InvoiceLookupByID('%06d' % invoice_id)
- if invoice:
- invoice_list.append(invoice)
+
+ result = query.run()
+ for result in query.run():
+ invoice_list.append(Invoice(instance=result))
+
+ query.destroy()
return invoice_list
commit 9595062e5fa618a084c96d621a3aed9c9f74f68c
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Mon Nov 10 18:52:24 2014 +0100
Invoice.tex is to be created not to be on github
diff --git a/src/optional/python-bindings/example_scripts/Invoice.tex b/src/optional/python-bindings/example_scripts/Invoice.tex
deleted file mode 100644
index 1c0701f..0000000
--- a/src/optional/python-bindings/example_scripts/Invoice.tex
+++ /dev/null
@@ -1,154 +0,0 @@
-%---------------------------------------------------------------------------
-% Invoice.tex v0.1 by Christoph Holtermann (c.holtermann at gmx.de)
-%
-% modified from
-% scrlttr2.tex v0.3. (c) by Juergen Fenn <juergen.fenn at gmx.de>
-% Template for a letter to be typeset with scrlttr2.cls from KOMA-Script.
-% Latest version of the LaTeX Project Public License is applicable.
-% File may not be modified and redistributed under the same name
-% without the author's prior consent.
-%---------------------------------------------------------------------------
-\documentclass%%
-%---------------------------------------------------------------------------
- [fontsize=12pt,%% Schriftgroesse
-%---------------------------------------------------------------------------
-% Satzspiegel
- paper=a4,%% Papierformat
- enlargefirstpage=off,%% Erste Seite anders
- pagenumber=headright,%% Seitenzahl oben mittig
-%---------------------------------------------------------------------------
-% Layout
- headsepline=on,%% Linie unter der Seitenzahl
- parskip=half,%% Abstand zwischen Absaetzen
-%---------------------------------------------------------------------------
-% Briefkopf und Anschrift
- fromalign=right,%% Platzierung des Briefkopfs
- fromphone=on,%% Telefonnummer im Absender
- fromrule=off,%% Linie im Absender (aftername, afteraddress)
- fromfax=on,%% Faxnummer
- fromemail=on,%% Emailadresse
- fromurl=off,%% Homepage
- fromlogo=off,%% Firmenlogo
- addrfield=on,%% Adressfeld fuer Fensterkuverts
- backaddress=on,%% ...und Absender im Fenster
- subject=beforeopening,%% Plazierung der Betreffzeile
- locfield=narrow,%% zusaetzliches Feld fuer Absender
- foldmarks=on,%% Faltmarken setzen
- numericaldate=off,%% Datum numerisch ausgeben
- refline=narrow,%% Geschaeftszeile im Satzspiegel
-%---------------------------------------------------------------------------
-% Formatierung
- draft=off,%% Entwurfsmodus
- version=last,
- data%% data.lco ist die Datei aus der die Rechnungsdaten gelesen werden ( invoice-data to be read from data.lco )
-]{scrlttr2}
-%---------------------------------------------------------------------------
-\usepackage[ngerman]{babel}
-\usepackage[T1]{fontenc}
-\usepackage[utf8]{inputenc}
-\usepackage{url}
-\usepackage{eurosym}
-\usepackage{rechnung}
-\usepackage{textcomp}
-%---------------------------------------------------------------------------
-% Fonts
-\setkomafont{fromname}{\sffamily \LARGE}
-\setkomafont{fromaddress}{\sffamily}%% statt \small
-\setkomafont{pagenumber}{\sffamily}
-\setkomafont{subject}{\mdseries}
-\setkomafont{backaddress}{\mdseries}
-\usepackage{mathptmx}%% Schrift Times
-%\usepackage{mathpazo}%% Schrift Palatino
-%\setkomafont{fromname}{\LARGE}
-%---------------------------------------------------------------------------
-\begin{document}
-%---------------------------------------------------------------------------
-% Briefstil und Position des Briefkopfs
-\LoadLetterOption{DIN} %% oder: DINmtext, SN, SNleft, KOMAold.
-\makeatletter
-\@setplength{firstheadvpos}{20mm}
-\@setplength{firstheadwidth}{\paperwidth}
-\ifdim \useplength{toaddrhpos}>\z@
- \@addtoplength[-2]{firstheadwidth}{\useplength{toaddrhpos}}
-\else
- \@addtoplength[2]{firstheadwidth}{\useplength{toaddrhpos}}
-\fi
-\@setplength{foldmarkhpos}{6.5mm}
-%\setlength{\footskip}{1cm}
-\makeatother
-%---------------------------------------------------------------------------
-% Absender
-\setkomavar{fromname}{fromname}
-\setkomavar{fromaddress}{fromaddress}
-\setkomavar{fromphone}{fromphone}
-\renewcommand{\phonename}{Telefon}
-\setkomavar{fromfax}{fromfax}
-\setkomavar{fromemail}{fromemail}
-\setkomavar{backaddressseparator}{. }
-\setkomavar{signature}{(signature)}
-\setkomavar{frombank}{---NAME --- BANK ACCOUNT --- BANK NUMBER --- BANK NAME ---}
-\setkomavar{location}{\\[8ex]\raggedleft{\footnotesize{\usekomavar{fromaddress}\\
- Telefon: \usekomavar{fromphone}\\Mobil: mobile-number\\Fax: \usekomavar{fromfax}\\\usekomavar{fromemail}}}}%% Neben dem Adressfenster
-%---------------------------------------------------------------------------
-\firsthead{}
-%---------------------------------------------------------------------------
-% FuÃzeile
-\firstfoot{%
- \parbox[b]{\linewidth}{%
- \centering\def\\{, }\footnotesize\usekomavar{frombank}%
- }%
-}%
-%---------------------------------------------------------------------------
-% Geschaeftszeilenfelder
-%\setkomavar{place}{Stadel}
-%\setkomavar{placeseparator}{, den }
-%\setkomavar{date}{\today}
-%\setkomavar{yourmail}{1. 1. 2003}%% 'Ihr Schreiben...'
-%\setkomavar{yourref} {abcdefg}%% 'Ihr Zeichen...'
-%\setkomavar{myref}{}%% Unser Zeichen
-\setkomavar{invoice}{\usekomavar{rechnungsnummer}}%% Rechnungsnummer
-%\setkomavar{phoneseparator}{}
-
-%---------------------------------------------------------------------------
-% Versendungsart
-%\setkomavar{specialmail}{Einschreiben mit R�ckschein}
-%---------------------------------------------------------------------------
-% Anlage neu definieren
-\renewcommand{\enclname}{Anlage}
-\setkomavar{enclseparator}{: }
-%---------------------------------------------------------------------------
-% Seitenstil
-\pagestyle{plain}%% keine Header in der Kopfzeile
-%---------------------------------------------------------------------------
-% Rechnungsoptionen
-\Euro
-%---------------------------------------------------------------------------
-\begin{letter}{\usekomavar{toaddress2}}
-%---------------------------------------------------------------------------
-% Weitere Optionen
-\KOMAoptions{%%
-}
-%---------------------------------------------------------------------------
-%\setkomavar{subject}{Rechnungsnummer \usekomavar{rechnungsnummer}}
-%---------------------------------------------------------------------------
-\opening{Sehr geehrte Damen und Herren,}
-
-Ich erlaube mir, Ihnen folgende Beträge in Rechnung zu stellen:
-
-\begin{Rechnung}[N] %oder [N]
-\Steuersatz{0}{0}
-\usekomavar{entries}
-\end{Rechnung}
-
-Bitte zahlen Sie den Betrag von \Gesamtsumme \, bis zum \usekomavar{date_due} auf mein unten angegebenes Konto.
-
-\closing{Mit bestem Dank und freundlichen GrüÃen,}
-%---------------------------------------------------------------------------
-%\ps{PS:}
-%\encl{}
-%\cc{}
-%---------------------------------------------------------------------------
-\end{letter}
-%---------------------------------------------------------------------------
-\end{document}
-%---------------------------------------------------------------------------
commit 7de700d5b5be996508a60a0f1f01e133e32f7abf
Merge: 15a69f1 f750cab
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Mon Nov 10 16:00:43 2014 +0100
Merge remote-tracking branch 'upstream/master'
commit 15a69f120569a174837b467d54a22fb1b4345777
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Mon Nov 10 15:52:19 2014 +0100
Create invoices from templates with jinja2
diff --git a/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
new file mode 100644
index 0000000..714c4fe
--- /dev/null
+++ b/src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
@@ -0,0 +1,163 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+
+##@file
+# @ingroup python_bindings_examples
+# @author Christoph Holtermann (c.holtermann (at) gmx.de)
+# @date 2014-11
+# @brief exports an invoice from gnucash using a template file
+#
+# Input is a template file that will be filled with information from
+# gnucash Invoices. Jinja2 templating engine ist used. Templates can
+# be Latex, Html or anything.
+#
+# This is a sequel to latex_invoices.py that exported to a lco file
+# to be imported into a LaTeX letter.
+# The approach used here is not as dependent on external files and
+# more modular as it allows to use arbitrary templates
+#
+# Questions / Issues:
+# * How to print a list of all invoices ? ( Or to post a search via python )
+# * How much logic in the template, how much preprocessing in this file ?
+
+try:
+ import sys
+ import getopt
+ import gnucash
+ import str_methods
+ import jinja2
+ from gncinvoicefkt import *
+except ImportError as import_error:
+ print "Problem importing modules."
+ print import_error
+ sys.exit(2)
+
+class Usage(Exception):
+ def __init__(self, msg):
+ self.msg = msg
+
+def main(argv=None):
+ if argv is None:
+ argv = sys.argv
+ try:
+ # default values
+ prog_name = argv[0]
+ ignore_lock = True
+ filename_template = None
+ filename_output = None
+ no_output = False
+ list_invoices = True
+ invoice_number = None
+ invoice_id = None
+
+ try:
+ opts, args = getopt.getopt(argv[1:], "fhI:t:o:", ["help"])
+ except getopt.error, msg:
+ raise Usage(msg)
+
+ for opt in opts:
+ if opt[0] in ["-f"]:
+ print "ignoring lock"
+ ignore_lock = True
+ if opt[0] in ["-h","--help"]:
+ raise Usage("Help:")
+ if opt[0] in ["-I"]:
+ invoice_id = opt[1]
+ print "using invoice ID '" + str(invoice_id) + "'."
+ if opt[0] in ["-o"]:
+ filename_output = opt[1]
+ print "using output file", filename_output
+ if opt[0] in ["-t"]:
+ filename_template = opt[1]
+ print "using template file", filename_template
+
+ # Check for correct input
+ if len(args)>1:
+ print "opts:",opts,"args:",args
+ raise Usage("Only one input possible !")
+ if len(args)==0:
+ raise Usage("No input given !")
+ input_url = args[0]
+
+ # Check for correct template
+ if not filename_template:
+ raise Usage("No template given !")
+
+ # Check for output file
+ if not filename_output:
+ filename_output = filename_template + ".out"
+
+ except Usage, err:
+ if err.msg == "Help:":
+ retcode=0
+ else:
+ print >>sys.stderr, "Error:",err.msg
+ print >>sys.stderr, "for help use --help"
+ retcode=2
+
+ print
+ print "Usage:"
+ print
+ print "Invoke with",prog_name,"gnucash_url."
+ print "where input is"
+ print " filename"
+ print "or file://filename"
+ print "or mysql://user:password@host/databasename"
+ print
+ print "-f force open = ignore lock"
+ print "-h or --help for this help"
+ print "-I ID invoice with this ID"
+ print "-t filename use filename as template file"
+ print "-o filename use filename as output file"
+
+ return retcode
+
+ # Try to open the given input
+ try:
+ print "Opening", input_url, "."
+ session = gnucash.Session(input_url, ignore_lock=ignore_lock)
+ except Exception as exception:
+ print "Problem opening input."
+ print exception
+ return 2
+
+ book = session.book
+ root_account = book.get_root_account()
+ comm_table = book.get_table()
+ EUR = comm_table.lookup("CURRENCY", "EUR")
+
+ # invoice_list = get_all_invoices(book)
+
+ # if list_invoices:
+ # for number,invoice in enumerate(invoice_list):
+ # print str(number)+")"
+ # print invoice
+
+ if not (no_output):
+
+ if invoice_id:
+ invoice = book.InvoiceLookupByID(invoice_id)
+ if not invoice:
+ print "ID not found."
+ return 2
+
+ if invoice_number:
+ invoice = invoice_list[invoice_number]
+
+ print "Using the following invoice:"
+ print invoice
+
+ loader = jinja2.FileSystemLoader('.')
+ env = jinja2.Environment(loader=loader)
+ template = env.get_template(filename_template)
+
+ #import IPython
+ #IPython.embed()
+ output = template.render(invoice=invoice)
+
+ print "Writing output", filename_output, "."
+ with open(filename_output, 'w') as f:
+ f.write(output.encode('utf-8'))
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/src/optional/python-bindings/example_scripts/gncinvoicefkt.py b/src/optional/python-bindings/example_scripts/gncinvoicefkt.py
new file mode 100644
index 0000000..f01ea64
--- /dev/null
+++ b/src/optional/python-bindings/example_scripts/gncinvoicefkt.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python
+# -*- coding: UTF-8 -*-
+
+try:
+ import gnucash
+ from gnucash.gnucash_business import Customer, Employee, Vendor, Job, \
+ Address, Invoice, Entry, TaxTable, TaxTableEntry, GNC_AMT_TYPE_PERCENT, \
+ GNC_DISC_PRETAX
+ import str_methods
+except ImportError as import_error:
+ print "Problem importing modules."
+ print import_error
+ sys.exit(2)
+
+def get_all_lots(account):
+ """Return all lots in account and descendants"""
+ ltotal=[]
+ descs = account.get_descendants()
+ for desc in descs:
+ if type(desc).__name__ == 'SwigPyObject':
+ desc = gnucash.Account(instance=desc)
+ ll=desc.GetLotList()
+ ltotal+=ll
+ return ltotal
+
+def get_all_invoices_from_lots(account):
+ """Return all invoices in account and descendants
+
+ This is based on lots. So invoices without lots will be missed."""
+
+ lot_list=get_all_lots(account)
+ invoice_list=[]
+ for lot in lot_list:
+ if type(lot).__name__ == 'SwigPyObject':
+ lot = gnucash.GncLot(instance=lot)
+
+ invoice=gnucash.gnucash_core_c.gncInvoiceGetInvoiceFromLot(lot.instance)
+ if invoice:
+ invoice_list.append(Invoice(instance=invoice))
+ return invoice_list
+
+def get_all_invoices(book):
+ """Returns all invoices in the book."""
+
+ invoice_list = []
+ invoice = True
+ invoice_id = 0
+ while invoice:
+ invoice_id += 1
+ invoice = book.InvoiceLookupByID('%06d' % invoice_id)
+ if invoice:
+ invoice_list.append(invoice)
+
+ return invoice_list
+
+def get_all_customers(book):
+ """Returns all customers in book."""
+
+ customer_list = []
+ customer = True
+ customer_id = 0
+ while customer:
+ customer_id += 1
+ customer = book.CustomerLookupByID('%06d' % customer_id)
+ if customer:
+ customer_list.append(customer)
+
+ return customer_list
commit d2ed373426166d89765c449356e75a74cc148012
Merge: 3fc6239 6c2a42b
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Sun Nov 2 13:32:55 2014 +0100
Merge branch 'master' of https://github.com/Gnucash/gnucash
commit 3fc6239539a375947581cda0ee07aa440d674e59
Author: Christoph Holtermann <c.holtermann at gmx.de>
Date: Thu May 29 23:59:40 2014 +0200
Some adjustments, new IPython version
diff --git a/src/optional/python-bindings/example_scripts/latex_invoices.py b/src/optional/python-bindings/example_scripts/latex_invoices.py
index 622e987..b250684 100644
--- a/src/optional/python-bindings/example_scripts/latex_invoices.py
+++ b/src/optional/python-bindings/example_scripts/latex_invoices.py
@@ -53,7 +53,11 @@ try:
import getopt
import gnucash
import str_methods
- from IPython.Shell import IPShellEmbed
+ from IPython import version_info as IPython_version_info
+ if IPython_version_info[0]>=1:
+ from IPython.terminal.ipapp import TerminalIPythonApp
+ else:
+ from IPython.frontend.terminal.ipapp import TerminalIPythonApp
from gnucash.gnucash_business import Customer, Employee, Vendor, Job, \
Address, Invoice, Entry, TaxTable, TaxTableEntry, GNC_AMT_TYPE_PERCENT, \
GNC_DISC_PRETAX
@@ -120,7 +124,7 @@ def invoice_to_lco(invoice):
add_str=u""
owner = invoice.GetOwner()
if owner.GetName() != "":
- add_str += owner.GetName()+"\n"
+ add_str += owner.GetName().decode("UTF-8")+"\n"
addr = owner.GetAddr()
if addr.GetName() != "":
@@ -191,9 +195,10 @@ def main(argv=None):
prog_name = argv[0]
with_ipshell = False
ignore_lock = False
- no_latex_output = False
+ no_latex_output = True
list_invoices = False
output_file_name = "data.lco"
+ invoice_number = None
try:
opts, args = getopt.getopt(argv[1:], "fhiln:po:", ["help"])
@@ -215,12 +220,10 @@ def main(argv=None):
if opt[0] in ["-n"]:
invoice_number = int(opt[1])
print "using invoice number", invoice_number
+ no_latex_output = False
if opt[0] in ["-o"]:
output_file_name = opt[1]
- print "using outpu file", output_file_name
- if opt[0] in ["-p"]:
- print "no latex output"
- no_latex_output=True
+ print "using output file", output_file_name
if len(args)>1:
print "opts:",opts,"args:",args
raise Usage("Only one input can be accepted !")
@@ -249,9 +252,8 @@ def main(argv=None):
print "-h or --help for this help"
print "-i for ipython shell"
print "-l list all invoices"
- print "-n number use invoice number (no. from previous run -l)"
+ print "-n number use invoice number (no. from previous run with -l)"
print "-o name use name as outputfile. default: data.lco"
- print "-p pretend (=no) latex output"
return retcode
@@ -294,8 +296,9 @@ def main(argv=None):
f.close()
if with_ipshell:
- ipshell= IPShellEmbed()
- ipshell()
+ app = TerminalIPythonApp.instance()
+ app.initialize(argv=[]) # argv=[] instructs IPython to ignore sys.argv
+ app.start()
#session.save()
session.end()
Summary of changes:
src/core-utils/gnc-path.c | 12 +-
.../{Invoice.tex => Invoice.tex.tmpl} | 36 ++++-
.../{Invoice.tex => Invoice_2.tex.tmpl} | 63 ++++++--
.../example_scripts/gncinvoice_jinja.py | 179 +++++++++++++++++++++
.../example_scripts/gncinvoicefkt.py | 115 +++++++++++++
.../example_scripts/invoice_export_doxygen.txt | 48 ++++++
.../example_scripts/latex_invoices.py | 36 +----
.../example_scripts/simple_business_create.py | 4 +-
.../example_scripts/simple_invoice_insert.py | 15 +-
src/optional/python-bindings/gnucash_core.py | 8 +-
src/report/standard-reports/standard-reports.scm | 46 +++---
11 files changed, 482 insertions(+), 80 deletions(-)
copy src/optional/python-bindings/example_scripts/{Invoice.tex => Invoice.tex.tmpl} (84%)
copy src/optional/python-bindings/example_scripts/{Invoice.tex => Invoice_2.tex.tmpl} (74%)
create mode 100644 src/optional/python-bindings/example_scripts/gncinvoice_jinja.py
create mode 100644 src/optional/python-bindings/example_scripts/gncinvoicefkt.py
create mode 100644 src/optional/python-bindings/example_scripts/invoice_export_doxygen.txt
More information about the gnucash-changes
mailing list