[freeside-commits] freeside/FS/FS/ClientAPI MyAccount.pm, 1.53.2.15, 1.53.2.16
Ivan,,,
ivan at wavetail.420.am
Thu Jan 22 09:29:32 PST 2009
Update of /home/cvs/cvsroot/freeside/FS/FS/ClientAPI
In directory wavetail.420.am:/tmp/cvs-serv24922/FS/FS/ClientAPI
Modified Files:
Tag: FREESIDE_1_7_BRANCH
MyAccount.pm
Log Message:
add self-service methods renew_info, order_renew and process_payment_order_renew to enable self-renewal through self-service. RT#4623
Index: MyAccount.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/ClientAPI/MyAccount.pm,v
retrieving revision 1.53.2.15
retrieving revision 1.53.2.16
diff -u -d -r1.53.2.15 -r1.53.2.16
--- MyAccount.pm 9 Sep 2008 22:35:19 -0000 1.53.2.15
+++ MyAccount.pm 22 Jan 2009 17:29:30 -0000 1.53.2.16
@@ -478,6 +478,15 @@
order_pkg($p);
}
+sub process_payment_order_renew {
+ my $p = shift;
+
+ my $hr = process_payment($p);
+ return $hr if $hr->{'error'};
+
+ order_renew($p);
+}
+
sub process_prepay {
my $p = shift;
@@ -1006,6 +1015,64 @@
'';
}
+sub renew_info {
+ my $p = shift;
+
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
+
+ my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ or return { 'error' => "unknown custnum $custnum" };
+
+ my @cust_pkg = sort { $a->bill <=> $b->bill }
+ grep { $_->part_pkg->freq ne '0' }
+ $cust_main->ncancelled_pkgs;
+
+ #return { 'error' => 'No active packages to renew.' } unless @cust_pkg;
+
+ my $total = 0;
+
+ my @array = map {
+ $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' => $total,
+ };
+ }
+ @cust_pkg;
+
+ return { 'dates' => \@array };
+
+}
+
+sub order_renew {
+ my $p = shift;
+
+ my($context, $session, $custnum) = _custoragent_session_custnum($p);
+ return { 'error' => $session } if $context eq 'error';
+
+ my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } )
+ or return { 'error' => "unknown custnum $custnum" };
+
+ my $date = $p->{'date'};
+
+ my $now = time;
+
+ #freeside-daily -n -d $date fs_daily $custnum
+ $cust_main->bill_and_collect( 'time' => $date,
+ 'invoice_time' => $now,
+ 'actual_time' => $now,
+ 'check_freq' => '1d',
+ );
+
+ return { 'error' => '' };
+
+}
+
sub cancel_pkg {
my $p = shift;
my $session = _cache->get($p->{'session_id'})
More information about the freeside-commits
mailing list