Merge branch 'maint'

This commit is contained in:
Geert Janssens 2014-11-29 14:26:27 +01:00
commit e219ef22ea
5 changed files with 52 additions and 33 deletions

View File

@ -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);
}

View File

@ -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(), "", "")

View File

@ -22,11 +22,12 @@
# @author Mark Jenkins, ParIT Worker Co-operative <mark@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()

View File

@ -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()

View File

@ -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))