X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpay_batch.pm;h=86ef7b07425b4a34524aa32cb4626e09f878b855;hb=63a101757552ee54c300317c2e9ae87f5fb396ba;hp=069105a4eb13f5546e23e98adcf298fb7a613e39;hpb=a014f2e125028a5a80c0587f36df5e865b70b47f;p=freeside.git diff --git a/FS/FS/pay_batch.pm b/FS/FS/pay_batch.pm index 069105a4e..86ef7b074 100644 --- a/FS/FS/pay_batch.pm +++ b/FS/FS/pay_batch.pm @@ -6,6 +6,7 @@ use Time::Local; use Text::CSV_XS; use FS::Record qw( dbh qsearch qsearchs ); use FS::cust_pay; +use FS::part_bill_event qw(due_events); @ISA = qw(FS::Record); @@ -137,7 +138,7 @@ sub set_status { $self->replace(); } -=item import results OPTION => VALUE, ... +=item import_results OPTION => VALUE, ... Import batch results. @@ -145,14 +146,14 @@ Options are: I - open filehandle of results file. -I - "csv-td_canada_trust-merchant_pc_batch", "csv-chase_canada-E-xactBatch" or "PAP" +I - "csv-td_canada_trust-merchant_pc_batch", "csv-chase_canada-E-xactBatch", "ach-spiritone", or "PAP" =cut sub import_results { my $self = shift; - my $param = @_; + my $param = ref($_[0]) ? shift : { @_ }; my $fh = $param->{'filehandle'}; my $format = $param->{'format'}; @@ -333,6 +334,40 @@ sub import_results { 0; }; + }elsif ( $format eq 'ach-spiritone' ) { + + $filetype = "CSV"; + + @fields = ( + '', # Name + 'paybatchnum', # ID: Number of the transaction + 'aba', # ABA Number for the transaction + 'payinfo', # Bank Account Number for the transaction + '', # Transaction Type: 27 - debit + 'paid', # Amount: Amount of the transaction. Dollars and cents + # with decimal entered. + '', # Default Transaction Type + '', # Default Amount: Dollars and cents with decimal entered. + ); + + $end_condition = sub { + ''; + }; + + $hook = sub { + my $hash = shift; + $hash->{'_date'} = time; # got a better one? + $hash->{'payinfo'} = $hash->{'payinfo'} . '@' . $hash->{'aba'}; + }; + + $approved_condition = sub { + 1; + }; + + $declined_condition = sub { + 0; + }; + } else { return "Unknown format $format"; @@ -359,11 +394,6 @@ sub import_results { }; my $error = $self->set_status('R'); - - my $newbatch = new FS::pay_batch { $self->hash }; - $newbatch->status('R'); # Resolved - $newbatch->upload(time); - my $error = $newbatch->replace($self); if ( $error ) { $dbh->rollback if $oldAutoCommit; return $error