]> Dogcows Code - chaz/homebank/blobdiff - plugins/transfer-matcher.pl
add plugin engine (supports C and Perl plugins)
[chaz/homebank] / plugins / transfer-matcher.pl
diff --git a/plugins/transfer-matcher.pl b/plugins/transfer-matcher.pl
new file mode 100644 (file)
index 0000000..d173990
--- /dev/null
@@ -0,0 +1,28 @@
+
+# NAME:     Transfer Matcher
+# VERSION:  0.01
+# ABSTRACT: Automatically find and pair together internal transfers.
+# AUTHOR:   Charles McGarvey <chazmcgarvey@brokenzipper.com>
+# WEBSITE:  http://www.homebank.free.fr/
+
+eval { HomeBank->version } or die "Cannot run outside of HomeBank";
+
+use warnings FATAL => 'all';
+use strict;
+
+my $days = 3;
+
+sub on_transaction_inserted {
+    my ($self, $txn) = @_;
+
+    my @match = grep {
+        $txn->account_num != $_->account_num &&
+        $txn->amount == -$_->amount &&
+        abs($txn->date - $_->date) <= $days
+    } HomeBank::File->transactions;
+
+    return unless @match;
+
+    $txn->pair_with(@match);
+}
+
This page took 0.025901 seconds and 4 git commands to generate.