[freeside-commits] branch FREESIDE_2_3_BRANCH updated. defe558a286bbf46375c903c0aaef706b3071798
Ivan
ivan at 420.am
Tue Dec 4 08:59:48 PST 2012
The branch, FREESIDE_2_3_BRANCH has been updated
via defe558a286bbf46375c903c0aaef706b3071798 (commit)
from 475fd095e28f492075cdf4e7f95f4fdbf7777075 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit defe558a286bbf46375c903c0aaef706b3071798
Author: Ivan Kohler <ivan at freeside.biz>
Date: Tue Dec 4 08:59:47 2012 -0800
prepaid API respects pkg-balances config, RT#19560
diff --git a/FS/FS/ClientAPI/PrepaidPhone.pm b/FS/FS/ClientAPI/PrepaidPhone.pm
index c346179..c7317ea 100644
--- a/FS/FS/ClientAPI/PrepaidPhone.pm
+++ b/FS/FS/ClientAPI/PrepaidPhone.pm
@@ -3,6 +3,7 @@ package FS::ClientAPI::PrepaidPhone;
use strict;
use vars qw($DEBUG $me);
use FS::Record qw(qsearchs);
+use FS::Conf;
use FS::rate;
use FS::svc_phone;
@@ -156,11 +157,15 @@ sub call_time {
return \%return;
}
+ my $conf = new FS::Conf;
+ my $balance = $conf->config_bool('pkg-balances') ? $cust_pkg->balance
+ : $cust_main->balance;
+
#XXX granularity? included minutes? another day...
- if ( $cust_main->balance >= 0 ) {
+ if ( $balance >= 0 ) {
return { 'error'=>'No balance' };
} else {
- $return{'seconds'} = int(60 * abs($cust_main->balance) / $rate_detail->min_charge);
+ $return{'seconds'} = int(60 * abs($balance) / $rate_detail->min_charge);
}
warn "$me returning seconds: ". $return{'seconds'};
@@ -248,13 +253,18 @@ sub phonenum_balance {
my $cust_pkg = $svc_phone->cust_svc->cust_pkg;
- warn "$me returning ". $cust_pkg->cust_main->balance.
- " balance for custnum ". $cust_pkg->custnum
+ my $conf = new FS::Conf;
+ my $balance = $conf->config_bool('pkg-balances')
+ ? $cust_pkg->balance
+ : $cust_pkg->cust_main->balance;
+
+ warn "$me returning $balance balance for pkgnum ". $cust_pkg->pkgnum.
+ ", custnum ". $cust_pkg->custnum
if $DEBUG;
return {
'custnum' => $cust_pkg->custnum,
- 'balance' => $cust_pkg->cust_main->balance,
+ 'balance' => $balance,
};
}
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index fb774c6..b48fcd0 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -2572,6 +2572,18 @@ sub cust_main {
qsearchs( 'cust_main', { 'custnum' => $self->custnum } );
}
+=item balance
+
+Returns the balance for this specific package, when using
+experimental package balance.
+
+=cut
+
+sub balance {
+ my $self = shift;
+ $self->cust_main->balance_pkgnum( $self->pkgnum );
+}
+
#these subs are in location_Mixin.pm now... unfortunately the POD doesn't mixin
=item cust_location
-----------------------------------------------------------------------
Summary of changes:
FS/FS/ClientAPI/PrepaidPhone.pm | 20 +++++++++++++++-----
FS/FS/cust_pkg.pm | 12 ++++++++++++
2 files changed, 27 insertions(+), 5 deletions(-)
More information about the freeside-commits
mailing list