[freeside-commits] freeside/FS/FS AccessRight.pm, 1.14,
1.15 Record.pm, 1.126, 1.127 Schema.pm, 1.35,
1.36 cust_main.pm, 1.254, 1.255 cust_pkg.pm, 1.67,
1.68 prepay_credit.pm, 1.8, 1.9 svc_acct.pm, 1.207,
1.208 svc_broadband.pm, 1.6, 1.7
Jeff Finucane,420,,
jeff at wavetail.420.am
Wed Dec 6 18:40:33 PST 2006
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail:/tmp/cvs-serv19099/FS/FS
Modified Files:
AccessRight.pm Record.pm Schema.pm cust_main.pm cust_pkg.pm
prepay_credit.pm svc_acct.pm svc_broadband.pm
Log Message:
retouch bandwidth countdown
Index: svc_broadband.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_broadband.pm,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- svc_broadband.pm 3 Mar 2004 13:42:08 -0000 1.6
+++ svc_broadband.pm 7 Dec 2006 02:40:31 -0000 1.7
@@ -154,12 +154,24 @@
|| $self->ut_number('speed_up')
|| $self->ut_number('speed_down')
|| $self->ut_ipn('ip_addr')
+ || $self->ut_hexn('mac_addr')
+ || $self->ut_numbern('vlan')
;
return $error if $error;
if($self->speed_up < 0) { return 'speed_up must be positive'; }
if($self->speed_down < 0) { return 'speed_down must be positive'; }
+ if($self->vlan < 0 || $self->vlan > 4096) { # apropos?
+ return 'vlan is out of range'; }
+
+ if($self->latitude < -90 || $self->latitude > 90) {
+ return 'latitude must be between -90 and 90';
+ }
+ if($self->longitude < -180 || $self->longitude > 180) {
+ return 'longitude must be between -180 and 180';
+ }
+
if (not($self->ip_addr) or $self->ip_addr eq '0.0.0.0') {
my $next_addr = $self->addr_block->next_free_addr;
if ($next_addr) {
Index: svc_acct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/svc_acct.pm,v
retrieving revision 1.207
retrieving revision 1.208
diff -u -d -r1.207 -r1.208
--- svc_acct.pm 30 Nov 2006 02:27:54 -0000 1.207
+++ svc_acct.pm 7 Dec 2006 02:40:31 -0000 1.208
@@ -1431,10 +1431,90 @@
}
+sub set_usage {
+ my( $self, $valueref ) = @_;
+
+ warn "$me set_usage called for svcnum ". $self->svcnum.
+ ' ('. $self->email. "): ".
+ join(', ', map { "$_ => " . $valueref->{$_}} keys %$valueref) . "\n"
+ if $DEBUG;
+
+ local $SIG{HUP} = 'IGNORE';
+ local $SIG{INT} = 'IGNORE';
+ local $SIG{QUIT} = 'IGNORE';
+ local $SIG{TERM} = 'IGNORE';
+ local $SIG{TSTP} = 'IGNORE';
+ local $SIG{PIPE} = 'IGNORE';
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+
+ if ( $conf->exists("svc_acct-usage_unsuspend") ) {
+ my $error = $self->cust_svc->cust_pkg->unsuspend;
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ return "Error unsuspending: $error";
+ }
+ }
+
+ foreach my $field (keys %$valueref){
+ $self->setfield($field, $valueref->{$field});
+ $self->setfield( $field.'_threshold',
+ int($self->getfield($field)
+ * ( $conf->exists('svc_acct-usage_threshold')
+ ? 1 - $conf->config('svc_acct-usage_threshold')/100
+ : 0.20
+ )
+ )
+ );
+ }
+ my $error = $self->replace;
+ die $error if $error;
+
+ warn "$me update successful; committing\n"
+ if $DEBUG;
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ '';
+
+}
+
+
+=item recharge HASHREF
+
+ Increments usage columns by the amount specified in HASHREF as
+ column=>amount pairs.
+
+=cut
+
+sub recharge {
+ my ($self, $vhash) = @_;
+
+ if ( $DEBUG ) {
+ warn "[$me] recharge called on $self: ". Dumper($self).
+ "\nwith vhash: ". Dumper($vhash);
+ }
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ my $dbh = dbh;
+ my $error = '';
+
+ foreach my $column (keys %$vhash){
+ $error ||= $self->_op_usage('+', $column, $vhash->{$column});
+ }
+
+ if ( $error ) {
+ $dbh->rollback if $oldAutoCommit;
+ }else{
+ $dbh->commit or die $dbh->errstr if $oldAutoCommit;
+ }
+ return $error;
+}
=item is_rechargeable
-Returns true if this svc_account can be "rechaged" and false otherwise.
+Returns true if this svc_account can be "recharged" and false otherwise.
=cut
@@ -1956,7 +2036,7 @@
}elsif ( $opt{'op'} eq '-' ){
my $threshold = $svc_acct->getfield( $opt{'column'}.'_threshold' );
- return '' if ($threshold eq '' && opt{'column'} eq 'totalbytes');
+ return '' if ($threshold eq '' );
$svc_acct->setfield( $opt{'column'}.'_threshold', 0 );
my $error = $svc_acct->replace;
Index: cust_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_pkg.pm,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- cust_pkg.pm 27 Oct 2006 19:10:21 -0000 1.67
+++ cust_pkg.pm 7 Dec 2006 02:40:31 -0000 1.68
@@ -1452,6 +1452,26 @@
return $cust_pkg_reason->insert;
}
+=item set_usage USAGE_VALUE_HASHREF
+
+USAGE_VALUE_HASHREF is a hashref of svc_acct usage columns and the amounts
+to which they should be set (see L<FS::svc_acct>). Currently seconds,
+upbytes, downbytes, and totalbytes are appropriate keys.
+
+All svc_accts which are part of this package have their values reset.
+
+=cut
+
+sub set_usage {
+ my ($self, $valueref) = @_;
+
+ foreach my $cust_svc ($self->cust_svc){
+ my $svc_x = $cust_svc->svc_x;
+ $svc_x->set_usage($valueref)
+ if $svc_x->can("set_usage");
+ }
+}
+
=back
=head1 BUGS
Index: prepay_credit.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/prepay_credit.pm,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- prepay_credit.pm 18 Feb 2006 02:11:44 -0000 1.8
+++ prepay_credit.pm 7 Dec 2006 02:40:31 -0000 1.9
@@ -110,6 +110,9 @@
|| $self->ut_alpha('identifier')
|| $self->ut_money('amount')
|| $self->ut_numbern('seconds')
+ || $self->ut_numbern('upbytes')
+ || $self->ut_numbern('downbytes')
+ || $self->ut_numbern('totalbytes')
|| $self->ut_foreign_keyn('agentnum', 'agent', 'agentnum')
|| $self->SUPER::check
;
Index: cust_main.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_main.pm,v
retrieving revision 1.254
retrieving revision 1.255
diff -u -d -r1.254 -r1.255
--- cust_main.pm 3 Dec 2006 00:42:23 -0000 1.254
+++ cust_main.pm 7 Dec 2006 02:40:31 -0000 1.255
@@ -708,7 +708,7 @@
sub recharge_prepay {
my( $self, $prepay_credit, $amountref, $secondsref,
- $upbytesref, $downbytesref ) = @_;
+ $upbytesref, $downbytesref, $totalbytesref ) = @_;
local $SIG{HUP} = 'IGNORE';
local $SIG{INT} = 'IGNORE';
@@ -721,14 +721,14 @@
local $FS::UID::AutoCommit = 0;
my $dbh = dbh;
- my( $amount, $seconds, $upbytes, $downbytes ) = ( 0, 0, 0, 0 );
+ my( $amount, $seconds, $upbytes, $downbytes, $totalbytes) = ( 0, 0, 0, 0, 0 );
my $error = $self->get_prepay($prepay_credit, \$amount,
- \$seconds, \$upbytes, \$downbytes)
+ \$seconds, \$upbytes, \$downbytes, \$totalbytes)
|| $self->increment_seconds($seconds)
|| $self->increment_upbytes($upbytes)
|| $self->increment_downbytes($downbytes)
- || $self->increment_totalbytes($upbytes + $downbytes)
+ || $self->increment_totalbytes($totalbytes)
|| $self->insert_cust_pay_prepay( $amount,
ref($prepay_credit)
? $prepay_credit->identifier
@@ -744,6 +744,7 @@
if ( defined($secondsref) ) { $$secondsref = $seconds; }
if ( defined($upbytesref) ) { $$upbytesref = $upbytes; }
if ( defined($downbytesref) ) { $$downbytesref = $downbytes; }
+ if ( defined($totalbytesref) ) { $$totalbytesref = $totalbytes; }
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';
@@ -767,7 +768,8 @@
sub get_prepay {
- my( $self, $prepay_credit, $amountref, $secondsref, $upref, $downref) = @_;
+ my( $self, $prepay_credit, $amountref, $secondsref,
+ $upref, $downref, $totalref) = @_;
local $SIG{HUP} = 'IGNORE';
local $SIG{INT} = 'IGNORE';
@@ -816,6 +818,7 @@
$$secondsref += $prepay_credit->seconds;
$$upref += $prepay_credit->upbytes;
$$downref += $prepay_credit->downbytes;
+ $$totalref += $prepay_credit->totalbytes;
$dbh->commit or die $dbh->errstr if $oldAutoCommit;
'';
Index: Record.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Record.pm,v
retrieving revision 1.126
retrieving revision 1.127
diff -u -d -r1.126 -r1.127
--- Record.pm 23 Oct 2006 06:38:30 -0000 1.126
+++ Record.pm 7 Dec 2006 02:40:30 -0000 1.127
@@ -1456,6 +1456,33 @@
'';
}
+=item ut_hex COLUMN
+
+Check/untaint hexadecimal values.
+
+=cut
+
+sub ut_hex {
+ my($self, $field) = @_;
+ $self->getfield($field) =~ /^([\da-fA-F]+)$/
+ or return "Illegal (hex) $field: ". $self->getfield($field);
+ $self->setfield($field, uc($1));
+ '';
+}
+
+=item ut_hexn COLUMN
+
+Check/untaint hexadecimal values. May be null.
+
+=cut
+
+sub ut_hexn {
+ my($self, $field) = @_;
+ $self->getfield($field) =~ /^([\da-fA-F]*)$/
+ or return "Illegal (hex) $field: ". $self->getfield($field);
+ $self->setfield($field, uc($1));
+ '';
+}
=item ut_ip COLUMN
Check/untaint ip addresses. IPv4 only for now.
Index: Schema.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Schema.pm,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- Schema.pm 30 Nov 2006 02:27:54 -0000 1.35
+++ Schema.pm 7 Dec 2006 02:40:30 -0000 1.36
@@ -932,6 +932,7 @@
'seconds', 'int', 'NULL', '', '', '',
'upbytes', 'int', 'NULL', '', '', '',
'downbytes', 'int', 'NULL', '', '', '',
+ 'totalbytes', 'int', 'NULL', '', '', '',
'agentnum', 'int', 'NULL', '', '', '',
],
'primary_key' => 'prepaynum',
@@ -1144,6 +1145,10 @@
'speed_up', 'int', '', '', '', '',
'speed_down', 'int', '', '', '', '',
'ip_addr', 'varchar', '', 15, '', '',
+ 'mac_addr', 'varchar', 'NULL', 12, '', '',
+ 'latitude', 'decimal', 'NULL', '', '', '',
+ 'longitude', 'decimal', 'NULL', '', '', '',
+ 'vlan', 'int', 'NULL', '', '', '',
],
'primary_key' => 'svcnum',
'unique' => [],
Index: AccessRight.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/AccessRight.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- AccessRight.pm 30 Nov 2006 02:27:54 -0000 1.14
+++ AccessRight.pm 7 Dec 2006 02:40:30 -0000 1.15
@@ -114,6 +114,7 @@
###
# customer service rights
###
+ 'Edit usage',
'Provision customer service',
'Recharge customer service',
'Unprovision customer service',
More information about the freeside-commits
mailing list