Re: Custom .scm script: Query account balance

2016-10-12 Thread Eric Wheeler
On Wed, 5 Oct 2016, John Ralls wrote:
> 
> > On Oct 5, 2016, at 1:35 AM, Eric Wheeler  
> > wrote:
> > 
> > On Tue, 4 Oct 2016, Derek Atkins wrote:
> > 
> >> Hi,
> >> 
> >> Eric Wheeler  writes:
> >> 
> >>> Hello all,
> >>> 
> >>> I would like to update our invoice .scm template to include a balance 
> >>> from 
> >>> an account containing the customer's name (this is separate from any 
> >>> accounts receivable, it is a retainer liability account).
> >>> 
> >>> I tried digging through the account piechart.scm and the taxinvoice.scm 
> >>> to 
> >>> see if I can come up with a way to query the account something like this:
> >>> 
> >>> gnc:account-get-comm-balance-at-date append("Liabilities::Retainers::" 
> >>> coyname)
> >> 
> >> First, you probably don't need the double-colons.
> >> 
> >>> But I'm not sure how to pass today's date. It's been years since I've 
> >>> written scheme so any help would be greatly appreciated!
> >> 
> >> (current-time) ??   Or perhaps (localtime (current-time)) -- depending
> >> on what you need.
> > 
> > I'm still trying to get to the point where I can specify an account 
> > (hard-coded) by name in my report to get that account's balance.
> > 
> > I can map all of numerical values for balanaces, but they report all 0s 
> > for all accounts. This makes me think that "current-time" is being 
> > evaluated as the epoch, perhaps because it is an invalid data type for the 
> > gnc:account-get-balance-at-date function.
> > 
> > Do you know how the gnc:account-get-balance-at-date function expects date 
> > to be represented?
> > 
> > (display (append
> >(map
> >(lambda (x) (gnc:gnc-numeric-num (gnc:account-get-balance-at-date x 
> > (current-time) 0)))
> >(gnc-account-get-descendants-sorted (gnc-get-current-root-account))
> >))
> > )
> > 
> 
> 
> It's calling gnc:account-get-comm-balance-at-date 
> (src/report/report-system/report-utilities.scm:462) which in turn sets 
> the date in the query with xaccQueryAddDateMatchTS (ibid:489). That "TS" 
> on the end means it's looking for a timespec, a struct containing an 
> int64_t of seconds since the epoch and an int32_t of nanoseconds (always 
> 0 in GnuCash, so we're working slowly on replacing timespecs with just 
> an int64_t of seconds). You'll find functions for creating timespecs in 
> src/app-utils/date-utilities.scm.

Thank you everyone for your help getting balanaces from an account for our 
invoice report!

These are the defines that wrote to simplify the implementation in case it 
helps anyone else:

(define (account-exists name)
(let* (
(accts
(gnc-account-get-descendants-sorted 
(gnc-get-current-root-account))
)
)
(not
(=
(length
(filter
(lambda (acct) (string=? name 
(gnc-account-get-full-name acct)))
accts
)
)
0
)
)
)
)

(define (get-account-balance acct)
(let* (
(bal 
(gnc:account-get-balance-at-date
acct 
(gnc:date->timepair (localtime 
(current-time)))
0
)
)
(num (gnc:gnc-numeric-num bal))
(denom (gnc:gnc-numeric-denom bal))
)
(/ num denom 1.0)
)
)

(define (get-account-balance-by-name name)
(let* (
(accts
(gnc-account-get-descendants-sorted 
(gnc-get-current-root-account))
)
(balpair
(map
(lambda (acct) (get-account-balance 
acct))
(filter
(lambda (acct) (string=? name 
(gnc-account-get-full-name acct)))
accts
)
)
)
)
(car balpair)
)
)

--

 bal -0.01) (<= bal 0.0))
0
(* -1 bal)
)
)
)
(begin ?>
$
remains on account as of 
timepair 
(localtime (c

Compile on Windows with Python Bindings

2016-10-12 Thread Adam
I am compiling gnucash in Windows using MinGW  in order to include the
Python bindings. I have been using 2.6.14 release source code from Git.

I have arrived at step 10 in the python-bindings sections but now have 3
issues:

1) I get the following error message when attempting to run gnucash
using 'gnucash-launcher.cmd': "The procedure entry point
__gmpn_cnd_add_n could not be located in dynamic link library
C:\GCDev\gnucash\inst\bin\libhogweed-2-5.dll"
   - this happens with and without python bindings installed, when not
   installed the program starts
The error does not occur when the gnucash.exe is run directly from the
dist directory created for the installer package.

2) When python bindings are enabled, gnucash terminates with an
exception when the splash screen reaches 'gnucash/python'. This is the
best I could capture from the error logging via command line switches:
* 07:54:02  INFO  [main] System locale returned English_United
Kingdom.1252
* 07:54:02  INFO  [main] Effective locale set to English_United
Kingdom.1252.
* 07:54:03  WARN  Failed to dlopen()
'C:\GCDev\gnucash\inst\bin\libgncmod-aqbanking.dll':
'C:\GCDev\gnucash\inst\bin\libgncmod-aqbanking.dll': The specified
procedure could not be found.
* 07:54:04  INFO  [gnc_hook_lookup] no hook lists
* 07:54:04  INFO  [guid_init] got 1665 bytes
* 07:54:04  INFO  [gnc_module_init_backend_dbi] 3 DBD
drivers found
* 07:54:04  INFO  [gnc_module_init_backend_dbi] Driver:
mysql
* 07:54:04  INFO  [gnc_module_init_backend_dbi] Driver:
pgsql
* 07:54:04  INFO  [gnc_module_init_backend_dbi] Driver:
sqlite3
* 07:54:06 MESSG  Could not locate optional module
gnucash/import-export/aqbanking interface v.0
* 07:54:13 MESSG  Could not locate optional module
gnucash/gtkmm interface v.0

3) With the following batch script  setup, I have run Python and
attempted to import gnucash:

SET PYTHONPATH=C:\GCDev\gnucash\inst\lib\site-packages
SET PATH=%PATH%;C:\gcdev\gnucash\inst\bin
SET PATH=%PATH%;C:\gcdev\gnome\bin
SET PATH=%PATH%;C:\gcdev\mingw\bin
SET PATH=%PATH%;C:\gcdev\regex\bin
SET PATH=%PATH%;C:\gcdev\guile\bin
SET PATH=%PATH%;C:\gcdev\libxslt\bin
SET PATH=%PATH%;C:\gcdev\libdbi\bin
SET PATH=%PATH%;C:\gcdev\mysql\lib
SET PATH=%PATH%;C:\gcdev\pgsql\bin
SET PATH=%PATH%;C:\gcdev\pgsql\lib
SET PATH=%PATH%;C:\gcdev\sqlite3\bin

python -v

This crashes python.exe with an exception and results in the following
output:

# C:\Python27\lib\encodings\cp850.pyc matches
C:\Python27\lib\encodings\cp850.py
import encodings.cp850 # precompiled from
C:\Python27\lib\encodings\cp850.pyc
import gnucash # directory
C:\GCDev\gnucash\inst\lib\site-packages\gnucash
# C:\GCDev\gnucash\inst\lib\site-packages\gnucash\__init__.pyc matches
C:\GCDev\gnucash\inst\lib\site-packages\gnucash\__init__.py
import gnucash # precompiled from
C:\GCDev\gnucash\inst\lib\site-packages\gnucash\__init__.pyc
# C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core.pyc
matches C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core.py
import gnucash.gnucash_core # precompiled from
C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core.pyc
# C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core_c.pyc
matches
C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core_c.py
import gnucash.gnucash_core_c # precompiled from
C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core_c.pyc
import imp # builtin
* 21:17:31 OTHER  No GSettings schemas are installed on the
system

This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.

Any thoughts on where I might be going wrong? Is trying to compile with
Python bindings a lost cause?

Thanks

Adam
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: Compile on Windows with Python Bindings

2016-10-12 Thread John Ralls

> On Oct 12, 2016, at 10:21 PM, Adam  wrote:
> 
> I am compiling gnucash in Windows using MinGW  in order to include the
> Python bindings. I have been using 2.6.14 release source code from Git.
> 
> I have arrived at step 10 in the python-bindings sections but now have 3
> issues:
> 
> 1) I get the following error message when attempting to run gnucash
> using 'gnucash-launcher.cmd': "The procedure entry point
> __gmpn_cnd_add_n could not be located in dynamic link library
> C:\GCDev\gnucash\inst\bin\libhogweed-2-5.dll"
>   - this happens with and without python bindings installed, when not
>   installed the program starts
> The error does not occur when the gnucash.exe is run directly from the
> dist directory created for the installer package.
> 
> 2) When python bindings are enabled, gnucash terminates with an
> exception when the splash screen reaches 'gnucash/python'. This is the
> best I could capture from the error logging via command line switches:
> * 07:54:02  INFO  [main] System locale returned English_United
> Kingdom.1252
> * 07:54:02  INFO  [main] Effective locale set to English_United
> Kingdom.1252.
> * 07:54:03  WARN  Failed to dlopen()
> 'C:\GCDev\gnucash\inst\bin\libgncmod-aqbanking.dll':
> 'C:\GCDev\gnucash\inst\bin\libgncmod-aqbanking.dll': The specified
> procedure could not be found.
> * 07:54:04  INFO  [gnc_hook_lookup] no hook lists
> * 07:54:04  INFO  [guid_init] got 1665 bytes
> * 07:54:04  INFO  [gnc_module_init_backend_dbi] 3 DBD
> drivers found
> * 07:54:04  INFO  [gnc_module_init_backend_dbi] Driver:
> mysql
> * 07:54:04  INFO  [gnc_module_init_backend_dbi] Driver:
> pgsql
> * 07:54:04  INFO  [gnc_module_init_backend_dbi] Driver:
> sqlite3
> * 07:54:06 MESSG  Could not locate optional module
> gnucash/import-export/aqbanking interface v.0
> * 07:54:13 MESSG  Could not locate optional module
> gnucash/gtkmm interface v.0
> 
> 3) With the following batch script  setup, I have run Python and
> attempted to import gnucash:
> 
> SET PYTHONPATH=C:\GCDev\gnucash\inst\lib\site-packages
> SET PATH=%PATH%;C:\gcdev\gnucash\inst\bin
> SET PATH=%PATH%;C:\gcdev\gnome\bin
> SET PATH=%PATH%;C:\gcdev\mingw\bin
> SET PATH=%PATH%;C:\gcdev\regex\bin
> SET PATH=%PATH%;C:\gcdev\guile\bin
> SET PATH=%PATH%;C:\gcdev\libxslt\bin
> SET PATH=%PATH%;C:\gcdev\libdbi\bin
> SET PATH=%PATH%;C:\gcdev\mysql\lib
> SET PATH=%PATH%;C:\gcdev\pgsql\bin
> SET PATH=%PATH%;C:\gcdev\pgsql\lib
> SET PATH=%PATH%;C:\gcdev\sqlite3\bin
> 
> python -v
> 
> This crashes python.exe with an exception and results in the following
> output:
> 
> # C:\Python27\lib\encodings\cp850.pyc matches
> C:\Python27\lib\encodings\cp850.py
> import encodings.cp850 # precompiled from
> C:\Python27\lib\encodings\cp850.pyc
> import gnucash # directory
> C:\GCDev\gnucash\inst\lib\site-packages\gnucash
> # C:\GCDev\gnucash\inst\lib\site-packages\gnucash\__init__.pyc matches
> C:\GCDev\gnucash\inst\lib\site-packages\gnucash\__init__.py
> import gnucash # precompiled from
> C:\GCDev\gnucash\inst\lib\site-packages\gnucash\__init__.pyc
> # C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core.pyc
> matches C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core.py
> import gnucash.gnucash_core # precompiled from
> C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core.pyc
> # C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core_c.pyc
> matches
> C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core_c.py
> import gnucash.gnucash_core_c # precompiled from
> C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core_c.pyc
> import imp # builtin
> * 21:17:31 OTHER  No GSettings schemas are installed on the
> system
> 
> This application has requested the Runtime to terminate it in an unusual
> way.
> Please contact the application's support team for more information.
> 
> Any thoughts on where I might be going wrong? Is trying to compile with
> Python bindings a lost cause?

Dunno about being a lost cause, but it might be a bit of work on Windows. I 
don't think anyone has ever tried before.

Regards,
John Ralls




___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: Compile on Windows with Python Bindings

2016-10-12 Thread Geert Janssens
On Wednesday 12 October 2016 22:36:44 John Ralls wrote:
> > On Oct 12, 2016, at 10:21 PM, Adam 
> > wrote:
> > 
> > I am compiling gnucash in Windows using MinGW  in order to include
> > the Python bindings. I have been using 2.6.14 release source code
> > from Git.
> > 
> > I have arrived at step 10 in the python-bindings sections but now
> > have 3 issues:
> > 
> > 1) I get the following error message when attempting to run gnucash
> > using 'gnucash-launcher.cmd': "The procedure entry point
> > __gmpn_cnd_add_n could not be located in dynamic link library
> > C:\GCDev\gnucash\inst\bin\libhogweed-2-5.dll"
> > 
> >   - this happens with and without python bindings installed, when
> >   not
> >   installed the program starts
> > 
> > The error does not occur when the gnucash.exe is run directly from
> > the dist directory created for the installer package.
> > 
> > 2) When python bindings are enabled, gnucash terminates with an
> > exception when the splash screen reaches 'gnucash/python'. This is
> > the best I could capture from the error logging via command line
> > switches: * 07:54:02  INFO  [main] System locale returned
> > English_United Kingdom.1252
> > * 07:54:02  INFO  [main] Effective locale set to
> > English_United Kingdom.1252.
> > * 07:54:03  WARN  Failed to dlopen()
> > 'C:\GCDev\gnucash\inst\bin\libgncmod-aqbanking.dll':
> > 'C:\GCDev\gnucash\inst\bin\libgncmod-aqbanking.dll': The specified
> > procedure could not be found.
> > * 07:54:04  INFO  [gnc_hook_lookup] no hook lists
> > * 07:54:04  INFO  [guid_init] got 1665 bytes
> > * 07:54:04  INFO  [gnc_module_init_backend_dbi] 3
> > DBD drivers found
> > * 07:54:04  INFO  [gnc_module_init_backend_dbi]
> > Driver: mysql
> > * 07:54:04  INFO  [gnc_module_init_backend_dbi]
> > Driver: pgsql
> > * 07:54:04  INFO  [gnc_module_init_backend_dbi]
> > Driver: sqlite3
> > * 07:54:06 MESSG  Could not locate optional module
> > gnucash/import-export/aqbanking interface v.0
> > * 07:54:13 MESSG  Could not locate optional module
> > gnucash/gtkmm interface v.0
> > 
> > 3) With the following batch script  setup, I have run Python and
> > attempted to import gnucash:
> > 
> > SET PYTHONPATH=C:\GCDev\gnucash\inst\lib\site-packages
> > SET PATH=%PATH%;C:\gcdev\gnucash\inst\bin
> > SET PATH=%PATH%;C:\gcdev\gnome\bin
> > SET PATH=%PATH%;C:\gcdev\mingw\bin
> > SET PATH=%PATH%;C:\gcdev\regex\bin
> > SET PATH=%PATH%;C:\gcdev\guile\bin
> > SET PATH=%PATH%;C:\gcdev\libxslt\bin
> > SET PATH=%PATH%;C:\gcdev\libdbi\bin
> > SET PATH=%PATH%;C:\gcdev\mysql\lib
> > SET PATH=%PATH%;C:\gcdev\pgsql\bin
> > SET PATH=%PATH%;C:\gcdev\pgsql\lib
> > SET PATH=%PATH%;C:\gcdev\sqlite3\bin
> > 
> > python -v
> > 
> > This crashes python.exe with an exception and results in the
> > following output:
> > 
> > # C:\Python27\lib\encodings\cp850.pyc matches
> > C:\Python27\lib\encodings\cp850.py
> > import encodings.cp850 # precompiled from
> > C:\Python27\lib\encodings\cp850.pyc
> > import gnucash # directory
> > C:\GCDev\gnucash\inst\lib\site-packages\gnucash
> > # C:\GCDev\gnucash\inst\lib\site-packages\gnucash\__init__.pyc
> > matches C:\GCDev\gnucash\inst\lib\site-packages\gnucash\__init__.py
> > import gnucash # precompiled from
> > C:\GCDev\gnucash\inst\lib\site-packages\gnucash\__init__.pyc
> > # C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core.pyc
> > matches
> > C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core.py
> > import gnucash.gnucash_core # precompiled from
> > C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core.pyc
> > # C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core_c.pyc
> > matches
> > C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core_c.py
> > import gnucash.gnucash_core_c # precompiled from
> > C:\GCDev\gnucash\inst\lib\site-packages\gnucash\gnucash_core_c.pyc
> > import imp # builtin
> > * 21:17:31 OTHER  No GSettings schemas are installed on
> > the
> > system
> > 
> > This application has requested the Runtime to terminate it in an
> > unusual way.
> > Please contact the application's support team for more information.
> > 
> > Any thoughts on where I might be going wrong? Is trying to compile
> > with Python bindings a lost cause?
> 
> Dunno about being a lost cause, but it might be a bit of work on
> Windows. I don't think anyone has ever tried before.
> 
Wm Tarr did try a couple of years ago but never managed to get it to 
work completely. There is a thread on gnucash-devel about it which 
starts here:
http://lists.gnucash.org/pipermail/gnucash-devel/2014-May/037635.html

Perhaps Wm can write up what he did to get to a complete build at that 
time (even though it didn't run successfully).

Geert
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: qof_instance_set/get_kvp cannot handle boolean?

2016-10-12 Thread Carsten Rinke

Hi John,

took a while, but now I checked: the "TaxRelated" flag of the accounts 
is working again as expected.


Thanks a lot,
Carsten


On 23.09.2016 18:30, John Ralls wrote:

On Sep 22, 2016, at 6:49 PM, Robert Fewell <14ubo...@gmail.com> wrote:

I noticed this before while doing my find account dialogue, at the start of 
pull request 83 there is a patch for this and the account hidden setting.

I've pushed a fix to master. Sorry, Bob, not yours, I decided to extract the guts 
to a new function and call it instead of copy&pasting.

Regards,
John Ralls




___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: Are There Plans For A GUI Overhaul?

2016-10-12 Thread Paul Phillips

Hi everyone,

From the comments so far, it sounds like there is a huge mountain of 
work here regardless of the route chosen to achieve it.  Not enough 
active developers. And In past posts there was mention of a gnucash 
bounty program that didn't succeed in attracting developers to the project.


Has any thought been given to approaching crowdfunding sites such as 
bounty source or freedom sponsors to help speed development time?


Regards,

Paul.


On 06/10/16 07:24, Christian Stimming wrote:

On Dienstag, 4. Oktober 2016 21:34:51 CEST Dave wrote:

Thanks for the great responses! It does clarify quite a bit.


 From the looks of things, it seems that the C -- C++ port would have the
most impact right now. It would take me awhile to get my C/C++ abilities
ramped up again. Where's the best place to start learning about gnucash
code? I don't know when I'd be able to start helping, but I'd at least want
to learn what I could.

Some more pointers for learning about the internal C API: I wrote this wiki
page http://wiki.gnucash.org/wiki/C_API in 2011 as a Summe of Code student had
the same question. To me the explanation still seems valid. Maybe this is of
some help here.

Regards,
Christian
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel



___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel


Re: Introducing myself

2016-10-12 Thread José JORGE
   Le 11/10/2016 à 22:36, Lincoln A Baxter a écrit :

I took a look at a (google translated) version of the referenced french
website. I like the concept in principle.  Too bad there is not an ISO
standard format (that would be the way to go if there were one).  I did
not see an actual XSD referenced -- :-(  It would be nice to see an
actual sample of what the data is supposed to look like.  That would
help one understand the best approach to take. It maybe that converting
an existing report or building a new one would do it.

   Yes I also feel this is a way to go : an ISO export format.
   As for an exemple, I was told there is a site to get it from the xsd :
   [1]http://xsd2xml.com/ or [2]https://devutilsonline.com/
   xsd-xml/generate-xml-from-xsd
   The needed XSD is there : [3]http://www.impots.gouv.fr/
   portal/deploiement/p1/fichedescriptive_6706/fichedescriptive_6706.xsd.

   --
   [anim-logo.gif]
 __

   *
   "Le contenu de ce courriel et ses eventuelles pièces jointes sont
   confidentiels. Ils s'adressent exclusivement à la personne
   destinataire. Si cet envoi ne vous est pas destiné, ou si vous l'avez
   reçu par erreur, et afin de ne pas violer le secret des
   correspondances, vous ne devez pas le transmettre à d'autres personnes
   ni le reproduire. Merci de le renvoyer à l'émetteur et de le détruire.
   Attention : L'Organisme de l'émetteur du message ne pourra être tenu
   responsable de l'altération du présent courriel. Il appartient au
   destinataire de vérifier que les messages et pièces jointes reçus ne
   contiennent pas de virus. Les opinions contenues dans ce courriel et
   ses éventuelles pièces jointes sont celles de l'émetteur. Elles ne
   reflètent pas la position de l'Organisme sauf s'il en est disposé
   autrement dans le présent courriel."
   **

References

   1. http://xsd2xml.com/
   2. https://devutilsonline.com/xsd-xml/generate-xml-from-xsd
   3. 
http://www.impots.gouv.fr/portal/deploiement/p1/fichedescriptive_6706/fichedescriptive_6706.xsd
___
gnucash-devel mailing list
gnucash-devel@gnucash.org
https://lists.gnucash.org/mailman/listinfo/gnucash-devel