internal xfers no longer use a paymode
authorCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sat, 2 May 2020 19:02:32 +0000 (13:02 -0600)
committerCharles McGarvey <chazmcgarvey@brokenzipper.com>
Sat, 2 May 2020 19:02:32 +0000 (13:02 -0600)
lib/App/HomeBank2Ledger.pm
lib/File/HomeBank.pm

index cd3e0dbfd26d5b1e0dc0c8a1e6fec39f16794bfa..c4bf5a6dcacd3d17dd44ec07caf5402aee8f2226 100644 (file)
@@ -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});
index 004e768de3a3377a79d9af975b97f13a7fd9825b..184cb8928193beb804cf9bc031fc768dbde2f20c 100644 (file)
@@ -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]';
This page took 0.025422 seconds and 4 git commands to generate.