Revision history for App-HomeBank2Ledger.
+0.004 2019-06-17 23:28:10-06:00 MST7MDT
+ * Remove --default-account option. Instead the default account(s) can be
+ customized using the --rename-account option, like this:
+
+ --rename-account='^Expenses:Unknown$=Foo'
+ --rename-account='^Income:Unknown$=Foo'
+
+ * Remove single use of "yada yada" for perls <5.12.
+
0.003 2019-06-13 02:55:59-06:00 MST7MDT
- * Fix bug that makes the --version and --help flags broken
+ * Fix bug that makes the --version and --help flags broken.
0.002 2019-06-12 23:39:32-06:00 MST7MDT
* Rename dist
"provides" : {
"App::HomeBank2Ledger" : {
"file" : "lib/App/HomeBank2Ledger.pm",
- "version" : "0.003"
+ "version" : "0.004"
},
"App::HomeBank2Ledger::Formatter" : {
"file" : "lib/App/HomeBank2Ledger/Formatter.pm",
- "version" : "0.003"
+ "version" : "0.004"
},
"App::HomeBank2Ledger::Formatter::Beancount" : {
"file" : "lib/App/HomeBank2Ledger/Formatter/Beancount.pm",
- "version" : "0.003"
+ "version" : "0.004"
},
"App::HomeBank2Ledger::Formatter::Ledger" : {
"file" : "lib/App/HomeBank2Ledger/Formatter/Ledger.pm",
- "version" : "0.003"
+ "version" : "0.004"
},
"App::HomeBank2Ledger::Ledger" : {
"file" : "lib/App/HomeBank2Ledger/Ledger.pm",
- "version" : "0.003"
+ "version" : "0.004"
},
"App::HomeBank2Ledger::Util" : {
"file" : "lib/App/HomeBank2Ledger/Util.pm",
- "version" : "0.003"
+ "version" : "0.004"
},
"File::HomeBank" : {
"file" : "lib/File/HomeBank.pm",
- "version" : "0.003"
+ "version" : "0.004"
}
},
"release_status" : "stable",
"web" : "https://github.com/chazmcgarvey/homebank2ledger"
}
},
- "version" : "0.003",
+ "version" : "0.004",
"x_authority" : "cpan:CCM",
"x_generated_by_perl" : "v5.28.0",
"x_serialization_backend" : "Cpanel::JSON::XS version 4.08"
provides:
App::HomeBank2Ledger:
file: lib/App/HomeBank2Ledger.pm
- version: '0.003'
+ version: '0.004'
App::HomeBank2Ledger::Formatter:
file: lib/App/HomeBank2Ledger/Formatter.pm
- version: '0.003'
+ version: '0.004'
App::HomeBank2Ledger::Formatter::Beancount:
file: lib/App/HomeBank2Ledger/Formatter/Beancount.pm
- version: '0.003'
+ version: '0.004'
App::HomeBank2Ledger::Formatter::Ledger:
file: lib/App/HomeBank2Ledger/Formatter/Ledger.pm
- version: '0.003'
+ version: '0.004'
App::HomeBank2Ledger::Ledger:
file: lib/App/HomeBank2Ledger/Ledger.pm
- version: '0.003'
+ version: '0.004'
App::HomeBank2Ledger::Util:
file: lib/App/HomeBank2Ledger/Util.pm
- version: '0.003'
+ version: '0.004'
File::HomeBank:
file: lib/File/HomeBank.pm
- version: '0.003'
+ version: '0.004'
requires:
Carp: '0'
Exporter: '0'
bugtracker: https://github.com/chazmcgarvey/homebank2ledger/issues
homepage: https://github.com/chazmcgarvey/homebank2ledger
repository: https://github.com/chazmcgarvey/homebank2ledger.git
-version: '0.003'
+version: '0.004'
x_authority: cpan:CCM
x_generated_by_perl: v5.28.0
x_serialization_backend: 'YAML::Tiny version 1.73'
"IPC::Open3" => 0,
"Test::More" => 0
},
- "VERSION" => "0.003",
+ "VERSION" => "0.004",
"test" => {
"TESTS" => "t/*.t"
}
VERSION
- version 0.003
+ version 0.004
SYNOPSIS
[--version|--help|--manual] [--account-width NUM]
[--accounts|--no-accounts] [--payees|--no-payees]
[--tags|--no-tags] [--commodities|--no-commodities]
- [--opening-date DATE] [--default-account STR]
+ [--opening-date DATE]
[--rename-account STR]... [--exclude-account STR]...
DESCRIPTION
Date must be in the form "YYYY-MM-DD". Defaults to the date of the
first transaction.
- --default-account STR
-
- Specify the account to use for one-sided transactions (if any).
- Defaults to "Expenses:No Category".
-
- A default account may be necessary because with Ledger all transactions
- are double-entry.
-
--rename-account STR
Specifies a mapping for renaming accounts in the output. By default
use App::HomeBank2Ledger;
-our $VERSION = '0.003'; # VERSION
+our $VERSION = '0.004'; # VERSION
App::HomeBank2Ledger->main(@ARGV);
=head1 VERSION
-version 0.003
+version 0.004
=head1 SYNOPSIS
[--version|--help|--manual] [--account-width NUM]
[--accounts|--no-accounts] [--payees|--no-payees]
[--tags|--no-tags] [--commodities|--no-commodities]
- [--opening-date DATE] [--default-account STR]
+ [--opening-date DATE]
[--rename-account STR]... [--exclude-account STR]...
=head1 DESCRIPTION
Date must be in the form "YYYY-MM-DD". Defaults to the date of the first transaction.
-=head2 --default-account STR
-
-Specify the account to use for one-sided transactions (if any). Defaults to "Expenses:No Category".
-
-A default account may be necessary because with Ledger all transactions are double-entry.
-
=head2 --rename-account STR
Specifies a mapping for renaming accounts in the output. By default C<homebank2ledger> tries to come
use Getopt::Long 2.38 qw(GetOptionsFromArray);
use Pod::Usage;
-our $VERSION = '0.003'; # VERSION
+our $VERSION = '0.004'; # VERSION
my %ACCOUNT_TYPES = ( # map HomeBank account types to Ledger accounts
bank => 'Assets:Bank',
my $homebank = shift;
my $opts = shift || {};
+ my $default_account_income = 'Income:Unknown';
+ my $default_account_expenses = 'Expenses:Unknown';
+
my $ledger = App::HomeBank2Ledger::Ledger->new;
my $transactions = $homebank->sorted_transactions;
$item->{excluded} = 1 if $item->{ledger_name} =~ /$re/;
}
}
+ while (my ($re, $replacement) = each %{$opts->{rename_accounts}}) {
+ $default_account_income =~ s/$re/$replacement/;
+ $default_account_expenses =~ s/$re/$replacement/;
+ }
my $has_initial_balance = grep { $_->{initial} && !$_->{excluded} } @$accounts;
if ($opts->{accounts}) {
my @accounts = map { $_->{ledger_name} } grep { !$_->{excluded} } @$accounts, @$categories;
- push @accounts, $opts->{default_account};
+ push @accounts, $default_account_income, $default_account_expenses;
push @accounts, $OPENING_BALANCES_ACCOUNT if $has_initial_balance;
$ledger->add_accounts(@accounts);
my @categories = split(/\|\|/, $transaction->{split_category} || '');
for (my $i = 0; $amounts[$i]; ++$i) {
- my $amount = -$amounts[$i];
- my $category = $homebank->find_category_by_key($categories[$i]);
- my $memo = $memos[$i] || '';
- my $other_account = $category ? $category->{ledger_name} : $opts->{default_account};
+ my $amount = -$amounts[$i];
+ my $category = $homebank->find_category_by_key($categories[$i]);
+ my $memo = $memos[$i] || '';
+ my $other_account = $category ? $category->{ledger_name}
+ : $amount < 0 ? $default_account_income
+ : $default_account_expenses;
push @postings, {
account => $other_account,
}
}
else { # with or without category
- my $category = $homebank->find_category_by_key($transaction->{category});
- my $other_account = $category ? $category->{ledger_name} : $opts->{default_account};
+ my $amount = -$transaction->{amount};
+ my $category = $homebank->find_category_by_key($transaction->{category});
+ my $other_account = $category ? $category->{ledger_name}
+ : $amount < 0 ? $default_account_income
+ : $default_account_expenses;
+
push @postings, {
account => $other_account,
commodity => $commodities{$account->{currency}},
- amount => -$transaction->{amount},
+ amount => $amount,
payee => $payee->{name},
memo => $memo,
status => $status,
tags => 1,
commodities => 1,
opening_date => '',
- default_account => 'Expenses:No Category',
rename_accounts => {},
exclude_accounts => [],
);
'tags!' => \$opts{tags},
'commodities!' => \$opts{commodities},
'opening-date=s' => \$opts{opening_date},
- 'default-account=s' => \$opts{default_account},
'rename-account|r=s' => \%{$opts{rename_accounts}},
'exclude-account|x=s' => \@{$opts{exclude_accounts}},
) or pod2usage(-exitval => 1, -verbose => 99, -sections => [qw(SYNOPSIS OPTIONS)]);
=head1 VERSION
-version 0.003
+version 0.004
=head1 SYNOPSIS
use Module::Pluggable search_path => [__PACKAGE__],
sub_name => 'available_formatters';
-our $VERSION = '0.003'; # VERSION
+our $VERSION = '0.004'; # VERSION
sub _croak { require Carp; Carp::croak(@_) }
sub format {
- ...
+ die "Unimplemented\n";
}
=head1 VERSION
-version 0.003
+version 0.004
=head1 SYNOPSIS
use parent 'App::HomeBank2Ledger::Formatter';
-our $VERSION = '0.003'; # VERSION
+our $VERSION = '0.004'; # VERSION
my %STATUS_SYMBOLS = (
cleared => '*',
=head1 VERSION
-version 0.003
+version 0.004
=head1 DESCRIPTION
use parent 'App::HomeBank2Ledger::Formatter';
-our $VERSION = '0.003'; # VERSION
+our $VERSION = '0.004'; # VERSION
my %STATUS_SYMBOLS = (
cleared => '*',
=head1 VERSION
-version 0.003
+version 0.004
=head1 DESCRIPTION
use warnings;
use strict;
-our $VERSION = '0.003'; # VERSION
+our $VERSION = '0.004'; # VERSION
sub new {
=head1 VERSION
-version 0.003
+version 0.004
=head1 SYNOPSIS
use Exporter qw(import);
-our $VERSION = '0.003'; # VERSION
+our $VERSION = '0.004'; # VERSION
our @EXPORT_OK = qw(commify rtrim);
=head1 VERSION
-version 0.003
+version 0.004
=head1 FUNCTIONS
use XML::Entities;
use XML::Parser::Lite;
-our $VERSION = '0.003'; # VERSION
+our $VERSION = '0.004'; # VERSION
our @EXPORT_OK = qw(parse_string parse_file);
=head1 VERSION
-version 0.003
+version 0.004
=head1 SYNOPSIS