option to charge the next full period when prorating, RT#9874
authormark <mark>
Wed, 29 Sep 2010 23:41:34 +0000 (23:41 +0000)
committermark <mark>
Wed, 29 Sep 2010 23:41:34 +0000 (23:41 +0000)
FS/FS/part_pkg/agent.pm
FS/FS/part_pkg/cdr_termination.pm
FS/FS/part_pkg/prorate.pm
FS/FS/part_pkg/prorate_Mixin.pm
FS/FS/part_pkg/sql_external.pm
FS/FS/part_pkg/voip_cdr.pm
FS/FS/part_pkg/voip_inbound.pm

index e5bd163..69ecf77 100644 (file)
@@ -38,6 +38,10 @@ $me = '[FS::part_pkg::agent]';
     'cutoff_day'    => { 'name' => 'Billing Day (1 - 28)',
                          'default' => '1',
                        },
+    'add_full_period'=> { 'name' => 'When prorating first month, also bill '.
+                                    'for one full period after that',
+                          'type' => 'checkbox',
+                        },
 
     'no_pkg_prorate'   => { 'name' => 'Disable prorating bulk packages (charge full price for packages active only a portion of the month)',
                             'type' => 'checkbox',
@@ -46,7 +50,7 @@ $me = '[FS::part_pkg::agent]';
   },
 
   #'fieldorder' => [qw( setup_fee recur_fee recur_method cutoff_day ) ],
-  'fieldorder' => [qw( setup_fee recur_fee cutoff_day no_pkg_prorate ) ],
+  'fieldorder' => [qw( setup_fee recur_fee cutoff_day add_full_period no_pkg_prorate ) ],
 
   'weight' => 51,
 
index cfd6b4e..0666d79 100644 (file)
@@ -58,6 +58,10 @@ tie my %temporalities, 'Tie::IxHash',
                                    'subscription',
                          'default' => '1',
                        },
+    'add_full_period'=> { 'name' => 'When prorating first month, also bill '.
+                                    'for one full period after that',
+                          'type' => 'checkbox',
+                        },
 
     'recur_method'  => { 'name' => 'Recurring fee method',
                          #'type' => 'radio',
@@ -90,6 +94,7 @@ tie my %temporalities, 'Tie::IxHash',
   'fieldorder' => [qw(
                        setup_fee recur_fee
                        recur_temporality unused_credit recur_method cutoff_day
+                       add_full_period
                        output_format usage_section summarize_usage usage_mandate
                      )
                   ],
index 918b910..22bb809 100644 (file)
@@ -79,6 +79,11 @@ use FS::part_pkg::flat;
                                     'package recharge',
                           'type' => 'checkbox',
                         },
+    'add_full_period'=> { 'name' => 'When prorating first month, also bill '.
+                                    'for one full period after that',
+                          'type' => 'checkbox',
+                        },
+
 
     #it would be better if this had to be turned on, its confusing
     'externalid' => { 'name'   => 'Optional External ID',
@@ -89,7 +94,8 @@ use FS::part_pkg::flat;
                     'seconds', 'upbytes', 'downbytes', 'totalbytes',
                     'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
                     'recharge_downbytes', 'recharge_totalbytes',
-                    'usage_rollover', 'recharge_reset', 'externalid', ],
+                    'usage_rollover', 'recharge_reset', 'add_full_period',
+                    'externalid', ],
   'freq' => 'm',
   'weight' => 20,
 );
index 2adf2f1..ed532ee 100644 (file)
@@ -80,12 +80,19 @@ sub calc_prorate {
       $mstart = 
         timelocal(0,0,0,$cutoff_day,$mon == 0 ? 11 : $mon - 1,$year-($mon==11));
     }
-    
+   
+    # next bill date will be figured as $$sdate + one period
     $$sdate = $mstart;
 
     my $permonth = $self->option('recur_fee', 1) / $self->freq;
     my $months = ( ( $self->freq - 1 ) + ($mend-$mnow) / ($mend-$mstart) );
-    
+
+    if ( $self->option('add_full_period',1) ) {
+      # charge a full period in addition to the partial month
+      $months += $self->freq;
+      $$sdate = $self->add_freq($mstart);
+    }
+
     $param->{'months'} = $months;
     $charge = sprintf('%.2f', $permonth * $months);
   }
index 3cf2064..8e803f9 100644 (file)
@@ -24,6 +24,10 @@ use DBI;
                                    'subscription',
                          'default' => '1',
                        },
+    'add_full_period'=> { 'name' => 'When prorating first month, also bill '.
+                                    'for one full period after that',
+                          'type' => 'checkbox',
+                       },
 
     'recur_method'  => { 'name' => 'Recurring fee method',
                          #'type' => 'radio',
@@ -45,7 +49,7 @@ use DBI;
                },
   },
   'fieldorder' => [qw( setup_fee recur_fee unused_credit recur_method cutoff_day
-                       datasrc db_username db_password query 
+                      add_full_period datasrc db_username db_password query 
                   )],
   'weight' => '58',
 );
index 005009a..5b83cc7 100644 (file)
@@ -70,7 +70,10 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
                                    'subscription',
                          'default' => '1',
                        },
-
+    'add_full_period'=> { 'name' => 'When prorating first month, also bill '.
+                                    'for one full period after that',
+                          'type' => 'checkbox',
+                        },
     'recur_method'  => { 'name' => 'Recurring fee method',
                          #'type' => 'radio',
                          #'options' => \%recur_method,
@@ -253,6 +256,7 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
   'fieldorder' => [qw(
                        setup_fee recur_fee recur_temporality unused_credit
                        recur_method cutoff_day
+                       add_full_period
                        cdr_svc_method
                        rating_method ratenum min_charge sec_granularity
                        ignore_unrateable
index 4937bb8..8b1844a 100644 (file)
@@ -47,6 +47,10 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
                                    'subscription',
                          'default' => '1',
                        },
+    'add_full_period'=> { 'name' => 'When prorating first month, also bill '.
+                                    'for one full period after that',
+                          'type' => 'checkbox',
+                        },
 
     'recur_method'  => { 'name' => 'Recurring fee method',
                          'type' => 'select',
@@ -152,7 +156,7 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
   },
   'fieldorder' => [qw(
                        setup_fee recur_fee recur_temporality unused_credit
-                       recur_method cutoff_day
+                       recur_method cutoff_day add_full_period
                        min_charge sec_granularity
                        default_prefix
                        disable_tollfree