]> Dogcows Code - chaz/homebank/blob - plugins/transfer-matcher.pl
add plugin engine (supports C and Perl plugins)
[chaz/homebank] / plugins / transfer-matcher.pl
1
2 # NAME: Transfer Matcher
3 # VERSION: 0.01
4 # ABSTRACT: Automatically find and pair together internal transfers.
5 # AUTHOR: Charles McGarvey <chazmcgarvey@brokenzipper.com>
6 # WEBSITE: http://www.homebank.free.fr/
7
8 eval { HomeBank->version } or die "Cannot run outside of HomeBank";
9
10 use warnings FATAL => 'all';
11 use strict;
12
13 my $days = 3;
14
15 sub on_transaction_inserted {
16 my ($self, $txn) = @_;
17
18 my @match = grep {
19 $txn->account_num != $_->account_num &&
20 $txn->amount == -$_->amount &&
21 abs($txn->date - $_->date) <= $days
22 } HomeBank::File->transactions;
23
24 return unless @match;
25
26 $txn->pair_with(@match);
27 }
28
This page took 0.032366 seconds and 4 git commands to generate.