Skip to content

Latest commit

 

History

History
132 lines (84 loc) · 3.88 KB

README.pod

File metadata and controls

132 lines (84 loc) · 3.88 KB

NAME

GnuCash::MySQL - A module to access GnuCash MySQL database

VERSION

version 0.01

SYNOPSIS

use GnuCash::MySQL;

# create the book

I need to write some stuff here

DESCRIPTION

GnuCash::SQLite provides an API to read account balances and write transactions against a GnuCash set of accounts (only MySQL backend supported).

When using the module, always provide account names in full e.g. "Assets:Cash" rather than just "Cash". This lets the module distinguish between accounts with the same name but different parents e.g. Assets:Misc and Expenses:Misc

METHODS

Constructor

$book = GnuCash::SQLite->new(db => 'my_account.gnucash');

I have not yet writen the constructor.

Returns a new GnuCash::SQLite object that accesses a GnuCash with and SQLite backend. The module assumes you have already created a GnuCash file with an SQLite backend and that is the file that should be passed as the parameter.

If no file parameter is passed, or if the file is missing, the program will terminate.

account_balance

$book->account_balance('Assets:Cash');   # always provide account names in full
$book->account_balance('Assets');        # includes child accounts e.g. Assets:Cash

Given an account name, return the balance in the account. Account names must be provided in full to distinguish between accounts with the same name but different parents e.g. Assets:Alice:Cash and Assets:Bob:Cash

If a parent account name is provided, the total balance, which includes all children accounts, will be returned.

add_transaction

$deposit = {
    date         => '20140102',
    description  => 'Deposit monthly savings',
    from_account => 'Assets:Cash',
    to_account   => 'Assets:aBank',
    amount       => 2540.15,
    number       => ''
};
$book->add_transaction($deposit);

A transaction is defined to have the fields as listed in the example above. All fields are mandatory and hopefully self-explanatory. Constraints on some of the fields are listed below:

date         Date of the transaction. Formatted as YYYYMMDD.
from_account Full account name required.
to_account   Full account name required.

CAVEATS/LIMITATIONS

Some things to be aware of:

1. You should have created a GnuCash file with an MySQL backend already
2. Module accesses the GnuCash MySQL db directly; i.e. use at your own risk.

### At this point nothing had been tested.

This module works with GnuCash v2.6.5 on Linux.

SEE ALSO

GnuCash wiki pages includes a section on C API and a section on Python bindings which may be of interest.

C API          : http://wiki.gnucash.org/wiki/C_API
Python bindings: http://wiki.gnucash.org/wiki/Python_Bindings

This module was inspired by Hoe Kit CHEW's work. https://github.com/hoekit/GnuCash-SQLite

This module does not rely on the C API (maybe it should). Instead it relies on some reverse engineering work to understand the changes a transaction makes to the sqlite database. See http://wideopenstudy.blogspot.com/search/label/GnuCash for details.

SUPPORT

Bugs / Feature Requests

Please report any bugs or feature requests through the issue tracker at https://github.com/theochino/GnuCash-MySQL/issues. You will be notified automatically of any progress on your issue.

Source Code

This is open source software. The code repository is available for public review and contribution under the terms of the license.

<https://github.com/hoekit/GnuCash-MySQL>

git clone [email protected]:theochino/GnuCash-MySQL.git

AUTHOR

Theo CHINO, <GitPerlModuleGNUCash at theochino.com>

COPYRIGHT AND LICENSE

Copyright (C) 2015 by Theo Chino

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.