From: Charles McGarvey Date: Sat, 2 May 2020 19:02:32 +0000 (-0600) Subject: internal xfers no longer use a paymode X-Git-Tag: v0.008~1 X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=45cd86c510955a5de4fac808945468a1efdac3ea;p=chaz%2Fhomebank2ledger internal xfers no longer use a paymode --- diff --git a/lib/App/HomeBank2Ledger.pm b/lib/App/HomeBank2Ledger.pm index cd3e0db..c4bf5a6 100644 --- a/lib/App/HomeBank2Ledger.pm +++ b/lib/App/HomeBank2Ledger.pm @@ -291,7 +291,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}); @@ -308,7 +307,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}); diff --git a/lib/File/HomeBank.pm b/lib/File/HomeBank.pm index 004e768..184cb89 100644 --- a/lib/File/HomeBank.pm +++ b/lib/File/HomeBank.pm @@ -377,7 +377,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}; @@ -397,7 +397,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}; @@ -412,9 +412,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]';