From 8feecd3de0d3293f8a26c05fc880415aee283e12 Mon Sep 17 00:00:00 2001 From: Charles McGarvey Date: Mon, 2 Sep 2019 20:03:40 -0600 Subject: [PATCH] Version 0.006 --- Changes | 3 ++ META.json | 17 ++++--- META.yml | 16 +++--- Makefile.PL | 2 +- README | 41 +++++++++++++++- bin/homebank2ledger | 49 +++++++++++++++++-- lib/App/HomeBank2Ledger.pm | 4 +- lib/App/HomeBank2Ledger/Formatter.pm | 4 +- .../HomeBank2Ledger/Formatter/Beancount.pm | 19 ++++++- lib/App/HomeBank2Ledger/Formatter/Ledger.pm | 16 +++++- lib/App/HomeBank2Ledger/Ledger.pm | 4 +- lib/App/HomeBank2Ledger/Util.pm | 4 +- lib/File/HomeBank.pm | 4 +- t/00-report-prereqs.dd | 1 + 14 files changed, 147 insertions(+), 37 deletions(-) diff --git a/Changes b/Changes index 3a74157..d98cd36 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,8 @@ Revision history for App-HomeBank2Ledger. +0.006 2019-09-02 20:02:53-06:00 MST7MDT + * Add fatpack release. + 0.005 2019-08-17 16:26:33-06:00 MST7MDT * Add --budget option for converting HomeBank budget to Ledger. * Support quoting commodities when needed. diff --git a/META.json b/META.json index 15836ee..54f089d 100644 --- a/META.json +++ b/META.json @@ -32,6 +32,7 @@ "requires" : { "Dist::Zilla" : "5", "Dist::Zilla::Plugin::ConsistentVersionTest" : "0", + "Dist::Zilla::Plugin::Run::Release" : "0", "Dist::Zilla::PluginBundle::Author::CCM" : "0", "Dist::Zilla::PluginBundle::Filter" : "0", "Pod::Coverage::TrustPod" : "0", @@ -84,31 +85,31 @@ "provides" : { "App::HomeBank2Ledger" : { "file" : "lib/App/HomeBank2Ledger.pm", - "version" : "0.005" + "version" : "0.006" }, "App::HomeBank2Ledger::Formatter" : { "file" : "lib/App/HomeBank2Ledger/Formatter.pm", - "version" : "0.005" + "version" : "0.006" }, "App::HomeBank2Ledger::Formatter::Beancount" : { "file" : "lib/App/HomeBank2Ledger/Formatter/Beancount.pm", - "version" : "0.005" + "version" : "0.006" }, "App::HomeBank2Ledger::Formatter::Ledger" : { "file" : "lib/App/HomeBank2Ledger/Formatter/Ledger.pm", - "version" : "0.005" + "version" : "0.006" }, "App::HomeBank2Ledger::Ledger" : { "file" : "lib/App/HomeBank2Ledger/Ledger.pm", - "version" : "0.005" + "version" : "0.006" }, "App::HomeBank2Ledger::Util" : { "file" : "lib/App/HomeBank2Ledger/Util.pm", - "version" : "0.005" + "version" : "0.006" }, "File::HomeBank" : { "file" : "lib/File/HomeBank.pm", - "version" : "0.005" + "version" : "0.006" } }, "release_status" : "stable", @@ -123,7 +124,7 @@ "web" : "https://github.com/chazmcgarvey/homebank2ledger" } }, - "version" : "0.005", + "version" : "0.006", "x_authority" : "cpan:CCM", "x_generated_by_perl" : "v5.28.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.08" diff --git a/META.yml b/META.yml index cc85c06..8cf88e7 100644 --- a/META.yml +++ b/META.yml @@ -27,25 +27,25 @@ no_index: provides: App::HomeBank2Ledger: file: lib/App/HomeBank2Ledger.pm - version: '0.005' + version: '0.006' App::HomeBank2Ledger::Formatter: file: lib/App/HomeBank2Ledger/Formatter.pm - version: '0.005' + version: '0.006' App::HomeBank2Ledger::Formatter::Beancount: file: lib/App/HomeBank2Ledger/Formatter/Beancount.pm - version: '0.005' + version: '0.006' App::HomeBank2Ledger::Formatter::Ledger: file: lib/App/HomeBank2Ledger/Formatter/Ledger.pm - version: '0.005' + version: '0.006' App::HomeBank2Ledger::Ledger: file: lib/App/HomeBank2Ledger/Ledger.pm - version: '0.005' + version: '0.006' App::HomeBank2Ledger::Util: file: lib/App/HomeBank2Ledger/Util.pm - version: '0.005' + version: '0.006' File::HomeBank: file: lib/File/HomeBank.pm - version: '0.005' + version: '0.006' requires: Carp: '0' Exporter: '0' @@ -65,7 +65,7 @@ resources: bugtracker: https://github.com/chazmcgarvey/homebank2ledger/issues homepage: https://github.com/chazmcgarvey/homebank2ledger repository: https://github.com/chazmcgarvey/homebank2ledger.git -version: '0.005' +version: '0.006' x_authority: cpan:CCM x_generated_by_perl: v5.28.0 x_serialization_backend: 'YAML::Tiny version 1.73' diff --git a/Makefile.PL b/Makefile.PL index 83b1aa4..b1cfb50 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -41,7 +41,7 @@ my %WriteMakefileArgs = ( "IPC::Open3" => 0, "Test::More" => 0 }, - "VERSION" => "0.005", + "VERSION" => "0.006", "test" => { "TESTS" => "t/*.t" } diff --git a/README b/README index 2209329..7f25f53 100644 --- a/README +++ b/README @@ -4,7 +4,7 @@ NAME VERSION - version 0.005 + version 0.006 SYNOPSIS @@ -58,6 +58,45 @@ DESCRIPTION continue to maintain your accounts in HomeBank and use this script to also take advantage of the reports Ledger offers. +INSTALL + + There are several ways to install homebank2ledger to your system. + + using cpanm + + You can install homebank2ledger using cpanm. If you have a local perl + (plenv, perlbrew, etc.), you can just do: + + cpanm App::Homebank2Ledger + + to install the homebank2ledger executable and its dependencies. The + executable will be installed to your perl's bin path, like + ~/perl5/perlbrew/bin/homebank2ledger. + + If you're installing to your system perl, you can do: + + cpanm --sudo App::Homebank2Ledger + + to install the homebank2ledger executable to a system directory, like + /usr/local/bin/homebank2ledger (depending on your perl). + + Downloading just the executable + + You may also choose to download homebank2ledger as a single executable, + like this: + + curl -OL https://raw.githubusercontent.com/chazmcgarvey/homebank2ledger/solo/homebank2ledger + chmod +x homebank2ledger + + For developers + + If you're a developer and want to hack on the source, clone the + repository and pull the dependencies: + + git clone https://github.com/chazmcgarvey/homebank2ledger.git + cd homebank2ledger + make bootstrap # installs dependencies; requires cpanm + OPTIONS --version diff --git a/bin/homebank2ledger b/bin/homebank2ledger index 933243f..ce1c605 100644 --- a/bin/homebank2ledger +++ b/bin/homebank2ledger @@ -3,12 +3,14 @@ # PODNAME: homebank2ledger +# FATPACK - Do not remove this line. + use warnings; use strict; use App::HomeBank2Ledger; -our $VERSION = '0.005'; # VERSION +our $VERSION = '0.006'; # VERSION App::HomeBank2Ledger->main(@ARGV); @@ -24,7 +26,7 @@ homebank2ledger - A tool to convert HomeBank files to Ledger format =head1 VERSION -version 0.005 +version 0.006 =head1 SYNOPSIS @@ -37,13 +39,13 @@ version 0.005 =head1 DESCRIPTION -C converts L files to a format usable by +F converts L files to a format usable by L. It can also convert directly to the similar L format. This software is B, in early development. Its interface may change without notice. -I wrote C because I have been maintaining my own personal finances using HomeBank +I wrote F because I have been maintaining my own personal finances using HomeBank (which is awesome) and I wanted to investigate using plain text accounting programs. It works well enough for my data, but you may be using HomeBank features that I don't so there may be cases this doesn't handle well or at all. Feel free to file a bug report. This script does NOT try to modify @@ -80,6 +82,43 @@ You can migrate the data you have in HomeBank so you can start maintaining your Or if you don't plan to switch completely off of HomeBank, you can continue to maintain your accounts in HomeBank and use this script to also take advantage of the reports Ledger offers. +=head1 INSTALL + +There are several ways to install F to your system. + +=head2 using cpanm + +You can install F using L. If you have a local perl (plenv, perlbrew, etc.), +you can just do: + + cpanm App::Homebank2Ledger + +to install the F executable and its dependencies. The executable will be installed +to your perl's bin path, like F<~/perl5/perlbrew/bin/homebank2ledger>. + +If you're installing to your system perl, you can do: + + cpanm --sudo App::Homebank2Ledger + +to install the F executable to a system directory, like +F (depending on your perl). + +=head2 Downloading just the executable + +You may also choose to download F as a single executable, like this: + + curl -OL https://raw.githubusercontent.com/chazmcgarvey/homebank2ledger/solo/homebank2ledger + chmod +x homebank2ledger + +=head2 For developers + +If you're a developer and want to hack on the source, clone the repository and pull the +dependencies: + + git clone https://github.com/chazmcgarvey/homebank2ledger.git + cd homebank2ledger + make bootstrap # installs dependencies; requires cpanm + =head1 OPTIONS =head2 --version @@ -178,7 +217,7 @@ Date must be in the form "YYYY-MM-DD". Defaults to the date of the first transac =head2 --rename-account STR -Specifies a mapping for renaming accounts in the output. By default C tries to come +Specifies a mapping for renaming accounts in the output. By default F tries to come up with sensible account names (based on your HomeBank accounts and categories) that fit into five root accounts: diff --git a/lib/App/HomeBank2Ledger.pm b/lib/App/HomeBank2Ledger.pm index 9d6ce60..cc69d4e 100644 --- a/lib/App/HomeBank2Ledger.pm +++ b/lib/App/HomeBank2Ledger.pm @@ -11,7 +11,7 @@ use File::HomeBank; use Getopt::Long 2.38 qw(GetOptionsFromArray); use Pod::Usage; -our $VERSION = '0.005'; # VERSION +our $VERSION = '0.006'; # VERSION my %ACCOUNT_TYPES = ( # map HomeBank account types to Ledger accounts bank => 'Assets:Bank', @@ -446,7 +446,7 @@ App::HomeBank2Ledger - A tool to convert HomeBank files to Ledger format =head1 VERSION -version 0.005 +version 0.006 =head1 SYNOPSIS diff --git a/lib/App/HomeBank2Ledger/Formatter.pm b/lib/App/HomeBank2Ledger/Formatter.pm index f529943..cc18be5 100644 --- a/lib/App/HomeBank2Ledger/Formatter.pm +++ b/lib/App/HomeBank2Ledger/Formatter.pm @@ -9,7 +9,7 @@ use Module::Load; use Module::Pluggable search_path => [__PACKAGE__], sub_name => 'available_formatters'; -our $VERSION = '0.005'; # VERSION +our $VERSION = '0.006'; # VERSION sub _croak { require Carp; Carp::croak(@_) } @@ -59,7 +59,7 @@ App::HomeBank2Ledger::Formatter - Abstract class for formatting a ledger =head1 VERSION -version 0.005 +version 0.006 =head1 SYNOPSIS diff --git a/lib/App/HomeBank2Ledger/Formatter/Beancount.pm b/lib/App/HomeBank2Ledger/Formatter/Beancount.pm index 2ec6a2c..7e3f785 100644 --- a/lib/App/HomeBank2Ledger/Formatter/Beancount.pm +++ b/lib/App/HomeBank2Ledger/Formatter/Beancount.pm @@ -7,10 +7,11 @@ use warnings; use strict; use App::HomeBank2Ledger::Util qw(commify rtrim); +use Scalar::Util qw(looks_like_number); use parent 'App::HomeBank2Ledger::Formatter'; -our $VERSION = '0.005'; # VERSION +our $VERSION = '0.006'; # VERSION my %STATUS_SYMBOLS = ( cleared => '*', @@ -142,6 +143,13 @@ sub _format_transaction { $out[-1] .= ' '.join(' ', @tags); } + my $metadata = $transaction->{metadata} || {}; + for my $key (sort keys %$metadata) { + my $value = looks_like_number($metadata->{$key}) ? $metadata->{$key} + : $self->_format_string($metadata->{$key}); + push @out, " ; ${key}: ${value}"; + } + for my $posting (@postings) { my @line; @@ -178,6 +186,13 @@ sub _format_transaction { } push @out, join('', @line); + + my $metadata = $posting->{metadata} || {}; + for my $key (sort keys %$metadata) { + my $value = looks_like_number($metadata->{$key}) ? $metadata->{$key} + : $self->_format_string($metadata->{$key}); + push @out, " ; ${key}: ${value}"; + } } push @out, ''; @@ -282,7 +297,7 @@ App::HomeBank2Ledger::Formatter::Beancount - Beancount formatter =head1 VERSION -version 0.005 +version 0.006 =head1 DESCRIPTION diff --git a/lib/App/HomeBank2Ledger/Formatter/Ledger.pm b/lib/App/HomeBank2Ledger/Formatter/Ledger.pm index 4cf72cb..ebfa456 100644 --- a/lib/App/HomeBank2Ledger/Formatter/Ledger.pm +++ b/lib/App/HomeBank2Ledger/Formatter/Ledger.pm @@ -10,7 +10,7 @@ use App::HomeBank2Ledger::Util qw(commify rtrim); use parent 'App::HomeBank2Ledger::Formatter'; -our $VERSION = '0.005'; # VERSION +our $VERSION = '0.006'; # VERSION my %STATUS_SYMBOLS = ( cleared => '*', @@ -157,6 +157,12 @@ sub _format_transaction { $memo && " ; $memo", ); + my $metadata = $transaction->{metadata} || {}; + for my $key (sort keys %$metadata) { + my $value = $self->_format_string($metadata->{$key}); + push @out, " ; ${key}: ${value}"; + } + for my $posting (@postings) { my @line; @@ -194,6 +200,12 @@ sub _format_transaction { push @out, join('', @line); + my $metadata = $posting->{metadata} || {}; + for my $key (sort keys %$metadata) { + my $value = $self->_format_string($metadata->{$key}); + push @out, " ; ${key}: ${value}"; + } + if (my $posting_payee = $posting->{payee}) { $posting_payee = $self->_format_string($posting_payee); push @out, " ; Payee: $posting_payee" if $posting_payee ne $payee; @@ -255,7 +267,7 @@ App::HomeBank2Ledger::Formatter::Ledger - Ledger formatter =head1 VERSION -version 0.005 +version 0.006 =head1 DESCRIPTION diff --git a/lib/App/HomeBank2Ledger/Ledger.pm b/lib/App/HomeBank2Ledger/Ledger.pm index f89063f..245e9b5 100644 --- a/lib/App/HomeBank2Ledger/Ledger.pm +++ b/lib/App/HomeBank2Ledger/Ledger.pm @@ -5,7 +5,7 @@ package App::HomeBank2Ledger::Ledger; use warnings; use strict; -our $VERSION = '0.005'; # VERSION +our $VERSION = '0.006'; # VERSION sub new { @@ -63,7 +63,7 @@ App::HomeBank2Ledger::Ledger - Ledger data representation =head1 VERSION -version 0.005 +version 0.006 =head1 SYNOPSIS diff --git a/lib/App/HomeBank2Ledger/Util.pm b/lib/App/HomeBank2Ledger/Util.pm index c4d00e0..3bf72b6 100644 --- a/lib/App/HomeBank2Ledger/Util.pm +++ b/lib/App/HomeBank2Ledger/Util.pm @@ -6,7 +6,7 @@ use strict; use Exporter qw(import); -our $VERSION = '0.005'; # VERSION +our $VERSION = '0.006'; # VERSION our @EXPORT_OK = qw(commify rtrim); @@ -42,7 +42,7 @@ App::HomeBank2Ledger::Util - Miscellaneous utility functions =head1 VERSION -version 0.005 +version 0.006 =head1 FUNCTIONS diff --git a/lib/File/HomeBank.pm b/lib/File/HomeBank.pm index 5a8da62..e33b933 100644 --- a/lib/File/HomeBank.pm +++ b/lib/File/HomeBank.pm @@ -12,7 +12,7 @@ use Time::Piece; use XML::Entities; use XML::Parser::Lite; -our $VERSION = '0.005'; # VERSION +our $VERSION = '0.006'; # VERSION our @EXPORT_OK = qw(parse_string parse_file); @@ -491,7 +491,7 @@ File::HomeBank - Parse HomeBank files =head1 VERSION -version 0.005 +version 0.006 =head1 SYNOPSIS diff --git a/t/00-report-prereqs.dd b/t/00-report-prereqs.dd index 0f6138b..0b09b63 100644 --- a/t/00-report-prereqs.dd +++ b/t/00-report-prereqs.dd @@ -8,6 +8,7 @@ do { my $x = { 'requires' => { 'Dist::Zilla' => '5', 'Dist::Zilla::Plugin::ConsistentVersionTest' => '0', + 'Dist::Zilla::Plugin::Run::Release' => '0', 'Dist::Zilla::PluginBundle::Author::CCM' => '0', 'Dist::Zilla::PluginBundle::Filter' => '0', 'Pod::Coverage::TrustPod' => '0', -- 2.43.0