X-Git-Url: https://git.dogcows.com/gitweb?p=chaz%2Fhomebank2ledger;a=blobdiff_plain;f=lib%2FFile%2FHomeBank.pm;h=004e768de3a3377a79d9af975b97f13a7fd9825b;hp=7d29ada68dfa09d4acc4459090b60af58ec6bfc2;hb=50e8907a2f78d956d1d0c6ffb8176216b4185ce5;hpb=d9581d0d135b6e4b1da2ce825d592599d85d44cb diff --git a/lib/File/HomeBank.pm b/lib/File/HomeBank.pm index 7d29ada..004e768 100644 --- a/lib/File/HomeBank.pm +++ b/lib/File/HomeBank.pm @@ -152,6 +152,18 @@ sub file { shift->{file}; } +=method file_version + + $version = $homebank->file_version; + +Get the file format version. + +=cut + +sub file_version { + shift->{homebank}{version}; +} + =method title $title = $homebank->title; @@ -226,7 +238,7 @@ sub tags { $account = $homebank->find_account_by_key($key); -Find a account with the given key. +Find an account with the given key. =cut @@ -520,6 +532,7 @@ Parse a HomeBank file from a string. sub parse_string { my $str = shift or die _usage(q{parse_string($str)}); + my %homebank; my %properties; my @accounts; my @payees; @@ -539,7 +552,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; } @@ -605,6 +622,7 @@ sub parse_string { $xml_parser->parse($str); return { + homebank => \%homebank, properties => \%properties, accounts => \@accounts, payees => \@payees,