[freeside-commits] freeside/FS/FS/part_pkg flat.pm, 1.31, 1.32 prepaid.pm, 1.4, 1.5

Ivan,,, ivan at wavetail.420.am
Fri May 29 20:14:15 PDT 2009


Update of /home/cvs/cvsroot/freeside/FS/FS/part_pkg
In directory wavetail.420.am:/tmp/cvs-serv12047/part_pkg

Modified Files:
	flat.pm prepaid.pm 
Log Message:
add ability for prepaid packages to have usage limits and cancel if they're hit, RT#4995

Index: prepaid.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/prepaid.pm,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- prepaid.pm	13 Apr 2008 07:41:28 -0000	1.4
+++ prepaid.pm	30 May 2009 03:14:13 -0000	1.5
@@ -12,6 +12,11 @@
   '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 @@
                         '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,
 );
 

Index: flat.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/flat.pm,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- flat.pm	23 Mar 2009 23:33:04 -0000	1.31
+++ flat.pm	30 May 2009 03:14:13 -0000	1.32
@@ -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 @@
   '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 @@
                          '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 @@
                                     'package recharge',
                           'type' => 'checkbox',
                         },
+);
+
+ at usage_fieldorder = qw( seconds upbytes downbytes totalbytes );
+ at 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,
 );



More information about the freeside-commits mailing list