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});
+ my $date = $transaction->{date};
+ my $code = $transaction->{paymode} =~ /^(?:check|epayment)$/ ? $transaction->{info}
+ : undef;
my @postings;
push @postings, {
+ date => $date,
account => $account->{ledger_name},
amount => $amount,
commodity => $commodities{$account->{currency}},
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});
$seen{$transaction->{transfer_key}}++ if $transaction->{transfer_key};
$seen{$paired_transaction->{transfer_key}}++ if $paired_transaction->{transfer_key};
+ my $paired_date = $paired_transaction && $paired_transaction->{date};
my $paired_payee = $homebank->find_payee_by_key($paired_transaction->{payee});
push @postings, {
+ date => $paired_date,
account => $dst_account->{ledger_name},
amount => $paired_transaction->{amount} || -$transaction->{amount},
commodity => $commodities{$dst_account->{currency}},
};
}
}
- else { # with or without category
+ else { # normal transaction with or without category
my $amount = -$transaction->{amount};
my $category = $homebank->find_category_by_key($transaction->{category});
my $other_account = $category ? $category->{ledger_name}
}
$ledger->add_transactions({
- date => $transaction->{date},
+ date => $date,
payee => $payee->{name},
+ code => $code,
memo => $memo,
postings => \@postings,
});