add debugging to agent.cgi, make sure warnings are turned off when parsing templates...
[freeside.git] / FS / FS / ClientAPI / MyAccount.pm
index 6caa197..58ab6c0 100644 (file)
@@ -238,7 +238,7 @@ sub payment_info {
 
   #list all counties/states/countries
   $return{'cust_main_county'} = 
-      [ map { $_->hashref } qsearch('cust_main_county', {}) ],
+      [ map { $_->hashref } qsearch('cust_main_county', {}) ];
 
   #shortcut for one-country folks
   my $conf = new FS::Conf;
@@ -541,6 +541,11 @@ sub order_pkg {
 
     if ( $cust_main->balance > $old_balance
          && $cust_main->payby !~ /^(BILL|DCRD|DCHK)$/ ) {
+      #this makes sense.  credit is "un-doing" the invoice
+      $cust_main->credit( sprintf("%.2f", $cust_main->balance - $old_balance ),
+                          'self-service decline' );
+      $cust_main->apply_credits( 'order' => 'newest' );
+
       $cust_pkg->cancel('quiet'=>1);
       return { 'error' => '_decline' };
     } else {