summaryrefslogtreecommitdiff
path: root/httemplate/misc/download-batch.cgi
diff options
context:
space:
mode:
authorjeff <jeff>2006-08-09 06:43:02 +0000
committerjeff <jeff>2006-08-09 06:43:02 +0000
commit6c375156081be5d2023001ed8eaac9b6db568e95 (patch)
tree2fc0676f8f6facd38773035e4a22ba23fd7d85ed /httemplate/misc/download-batch.cgi
parentb58e61ac7df612f606c3e68371265e790e0be585 (diff)
batch refactor
Diffstat (limited to 'httemplate/misc/download-batch.cgi')
-rw-r--r--httemplate/misc/download-batch.cgi37
1 files changed, 32 insertions, 5 deletions
diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi
index 6172b1335..2c6481493 100644
--- a/httemplate/misc/download-batch.cgi
+++ b/httemplate/misc/download-batch.cgi
@@ -5,6 +5,13 @@ my $conf=new FS::Conf;
#http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes
http_header('Content-Type' => 'text/plain' );
+my $batchnum;
+if ( $cgi->param('batchnum') =~ /^(\d+)$/ ) {
+ $batchnum = $1;
+} else {
+ die "No batch number (bad URL) \n";
+}
+
my $format;
if ( $cgi->param('format') =~ /^([\w\- ]+)$/ ) {
$format = $1;
@@ -16,11 +23,12 @@ my $oldAutoCommit = $FS::UID::AutoCommit;
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
-my $pay_batch = qsearchs('pay_batch', {'status'=>'O'} );
+my $pay_batch = qsearchs('pay_batch', {'batchnum'=>$batchnum, 'status'=>'O'} );
die "No pending batch. \n" unless $pay_batch;
my %batchhash = $pay_batch->hash;
$batchhash{'status'} = 'I';
+$batchhash{'download'} = time unless $batchhash{'download'};
my $new = new FS::pay_batch \%batchhash;
my $error = $new->replace($pay_batch);
die "error updating batch status: $error\n" if $error;
@@ -28,8 +36,10 @@ die "error updating batch status: $error\n" if $error;
my $batchtotal=0;
my $batchcount=0;
-my (@date)=localtime();
-my $jdate = sprintf("%03d", $date[5] % 100).sprintf("%03d", $date[7]);
+my (@date)=localtime($new->download);
+my $jdate = sprintf("%03d", $date[5] % 100).sprintf("%03d", $date[7] + 1);
+my $cdate = sprintf("%02d", $date[3]).sprintf("%02d", $date[4] + 1).
+ sprintf("%02d", $date[5] % 100);
if ($format eq "BoM") {
@@ -39,6 +49,14 @@ if ($format eq "BoM") {
sprintf( "XD%03u%06u%-15s%-30s%09u%-12s \n",$typecode,$jdate,$shortname,$longname,$mybank,$myacct )
%><%
+}elsif ($format eq "PAP"){
+
+ my($origid,$datacenter,$typecode,$shortname,$longname,$mybank,$myacct) =
+ $conf->config("batchconfig-$format");
+ %><%= sprintf( "H%10sD%3s%06u%-15s%09u%-12s%04u%19s\n",$origid,$typecode,$cdate,$shortname,$mybank,$myacct,$pay_batch->batchnum,"")
+
+ %><%
+
}elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){
# 1;
}else{
@@ -61,7 +79,12 @@ for my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum }
if ($format eq "BoM") {
my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo );
- %><%= sprintf( "D%010u%09u%-12s%-29s%-19s\n",$cust_pay_batch->amount*100,$aba,$account,$cust_pay_batch->payname,$cust_pay_batch->invnum %><%
+ %><%= sprintf( "D%010.0f%09u%-12s%-29s%-19s\n",$cust_pay_batch->amount*100,$aba,$account,$cust_pay_batch->payname,$cust_pay_batch->paybatchnum) %><%
+
+ } elsif ($format eq "PAP"){
+
+ my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo );
+ %><%= sprintf( "D%-23s%06u%-19s%09u%-12s%010.0f\n",$cust_pay_batch->payname,$cdate,$cust_pay_batch->paybatchnum,$aba,$account,$cust_pay_batch->amount*100) %><%
} elsif ($format eq "csv-td_canada_trust-merchant_pc_batch") {
@@ -75,9 +98,13 @@ for my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum }
if ($format eq "BoM") {
- %><%= sprintf( "YD%08u%014u%56s\n",$batchcount,$batchtotal*100,"" ).
+ %><%= sprintf( "YD%08u%014.0f%56s\n",$batchcount,$batchtotal*100,"" ).
sprintf( "Z%014u%05u%014u%05u%41s\n",$batchtotal*100,$batchcount,"0","0","" ) %><%
+} elsif ($format eq "PAP"){
+
+ %><%= sprintf( "T%08u%014.0f%57s\n",$batchcount,$batchtotal*100,"" ) %><%
+
} elsif ($format eq "csv-td_canada_trust-merchant_pc_batch"){
#1;
} else {