update example usage in README.md
This commit is contained in:
parent
0c07735cea
commit
c3f3b80bf3
17
README.md
17
README.md
@ -18,8 +18,25 @@ Or install it yourself as:
|
|||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
|
require "gnucash"
|
||||||
|
|
||||||
book = Gnucash.open("MyBook.gnucash")
|
book = Gnucash.open("MyBook.gnucash")
|
||||||
|
|
||||||
|
book.accounts.each do |account|
|
||||||
|
puts "#{account.full_name}: #{account.final_balance}"
|
||||||
|
end
|
||||||
|
|
||||||
|
act = book.find_account_by_full_name("Assets::Checking")
|
||||||
|
balance = Gnucash::Value.zero
|
||||||
|
act.transactions.each do |txn|
|
||||||
|
balance += txn.value
|
||||||
|
$stdout.puts(sprintf("%s %8s %8s %s",
|
||||||
|
txn.date,
|
||||||
|
txn.value,
|
||||||
|
balance,
|
||||||
|
txn.description))
|
||||||
|
end
|
||||||
|
|
||||||
## Contributing
|
## Contributing
|
||||||
|
|
||||||
1. Fork it
|
1. Fork it
|
||||||
|
Loading…
x
Reference in New Issue
Block a user