summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjeff <jeff>2007-09-18 06:32:51 +0000
committerjeff <jeff>2007-09-18 06:32:51 +0000
commit64852c30f3025d1aafa3c9d5c81f6b20dddd1a36 (patch)
tree2d86e7a5c990803c22d7de99fbb0b1dca598fdcc
parente1505ce8386ac19d01bbcf7ef2ac6f1f3798560b (diff)
allow assignment of auto recharge values AND rollover
-rw-r--r--FS/FS/cust_pkg.pm20
-rw-r--r--FS/FS/part_pkg/base_rate.pm9
-rw-r--r--FS/FS/part_pkg/flat.pm12
-rw-r--r--FS/FS/part_pkg/prorate.pm8
-rw-r--r--FS/FS/part_pkg/subscription.pm5
5 files changed, 40 insertions, 14 deletions
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 77438c1..a37abe2 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -1754,6 +1754,26 @@ sub set_usage {
}
}
+=item recharge 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 incremented.
+
+=cut
+
+sub recharge {
+ my ($self, $valueref) = @_;
+
+ foreach my $cust_svc ($self->cust_svc){
+ my $svc_x = $cust_svc->svc_x;
+ $svc_x->recharge($valueref)
+ if $svc_x->can("recharge");
+ }
+}
+
=back
=head1 BUGS
diff --git a/FS/FS/part_pkg/base_rate.pm b/FS/FS/part_pkg/base_rate.pm
index 9e64184..04896e0 100644
--- a/FS/FS/part_pkg/base_rate.pm
+++ b/FS/FS/part_pkg/base_rate.pm
@@ -43,7 +43,6 @@ sub calc_setup {
sub calc_recur {
my($self, $cust_pkg) = @_;
- $self->reset_usage($cust_pkg);
$self->base_recur($cust_pkg);
}
@@ -91,12 +90,4 @@ sub is_prepaid {
0; #no, we're postpaid
}
-sub reset_usage {
- my($self, $cust_pkg) = @_;
- my %values = map { $_, $self->option($_) }
- grep { $self->option($_, 'hush') }
- qw(seconds upbytes downbytes totalbytes);
- $cust_pkg->set_usage(\%values);
-}
-
1;
diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm
index 6d1fbde..471f216 100644
--- a/FS/FS/part_pkg/flat.pm
+++ b/FS/FS/part_pkg/flat.pm
@@ -63,12 +63,16 @@ use FS::part_pkg;
'format' => \&FS::UI::bytecount::display_bytecount,
'parse' => \&FS::UI::bytecount::parse_bytecount,
},
+ 'usage_rollover' => { 'name' => 'Allow usage from previous period to roll '.
+ ' over into current period',
+ 'type' => 'checkbox',
+ },
},
'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit',
'seconds', 'upbytes', 'downbytes', 'totalbytes',
'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
'recharge_downbytes', 'recharge_totalbytes',
- 'externalid' ],
+ 'usage_rollover', 'externalid' ],
'weight' => 10,
);
@@ -141,7 +145,11 @@ sub reset_usage {
my %values = map { $_, $self->option($_) }
grep { $self->option($_, 'hush') }
qw(seconds upbytes downbytes totalbytes);
- $cust_pkg->set_usage(\%values);
+ if ($self->option('usage_rollover', 1)) {
+ $cust_pkg->recharge(\%values);
+ }else{
+ $cust_pkg->set_usage(\%values);
+ }
}
1;
diff --git a/FS/FS/part_pkg/prorate.pm b/FS/FS/part_pkg/prorate.pm
index 02ce6b9..6b7c615 100644
--- a/FS/FS/part_pkg/prorate.pm
+++ b/FS/FS/part_pkg/prorate.pm
@@ -61,6 +61,10 @@ use FS::part_pkg::flat;
'format' => \&FS::UI::bytecount::display_bytecount,
'parse' => \&FS::UI::bytecount::parse_bytecount,
},
+ 'usage_rollover' => { 'name' => 'Allow usage from previous period to roll '.
+ 'over into current period',
+ 'type' => 'checkbox',
+ },
#it would be better if this had to be turned on, its confusing
'externalid' => { 'name' => 'Optional External ID',
'default' => '',
@@ -70,7 +74,7 @@ use FS::part_pkg::flat;
'seconds', 'upbyte', 'downbytes', 'totalbytes',
'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
'recharge_downbytes', 'recharge_totalbytes',
- 'externalid', ],
+ 'usage_rollover', 'externalid', ],
'freq' => 'm',
'weight' => 20,
);
@@ -83,8 +87,6 @@ sub calc_recur {
my $mend;
my $mstart;
- $self->reset_usage($cust_pkg);
-
if ( $mday >= $cutoff_day ) {
$mend =
timelocal(0,0,0,$cutoff_day, $mon == 11 ? 0 : $mon+1, $year+($mon==11));
diff --git a/FS/FS/part_pkg/subscription.pm b/FS/FS/part_pkg/subscription.pm
index 00d15cd..7f4dbca 100644
--- a/FS/FS/part_pkg/subscription.pm
+++ b/FS/FS/part_pkg/subscription.pm
@@ -57,6 +57,10 @@ use FS::part_pkg::flat;
'format' => \&FS::UI::bytecount::display_bytecount,
'parse' => \&FS::UI::bytecount::parse_bytecount,
},
+ 'usage_rollover' => { 'name' => 'Allow usage from previous period to roll '.
+ 'over into current period',
+ 'type' => 'checkbox',
+ },
#it would be better if this had to be turned on, its confusing
'externalid' => { 'name' => 'Optional External ID',
'default' => '',
@@ -71,6 +75,7 @@ use FS::part_pkg::flat;
'upbytes', 'downbytes', 'totalbytes',
'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
'recharge_downbytes', 'recharge_totalbytes',
+ 'usage_rollover',
],
'freq' => 'm',
'weight' => 30,