72219: High-Priority: Electronic Check Batches, BillBuddy [download fixes]
[Business-BatchPayment-BillBuddy.git] / BillBuddy.pm
index 3b125e7..8eb4860 100644 (file)
@@ -134,7 +134,7 @@ sub format_item {
   #18-18 1 blank, filled with space 
   $line .= ' ';
   #19-28 10 amount, numbers only, by cents, zero padded to the left 
-  $line .= sprintf("%10s",$item->amount * 100);
+  $line .= sprintf("%010s",$item->amount * 100);
   #29-30 2 blank, filled with spaces 
   $line .= '  ';
   #31-32 2 account type: "BC" for bank account, "CC" for credit card account 
@@ -165,6 +165,7 @@ sub format_item {
   $line .= $cnum;
   #67-98 32 bank account name or name on the credit card 
   my $name = $item->first_name . ' ' . $item->last_name;
+  $name =~ s/\'//g; # gateway should be handling this, but it's not
   $line .= sprintf("%-32.32s",$name);
   #99-99 1 blank 
   $line .= ' ';
@@ -337,7 +338,7 @@ sub download {
       my $error = '';
       next if grep(/^$status$/,('submitted','processing','scheduled'));
       $error = "Unknown return status: $status"
-        unless grep(/^$status$/,('deleted','declined'));
+        unless grep(/^$status$/,('approved','deleted','declined'));
       my $item = Business::BatchPayment->create(Item =>
         order_number  => $tid,
         tid           => $resp->{'ResponseData'}->{'referencenumber'},
@@ -346,7 +347,15 @@ sub download {
         authorization => '',
       );
       if ($resp->{'ResponseData'}->{'actualprocessdate'} =~ /^(\d\d\d\d).(\d\d).(\d\d)/) {
-        $item->payment_date($1.'-'.$2.'-'.$3);
+        $item->payment_date(
+          DateTime->new(
+            year      => $1,
+            month     => $2,
+            day       => $3,
+            # this appears to be the tz being passed by BillBuddy
+            time_zone => 'Australia/Queensland',
+          )
+        );
       } else {
         warn "Could not parse actualprocessdate ".$resp->{'ResponseData'}->{'actualprocessdate'};
       }