NAME

File::HomeBank - Parse HomeBank files

VERSION

version 0.005

SYNOPSIS

    # Functional:

    use File::HomeBank qw(parse_file);

    my $raw_data = parse_file('path/to/homebank.xhb');

    # Or OOP:

    my $homebank = File::HomeBank->new(file => 'path/to/homebank.xhb');

    for my $account (@{$homebank->accounts}) {
        print "Found account named $account->{name}\n";
    }

DESCRIPTION

This module parses HomeBank files.

ATTRIBUTES

file

Get the filepath (if parsed from a file).

METHODS

new

    $homebank = File::HomeBank->new(string => $str);
    $homebank = File::HomeBank->new(file => $filepath);

Construct a File::HomeBank.

title

    $title = $homebank->title;

Get the title or owner property.

base_currency

    $base_currency = $homebank->base_currency;

Get the key of the base currency.

accounts

Get an arrayref of accounts.

categories

Get an arrayref of categories.

currencies

Get an arrayref of currencies.

payees

Get an arrayref of payees.

tags

Get an arrayref of tags.

transactions

Get an arrayref of transactions.

find_account_by_key

    $account = $homebank->find_account_by_key($key);

Find a account with the given key.

find_currency_by_key

    $currency = $homebank->find_currency_by_key($key);

Find a currency with the given key.

find_category_by_key

    $category = $homebank->find_category_by_key($key);

Find a category with the given key.

find_payee_by_key

    $payee = $homebank->find_payee_by_key($key);

Find a payee with the given key.

find_transactions_by_transfer_key

    @transactions = $homebank->find_transactions_by_transfer_key($key);

Find all transactions that share the same transfer key.

find_transaction_transfer_pair

    $other_transaction = $homebank->find_transaction_transfer_pair($transaction);

Given a transaction hashref, return its corresponding transaction if it is an internal transfer. If the transaction is an internal transaction with a destination account but is orphaned (has no matching transfer key), this also looks for another orphaned transaction in the destination account that it can call its partner.

Returns undef or empty if no corresponding transaction is found.

sorted_transactions

    $transations = $homebank->sorted_transactions;

Get an arrayref of transactions sorted by date (oldest first).

full_category_name

    $category_name = $homebank->full_category_name($key);

Generate the full name for a category, taking category inheritance into consideration.

    Income
      Salary    <--

will become:

    "Income:Salary"

format_amount

    $formatted_amount = $homebank->format_amount($amount);
    $formatted_amount = $homebank->format_amount($amount, $currency);

Formats an amount in either the base currency (for the whole file) or in the given currency. Currency can be a key or the actualy currency structure.

FUNCTIONS

parse_file

    $homebank_data = parse_file($filepath);

Read and parse a HomeBank .xhb file from a filesystem.

parse_string

    $homebank_data = parse_string($str);

Parse a HomeBank file from a string.

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/chazmcgarvey/homebank2ledger/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHOR

Charles McGarvey <chazmcgarvey@brokenzipper.com>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2019 by Charles McGarvey.

This is free software, licensed under:

  The MIT (X11) License