summaryrefslogtreecommitdiff
path: root/FS/FS/part_pkg
diff options
context:
space:
mode:
authorivan <ivan>2009-05-30 03:14:13 +0000
committerivan <ivan>2009-05-30 03:14:13 +0000
commit467b269c5cacef3e8486e2288f1b0eeec8fea088 (patch)
tree05a8f8cdc89b703e4bf08ef1de97e4eaf4b807d6 /FS/FS/part_pkg
parente13421f071b4a7b872e6d40205ca736125cb294d (diff)
add ability for prepaid packages to have usage limits and cancel if they're hit, RT#4995
Diffstat (limited to 'FS/FS/part_pkg')
-rw-r--r--FS/FS/part_pkg/flat.pm78
-rw-r--r--FS/FS/part_pkg/prepaid.pm16
2 files changed, 63 insertions, 31 deletions
diff --git a/FS/FS/part_pkg/flat.pm b/FS/FS/part_pkg/flat.pm
index 009e54c78..171885770 100644
--- a/FS/FS/part_pkg/flat.pm
+++ b/FS/FS/part_pkg/flat.pm
@@ -1,7 +1,10 @@
package FS::part_pkg::flat;
use strict;
-use vars qw(@ISA %info);
+use vars qw( @ISA %info
+ %usage_fields %usage_recharge_fields
+ @usage_fieldorder @usage_recharge_fieldorder
+ );
use Tie::IxHash;
#use FS::Record qw(qsearch);
use FS::UI::bytecount;
@@ -14,30 +17,8 @@ tie my %temporalities, 'Tie::IxHash',
'preceding' => "Preceding (past)",
;
-%info = (
- 'name' => 'Flat rate (anniversary billing)',
- 'shortname' => 'Anniversary',
- 'fields' => {
- 'setup_fee' => { 'name' => 'Setup fee for this package',
- 'default' => 0,
- },
- 'recur_fee' => { 'name' => 'Recurring fee for this package',
- 'default' => 0,
- },
-
- #false laziness w/voip_cdr.pm
- 'recur_temporality' => { 'name' => 'Charge recurring fee for period',
- 'type' => 'select',
- 'select_options' => \%temporalities,
- },
+%usage_fields = (
- 'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
- ' of service at cancellation',
- 'type' => 'checkbox',
- },
- 'externalid' => { 'name' => 'Optional External ID',
- 'default' => '',
- },
'seconds' => { 'name' => 'Time limit for this package',
'default' => '',
'check' => sub { shift =~ /^\d*$/ },
@@ -60,6 +41,10 @@ tie my %temporalities, 'Tie::IxHash',
'format' => \&FS::UI::bytecount::display_bytecount,
'parse' => \&FS::UI::bytecount::parse_bytecount,
},
+);
+
+%usage_recharge_fields = (
+
'recharge_amount' => { 'name' => 'Cost of recharge for this package',
'default' => '',
'check' => sub { shift =~ /^\d*(\.\d{2})?$/ },
@@ -94,13 +79,46 @@ tie my %temporalities, 'Tie::IxHash',
'package recharge',
'type' => 'checkbox',
},
+);
+
+@usage_fieldorder = qw( seconds upbytes downbytes totalbytes );
+@usage_recharge_fieldorder = qw(
+ recharge_amount recharge_seconds recharge_upbytes
+ recharge_downbytes recharge_totalbytes
+ usage_rollover recharge_reset
+);
+
+%info = (
+ 'name' => 'Flat rate (anniversary billing)',
+ 'shortname' => 'Anniversary',
+ 'fields' => {
+ 'setup_fee' => { 'name' => 'Setup fee for this package',
+ 'default' => 0,
+ },
+ 'recur_fee' => { 'name' => 'Recurring fee for this package',
+ 'default' => 0,
+ },
+
+ #false laziness w/voip_cdr.pm
+ 'recur_temporality' => { 'name' => 'Charge recurring fee for period',
+ 'type' => 'select',
+ 'select_options' => \%temporalities,
+ },
+
+ %usage_fields,
+ %usage_recharge_fields,
+
+ 'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
+ ' of service at cancellation',
+ 'type' => 'checkbox',
+ },
+ 'externalid' => { 'name' => 'Optional External ID',
+ 'default' => '',
+ },
},
- 'fieldorder' => [qw( setup_fee recur_fee recur_temporality unused_credit
- seconds upbytes downbytes totalbytes
- recharge_amount recharge_seconds recharge_upbytes
- recharge_downbytes recharge_totalbytes
- usage_rollover recharge_reset externalid
- )
+ 'fieldorder' => [ qw( setup_fee recur_fee recur_temporality unused_credit ),
+ @usage_fieldorder, @usage_recharge_fieldorder,
+ qw( externalid ),
],
'weight' => 10,
);
diff --git a/FS/FS/part_pkg/prepaid.pm b/FS/FS/part_pkg/prepaid.pm
index 4499d0e52..23d340167 100644
--- a/FS/FS/part_pkg/prepaid.pm
+++ b/FS/FS/part_pkg/prepaid.pm
@@ -12,6 +12,11 @@ tie %recur_action, 'Tie::IxHash',
'cancel' => 'cancel',
;
+tie my %overlimit_action, 'Tie::IxHash',
+ 'overlimit' => 'Default overlimit processing',
+ 'cancel' => 'Cancel',
+;
+
%info = (
'name' => 'Prepaid, flat rate',
#'name' => 'Prepaid (no automatic recurring)', #maybe use it here too
@@ -27,8 +32,17 @@ tie %recur_action, 'Tie::IxHash',
'type' => 'select',
'select_options' => \%recur_action,
},
+ %FS::part_pkg::flat::usage_fields,
+ 'overlimit_action' => { 'name' => 'Action to take upon reaching a usage limit.',
+ 'type' => 'select',
+ 'select_options' => \%overlimit_action,
+ },
+ #XXX if you set overlimit_action to 'cancel', should also have the ability
+ # to select a reason
},
- 'fieldorder' => [ 'setup_fee', 'recur_fee', 'recur_action', ],
+ 'fieldorder' => [ qw( setup_fee recur_fee recur_action ),
+ @FS::part_pkg::flat::usage_fieldorder,
+ ],
'weight' => 25,
);