Re: [GNC] unable to iterate accounts with API Python bindings

2024-10-26 Thread John Ralls



> On Oct 26, 2024, at 4:59 PM, John Ralls  wrote:
> 
> Now to revisit getting the Session constructor to load xml files since I 
> obviously got that wrong.
> 

Which I've now done, and pushed the result. Noah, if you built GnuCash from 
git, please pull and rebuild. The added `session.load()` should no longer be 
needed.

Regards,
John Ralls


___
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
-
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.


[GNC] FW: gnucash-user Digest,new question

2024-10-26 Thread Eric Hammond
-Original Message-
From: gnucash-user  On 
Behalf Of gnucash-user-requ...@gnucash.org
Sent: Friday, October 25, 2024 7:11 PM
To: gnucash-user@gnucash.org
Subject: gnucash-user Digest, Vol 259, Issue 61

Send gnucash-user mailing list submissions to
gnucash-user@gnucash.org

To subscribe or unsubscribe via the World Wide Web, visit
https://lists.gnucash.org/mailman/listinfo/gnucash-user
or, via email, send a message with subject or body 'help' to
gnucash-user-requ...@gnucash.org

You can reach the person managing the list at
gnucash-user-ow...@gnucash.org

When replying, please edit your Subject line so it is more specific than "Re: 
Contents of gnucash-user digest..."

--

Question: correct debit account for labor:

I have completely replaced my defunct Quicken with GnuCash, and now trying to 
get the details fine-tuned:
I am using Job cost accounting for my business, my main resource is the 
OpenStax book - "Principles of Accounting, Volume 2: Managerial Accounting" 
page224 - 226
And a lot of internet searches...

Entering my labor, parts/supplies would look like this:
Assets:Jobs:xx:WIP 500.00
:Direct Labor   120.00
Assets: Stock   20.00
:Direct Labor360.00

1. If I use "Expenses:Direct Labor" as the credit account then those account 
balances are all negative (which, at least, looks weird in an expense journal) 
2. If i use "Income:Direct Labor" the balances are positive.

With settings #2 all the tax reports look correct. I didn't check during #1 
settings. 

Which one is correct? Does GnuCash care about the negative balance? Is there a 
better way log it?

Thank you for a great accounting tool, and all your help.

Eric Hammond

--

Subject: Digest Footer

___

gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
-
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.


--

End of gnucash-user Digest, Vol 259, Issue 61
*
___
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
-
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.


Re: [GNC] Transaction Report: Table for Exporting

2024-10-26 Thread Jim DeLaHunt

Fred:… Pa

Sometimes things are hidden in plain sight.

On 2024-10-26 09:39, Fred Tydeman wrote:

I am running Gnucash 5.9 on Fedora Linux 40

I have done a Transaction Report
In the General Options
I have checked Table for Exporting
I do not see any table
   in either the report (at the bottom)
   or in ~/Documents/ folder

Is this
   a bug
   a limitation
   user error


In the transaction report, do you see a row with column headers, 
followed by line after line of transaction listings?  That is the table.


Try selecting the headers and the lines of date, doing an Edit… Copy, 
then opening a blank spreadsheet, and do an Edit… Paste. I expect that 
you will see the headers and the lines of the transaction report in the 
spreadsheet.


This is not very well documented, but have a look at the /GnuCash 
Manual/, section 9.3.1.3. *Transaction Report* 
. It says,


*Table for Exporting*: Formats the table for cut & paste exporting 
with extra cells


The manual does not say what "the table" is, but I understand it to mean 
the list of transactions itself.


Does this work for you?

Best regards,
    —Jim DeLaHunt
___
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
-
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.


Re: [GNC] Transaction Report: Table for Exporting

2024-10-26 Thread David H
Fred,

No real idea on this, but I think it only affects the report out display
format so that when you click the export button after running the report to
export the results it's more suited to displaying in a web browser or
pasting into spreadsheet.  Run your report with it unchecked and run the
same report with it checked on in another tab and you'll see the formatting
has changed.

Cheers David H.


On Sun, 27 Oct 2024 at 02:40, Fred Tydeman  wrote:

> I am running Gnucash 5.9 on Fedora Linux 40
>
> I have done a Transaction Report
> In the General Options
> I have checked Table for Exporting
> I do not see any table
>   in either the report (at the bottom)
>   or in ~/Documents/ folder
>
> Is this
>   a bug
>   a limitation
>   user error
>
> I recall seeing a table at the bottom of some other reports.
> ___
> gnucash-user mailing list
> gnucash-user@gnucash.org
> To update your subscription preferences or to unsubscribe:
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> -
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.
>
___
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
-
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.


Re: [GNC] unable to iterate accounts with API Python bindings

2024-10-26 Thread John Ralls
Jon,

Thanks for digging into it. Reporting that Noah's script works for you in 
GnuCash 5.5 was very helpful because there's been only one change to the 
bindings since then: I removed a load call from the Session constructor to fix 
bug 799308. That wasn't exactly the right thing to do, but it's a surmountable 
problem: Load the session in the script.

Noah's other problem, that the lock file is left, is because `session` never 
goes out of scope before the script ends, preventing the destructor from being 
called. Use Python's RAII keyword `with…;` to  ensure that `session` is 
destroyed. There's one other problem, ACCT_TYPE_STOCK isn't explicitly imported 
so it needs its package prefix. The following diff fixes all three problems:
--- test.py~2024-10-26 16:15:09.0 -0700
+++ test.py 2024-10-26 16:30:06.0 -0700
@@ -2,14 +2,15 @@
 from gnucash import (Session, Account, Transaction, Split, GncNumeric,
 SessionOpenMode, gnucash_core)
 uri="file:///Users/me/Downloads/gnucash_localSave.gnucash"
-session = Session(book_uri=uri,
-mode=gnucash_core.SessionOpenMode.SESSION_NORMAL_OPEN )
-book = session.book
-table = book.get_table()
-currency_code = 'USD'
-currency = table.lookup('ISO4217', currency_code)
-root_account = book.get_root_account()
-for acc in root_account.get_descendants():
-   print('checking a descendant...')
-   if acc.GetType() == ACCT_TYPE_STOCK:
-   print('found a stock')
+with Session(book_uri=uri,
+ mode=gnucash_core.SessionOpenMode.SESSION_NORMAL_OPEN) as session:
+session.load()
+book = session.book
+table = book.get_table()
+currency_code = 'USD'
+currency = table.lookup('ISO4217', currency_code)
+root_account = book.get_root_account()
+for acc in root_account.get_descendants():
+print('checking a descendant...')
+if acc.GetType() == gnucash_core.ACCT_TYPE_STOCK:
+print('found a stock')

Note that I didn't change get_descendants() to get_children(). get_children() 
returns only the immediate children of the account, get_descendants() 
recursively calls get_children() to return all of the account's descendants. 
Since Noah is looking for a Stock account and it's rare that a stock account 
would be at the top level, get_descendants() is the right function.

Now to revisit getting the Session constructor to load xml files since I 
obviously got that wrong.

Regards,
John Ralls

> On Oct 26, 2024, at 10:21 AM, Jon Schewe  wrote:
> 
> Noah and I traded a couple of messages directly about this off-list. I
> tried reading Noah's file and and it worked just fine, get_children
> showed the accounts; on their computer it did not. I was using the
> python bindings for GNuCash 5.5 that are shipped with Ubuntu 24.04. I
> don't know how to get the version of the gnucash bindings from inside
> python, so I'm not sure what version Noah was using, however they are
> on mac OS. 
> Does anyone have suggestions why I would see the list of accounts and
> Noah would not?
> 
> Example output from my system. Noah gets an empty list when calling
> get_children().
> 
>> python3
> Python 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
 import gnucash
 filename = 'gnucash_localSave.gnucash'
 session = gnucash.Session(filename,
> gnucash.SessionOpenMode.SESSION_NORMAL_OPEN)
 root_account = session.book.get_root_account()
 root_account.get_children()
> [,
> ,
> ]
 session.end()
 quit()
> 
> Jon
> 
> On Fri, 2024-10-25 at 19:59 -0500, Jon Schewe wrote:
>> You want "get_children" instead of "get_descendents".
>> 
>> On Thu, 2024-10-24 at 21:51 -0700, Noerr via gnucash-user wrote:
>>> Hi,
>>> 
>>>  I've been trying to get started with the GnuCash API Python
>>> bindings
>>> after just using the main desktop app for the last 12 years.
>>> I built GnuCash app (Build ID: 5.9+(2024-09-28) along with API and
>>> Python
>>> bindings enabled for my system (MacOS 15.0 , M1 Arm)
>>> 
>>> My problem is that I haven't been able to interact with my GnuCash
>>> data in
>>> a useful way yet.  Namely, I can't seem to access any existing
>>> accounts,
>>> and thus no transactions either.  Nor any entries in the price
>>> database.
>>> 
>>> First I used the desktop app to save-as a copy of my GnuCash data
>>> in
>>> the
>>> XML format.
>>> Next I use python and  commands generally like the following.  I do
>>> not see
>>> any output that is expected when iterating over the descendants of
>>> root_account.  ( I never see the text output, 'checking a
>>> descendant...' )
>>> 
>>> 
>>> from gnucash import (Session, Account, Transaction, Split,
>>> GncNumeric,
>>> SessionOpenMode, gnucash_core)
>>> uri="file:///Users/me/Downloads/gnucash_localSave.gnucash"
>>> session = Session(book_uri=uri,
>>> mode=gnucash_core.SessionOpenMode.SESSION_NORMAL_OPEN )
>>> book = session.book
>>> table = book.get_table()
>>> currency_code = 'USD'
>>> 

Re: [GNC] unable to iterate accounts with API Python bindings

2024-10-26 Thread Jon Schewe
Noah and I traded a couple of messages directly about this off-list. I
tried reading Noah's file and and it worked just fine, get_children
showed the accounts; on their computer it did not. I was using the
python bindings for GNuCash 5.5 that are shipped with Ubuntu 24.04. I
don't know how to get the version of the gnucash bindings from inside
python, so I'm not sure what version Noah was using, however they are
on mac OS. 
Does anyone have suggestions why I would see the list of accounts and
Noah would not?

Example output from my system. Noah gets an empty list when calling
get_children().

>python3
Python 3.12.3 (main, Sep 11 2024, 14:17:37) [GCC 13.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gnucash
>>> filename = 'gnucash_localSave.gnucash'
>>> session = gnucash.Session(filename,
gnucash.SessionOpenMode.SESSION_NORMAL_OPEN)
>>> root_account = session.book.get_root_account()
>>> root_account.get_children()
[,
,
]
>>> session.end()
>>> quit()

Jon

On Fri, 2024-10-25 at 19:59 -0500, Jon Schewe wrote:
> You want "get_children" instead of "get_descendents".
> 
> On Thu, 2024-10-24 at 21:51 -0700, Noerr via gnucash-user wrote:
> > Hi,
> > 
> >  I've been trying to get started with the GnuCash API Python
> > bindings
> > after just using the main desktop app for the last 12 years.
> > I built GnuCash app (Build ID: 5.9+(2024-09-28) along with API and
> > Python
> > bindings enabled for my system (MacOS 15.0 , M1 Arm)
> > 
> > My problem is that I haven't been able to interact with my GnuCash
> > data in
> > a useful way yet.  Namely, I can't seem to access any existing
> > accounts,
> > and thus no transactions either.  Nor any entries in the price
> > database.
> > 
> > First I used the desktop app to save-as a copy of my GnuCash data
> > in
> > the
> > XML format.
> > Next I use python and  commands generally like the following.  I do
> > not see
> > any output that is expected when iterating over the descendants of
> > root_account.  ( I never see the text output, 'checking a
> > descendant...' )
> > 
> > 
> > from gnucash import (Session, Account, Transaction, Split,
> > GncNumeric,
> > SessionOpenMode, gnucash_core)
> > uri="file:///Users/me/Downloads/gnucash_localSave.gnucash"
> > session = Session(book_uri=uri,
> > mode=gnucash_core.SessionOpenMode.SESSION_NORMAL_OPEN )
> > book = session.book
> > table = book.get_table()
> > currency_code = 'USD'
> > currency = table.lookup('ISO4217', currency_code)
> > root_account = book.get_root_account()
> > for acc in root_account.get_descendants():
> >     print('checking a descendant...')
> >     if acc.GetType() == ACCT_TYPE_STOCK:
> >     print('found a stock')
> > 
> > 
> > **So why is root_account.get_descendants() returning an empty
> > container?**
> > 
> > The Bindings/API aren't completely dead though.  With the same
> > session and
> > book open above, I was playing around with some of the ideas
> > Eberhard
> > demonstrated in this thread [
> > https://lists.gnucash.org/pipermail/gnucash-user/2024-September/113402.html
> > ]
> > and I called
> > > > > create_accounts(session, book, root_acct)
> > > > > quit()
> > 
> > To my suprise, when I used the desktop app to open
> > gnucash_localSave.gnucash, my real accounts and transactions are
> > gone, but
> > I have three accounts: Expenses, Opening Balance, and Savings in
> > CAD
> > currency, and with the specified opening balances.
> > So the Bindings and API worked to create stuff.
> > 
> > As an aside, the file did flag as locked upon open in the desktop
> > app.  I
> > suspect there's a missing unlock somewhere in Python Bindings /
> > destructor
> > code.
> > 
> > Cheers,
> > 
> > Noah
> > ___
> > gnucash-user mailing list
> > gnucash-user@gnucash.org
> > To update your subscription preferences or to unsubscribe:
> > https://lists.gnucash.org/mailman/listinfo/gnucash-user
> > -
> > Please remember to CC this list on all your replies.
> > You can do this by using Reply-To-List or Reply-All.
> 
> ___
> gnucash-user mailing list
> gnucash-user@gnucash.org
> To update your subscription preferences or to unsubscribe:
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> -
> Please remember to CC this list on all your replies.
> You can do this by using Reply-To-List or Reply-All.

___
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
-
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.


[GNC] Transaction Report: Table for Exporting

2024-10-26 Thread Fred Tydeman
I am running Gnucash 5.9 on Fedora Linux 40

I have done a Transaction Report
In the General Options
I have checked Table for Exporting
I do not see any table
  in either the report (at the bottom)
  or in ~/Documents/ folder

Is this
  a bug
  a limitation
  user error

I recall seeing a table at the bottom of some other reports.
___
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
-
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.


Re: [GNC] Printing checks

2024-10-26 Thread Michael or Penny Novack via gnucash-user

On 10/25/2024 8:34 PM, Sherman Yoder wrote:

Hello,

You can find instructions how to create and modify checks in the
Tutorial and Concepts Guide. On gnucash.org, click on Documentation,
then The Tutorial and Concepts Guide. Appendix B describes how to
create a check form.

If you need help after reading that, please ask.

Sherman


Strong suggestion  -- if you are printing checks or invoices for a 
business and intend to mail these in window envelopes do NOT attempt to 
do final editing within gnucash. In stead, "print to file" so a final 
formatting program has a chance to modify before printing. Then when the 
"unexpected" happens and it will << example -- new batch of envelopes, 
supposedly the same as the previous, has window a couple mm higher, 
lower, left, or right >> you can quickly make the adjustment in that 
final editing program instead of in gnucash (and the having to rerun).


Initially, your final edit program can be "do nothing" (pass through 
unaltered)


Michael D Novack  ex senior systems analyst/senior business analyst 
who in working days often had to field emergency calls from the print 
room to quickly write an edit to make stuffing fit with address properly 
centered in window. The suppliers of window envelopes rarely inform 
their customers that they made a slight change to model XYZ envelope.



___
gnucash-user mailing list
gnucash-user@gnucash.org
To update your subscription preferences or to unsubscribe:
https://lists.gnucash.org/mailman/listinfo/gnucash-user
-
Please remember to CC this list on all your replies.
You can do this by using Reply-To-List or Reply-All.


Re: [GNC] FW: gnucash-user Digest,new question

2024-10-26 Thread David Cousens

Eric

This is really a Cost Management Accounting issue which is usually
beyond basic books on principles of Accounting so if you can find a
book on Cost Management Accounting it may give a better understanding
of the process. 

An outline of the basic process for dealing with direct maerials and
labour costs would be for the purchase of materials and application of
direct labour to production

on purchase

Assets:WIP Inventory  Dr 
Liabilities:Accounts Payable  Cr xxx

payments for purchase

Assets:Bank Account Cr 
Liabilities::Accounts Payable  Dr 

here  may not be for a single purchase but for multiple purchases.

when the labour is performed 
Assets:WiP Inventory Dr 
Liabilities:Wages Payable  Cr 

when wages are paid
Assets:Bank  Cr 
Liabilities:Wages Payable  Dr 
and again  may be the sum of several such entries.

at the completion of the production process os a batch of product you
would prepare a report of the costs of production for that batch and
calculate a unit cost of the product. Your costs may for example
include materials purchases at different times with a differnt unit
cost.

Then you would transfer the product from the Work in Progress Inventory
to the Stock Inventory at that unit cost.

(n widgets at unit cost ccc =n*ccc )=
Asset:Inventory WiPCr   
Asset: Inventory:Stock Dr  

These costs are usually expensed at the time of sale, not at the time
they are incurred, through entries which decrease the inventory an
expense through cost of goods sold.

Similarly they don't affect income until they are sold.  A typical sale
entry would be

Asset:Bank  Dr  
Income SalesCr  
Asset:Inventory:Stock   Cr  
Expenses:COGS   Dr  

There are a lot of complex parts of complex accounting for
manufacturing processes (allowances for spoilage etc etc, overhead
costs and many more) and whether using FIFO or some other basis for
managing inventory. 

Often there will be standard treatments in your jurisdiction for
particular industries approved by the tax authorities which make
consulting a practising accountant in your jurisdiction with relevant
experience a very good idea.

The process above is generic and meant to be illustrative and does not
constitute accounting advice which may be relevant to your situation.
You will likely have to maintain many aspects of the cost management
accounting outside GnuCash (e.g. spreadshetts or other software) as
GnuCash does not have inventory and cost management programmed in and
can only handle the accounts aspects of it.

David Cousens


 On Sun, 2024-10-27 at 01:06 +, Eric Hammond wrote:
> -Original Message-
> From: gnucash-user
>  On Behalf Of
> gnucash-user-requ...@gnucash.org
> Sent: Friday, October 25, 2024 7:11 PM
> To: gnucash-user@gnucash.org
> Subject: gnucash-user Digest, Vol 259, Issue 61
> 
> Send gnucash-user mailing list submissions to
>   gnucash-user@gnucash.org
> 
> To subscribe or unsubscribe via the World Wide Web, visit
>   https://lists.gnucash.org/mailman/listinfo/gnucash-user
> or, via email, send a message with subject or body 'help' to
>   gnucash-user-requ...@gnucash.org
> 
> You can reach the person managing the list at
>   gnucash-user-ow...@gnucash.org
> 
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of gnucash-user digest..."
> 
> -
> -
> 
> Question: correct debit account for labor:
> 
> I have completely replaced my defunct Quicken with GnuCash, and now
> trying to get the details fine-tuned:
> I am using Job cost accounting for my business, my main resource is
> the OpenStax book - "Principles of Accounting, Volume 2: Managerial
> Accounting" page224 - 226
>     And a lot of internet searches...
> 
> Entering my labor, parts/supplies would look like this:
> Assets:Jobs:xx:WIP 500.00
> :Direct Labor   120.00
> Assets: Stock   20.00
> :Direct Labor    360.00
> 
> 1. If I use "Expenses:Direct Labor" as the credit account then those
> account balances are all negative (which, at least, looks weird in an
> expense journal) 
> 2. If i use "Income:Direct Labor" the balances are positive.
> 
> With settings #2 all the tax reports look correct. I didn't check
> during #1 settings. 
> 
> Which one is correct? Does GnuCash care about the negative balance?
> Is there a better way log it?
> 
> Thank you for a great accounting tool, and all your help.
> 
> Eric Hammond
> 
> --
> 
> Subject: Digest Footer
> 
> ___
> 
> gnucash-user mailing list
> gnucash-user@gnucash.org
> To update your subscription preferences or to unsubscribe:
> https://lists.gnucash.org/mailman/listinfo/gnucash-user
> -
> Please remember to CC t