From: Charles McGarvey Date: Sat, 2 May 2020 19:06:34 +0000 (-0600) Subject: Version 0.008 X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fhomebank2ledger;a=commitdiff_plain;h=e325852aa9ca67592ca857dd4f38cb3f13a97715 Version 0.008 --- diff --git a/Changes b/Changes index 60a9c79..81ca6b8 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,9 @@ Revision history for App-HomeBank2Ledger. +0.008 2020-05-02 13:06:06-06:00 MST7MDT + * Add file_version method to File::HomeBank. + * Fix matching internal transfers for files generated by HomeBank 5.4. + 0.007 2019-12-29 14:27:52-07:00 MST7MDT * Fix problem when formatting non-fraction amounts. diff --git a/MANIFEST b/MANIFEST index 69e0884..7d0f5eb 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1,4 +1,4 @@ -# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.012. +# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.014. Changes LICENSE MANIFEST diff --git a/META.json b/META.json index 2fb245e..62b9e97 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "Charles McGarvey " ], "dynamic_config" : 0, - "generated_by" : "Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010", + "generated_by" : "Dist::Zilla version 6.014, CPAN::Meta::Converter version 2.150010", "license" : [ "mit" ], @@ -85,31 +85,31 @@ "provides" : { "App::HomeBank2Ledger" : { "file" : "lib/App/HomeBank2Ledger.pm", - "version" : "0.007" + "version" : "0.008" }, "App::HomeBank2Ledger::Formatter" : { "file" : "lib/App/HomeBank2Ledger/Formatter.pm", - "version" : "0.007" + "version" : "0.008" }, "App::HomeBank2Ledger::Formatter::Beancount" : { "file" : "lib/App/HomeBank2Ledger/Formatter/Beancount.pm", - "version" : "0.007" + "version" : "0.008" }, "App::HomeBank2Ledger::Formatter::Ledger" : { "file" : "lib/App/HomeBank2Ledger/Formatter/Ledger.pm", - "version" : "0.007" + "version" : "0.008" }, "App::HomeBank2Ledger::Ledger" : { "file" : "lib/App/HomeBank2Ledger/Ledger.pm", - "version" : "0.007" + "version" : "0.008" }, "App::HomeBank2Ledger::Util" : { "file" : "lib/App/HomeBank2Ledger/Util.pm", - "version" : "0.007" + "version" : "0.008" }, "File::HomeBank" : { "file" : "lib/File/HomeBank.pm", - "version" : "0.007" + "version" : "0.008" } }, "release_status" : "stable", @@ -124,9 +124,10 @@ "web" : "https://github.com/chazmcgarvey/homebank2ledger" } }, - "version" : "0.007", + "version" : "0.008", "x_authority" : "cpan:CCM", "x_generated_by_perl" : "v5.28.0", - "x_serialization_backend" : "Cpanel::JSON::XS version 4.15" + "x_serialization_backend" : "Cpanel::JSON::XS version 4.15", + "x_spdx_expression" : "MIT" } diff --git a/META.yml b/META.yml index 516d8b0..e1aa9b6 100644 --- a/META.yml +++ b/META.yml @@ -11,7 +11,7 @@ build_requires: configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 0 -generated_by: 'Dist::Zilla version 6.012, CPAN::Meta::Converter version 2.150010' +generated_by: 'Dist::Zilla version 6.014, CPAN::Meta::Converter version 2.150010' license: mit meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html @@ -27,25 +27,25 @@ no_index: provides: App::HomeBank2Ledger: file: lib/App/HomeBank2Ledger.pm - version: '0.007' + version: '0.008' App::HomeBank2Ledger::Formatter: file: lib/App/HomeBank2Ledger/Formatter.pm - version: '0.007' + version: '0.008' App::HomeBank2Ledger::Formatter::Beancount: file: lib/App/HomeBank2Ledger/Formatter/Beancount.pm - version: '0.007' + version: '0.008' App::HomeBank2Ledger::Formatter::Ledger: file: lib/App/HomeBank2Ledger/Formatter/Ledger.pm - version: '0.007' + version: '0.008' App::HomeBank2Ledger::Ledger: file: lib/App/HomeBank2Ledger/Ledger.pm - version: '0.007' + version: '0.008' App::HomeBank2Ledger::Util: file: lib/App/HomeBank2Ledger/Util.pm - version: '0.007' + version: '0.008' File::HomeBank: file: lib/File/HomeBank.pm - version: '0.007' + version: '0.008' requires: Carp: '0' Exporter: '0' @@ -65,7 +65,8 @@ resources: bugtracker: https://github.com/chazmcgarvey/homebank2ledger/issues homepage: https://github.com/chazmcgarvey/homebank2ledger repository: https://github.com/chazmcgarvey/homebank2ledger.git -version: '0.007' +version: '0.008' x_authority: cpan:CCM x_generated_by_perl: v5.28.0 x_serialization_backend: 'YAML::Tiny version 1.73' +x_spdx_expression: MIT diff --git a/Makefile.PL b/Makefile.PL index 086544d..adfe83e 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,4 +1,4 @@ -# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.012. +# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.014. use strict; use warnings; @@ -41,7 +41,7 @@ my %WriteMakefileArgs = ( "IPC::Open3" => 0, "Test::More" => 0 }, - "VERSION" => "0.007", + "VERSION" => "0.008", "test" => { "TESTS" => "t/*.t" } diff --git a/README b/README index 4e1f4cf..9a40d41 100644 --- a/README +++ b/README @@ -4,7 +4,7 @@ NAME VERSION - version 0.007 + version 0.008 SYNOPSIS diff --git a/bin/homebank2ledger b/bin/homebank2ledger index ee909bb..a3ffbf8 100644 --- a/bin/homebank2ledger +++ b/bin/homebank2ledger @@ -10,7 +10,7 @@ use strict; use App::HomeBank2Ledger; -our $VERSION = '0.007'; # VERSION +our $VERSION = '0.008'; # VERSION App::HomeBank2Ledger->main(@ARGV); @@ -26,7 +26,7 @@ homebank2ledger - A tool to convert HomeBank files to Ledger format =head1 VERSION -version 0.007 +version 0.008 =head1 SYNOPSIS diff --git a/lib/App/HomeBank2Ledger.pm b/lib/App/HomeBank2Ledger.pm index 57e32cb..bad0a39 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.007'; # VERSION +our $VERSION = '0.008'; # VERSION my %ACCOUNT_TYPES = ( # map HomeBank account types to Ledger accounts bank => 'Assets:Bank', @@ -261,7 +261,6 @@ sub convert_homebank_to_ledger { my $account = $homebank->find_account_by_key($transaction->{account}); my $amount = $transaction->{amount}; my $status = $STATUS_SYMBOLS{$transaction->{status} || ''} || ''; - my $paymode = $transaction->{paymode} || ''; # internaltransfer my $memo = $transaction->{wording} || ''; my $payee = $homebank->find_payee_by_key($transaction->{payee}); my $tags = _split_tags($transaction->{tags}); @@ -278,7 +277,7 @@ sub convert_homebank_to_ledger { tags => $tags, }; - if ($paymode eq 'internaltransfer') { + if ($transaction->{dst_account}) { # is an internal transfer my $paired_transaction = $homebank->find_transaction_transfer_pair($transaction); my $dst_account = $homebank->find_account_by_key($transaction->{dst_account}); @@ -446,7 +445,7 @@ App::HomeBank2Ledger - A tool to convert HomeBank files to Ledger format =head1 VERSION -version 0.007 +version 0.008 =head1 SYNOPSIS diff --git a/lib/App/HomeBank2Ledger/Formatter.pm b/lib/App/HomeBank2Ledger/Formatter.pm index 53148a1..de179e3 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.007'; # VERSION +our $VERSION = '0.008'; # VERSION sub _croak { require Carp; Carp::croak(@_) } @@ -59,7 +59,7 @@ App::HomeBank2Ledger::Formatter - Abstract class for formatting a ledger =head1 VERSION -version 0.007 +version 0.008 =head1 SYNOPSIS diff --git a/lib/App/HomeBank2Ledger/Formatter/Beancount.pm b/lib/App/HomeBank2Ledger/Formatter/Beancount.pm index 85810b0..a7a66bf 100644 --- a/lib/App/HomeBank2Ledger/Formatter/Beancount.pm +++ b/lib/App/HomeBank2Ledger/Formatter/Beancount.pm @@ -11,7 +11,7 @@ use Scalar::Util qw(looks_like_number); use parent 'App::HomeBank2Ledger::Formatter'; -our $VERSION = '0.007'; # VERSION +our $VERSION = '0.008'; # VERSION my %STATUS_SYMBOLS = ( cleared => '*', @@ -301,7 +301,7 @@ App::HomeBank2Ledger::Formatter::Beancount - Beancount formatter =head1 VERSION -version 0.007 +version 0.008 =head1 DESCRIPTION diff --git a/lib/App/HomeBank2Ledger/Formatter/Ledger.pm b/lib/App/HomeBank2Ledger/Formatter/Ledger.pm index 6171fae..dcae0dd 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.007'; # VERSION +our $VERSION = '0.008'; # VERSION my %STATUS_SYMBOLS = ( cleared => '*', @@ -271,7 +271,7 @@ App::HomeBank2Ledger::Formatter::Ledger - Ledger formatter =head1 VERSION -version 0.007 +version 0.008 =head1 DESCRIPTION diff --git a/lib/App/HomeBank2Ledger/Ledger.pm b/lib/App/HomeBank2Ledger/Ledger.pm index 190a376..98b84d1 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.007'; # VERSION +our $VERSION = '0.008'; # VERSION sub new { @@ -63,7 +63,7 @@ App::HomeBank2Ledger::Ledger - Ledger data representation =head1 VERSION -version 0.007 +version 0.008 =head1 SYNOPSIS diff --git a/lib/App/HomeBank2Ledger/Util.pm b/lib/App/HomeBank2Ledger/Util.pm index 7096899..7034fe2 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.007'; # VERSION +our $VERSION = '0.008'; # VERSION our @EXPORT_OK = qw(commify rtrim); @@ -42,7 +42,7 @@ App::HomeBank2Ledger::Util - Miscellaneous utility functions =head1 VERSION -version 0.007 +version 0.008 =head1 FUNCTIONS diff --git a/lib/File/HomeBank.pm b/lib/File/HomeBank.pm index 0e1c2bd..363fb3f 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.007'; # VERSION +our $VERSION = '0.008'; # VERSION our @EXPORT_OK = qw(parse_string parse_file); @@ -119,6 +119,11 @@ sub file { } +sub file_version { + shift->{homebank}{version}; +} + + sub title { shift->{properties}{title}; } @@ -245,7 +250,7 @@ sub find_transaction_transfer_pair { my $self = shift; my $transaction = shift; - return if $transaction->{paymode} ne 'internaltransfer'; + return if !$transaction->{dst_account}; my $transfer_key = $transaction->{transfer_key}; @@ -265,7 +270,7 @@ sub find_transaction_transfer_pair { my @candidates; for my $t (@{$self->transactions}) { - next if $t->{paymode} ne 'internaltransfer'; + next if !$t->{dst_account}; next if $t->{account} != $transaction->{dst_account}; next if $t->{dst_account} != $transaction->{account}; next if $t->{amount} != -$transaction->{amount}; @@ -280,9 +285,9 @@ sub find_transaction_transfer_pair { # sort the candidates so we can pick the nearest one by date my @ordered_candidates = - map { $_->[1] } + map { $_->[1] } sort { $a->[0] <=> $b->[0] } - map { [abs($transaction_day - _ymd_to_julian($_->{date})), $_] } @candidates; + map { [abs($transaction_day - _ymd_to_julian($_->{date})), $_] } @candidates; if (my $winner = $ordered_candidates[0]) { my $key1 = $transfer_key || '[no key]'; @@ -356,6 +361,7 @@ sub parse_file { sub parse_string { my $str = shift or die _usage(q{parse_string($str)}); + my %homebank; my %properties; my @accounts; my @payees; @@ -375,7 +381,11 @@ sub parse_string { $attr{$key} = _decode_xml_entities($attr{$key}); } - if ($node eq 'properties') { + if ($node eq 'homebank') { + $attr{version} = delete $attr{v} if $attr{v}; + %homebank = %attr; + } + elsif ($node eq 'properties') { $attr{currency} = delete $attr{curr} if $attr{curr}; %properties = %attr; } @@ -441,6 +451,7 @@ sub parse_string { $xml_parser->parse($str); return { + homebank => \%homebank, properties => \%properties, accounts => \@accounts, payees => \@payees, @@ -491,7 +502,7 @@ File::HomeBank - Parse HomeBank files =head1 VERSION -version 0.007 +version 0.008 =head1 SYNOPSIS @@ -528,6 +539,12 @@ Get the filepath (if parsed from a file). Construct a L. +=head2 file_version + + $version = $homebank->file_version; + +Get the file format version. + =head2 title $title = $homebank->title; @@ -568,7 +585,7 @@ Get an arrayref of transactions. $account = $homebank->find_account_by_key($key); -Find a account with the given key. +Find an account with the given key. =head2 find_currency_by_key