+=item batch_download_formats
+
+returns a hash of batch download formats.
+
+my %download_formats = FS::pay_batch::batch_download_formats;
+
+=cut
+
+sub batch_download_formats {
+
+ my @formats = (
+ '' =>
+ 'Default batch mode',
+ 'NACHA' =>
+ '94 byte NACHA',
+ 'csv-td_canada_trust-merchant_pc_batch' =>
+ 'CSV file for TD Canada Trust Merchant PC Batch',
+ 'csv-chase_canada-E-xactBatch' =>
+ 'CSV file for Chase Canada E-xactBatch',
+ 'PAP' =>
+ '80 byte file for TD Canada Trust PAP Batch',
+ 'BoM' =>
+ 'Bank of Montreal ECA batch',
+ 'ach-spiritone' =>
+ 'Spiritone ACH batch',
+ 'paymentech' =>
+ 'XML file for Chase Paymentech',
+ 'RBC' =>
+ 'Royal Bank of Canada PDS batch',
+ 'td_eft1464' =>
+ '1464 byte file for TD Commercial Banking EFT',
+ 'eft_canada' =>
+ 'EFT Canada CSV batch',
+ 'CIBC' =>
+ '80 byte file for Canadian Imperial Bank of Commerce',
+ # insert new batch formats here
+ );
+
+}
+
+=item batch_download_formats
+
+returns a hash of batch download formats.
+
+my %download_formats = FS::pay_batch::batch_download_formats;
+
+=cut
+
+sub can_handle_electronic_refunds {
+
+ my $self = shift;
+ my $format = shift;
+ my $conf = new FS::Conf;
+
+ tie my %download_formats, 'Tie::IxHash', batch_download_formats;
+
+ my %paybatch_mods = (
+ 'NACHA' => 'nacha',
+ 'csv-td_canada_trust-merchant_pc_batch' => 'td_canada_trust',
+ 'csv-chase_canada-E-xactBatch' => 'chase-canada',
+ 'PAP' => 'PAP',
+ 'BoM' => 'BoM',
+ 'ach-spiritone' => 'ach_spiritone',
+ 'paymentech' => 'paymentech',
+ 'RBC' => 'RBC',
+ 'td_eft1464' => 'td_eft1464',
+ 'eft_canada' => 'eft_canada',
+ 'CIBC' => 'CIBC',
+ );
+
+ %download_formats = ( $format => $download_formats{$format}, ) if $format;
+
+ foreach my $key (keys %download_formats) {
+ my $mod = "FS::pay_batch::".$paybatch_mods{$key};
+ if ($mod->can('can_handle_credits')) {
+ return '1' if $conf->exists('batchconfig-'.$key);
+ }
+ }
+
+ return;
+
+}
+
+use FS::upgrade_journal;