[freeside-commits] freeside/FS/FS/part_event/Condition svc_acct_overlimit.pm, NONE, 1.1 svc_acct_threshold.pm, NONE, 1.1 pkg_status.pm, 1.2, 1.3
Mark Wells
mark at wavetail.420.am
Wed Aug 31 22:13:10 PDT 2011
- Previous message: [freeside-commits] freeside/FS/FS/part_event/Action svc_acct_notice.pm, NONE, 1.1 pkg_cancel.pm, 1.1, 1.2 pkg_suspend.pm, 1.1, 1.2
- Next message: [freeside-commits] freeside/FS/FS msg_template.pm, 1.22, 1.23 part_event.pm, 1.4, 1.5 svc_Common.pm, 1.62, 1.63
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /home/cvs/cvsroot/freeside/FS/FS/part_event/Condition
In directory wavetail.420.am:/tmp/cvs-serv1936/FS/FS/part_event/Condition
Modified Files:
pkg_status.pm
Added Files:
svc_acct_overlimit.pm svc_acct_threshold.pm
Log Message:
svc_acct events for usage limits, #13202
--- NEW FILE: svc_acct_overlimit.pm ---
package FS::part_event::Condition::svc_acct_overlimit;
use strict;
use FS::svc_acct;
use base qw( FS::part_event::Condition );
sub description { 'Service is over its usage limit' };
sub eventtable_hashref {
{ 'svc_acct' => 1 }
}
tie my %usage_types, 'Tie::IxHash', (
'seconds' => 'Time',
'upbytes' => 'Upload',
'downbytes' => 'Download',
'totalbytes'=> 'Total transfer',
);
sub option_fields {
(
'usage_types' => {
type => 'checkbox-multiple',
options => [ keys %usage_types ],
option_labels => \%usage_types,
},
);
}
sub condition {
my($self, $svc_acct) = @_;
my $types = $self->option('usage_types') || {};
foreach my $column (keys %$types) {
# don't trigger if this type of usage isn't tracked on the service
next if $svc_acct->$column eq '';
return 1 if ( $svc_acct->$column <= 0 );
}
return 0;
}
sub condition_sql {
my($self) = @_;
# not an exact condition_sql--ignores the usage_types option
'(' . join(' OR ',
map {
"( svc_acct.$_ IS NOT NULL AND svc_acct.$_ <= 0 )"
} keys %usage_types
) . ')'
}
1;
--- NEW FILE: svc_acct_threshold.pm ---
package FS::part_event::Condition::svc_acct_threshold;
use strict;
use FS::svc_acct;
use base qw( FS::part_event::Condition );
sub description { 'Service is over its usage warning threshold' };
sub eventtable_hashref {
{ 'svc_acct' => 1 }
}
tie my %usage_types, 'Tie::IxHash', (
'seconds' => 'Time',
'upbytes' => 'Upload',
'downbytes' => 'Download',
'totalbytes'=> 'Total transfer',
);
sub option_fields {
(
'usage_types' => {
type => 'checkbox-multiple',
options => [ keys %usage_types ],
option_labels => \%usage_types,
},
);
}
sub condition {
my($self, $svc_acct) = @_;
my $types = $self->option('usage_types') || {};
foreach my $column (keys %$types) {
# don't trigger if this type of usage isn't tracked on the service
next if $svc_acct->$column eq '';
my $threshold;
my $method = $column.'_threshold';
$threshold = $svc_acct->$method;
# don't trigger if seconds = 0 and seconds_threshold is null
next if $threshold eq '';
return 1 if ( $svc_acct->$column <= $threshold );
}
return 0;
}
sub condition_sql {
my($self) = @_;
# not an exact condition_sql--ignores the usage_types option
'(' . join(' OR ',
map {
my $threshold = $_.'_threshold';
"( svc_acct.$_ IS NOT NULL AND svc_acct.$threshold IS NOT NULL AND ".
"svc_acct.$_ <= svc_acct.$threshold )"
} keys %usage_types
) . ')'
}
1;
Index: pkg_status.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_event/Condition/pkg_status.pm,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -w -d -r1.2 -r1.3
--- pkg_status.pm 14 Oct 2010 00:59:07 -0000 1.2
+++ pkg_status.pm 1 Sep 2011 05:13:08 -0000 1.3
@@ -13,6 +13,7 @@
{ 'cust_main' => 0,
'cust_bill' => 0,
'cust_pkg' => 1,
+ 'svc_acct' => 1,
};
}
@@ -27,8 +28,9 @@
}
sub condition {
- my( $self, $cust_pkg ) = @_;
+ my( $self, $object ) = @_;
+ my $cust_pkg = $self->cust_pkg($object);
#XXX test
my $hashref = $self->option('status') || {};
$hashref->{ $cust_pkg->status };
- Previous message: [freeside-commits] freeside/FS/FS/part_event/Action svc_acct_notice.pm, NONE, 1.1 pkg_cancel.pm, 1.1, 1.2 pkg_suspend.pm, 1.1, 1.2
- Next message: [freeside-commits] freeside/FS/FS msg_template.pm, 1.22, 1.23 part_event.pm, 1.4, 1.5 svc_Common.pm, 1.62, 1.63
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the freeside-commits
mailing list