add payment_info_renew_info method to ClientAPI/MyAccount and SG-equivalent previous_...
authorivan <ivan>
Tue, 17 Mar 2009 21:38:39 +0000 (21:38 +0000)
committerivan <ivan>
Tue, 17 Mar 2009 21:38:39 +0000 (21:38 +0000)
FS/FS/ClientAPI/MyAccount.pm
FS/FS/ClientAPI/SGNG.pm
fs_selfservice/FS-SelfService/SelfService.pm

index c6a4e00..564acb1 100644 (file)
@@ -1162,11 +1162,14 @@ sub renew_info {
                     $total += $_->part_pkg->base_recur;
                     my $renew_date = $_->part_pkg->add_freq($_->bill);
                     {
-                      'bill_date'         => $_->bill,
-                      'bill_date_pretty'  => time2str('%x', $_->bill),
-                      'renew_date'        => $renew_date,
-                      'renew_date_pretty' => time2str('%x', $renew_date),
-                      'amount'            => sprintf('%.2f', $total),
+                      'pkgnum'             => $_->pkgnum,
+                      'amount'             => sprintf('%.2f', $total),
+                      'bill_date'          => $_->bill,
+                      'bill_date_pretty'   => time2str('%x', $_->bill),
+                      'renew_date'         => $renew_date,
+                      'renew_date_pretty'  => time2str('%x', $renew_date),
+                      'expire_date'        => $_->expire,
+                      'expire_date_pretty' => time2str('%x', $_->expire),
                     };
                   }
                   @cust_pkg;
@@ -1175,6 +1178,15 @@ sub renew_info {
 
 }
 
+sub payment_info_renew_info {
+  my $p = shift;
+  my $renew_info   = renew_info($p);
+  my $payment_info = payment_info($p);
+  return { %$renew_info,
+           %$payment_info,
+         };
+}
+
 sub order_renew {
   my $p = shift;
 
index 6f74e23..872148a 100644 (file)
@@ -7,6 +7,7 @@ use vars qw( $cache $DEBUG );
 use Time::Local qw(timelocal timelocal_nocheck);
 use Business::CreditCard;
 use FS::Record qw( qsearch qsearchs );
+use FS::Conf;
 use FS::cust_main;
 use FS::cust_pkg;
 use FS::ClientAPI::MyAccount; #qw( payment_info process_payment )
@@ -158,6 +159,10 @@ sub _cust_main_payment_info {
 
 #find old cust_main records (with payments)
 sub _previous_cust_main {
+
+  #safety check!  return nothing unless we're enabled explicitly
+  return () unless FS::Conf->new->exists('sg-multicustomer_hack');
+
   my %opt = @_;
   my $custnum  = $opt{'custnum'};
   my $username = $opt{'username'};
@@ -225,6 +230,15 @@ sub previous_process_payment {
 
 }
 
+sub previous_payment_info_renew_info {
+  my $p = shift;
+  my $renew_info   = renew_info($p);
+  my $payment_info = previous_payment_info($p);
+  return { %$renew_info,
+           %$payment_info,
+         };
+}
+
 sub previous_process_payment_order_pkg {
   my $p = shift;
 
index fda3e85..b4b9ecf 100644 (file)
@@ -944,6 +944,20 @@ Specified as a integer UNIX timestamp.
 Renewal date as a human-readable string.  (Convenience for display;
 subject to change, so best not to parse for the date.)
 
+=item pkgnum
+
+Package that will be renewed.
+
+=item expire_date
+
+Expiration date of the package that will be renewed.
+
+=item expire_date_pretty
+
+Expiration date of the package that will be renewed, as a human-readable
+string.  (Convenience for display; subject to change, so best not to parse for
+the date.)
+
 =back
 
 =item order_renew