summaryrefslogtreecommitdiff
path: root/httemplate
diff options
context:
space:
mode:
Diffstat (limited to 'httemplate')
-rwxr-xr-xhttemplate/browse/cust_pay_batch.cgi6
-rw-r--r--httemplate/docs/schema.html10
-rw-r--r--httemplate/docs/upgrade10.html8
-rw-r--r--httemplate/misc/download-batch.cgi69
4 files changed, 87 insertions, 6 deletions
diff --git a/httemplate/browse/cust_pay_batch.cgi b/httemplate/browse/cust_pay_batch.cgi
index 0f05ecb25..6ee983ab4 100755
--- a/httemplate/browse/cust_pay_batch.cgi
+++ b/httemplate/browse/cust_pay_batch.cgi
@@ -3,7 +3,9 @@
<FORM ACTION="<%=$p%>misc/download-batch.cgi" METHOD="POST">
Download batch in format <SELECT NAME="format">
+<OPTION VALUE="">Default batch mode</OPTION>
<OPTION VALUE="csv-td_canada_trust-merchant_pc_batch">CSV file for TD Canada Trust Merchant PC Batch</OPTION>
+<OPTION VALUE="BoM">Bank of Montreal ECA results</OPTION>
</SELECT><INPUT TYPE="submit" VALUE="Download"></FORM>
<BR><BR>
@@ -11,7 +13,9 @@ Download batch in format <SELECT NAME="format">
Upload results<BR>
Filename <INPUT TYPE="file" NAME="batch_results"><BR>
Format <SELECT NAME="format">
+<OPTION VALUE="">Default batch mode</OPTION>
<OPTION VALUE="csv-td_canada_trust-merchant_pc_batch">CSV results from TD Canada Trust Merchant PC Batch</OPTION>
+<OPTION VALUE="BoM">Bank of Montreal ECA results</OPTION>
</SELECT><BR>
<INPUT TYPE="submit" VALUE="Upload"></FORM>
<BR>
@@ -47,7 +51,7 @@ $<%= sprintf("%.2f", $total) %> total in pending batch<BR>
foreach my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum }
qsearch('cust_pay_batch', {} )
) {
- my $cardnum = $cust_pay_batch->cardnum;
+ my $cardnum = $cust_pay_batch->payinfo;
#$cardnum =~ s/.{4}$/xxxx/;
$cardnum = 'x'x(length($cardnum)-4). substr($cardnum,(length($cardnum)-4));
diff --git a/httemplate/docs/schema.html b/httemplate/docs/schema.html
index cdb59a2e9..d9e35efc7 100644
--- a/httemplate/docs/schema.html
+++ b/httemplate/docs/schema.html
@@ -199,10 +199,16 @@
<li>amount
<li>_date
</ul>
- <li><a name="cust_pay_batch" href="man/FS/cust_pay_batch.html">cust_pay_batch</a> - Pending batch
+ <li><a name="pay_batch" href="man/FS/pay_batch.html">pay_batch</a> - Pending batch
+ <ul>
+ <li>batchnum
+ <li>status
+ </ul>
+ <li><a name="cust_pay_batch" href="man/FS/cust_pay_batch.html">cust_pay_batch</a> - Pending batch members
<ul>
<li>paybatchnum
- <li>cardnum
+ <li>batchnum
+ <li>payinfo - account number
<li>exp - card expiration
<li>amount
<li>invnum - <a href="#cust_bill">invoice</a>
diff --git a/httemplate/docs/upgrade10.html b/httemplate/docs/upgrade10.html
index 7cd1d8e50..2a4b0d975 100644
--- a/httemplate/docs/upgrade10.html
+++ b/httemplate/docs/upgrade10.html
@@ -46,6 +46,14 @@ DROP INDEX cust_bill_pkg1;
<pre>
ALTER TABLE cust_main ALTER COLUMN payinfo varchar(512) NULL;
ALTER TABLE h_cust_main ALTER COLUMN payinfo varchar(512) NULL;
+ALTER TABLE cust_pay_batch ADD COLUMN batchnum int NOT NULL;
+ALTER TABLE cust_pay_batch ALTER COLUMN batchnum SET NOT NULL;
+ALTER TABLE cust_pay_batch ADD COLUMN payinfo varchar(512) NULL;
+UPDATE cust_pay_batch SET payinfo = cardnum;
+ALTER TABLE cust_pay_batch DROP COLUMN cardnum;
+ALTER TABLE h_cust_pay_batch ADD COLUMN payinfo varchar(512) NULL;
+UPDATE h_cust_pay_batch SET payinfo = cardnum;
+ALTER TABLE h_cust_pay_batch DROP COLUMN cardnum;
</pre>
On older Pg versions that don't support altering columns directly, you will need to dump the database, edit the schema definitions in the dump file, and reload.
diff --git a/httemplate/misc/download-batch.cgi b/httemplate/misc/download-batch.cgi
index 306ef5d63..5a98f1d51 100644
--- a/httemplate/misc/download-batch.cgi
+++ b/httemplate/misc/download-batch.cgi
@@ -1,16 +1,79 @@
<%
+my $conf=new FS::Conf;
+
#http_header('Content-Type' => 'text/comma-separated-values' ); #IE chokes
http_header('Content-Type' => 'text/plain' );
+#need default
+my $formatconfig = "batchconfig".$cgi->param('format');
+
+die "No batch configuration exists.\n$formatconfig\n" unless $conf->exists($formatconfig);
+my $format = $conf->config($formatconfig);
+
+my $oldAutoCommit = $FS::UID::AutoCommit;
+local $FS::UID::AutoCommit = 0;
+my $dbh = dbh;
+
+my $pay_batch = qsearchs('pay_batch', {'status'=>''} );
+die "No pending batch. \n" unless $pay_batch;
+
+my %batchhash = $pay_batch->hash;
+$batchhash{'status'} = 'I';
+my $new = new FS::pay_batch \%batchhash;
+my $error = $new->replace($pay_batch);
+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]);
+
+if ($format eq "BoM") {
+ my($reformat,$origid,$datacenter,$typecode,$shortname,$longname,$mybank,$myacct) = $conf->config('batchconfig');
+ printf "A%10s%04u%06u%05u%54s\n",$origid,$pay_batch->batchnum,$jdate,$datacenter,"";
+ printf "XD%03u%06u%-15s%-30s%09u%-12s \n",$typecode,$jdate,$shortname,$longname,$mybank,$myacct;
+}elsif ($format eq "CSV file for TD Canada Trust Merchant PC Batch"){
+ 1;
+}else{
+ die "Unknown format for batch in batchconfig. \n";
+}
+
+
for my $cust_pay_batch ( sort { $a->paybatchnum <=> $b->paybatchnum }
- qsearch('cust_pay_batch', {} )
+ qsearch('cust_pay_batch',
+ {'batchnum'=>$pay_batch->batchnum} )
) {
$cust_pay_batch->exp =~ /^\d{2}(\d{2})[\/\-](\d+)[\/\-]\d+$/;
my( $mon, $y ) = ( $2, $1 );
$mon = "0$mon" if $mon < 10;
my $exp = "$mon$y";
+$batchcount++;
+$batchtotal += $cust_pay_batch->amount;
+
+if ($format eq "BoM") {
+ my( $account, $aba ) = split( '@', $cust_pay_batch->payinfo );
+ printf "D%010u%09u%-12s%-29s%-19s\n",$cust_pay_batch->amount*100,$aba,$account,$cust_pay_batch->payname,$cust_pay_batch->invnum;
+}elsif ($format eq "CSV file for TD Canada Trust Merchant PC Batch"){
+%>,,,,<%= $cust_pay_batch->payinfo %>,<%= $exp %>,<%= $cust_pay_batch->amount %>,<%= $cust_pay_batch->paybatchnum %>
+<% }else{
+ die "I'm already dead, but you did not know that.\n";
+}
+
+}
+
+if ($format eq "BoM") {
+ printf "YD%08u%014u%56s\n",$batchcount,$batchtotal*100,"";
+ printf "Z%014u%05u%014u%05u%41s\n",$batchtotal*100,$batchcount,"0","0","";
+}elsif ($format eq "CSV file for TD Canada Trust Merchant PC Batch"){
+ 1;
+} else{
+ die "I'm already dead (again), but you did not know that.\n";
+}
+
+$dbh->commit or die $dbh->errstr if $oldAutoCommit;
+
+%>
-%>,,,,<%= $cust_pay_batch->cardnum %>,<%= $exp %>,<%= $cust_pay_batch->amount %>,<%= $cust_pay_batch->paybatchnum %>
-<% } %>