]> Dogcows Code - chaz/homebank2ledger/commitdiff
Version 0.008
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sat, 2 May 2020 19:06:34 +0000 (13:06 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sat, 2 May 2020 19:06:34 +0000 (13:06 -0600)
14 files changed:
Changes
MANIFEST
META.json
META.yml
Makefile.PL
README
bin/homebank2ledger
lib/App/HomeBank2Ledger.pm
lib/App/HomeBank2Ledger/Formatter.pm
lib/App/HomeBank2Ledger/Formatter/Beancount.pm
lib/App/HomeBank2Ledger/Formatter/Ledger.pm
lib/App/HomeBank2Ledger/Ledger.pm
lib/App/HomeBank2Ledger/Util.pm
lib/File/HomeBank.pm

diff --git a/Changes b/Changes
index 60a9c795a1da67c40457dd3d673f0025088bf3fc..81ca6b8d28654e3f0bb33bdac0938d640b227c73 100644 (file)
--- 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.
 
index 69e0884eeec3321b8a0bd6d4c8557afb3d30a2d2..7d0f5eb2027baaa81b733030e17d6bc8087d9168 100644 (file)
--- 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
index 2fb245e972d0ec203dfc9f19a576e669043fb3c0..62b9e97429a2995dce917158683a2b8833bd48c3 100644 (file)
--- a/META.json
+++ b/META.json
@@ -4,7 +4,7 @@
       "Charles McGarvey <chazmcgarvey@brokenzipper.com>"
    ],
    "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"
    ],
    "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",
          "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"
 }
 
index 516d8b0fd16b0459e0eeaba1c25efc99f70ed0cc..e1aa9b6278409a513805718b59dc77c48dc9f342 100644 (file)
--- 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
index 086544d9c9929f1d4108b238235758c2dd953bc1..adfe83e25e432f1d86712bc7ac6a792825e28197 100644 (file)
@@ -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 4e1f4cf1246bf597aa38f8b1a36d99bcf5b2cf96..9a40d413453d06f00ac239afaae136a39bccd094 100644 (file)
--- a/README
+++ b/README
@@ -4,7 +4,7 @@ NAME
 
 VERSION
 
-    version 0.007
+    version 0.008
 
 SYNOPSIS
 
index ee909bb908081375d6b0a3f333306616565cc7be..a3ffbf806c6de6f599b90dc3bd1bbe5940b5c613 100644 (file)
@@ -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
 
index 57e32cbd432f1835813070d76f004b8e80e23316..bad0a39611626cafa8c1a1565a379710f30876dd 100644 (file)
@@ -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
 
index 53148a1b4e439e8f6df019a4bc0f7075e44094d5..de179e3a8040b561dae7c632b800ab789bc1e6f9 100644 (file)
@@ -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
 
index 85810b03b231e59b40fe654a3407c4a9d50ddf46..a7a66bf87c056cb067b5c76b9e7eb3499300910b 100644 (file)
@@ -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
 
index 6171faeeb5b4f2b6efc3e6990d35ce390fe8c2bd..dcae0ddbd27e12843ec05bcc4695a85561fdb14a 100644 (file)
@@ -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
 
index 190a376dc6273611cc45300e3e07cea688f96c69..98b84d11c8b38e93a6f70fe599a6fd784c36e475 100644 (file)
@@ -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
 
index 70968991fcd0e9720ebb7bce58fecc5a2c283a6c..7034fe2e8da2213aad8d36a5d4e45453536b760e 100644 (file)
@@ -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
 
index 0e1c2bd04ddb03948e5ff691af0b6d3482a3e574..363fb3f2b47c35ec15a15bef34625eef6b25d74c 100644 (file)
@@ -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<File::HomeBank>.
 
+=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
 
This page took 0.045559 seconds and 4 git commands to generate.