[freeside-commits] freeside/FS/FS/part_pkg agent.pm, 1.7, 1.7.2.1 base_delayed.pm, 1.4, 1.4.8.1 base_rate.pm, 1.4, 1.4.6.1 bulk.pm, 1.10, 1.10.2.1 cdr_termination.pm, 1.7, 1.7.2.1 flat_comission_cust.pm, 1.8, 1.8.4.1 flat_comission_pkg.pm, 1.7, 1.7.4.1 flat_comission.pm, 1.8, 1.8.4.1 flat_delayed.pm, 1.9, 1.9.6.1 flat_introrate.pm, 1.3, 1.3.6.1 flat.pm, 1.53.2.1, 1.53.2.2 global_Mixin.pm, NONE, 1.1.2.2 prepaid.pm, 1.6, 1.6.6.1 prorate_delayed.pm, 1.4, 1.4.6.1 prorate.pm, 1.23, 1.23.2.1 rt_time.pm, 1.3, 1.3.4.1 sesmon_hour.pm, 1.9, 1.9.4.1 sesmon_minute.pm, 1.10, 1.10.4.1 sql_external.pm, 1.11, 1.11.2.1 sql_generic.pm, 1.9, 1.9.4.1 sqlradacct_hour.pm, 1.10, 1.10.4.1 subscription.pm, 1.18, 1.18.2.1 usage_Mixin.pm, NONE, 1.1.2.2 voip_cdr.pm, 1.108, 1.108.2.1 voip_inbound.pm, 1.4, 1.4.2.1 voip_sqlradacct.pm, 1.22, 1.22.4.1

Mark Wells mark at wavetail.420.am
Fri Dec 24 01:49:52 PST 2010


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

Modified Files:
      Tag: FREESIDE_2_1_BRANCH
	agent.pm base_delayed.pm base_rate.pm bulk.pm 
	cdr_termination.pm flat_comission_cust.pm 
	flat_comission_pkg.pm flat_comission.pm flat_delayed.pm 
	flat_introrate.pm flat.pm prepaid.pm prorate_delayed.pm 
	prorate.pm rt_time.pm sesmon_hour.pm sesmon_minute.pm 
	sql_external.pm sql_generic.pm sqlradacct_hour.pm 
	subscription.pm voip_cdr.pm voip_inbound.pm voip_sqlradacct.pm 
Added Files:
      Tag: FREESIDE_2_1_BRANCH
	global_Mixin.pm usage_Mixin.pm 
Log Message:
part_pkg option inheritance, part 1

Index: prepaid.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/prepaid.pm,v
retrieving revision 1.6
retrieving revision 1.6.6.1
diff -u -w -d -r1.6 -r1.6.6.1
--- prepaid.pm	30 May 2009 03:40:12 -0000	1.6
+++ prepaid.pm	24 Dec 2010 09:49:49 -0000	1.6.6.1
@@ -21,28 +21,25 @@
   'name' => 'Prepaid, flat rate',
   #'name' => 'Prepaid (no automatic recurring)', #maybe use it here too
   'shortname' => 'Prepaid, no automatic cycle',
+  'inherit_fields' => [ 'usage_Mixin', 'global_Mixin' ],
   'fields' => {
-    'setup_fee'   =>  { 'name' => 'One-time setup fee for this package',
-                        'default' => 0,
-                      },
-    'recur_fee'   =>  { 'name' => 'Initial and recharge fee for this package',
-                        'default' => 0,
-                      },
     'recur_action' => { 'name' => 'Action to take upon reaching end of prepaid preiod',
                         '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
+    
+    # do we need to disable these?
+    map { $_ => { 'disabled' => 1 } } (
+      qw(recharge_amount recharge_seconds recharge_upbytes recharge_downbytes
+      recharge_totalbytes usage_rollover recharge_reset) ),
   },
-  'fieldorder' => [ qw( setup_fee recur_fee recur_action ),
-                    @FS::part_pkg::flat::usage_fieldorder, 'overlimit_action',
-                  ],
+  'fieldorder' => [ qw( recur_action overlimit_action ) ],
   'weight' => 25,
 );
 

--- NEW FILE: usage_Mixin.pm ---
package FS::part_pkg::usage_Mixin;

use strict;
use vars qw( @ISA %info );
use FS::part_pkg;
use FS::UI::bytecount;
@ISA = qw(FS::part_pkg);

# Field definitions for time and data usage, other than CDRs.

%info = (
  'disabled' => 1,
  'fields' => {
    'seconds'       => { 'name' => 'Time limit for this package',
                         'default' => '',
                         'check' => sub { shift =~ /^\d*$/ },
                       },
    'upbytes'       => { 'name' => 'Upload limit for this package',
                         'default' => '',
                         'check' => sub { shift =~ /^\d*$/ },
                         'format' => \&FS::UI::bytecount::display_bytecount,
                         'parse' => \&FS::UI::bytecount::parse_bytecount,
                       },
    'downbytes'     => { 'name' => 'Download limit for this package',
                         'default' => '',
                         'check' => sub { shift =~ /^\d*$/ },
                         'format' => \&FS::UI::bytecount::display_bytecount,
                         'parse' => \&FS::UI::bytecount::parse_bytecount,
                       },
    'totalbytes'    => { 'name' => 'Transfer limit for this package',
                         'default' => '',
                         'check' => sub { shift =~ /^\d*$/ },
                         'format' => \&FS::UI::bytecount::display_bytecount,
                         'parse' => \&FS::UI::bytecount::parse_bytecount,
                       },
    'recharge_amount'       => { 'name' => 'Cost of recharge for this package',
                         'default' => '',
                         'check' => sub { shift =~ /^\d*(\.\d{2})?$/ },
                       },
    'recharge_seconds'      => { 'name' => 'Recharge time for this package',
                         'default' => '',
                         'check' => sub { shift =~ /^\d*$/ },
                       },
    'recharge_upbytes'      => { 'name' => 'Recharge upload for this package',
                         'default' => '',
                         'check' => sub { shift =~ /^\d*$/ },
                         'format' => \&FS::UI::bytecount::display_bytecount,
                         'parse' => \&FS::UI::bytecount::parse_bytecount,
                       },
    'recharge_downbytes'    => { 'name' => 'Recharge download for this package',
                         'default' => '',
                         'check' => sub { shift =~ /^\d*$/ },
                         'format' => \&FS::UI::bytecount::display_bytecount,
                         'parse' => \&FS::UI::bytecount::parse_bytecount,
                       },
    'recharge_totalbytes'   => { 'name' => 'Recharge transfer for this package',
                         'default' => '',
                         'check' => sub { shift =~ /^\d*$/ },
                         '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',
                        },
    'recharge_reset' => { 'name' => 'Reset usage to these values on manual '.
                                    'package recharge',
                          'type' => 'checkbox',
                        },
  },
  'fieldorder' => [ qw( seconds upbytes downbytes totalbytes
                        recharge_amount recharge_seconds recharge_upbytes
                        recharge_downbytes recharge_totalbytes 
                        usage_rollover recharge_reset ) ],
);

1;

Index: sesmon_hour.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/sesmon_hour.pm,v
retrieving revision 1.9
retrieving revision 1.9.4.1
diff -u -w -d -r1.9 -r1.9.4.1
--- sesmon_hour.pm	31 Jan 2010 02:57:14 -0000	1.9
+++ sesmon_hour.pm	24 Dec 2010 09:49:49 -0000	1.9.4.1
@@ -10,17 +10,8 @@
 %info = (
   'name' => 'Base charge plus charge per-hour from the session monitor',
   'shortname' => 'Session monitor (per-hour)',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
-    'recur_fee' => { 'name' => 'Base recurring fee for this package',
-                     'default' => 0,
-                   },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
     'recur_included_hours' => { 'name' => 'Hours included',
                                 'default' => 0,
                               },
@@ -28,7 +19,7 @@
                                'default' => 0,
                              },
   },
-  'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'recur_included_hours', 'recur_hourly_charge' ],
+  'fieldorder' => [ 'recur_included_hours', 'recur_hourly_charge' ],
   #'setup' => 'what.setup_fee.value',
   #'recur' => '\'my $hours = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; \' + what.recur_fee.value + \' + \' + what.recur_hourly_charge.value + \' * $hours;\'',
   'weight' => 80,

Index: sql_external.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/sql_external.pm,v
retrieving revision 1.11
retrieving revision 1.11.2.1
diff -u -w -d -r1.11 -r1.11.2.1
--- sql_external.pm	29 Sep 2010 23:41:34 -0000	1.11
+++ sql_external.pm	24 Dec 2010 09:49:49 -0000	1.11.2.1
@@ -9,17 +9,8 @@
 %info = (
   'name' => 'Base charge plus additional fees for external services from a configurable SQL query',
   'shortname' => 'External SQL query',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
-    'recur_fee' => { 'name' => 'Base recurring fee for this package',
-                     'default' => 0,
-                   },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
     'cutoff_day'    => { 'name' => 'Billing Day (1 - 28) for prorating or '.
                                    'subscription',
                          'default' => '1',
@@ -48,7 +39,7 @@
                  'default' => '',
                },
   },
-  'fieldorder' => [qw( setup_fee recur_fee unused_credit recur_method cutoff_day
+  'fieldorder' => [qw( recur_method cutoff_day
                       add_full_period datasrc db_username db_password query 
                   )],
   'weight' => '58',

Index: flat_delayed.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/flat_delayed.pm,v
retrieving revision 1.9
retrieving revision 1.9.6.1
diff -u -w -d -r1.9 -r1.9.6.1
--- flat_delayed.pm	5 Aug 2009 23:34:28 -0000	1.9
+++ flat_delayed.pm	24 Dec 2010 09:49:49 -0000	1.9.6.1
@@ -11,28 +11,18 @@
   'name' => 'Free (or setup fee) for X days, then flat rate'.
             ' (anniversary billing)',
   'shortname' => 'Anniversary, with intro period',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' =>  {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
     'free_days' => { 'name' => 'Initial free days',
                      'default' => 0,
                    },
-    'recur_fee' => { 'name' => 'Recurring fee for this package',
-                     'default' => 0,
-                    },
     'recur_notify' => { 'name' => 'Number of days before recurring billing'.
                                   ' commences to notify customer. (0 means'.
                                   ' no warning)',
                      'default' => 0,
                     },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
                        },
-  },
-  'fieldorder' => [ 'free_days', 'setup_fee', 'recur_fee', 'recur_notify',
-                    'unused_credit'
+  'fieldorder' => [ 'free_days', 'recur_notify',
                   ],
   #'setup' => '\'my $d = $cust_pkg->bill || $time; $d += 86400 * \' + what.free_days.value + \'; $cust_pkg->bill($d); $cust_pkg_mod_flag=1; \' + what.setup_fee.value',
   #'recur' => 'what.recur_fee.value',
@@ -58,11 +48,6 @@
   return 0 if    $last_bill + (86400 * $free_days) == $next_bill
               && $last_bill == $cust_pkg->setup;
 
-  return 0 if    ! $self->base_recur($cust_pkg)
-              || ! $self->option('unused_credit', 1)
-              || ! $last_bill
-              || ! $next_bill;
-
   return $self->SUPER::calc_remain($cust_pkg, %options);
 }
 

Index: sqlradacct_hour.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/sqlradacct_hour.pm,v
retrieving revision 1.10
retrieving revision 1.10.4.1
diff -u -w -d -r1.10 -r1.10.4.1
--- sqlradacct_hour.pm	31 Jan 2010 02:57:14 -0000	1.10
+++ sqlradacct_hour.pm	24 Dec 2010 09:49:49 -0000	1.10.4.1
@@ -10,18 +10,8 @@
 %info = (
   'name' => 'Base charge plus per-hour (and for data) from an SQL RADIUS radacct table',
   'shortname' => 'Usage charges from RADIUS',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
-    'recur_fee' => { 'name' => 'Base recurring fee for this package',
-                     'default' => 0,
-                   },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
-
     'recur_included_hours' => { 'name' => 'Hours included',
                                 'default' => 0,
                               },
@@ -77,7 +67,7 @@
                             },
 
   },
-  'fieldorder' => [qw( setup_fee recur_fee unused_credit recur_included_hours recur_hourly_charge recur_hourly_cap recur_included_input recur_input_charge recur_input_cap recur_included_output recur_output_charge recur_output_cap recur_included_total recur_total_charge recur_total_cap global_cap )],
+  'fieldorder' => [qw( recur_included_hours recur_hourly_charge recur_hourly_cap recur_included_input recur_input_charge recur_input_cap recur_included_output recur_output_charge recur_output_cap recur_included_total recur_total_charge recur_total_cap global_cap )],
   #'setup' => 'what.setup_fee.value',
   #'recur' => '\'my $last_bill = $cust_pkg->last_bill; my $hours = $cust_pkg->seconds_since_sqlradacct($last_bill, $sdate ) / 3600 - \' + what.recur_included_hours.value + \'; $hours = 0 if $hours < 0; my $input = $cust_pkg->attribute_since_sqlradacct($last_bill, $sdate, \"AcctInputOctets\" ) / 1048576; my $output = $cust_pkg->attribute_since_sqlradacct($last_bill, $sdate, \"AcctOutputOctets\" ) / 1048576; my $total = $input + $output - \' + what.recur_included_total.value + \'; $total = 0 if $total < 0; my $input = $input - \' + what.recur_included_input.value + \'; $input = 0 if $input < 0; my $output = $output - \' + what.recur_included_output.value + \'; $output = 0 if $output < 0; my $totalcharge = sprintf(\"%.2f\", \' + what.recur_total_charge.value + \' * $total); my $inputcharge = sprintf(\"%.2f\", \' + what.recur_input_charge.value + \' * $input); my $outputcharge = sprintf(\"%.2f\", \' + what.recur_output_charge.value + \' * $output); my $hourscharge = sprintf(\"%.2f\", \' + what.recur_hourly_charge.value + \' * $hours); if ( \' + what.recur_total_charge.value + \' > 0 ) { push @details, \"Last month\\\'s data \". sprintf(\"%.1f\", $total). \" megs: \\\$$totalcharge\" } if ( \' + what.recur_input_charge.value + \' > 0 ) { push @details, \"Last month\\\'s download \". sprintf(\"%.1f\", $input). \" megs: \\\$$inputcharge\" } if ( \' + what.recur_output_charge.value + \' > 0 ) { push @details, \"Last month\\\'s upload \". sprintf(\"%.1f\", $output). \" megs: \\\$$outputcharge\" } if ( \' + what.recur_hourly_charge.value + \' > 0 ) { push @details, \"Last month\\\'s time \". sprintf(\"%.1f\", $hours). \" hours: \\\$$hourscharge\"; } \' + what.recur_fee.value + \' + $hourscharge + $inputcharge + $outputcharge + $totalcharge ;\'',
   'weight' => 40,

Index: rt_time.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/rt_time.pm,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -u -w -d -r1.3 -r1.3.4.1
--- rt_time.pm	31 Jan 2010 02:57:14 -0000	1.3
+++ rt_time.pm	24 Dec 2010 09:49:49 -0000	1.3.4.1
@@ -14,11 +14,14 @@
   'name'      =>  'Bill from Time Worked on tickets in RT',
   'shortname' =>  'Project Billing (RT)',
   'weight'    => 55,
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields'    =>  {
     'base_rate' =>  {   'name'    =>  'Rate (per minute)',
                         'default' => 0,
                     },
-  }
+    'recur_fee' => {'disabled' => 1},
+  },
+  'fieldorder' => [ 'base_rate' ],
 );
 
 sub calc_setup {

Index: prorate_delayed.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/prorate_delayed.pm,v
retrieving revision 1.4
retrieving revision 1.4.6.1
diff -u -w -d -r1.4 -r1.4.6.1
--- prorate_delayed.pm	5 Aug 2009 23:34:28 -0000	1.4
+++ prorate_delayed.pm	24 Dec 2010 09:49:49 -0000	1.4.6.1
@@ -11,27 +11,18 @@
   'name' => 'Free (or setup fee) for X days, then prorate, then flat-rate ' .
          '(1st of month billing)',
   'shortname' => 'Prorate (Nth of month billing), with intro period', #??
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' =>  {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
     'free_days' => { 'name' => 'Initial free days',
                      'default' => 0,
                    },
-    'recur_fee' => { 'name' => 'Recurring fee for this package',
-                     'default' => 0,
-                    },
     'recur_notify' => { 'name' => 'Number of days before recurring billing'.
                                   ' commences to notify customer. (0 means'.
                                   ' no warning)',
                      'default' => 0,
                     },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
   },
-  'fieldorder' => [ 'free_days', 'setup_fee', 'recur_fee', 'unused_credit' ],
+  'fieldorder' => [ 'free_days', 'recur_notify' ],
   #'setup' => '\'my $d = $cust_pkg->bill || $time; $d += 86400 * \' + what.free_days.value + \'; $cust_pkg->bill($d); $cust_pkg_mod_flag=1; \' + what.setup_fee.value',
   #'recur' => 'what.recur_fee.value',
   'weight' => 22,
@@ -49,18 +40,13 @@
 
 sub calc_remain {
   my ($self, $cust_pkg, %options) = @_;
-  my $next_bill = $cust_pkg->getfield('bill') || 0;
   my $last_bill = $cust_pkg->last_bill || 0;
+  my $next_bill = $cust_pkg->getfield('bill') || 0;
   my $free_days = $self->option('free_days');
 
   return 0 if    $last_bill + (86400 * $free_days) == $next_bill
               && $last_bill == $cust_pkg->setup;
 
-  return 0 if    ! $self->base_recur($cust_pkg)
-              || ! $self->option('unused_credit', 1)
-              || ! $last_bill
-              || ! $next_bill;
-
   return $self->SUPER::calc_remain($cust_pkg, %options);
 }
 

Index: base_rate.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/base_rate.pm,v
retrieving revision 1.4
retrieving revision 1.4.6.1
diff -u -w -d -r1.4 -r1.4.6.1
--- base_rate.pm	5 Aug 2009 23:32:34 -0000	1.4
+++ base_rate.pm	24 Dec 2010 09:49:48 -0000	1.4.6.1
@@ -12,23 +12,13 @@
             # XXX it multiplies recurring fee by cust_pkg option "units", how to
             # express that
   'shortname' => 'Bulk (manual from "units" option)',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-    'setup_fee'     => { 'name' => 'Setup fee for this package',
-                         'default' => 0,
-                       },
-    'recur_fee'     => { 'name' => 'Recurring Base fee for this package',
-                         'default' => 0,
-                       },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
     'externalid' => { 'name'   => 'Optional External ID',
                       'default' => '',
                     },
   },
-  'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 
-                    'externalid' ],
+  'fieldorder' => [ qw( externalid ) ],
   'weight' => 52,
 );
 
@@ -59,13 +49,10 @@
 }
 
 sub calc_remain {
-  my ($self, $cust_pkg) = @_;
-  my $time = time;  #should be able to pass this in for credit calculation
+  my ($self, $cust_pkg, %options) = @_;
+  my $time = $options{'time'} || time;
   my $next_bill = $cust_pkg->getfield('bill') || 0;
-  my $last_bill = $cust_pkg->last_bill || 0;
   return 0 if    ! $self->base_recur($cust_pkg)
-              || ! $self->option('unused_credit', 1)
-              || ! $last_bill
               || ! $next_bill
               || $next_bill < $time;
 

Index: base_delayed.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/base_delayed.pm,v
retrieving revision 1.4
retrieving revision 1.4.8.1
diff -u -w -d -r1.4 -r1.4.8.1
--- base_delayed.pm	13 Apr 2008 21:37:53 -0000	1.4
+++ base_delayed.pm	24 Dec 2010 09:49:48 -0000	1.4.8.1
@@ -11,28 +11,18 @@
   'name' => 'Free (or setup fee) for X days, then base rate'.
             ' (anniversary billing)',
   'shortname' => 'Bulk (manual from "units" option), w/intro period',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' =>  {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
     'free_days' => { 'name' => 'Initial free days',
                      'default' => 0,
                    },
-    'recur_fee' => { 'name' => 'Recurring base fee for this package',
-                     'default' => 0,
-                    },
     'recur_notify' => { 'name' => 'Number of days before recurring billing'.
                                   ' commences to notify customer. (0 means'.
                                   ' no warning)',
                      'default' => 0,
                     },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
   },
-  'fieldorder' => [ 'free_days', 'setup_fee', 'recur_fee', 'recur_notify',
-                    'unused_credit'
+  'fieldorder' => [ 'free_days', 'recur_notify',
                   ],
   #'setup' => '\'my $d = $cust_pkg->bill || $time; $d += 86400 * \' + what.free_days.value + \'; $cust_pkg->bill($d); $cust_pkg_mod_flag=1; \' + what.setup_fee.value',
   #'recur' => 'what.recur_fee.value',

Index: voip_sqlradacct.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/voip_sqlradacct.pm,v
retrieving revision 1.22
retrieving revision 1.22.4.1
diff -u -w -d -r1.22 -r1.22.4.1
--- voip_sqlradacct.pm	31 Jan 2010 02:57:14 -0000	1.22
+++ voip_sqlradacct.pm	24 Dec 2010 09:49:50 -0000	1.22.4.1
@@ -16,17 +16,8 @@
   'disabled' => 1, #they're sucked into our CDR table now instead
   'name' => 'VoIP rating by plan of CDR records in an SQL RADIUS radacct table',
   'shortname' => 'VoIP/telco CDR rating (external RADIUS)',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-    'setup_fee'     => { 'name' => 'Setup fee for this package',
-                         'default' => 0,
-                       },
-    'recur_fee'     => { 'name' => 'Base recurring fee for this package',
-                         'default' => 0,
-                       },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
     'ratenum'   => { 'name' => 'Rate plan',
                      'type' => 'select',
                      'select_table' => 'rate',
@@ -34,7 +25,7 @@
                      'select_label' => 'ratename',
                    },
   },
-  'fieldorder' => [qw( setup_fee recur_fee unused_credit ratenum ignore_unrateable )],
+  'fieldorder' => [qw( ratenum ignore_unrateable )],
   'weight' => 40,
 );
 

Index: prorate.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/prorate.pm,v
retrieving revision 1.23
retrieving revision 1.23.2.1
diff -u -w -d -r1.23 -r1.23.2.1
--- prorate.pm	30 Oct 2010 23:22:31 -0000	1.23
+++ prorate.pm	24 Dec 2010 09:49:49 -0000	1.23.2.1
@@ -11,74 +11,14 @@
 %info = (
   'name' => 'First partial month pro-rated, then flat-rate (selectable billing day)',
   'shortname' => 'Prorate (Nth of month billing)',
+  'inherit_fields' => [ 'flat', 'usage_Mixin', 'global_Mixin' ],
   'fields' => {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
-    'recur_fee' => { 'name' => 'Recurring fee for this package',
-                     'default' => 0,
-                    },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
+    'recur_temporality' => {'disabled' => 1},
+    'sync_bill_date' => {'disabled' => 1},
     'cutoff_day' => { 'name' => 'Billing Day (1 - 28)',
                       'default' => 1,
                     },
-    'seconds'       => { 'name' => 'Time limit for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-                       },
-    'upbytes'       => { 'name' => 'Upload limit for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-			 'format' => \&FS::UI::bytecount::display_bytecount,
-			 'parse' => \&FS::UI::bytecount::parse_bytecount,
-                       },
-    'downbytes'     => { 'name' => 'Download limit for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-			 'format' => \&FS::UI::bytecount::display_bytecount,
-			 'parse' => \&FS::UI::bytecount::parse_bytecount,
-                       },
-    'totalbytes'    => { 'name' => 'Transfer limit for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-			 'format' => \&FS::UI::bytecount::display_bytecount,
-			 'parse' => \&FS::UI::bytecount::parse_bytecount,
-                       },
-    'recharge_amount'       => { 'name' => 'Cost of recharge for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*(\.\d{2})?$/ },
-                       },
-    'recharge_seconds'      => { 'name' => 'Recharge time for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-                       },
-    'recharge_upbytes'      => { 'name' => 'Recharge upload for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-			 'format' => \&FS::UI::bytecount::display_bytecount,
-			 'parse' => \&FS::UI::bytecount::parse_bytecount,
-                       },
-    'recharge_downbytes'    => { 'name' => 'Recharge download for this package',                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-			 'format' => \&FS::UI::bytecount::display_bytecount,
-			 'parse' => \&FS::UI::bytecount::parse_bytecount,
-                       },
-    'recharge_totalbytes'   => { 'name' => 'Recharge transfer for this package',                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-			 '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',
-                        },
-    'recharge_reset' => { 'name' => 'Reset usage to these values on manual '.
-                                    'package recharge',
-                          'type' => 'checkbox',
-                        },
+
     'add_full_period'=> { 'name' => 'When prorating first month, also bill '.
                                     'for one full period after that',
                           'type' => 'checkbox',
@@ -88,18 +28,8 @@
                                     'the nearest full day',
                           'type' => 'checkbox',
                         },
-
-    #it would be better if this had to be turned on, its confusing
-    'externalid' => { 'name'   => 'Optional External ID',
-                      'default' => '',
-                    },
   },
-  'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'cutoff_day',
-                    'seconds', 'upbytes', 'downbytes', 'totalbytes',
-                    'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
-                    'recharge_downbytes', 'recharge_totalbytes',
-                    'usage_rollover', 'recharge_reset', 'add_full_period',
-                    'prorate_round_day', 'externalid', ],
+  'fieldorder' => [ 'cutoff_day', 'add_full_period', 'prorate_round_day' ],
   'freq' => 'm',
   'weight' => 20,
 );

Index: agent.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/agent.pm,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -w -d -r1.7 -r1.7.2.1
--- agent.pm	29 Sep 2010 23:41:34 -0000	1.7
+++ agent.pm	24 Dec 2010 09:49:48 -0000	1.7.2.1
@@ -19,16 +19,8 @@
 %info = (
   'name'      => 'Wholesale bulk billing, for master customers of an agent.',
   'shortname' => 'Wholesale bulk billing for agent.',
-
+  'inherit_fields' => [qw( prorate global_Mixin)],
   'fields' => {
-    'setup_fee'     => { 'name' => 'Setup fee for this package',
-                         'default' => 0,
-                       },
-    'recur_fee'     => { 'name' => 'Base recurring fee for this package',
-                         'default' => 0,
-                       },
-
-
     #'recur_method'  => { 'name' => 'Recurring fee method',
     #                     #'type' => 'radio',
     #                     #'options' => \%recur_method,
@@ -49,8 +41,7 @@
 
   },
 
-  #'fieldorder' => [qw( setup_fee recur_fee recur_method cutoff_day ) ],
-  'fieldorder' => [qw( setup_fee recur_fee cutoff_day add_full_period no_pkg_prorate ) ],
+  'fieldorder' => [qw( cutoff_day add_full_period no_pkg_prorate ) ],
 
   'weight' => 51,
 

Index: flat_comission.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/flat_comission.pm,v
retrieving revision 1.8
retrieving revision 1.8.4.1
diff -u -w -d -r1.8 -r1.8.4.1
--- flat_comission.pm	31 Jan 2010 02:57:14 -0000	1.8
+++ flat_comission.pm	24 Dec 2010 09:49:49 -0000	1.8.4.1
@@ -10,17 +10,8 @@
 %info = (
   'name' => 'Flat rate with recurring commission per (any) active package',
   'shortname' => 'Commission per (any) active package',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-    'setup_fee'     => { 'name' => 'Setup fee for this package',
-                         'default' => 0,
-                       },
-    'recur_fee'     => { 'name' => 'Recurring fee for this package',
-                         'default' => 0,
-                       },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
     'comission_amount' => { 'name' => 'Commission amount per month (per active package)',
                             'default' => 0,
                           },
@@ -35,7 +26,7 @@
                             'select_label' => 'type',
                           },
   },
-  'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'comission_depth', 'comission_amount', 'reason_type' ],
+  'fieldorder' => [ 'comission_depth', 'comission_amount', 'reason_type' ],
   #'setup' => 'what.setup_fee.value',
   #'recur' => '\'my $error = $cust_pkg->cust_main->credit( \' + what.comission_amount.value + \' * scalar($cust_pkg->cust_main->referral_cust_pkg(\' + what.comission_depth.value+ \')), "commission" ); die $error if $error; \' + what.recur_fee.value + \';\'',
   'weight' => 62,

Index: flat_introrate.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/flat_introrate.pm,v
retrieving revision 1.3
retrieving revision 1.3.6.1
diff -u -w -d -r1.3 -r1.3.6.1
--- flat_introrate.pm	2 Jul 2009 01:26:46 -0000	1.3
+++ flat_introrate.pm	24 Dec 2010 09:49:49 -0000	1.3.6.1
@@ -2,7 +2,6 @@
 
 use strict;
 use vars qw(@ISA %info $DEBUG $me);
-#use FS::Record qw(qsearch qsearchs);
 use FS::part_pkg::flat;
 
 use Date::Manip qw(DateCalc UnixDate ParseDate);
@@ -11,22 +10,23 @@
 $me = '[' . __PACKAGE__ . ']';
 $DEBUG = 0;
 
-(%info) = (%FS::part_pkg::flat::info);
-$info{name} = 'Introductory price for X months, then flat rate,'.
-              'relative to setup date (anniversary billing)';
-$info{shortname} = 'Anniversary, with intro price';
-$info{fields} = { %{$info{fields}} };
-$info{fields}{intro_fee} =
-         { 'name' => 'Introductory recurring fee for this package',
+%info = (
+  'name' => 'Introductory price for X months, then flat rate,'.
+            'relative to setup date (anniversary billing)',
+  'shortname' => 'Anniversary, with intro price',
+  'inherit_fields' => [ 'flat', 'usage_Mixin', 'global_Mixin' ],
+  'fields' => {
+    'intro_fee' => { 'name' => 'Introductory recurring fee for this package',
                      'default' => 0,
-         };
-$info{fields}{intro_duration} =
+                   },
+    'intro_duration' =>
          { 'name' => 'Duration of the introductory period, in number of months',
            'default' => 0,
-         };
-$info{fieldorder} = [ @{ $info{fieldorder} } ];
-splice @{$info{fieldorder}}, 1, 0, qw( intro_duration intro_fee );
-$info{weight} = 14;
+         },
+  },
+  'fieldorder' => [ qw(intro_duration intro_fee) ],
+  'weight' => 14,
+);
 
 sub base_recur {
   my($self, $cust_pkg, $time ) = @_;

Index: flat_comission_pkg.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/flat_comission_pkg.pm,v
retrieving revision 1.7
retrieving revision 1.7.4.1
diff -u -w -d -r1.7 -r1.7.4.1
--- flat_comission_pkg.pm	31 Jan 2010 02:57:14 -0000	1.7
+++ flat_comission_pkg.pm	24 Dec 2010 09:49:49 -0000	1.7.4.1
@@ -10,23 +10,8 @@
 %info = (
   'name' => 'Flat rate with recurring commission per (selected) active package',
   'shortname' => 'Commission per (selected) active package',
+  'inherit_fields' => [ 'flat_comission', 'global_Mixin' ],
   'fields' => {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
-    'recur_fee' => { 'name' => 'Recurring fee for this package',
-                     'default' => 0,
-                   },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
-    'comission_amount' => { 'name' => 'Commission amount per month (per uncancelled package)',
-                            'default' => 0,
-                          },
-    'comission_depth'  => { 'name' => 'Number of layers',
-                            'default' => 1,
-                          },
     'comission_pkgpart' => { 'name' => 'Applicable packages<BR><FONT SIZE="-1">(hold <b>ctrl</b> to select multiple packages)</FONT>',
                              'type' => 'select_multiple',
                              'select_table' => 'part_pkg',
@@ -34,15 +19,8 @@
                              'select_key'   => 'pkgpart',
                              'select_label' => 'pkg',
                            },
-    'reason_type'       => { 'name' => 'Reason type for commission credits',
-                             'type' => 'select',
-                             'select_table' => 'reason_type',
-                             'select_hash'  => { 'class' => 'R' } ,
-                             'select_key'   => 'typenum',
-                             'select_label' => 'type',
                            },
-  },
-  'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'comission_depth', 'comission_amount', 'comission_pkgpart', 'reason_type' ],
+  'fieldorder' => [ 'comission_depth', 'comission_amount', 'comission_pkgpart', 'reason_type' ],
   #'setup' => 'what.setup_fee.value',
   #'recur' => '""; var pkgparts = ""; for ( var c=0; c < document.flat_comission_pkg.comission_pkgpart.options.length; c++ ) { if (document.flat_comission_pkg.comission_pkgpart.options[c].selected) { pkgparts = pkgparts + document.flat_comission_pkg.comission_pkgpart.options[c].value + \', \'; } } what.recur.value = \'my $error = $cust_pkg->cust_main->credit( \' + what.comission_amount.value + \' * scalar( grep { my $pkgpart = $_->pkgpart; grep { $_ == $pkgpart } ( \' + pkgparts + \'  ) } $cust_pkg->cust_main->referral_cust_pkg(\' + what.comission_depth.value+ \')), "commission" ); die $error if $error; \' + what.recur_fee.value + \';\'',
   #'disabled' => 1,

--- NEW FILE: global_Mixin.pm ---
package FS::part_pkg::global_Mixin;

use strict;
use vars qw(@ISA %info);
use FS::part_pkg;
@ISA = qw(FS::part_pkg);

%info = (
  'disabled' => 1,
  'fields' => {
    'setup_fee' => { 
      'name' => 'Setup fee for this package',
      'default' => 0,
    },
    'recur_fee' => { 
      'name' => 'Recurring fee for this package',
      'default' => 0,
    },
    'unused_credit_cancel' => {
      'name' => 'Credit the customer for the unused portion of service at '.
                 'cancellation',
      'type' => 'checkbox',
    },
    'unused_credit_change' => {
      'name' => 'Credit the customer for the unused portion of service when '.
                'changing packages',
      'type' => 'checkbox',
    },
  },
  'fieldorder' => [ qw(
    setup_fee
    recur_fee
    unused_credit_cancel
    unused_credit_change
  )],
);

1;

Index: cdr_termination.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/cdr_termination.pm,v
retrieving revision 1.7
retrieving revision 1.7.2.1
diff -u -w -d -r1.7 -r1.7.2.1
--- cdr_termination.pm	29 Sep 2010 23:41:34 -0000	1.7
+++ cdr_termination.pm	24 Dec 2010 09:49:48 -0000	1.7.2.1
@@ -16,15 +16,8 @@
 %info = (
   'name' => 'VoIP rating of CDR records for termination partners.',
   'shortname' => 'VoIP/telco CDR termination',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-
-    'setup_fee'     => { 'name' => 'Setup fee for this package',
-                         'default' => 0,
-                       },
-    'recur_fee'     => { 'name' => 'Base recurring fee for this package',
-                         'default' => 0,
-                       },
-
     #'cdr_column'    => { 'name' => 'Column from CDR records',
     #                     'type' => 'select',
     #                     'select_enum' => [qw(
@@ -49,11 +42,6 @@
                              'select_options' => \%temporalities,
                            },
 
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
-
     'cutoff_day'    => { 'name' => 'Billing Day (1 - 28) for prorating or '.
                                    'subscription',
                          'default' => '1',
@@ -92,8 +80,7 @@
   },
                        #cdr_column
   'fieldorder' => [qw(
-                       setup_fee recur_fee
-                       recur_temporality unused_credit recur_method cutoff_day
+                       recur_temporality recur_method cutoff_day
                        add_full_period
                        output_format usage_section summarize_usage usage_mandate
                      )

Index: sesmon_minute.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/sesmon_minute.pm,v
retrieving revision 1.10
retrieving revision 1.10.4.1
diff -u -w -d -r1.10 -r1.10.4.1
--- sesmon_minute.pm	31 Jan 2010 02:57:14 -0000	1.10
+++ sesmon_minute.pm	24 Dec 2010 09:49:49 -0000	1.10.4.1
@@ -10,17 +10,8 @@
 %info = (
   'name' => 'Base charge plus charge per-minute from the session monitor',
   'shortname' => 'Session monitor (per-minute)',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
-    'recur_fee' => { 'name' => 'Base recurring fee for this package',
-                     'default' => 0,
-                   },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
     'recur_included_min' => { 'name' => 'Minutes included',
                               'default' => 0,
                               },
@@ -28,7 +19,7 @@
                               'default' => 0,
                             },
   },
-  'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'recur_included_min', 'recur_minly_charge' ],
+  'fieldorder' => [ 'recur_included_min', 'recur_minly_charge' ],
   #'setup' => 'what.setup_fee.value',
   #'recur' => '\'my $min = $cust_pkg->seconds_since($cust_pkg->bill || 0) / 60 - \' + what.recur_included_min.value + \'; $min = 0 if $min < 0; \' + what.recur_fee.value + \' + \' + what.recur_minly_charge.value + \' * $min;\'',
   'weight' => 80,

Index: sql_generic.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/sql_generic.pm,v
retrieving revision 1.9
retrieving revision 1.9.4.1
diff -u -w -d -r1.9 -r1.9.4.1
--- sql_generic.pm	31 Jan 2010 02:57:14 -0000	1.9
+++ sql_generic.pm	24 Dec 2010 09:49:49 -0000	1.9.4.1
@@ -11,17 +11,8 @@
 %info = (
   'name' => 'Base charge plus a per-domain metered rate from a configurable SQL query',
   'shortname' => 'Bulk (per-domain from SQL query)',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
-    'recur_fee' => { 'name' => 'Base recurring fee for this package',
-                     'default' => 0,
-                   },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
     'recur_included' => { 'name' => 'Units included',
                           'default' => 0,
                         },
@@ -41,7 +32,7 @@
                  'default' => '',
                },
   },
-  'fieldorder' => [qw( setup_fee recur_fee unused_credit recur_included recur_unit_charge datasrc db_username db_password query )],
+  'fieldorder' => [qw( recur_included recur_unit_charge datasrc db_username db_password query )],
  # 'setup' => 'what.setup_fee.value',
  # 'recur' => '\'my $dbh = DBI->connect(\"\' + what.datasrc.value + \'\", \"\' + what.db_username.value + \'\") or die $DBI::errstr; \'',
  #'recur' => '\'my $dbh = DBI->connect(\"\' + what.datasrc.value + \'\", \"\' + what.db_username.value + \'\", \"\' + what.db_password.value + \'\" ) or die $DBI::errstr; my $sth = $dbh->prepare(\"\' + what.query.value + \'\") or die $dbh->errstr; my $units = 0; foreach my $cust_svc ( grep { $_->part_svc->svcdb eq \"svc_domain\" } $cust_pkg->cust_svc ) { my $domain = $cust_svc->svc_x->domain; $sth->execute($domain) or die $sth->errstr; $units += $sth->fetchrow_arrayref->[0]; } $units -= \' + what.recur_included.value + \'; $units = 0 if $units < 0; \' + what.recur_fee.value + \' + $units * \' + what.recur_unit_charge.value + \';\'',

Index: voip_cdr.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/voip_cdr.pm,v
retrieving revision 1.108
retrieving revision 1.108.2.1
diff -u -w -d -r1.108 -r1.108.2.1
--- voip_cdr.pm	4 Nov 2010 20:35:55 -0000	1.108
+++ voip_cdr.pm	24 Dec 2010 09:49:50 -0000	1.108.2.1
@@ -48,25 +48,14 @@
 %info = (
   'name' => 'VoIP rating by plan of CDR records in an internal (or external) SQL table',
   'shortname' => 'VoIP/telco CDR rating (standard)',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-    'setup_fee'     => { 'name' => 'Setup fee for this package',
-                         'default' => 0,
-                       },
-    'recur_fee'     => { 'name' => 'Base recurring fee for this package',
-                         'default' => 0,
-                       },
-
     #false laziness w/flat.pm
     'recur_temporality' => { 'name' => 'Charge recurring fee for period',
                              'type' => 'select',
                              'select_options' => \%temporalities,
                            },
 
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
-
     'cutoff_day'    => { 'name' => 'Billing Day (1 - 28) for prorating or '.
                                    'subscription',
                          'default' => '1',
@@ -259,7 +248,7 @@
 
   },
   'fieldorder' => [qw(
-                       setup_fee recur_fee recur_temporality unused_credit
+                       recur_temporality
                        recur_method cutoff_day
                        add_full_period
                        cdr_svc_method

Index: flat.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/flat.pm,v
retrieving revision 1.53.2.1
retrieving revision 1.53.2.2
diff -u -w -d -r1.53.2.1 -r1.53.2.2
--- flat.pm	9 Nov 2010 21:41:39 -0000	1.53.2.1
+++ flat.pm	24 Dec 2010 09:49:49 -0000	1.53.2.2
@@ -2,8 +2,7 @@
 
 use strict;
 use vars qw( @ISA %info
-             %usage_fields %usage_recharge_fields
-             @usage_fieldorder @usage_recharge_fieldorder
+             %usage_recharge_fields @usage_recharge_fieldorder
            );
 use Tie::IxHash;
 use List::Util qw(min); # max);
@@ -26,97 +25,16 @@
   map { $_*12 => $_ } (1..5),
 );
 
-%usage_fields = (
-
-    'seconds'       => { 'name' => 'Time limit for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-                       },
-    'upbytes'       => { 'name' => 'Upload limit for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-                         'format' => \&FS::UI::bytecount::display_bytecount,
-                         'parse' => \&FS::UI::bytecount::parse_bytecount,
-                       },
-    'downbytes'     => { 'name' => 'Download limit for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-                         'format' => \&FS::UI::bytecount::display_bytecount,
-                         'parse' => \&FS::UI::bytecount::parse_bytecount,
-                       },
-    'totalbytes'    => { 'name' => 'Transfer limit for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-                         '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})?$/ },
-                       },
-    'recharge_seconds'      => { 'name' => 'Recharge time for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-                       },
-    'recharge_upbytes'      => { 'name' => 'Recharge upload for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-                         'format' => \&FS::UI::bytecount::display_bytecount,
-                         'parse' => \&FS::UI::bytecount::parse_bytecount,
-                       },
-    'recharge_downbytes'    => { 'name' => 'Recharge download for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-                         'format' => \&FS::UI::bytecount::display_bytecount,
-                         'parse' => \&FS::UI::bytecount::parse_bytecount,
-                       },
-    'recharge_totalbytes'   => { 'name' => 'Recharge transfer for this package',
-                         'default' => '',
-                         'check' => sub { shift =~ /^\d*$/ },
-                         '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',
-                        },
-    'recharge_reset' => { 'name' => 'Reset usage to these values on manual '.
-                                    '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',
+  'inherit_fields' => [ 'usage_Mixin', 'global_Mixin' ],
   '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,
                            },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
 
     #used in cust_pkg.pm so could add to any price plan
     'expire_months' => { 'name' => 'Auto-add an expiration date this number of months out',
@@ -145,22 +63,16 @@
                           'type' => 'checkbox',
                         },
 
-    %usage_fields,
-    %usage_recharge_fields,
-
     'externalid' => { 'name'   => 'Optional External ID',
                       'default' => '',
                     },
   },
-  'fieldorder' => [ qw( setup_fee recur_fee
-                        recur_temporality unused_credit
+  'fieldorder' => [ qw( recur_temporality 
                         expire_months adjourn_months
                         contract_end_months
                         start_1st sync_bill_date
                         suspend_bill unsuspend_adjust_bill
-                      ),
-                    @usage_fieldorder, @usage_recharge_fieldorder,
-                    qw( externalid ),
+                        externalid ),
                   ],
   'weight' => 10,
 );
@@ -239,12 +151,7 @@
 
   my $next_bill = $cust_pkg->getfield('bill') || 0;
 
-  #my $last_bill = $cust_pkg->last_bill || 0;
-  my $last_bill = $cust_pkg->get('last_bill') || 0; #->last_bill falls back to setup
-
   return 0 if    ! $self->base_recur($cust_pkg)
-              || ! $self->option('unused_credit', 1)
-              || ! $last_bill
               || ! $next_bill
               || $next_bill < $time;
 

Index: voip_inbound.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/voip_inbound.pm,v
retrieving revision 1.4
retrieving revision 1.4.2.1
diff -u -w -d -r1.4 -r1.4.2.1
--- voip_inbound.pm	29 Sep 2010 23:41:34 -0000	1.4
+++ voip_inbound.pm	24 Dec 2010 09:49:50 -0000	1.4.2.1
@@ -24,25 +24,13 @@
 %info = (
   'name' => 'VoIP flat rate pricing of CDRs for inbound calls',
   'shortname' => 'VoIP/telco CDR rating (inbound)',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-    'setup_fee'     => { 'name' => 'Setup fee for this package',
-                         'default' => 0,
-                       },
-    'recur_fee'     => { 'name' => 'Base recurring fee for this package',
-                         'default' => 0,
-                       },
-
     #false laziness w/flat.pm
     'recur_temporality' => { 'name' => 'Charge recurring fee for period',
                              'type' => 'select',
                              'select_options' => \%temporalities,
                            },
-
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
-
     'cutoff_day'    => { 'name' => 'Billing Day (1 - 28) for prorating or '.
                                    'subscription',
                          'default' => '1',
@@ -155,7 +143,7 @@
 
   },
   'fieldorder' => [qw(
-                       setup_fee recur_fee recur_temporality unused_credit
+                       recur_temporality
                        recur_method cutoff_day add_full_period
                        min_charge sec_granularity
                        default_prefix

Index: bulk.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/bulk.pm,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -w -d -r1.10 -r1.10.2.1
--- bulk.pm	31 Oct 2010 22:43:20 -0000	1.10
+++ bulk.pm	24 Dec 2010 09:49:48 -0000	1.10.2.1
@@ -12,23 +12,14 @@
 
 %info = (
   'name' => 'Bulk billing based on number of active services',
+  'inherit_fields' => [ 'global_Mixin' ],
   'fields' => {
-    'setup_fee' => { 'name'    => 'Setup fee for the entire bulk package',
-                     'default' => 0,
-                   },
-    'recur_fee' => { 'name'    => 'Recurring fee for the entire bulk package',
-                     'default' => 0,
-                   },
     'svc_setup_fee' => { 'name'    => 'Setup fee for each new service',
                          'default' => 0,
                        },
     'svc_recur_fee' => { 'name'    => 'Recurring fee for each service',
                          'default' => 0,
                        },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
     'summarize_svcs'=> { 'name' => 'Show a count of services on the invoice, '.
                                    'instead of a detailed list',
                          'type' => 'checkbox',
@@ -38,8 +29,8 @@
                          'type' => 'checkbox',
                        },
   },
-  'fieldorder' => [ 'setup_fee', 'recur_fee', 'svc_setup_fee', 'svc_recur_fee',
-                    'unused_credit', 'summarize_svcs', 'no_prorate' ],
+  'fieldorder' => [ 'svc_setup_fee', 'svc_recur_fee',
+                    'summarize_svcs', 'no_prorate' ],
   'weight' => 50,
 );
 

Index: flat_comission_cust.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/flat_comission_cust.pm,v
retrieving revision 1.8
retrieving revision 1.8.4.1
diff -u -w -d -r1.8 -r1.8.4.1
--- flat_comission_cust.pm	31 Jan 2010 02:57:14 -0000	1.8
+++ flat_comission_cust.pm	24 Dec 2010 09:49:48 -0000	1.8.4.1
@@ -10,32 +10,9 @@
 %info = (
   'name' => 'Flat rate with recurring commission per active customer',
   'shortname' => 'Commission per active customer',
-  'fields' => {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
-    'recur_fee' => { 'name' => 'Recurring fee for this package',
-                     'default' => 0,
-                   },
-    'unused_credit' => { 'name' => 'Credit the customer for the unused portion'.
-                                   ' of service at cancellation',
-                         'type' => 'checkbox',
-                       },
-    'comission_amount' => { 'name' => 'Commission amount per month (per active customer)',
-                            'default' => 0,
-                          },
-    'comission_depth'  => { 'name' => 'Number of layers',
-                            'default' => 1,
-                          },
-    'reason_type'      => { 'name' => 'Reason type for commission credits',
-                            'type' => 'select_table',
-                            'select_table' => 'reason_type',
-                            'select_hash'  => { 'class' => 'R' },
-                            'select_key'   => 'typenum',
-                            'select_label' => 'type',
-                          },
-  },
-  'fieldorder' => [ 'setup_fee', 'recur_fee', 'unused_credit', 'comission_depth', 'comission_amount', 'reason_type' ],
+  'inherit_fields' => [ 'flat_comission', 'global_Mixin' ],
+  'fields' => { },
+  'fieldorder' => [ ],
   #'setup' => 'what.setup_fee.value',
   #'recur' => '\'my $error = $cust_pkg->cust_main->credit( \' + what.comission_amount.value + \' * scalar($cust_pkg->cust_main->referral_cust_main_ncancelled(\' + what.comission_depth.value+ \')), "commission" ); die $error if $error; \' + what.recur_fee.value + \';\'',
   'weight' => '60',

Index: subscription.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/subscription.pm,v
retrieving revision 1.18
retrieving revision 1.18.2.1
diff -u -w -d -r1.18 -r1.18.2.1
--- subscription.pm	30 Oct 2010 23:22:31 -0000	1.18
+++ subscription.pm	24 Dec 2010 09:49:49 -0000	1.18.2.1
@@ -11,13 +11,8 @@
 %info = (
   'name' => 'First partial month full charge, then flat-rate (selectable billing day)',
   'shortname' => 'Subscription (Nth of month, full charge for first)',
+  'inherit_fields' => [ 'usage_Mixin', 'global_Mixin' ],
   'fields' => {
-    'setup_fee' => { 'name' => 'Setup fee for this package',
-                     'default' => 0,
-                   },
-    'recur_fee' => { 'name' => 'Recurring fee for this package',
-                     'default' => 0,
-			   },
     'cutoff_day' => { 'name' => 'Billing day',
                       'default' => 1,
                     },
@@ -81,7 +76,7 @@
                       'default' => '',
                     },
   },
-  'fieldorder' => [ 'setup_fee', 'recur_fee', 'cutoff_day', 'seconds',
+  'fieldorder' => [ 'cutoff_day', 'seconds',
                     'upbytes', 'downbytes', 'totalbytes',
                     'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
                     'recharge_downbytes', 'recharge_totalbytes',



More information about the freeside-commits mailing list