[freeside-commits] freeside/FS/FS/part_pkg prorate_Mixin.pm, 1.15.2.5, 1.15.2.6 prorate.pm, 1.29.2.1, 1.29.2.2

Mark Wells mark at wavetail.420.am
Mon Feb 6 17:35:33 PST 2012


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

Modified Files:
      Tag: FREESIDE_2_3_BRANCH
	prorate_Mixin.pm prorate.pm 
Log Message:
show prorate details on invoice, #16010

Index: prorate.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/prorate.pm,v
retrieving revision 1.29.2.1
retrieving revision 1.29.2.2
diff -u -w -d -r1.29.2.1 -r1.29.2.2
--- prorate.pm	5 Aug 2011 22:38:07 -0000	1.29.2.1
+++ prorate.pm	7 Feb 2012 01:35:30 -0000	1.29.2.2
@@ -32,8 +32,12 @@
                         'name' => 'Defer the first bill until the billing day',
                         'type' => 'checkbox',
                         },
+    'prorate_verbose' => {
+                        'name' => 'Show prorate details on the invoice',
+                        'type' => 'checkbox',
   },
-  'fieldorder' => [ 'cutoff_day', 'prorate_defer_bill', 'add_full_period', 'prorate_round_day' ],
+  },
+  'fieldorder' => [ 'cutoff_day', 'prorate_defer_bill', 'add_full_period', 'prorate_round_day', 'prorate_verbose' ],
   'freq' => 'm',
   'weight' => 20,
 );

Index: prorate_Mixin.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/prorate_Mixin.pm,v
retrieving revision 1.15.2.5
retrieving revision 1.15.2.6
diff -u -w -d -r1.15.2.5 -r1.15.2.6
--- prorate_Mixin.pm	14 Jan 2012 23:02:42 -0000	1.15.2.5
+++ prorate_Mixin.pm	7 Feb 2012 01:35:30 -0000	1.15.2.6
@@ -3,6 +3,7 @@
 use strict;
 use vars qw( %info );
 use Time::Local qw( timelocal );
+use Date::Format qw( time2str );
 
 %info = ( 
   'disabled'  => 1,
@@ -22,8 +23,13 @@
                           'billing day',
                 'type' => 'checkbox',
     },
+    'prorate_verbose' => {
+                'name' => 'Show prorate details on the invoice',
+                'type' => 'checkbox',
   },
-  'fieldorder' => [ qw(prorate_defer_bill prorate_round_day add_full_period) ],
+  },
+  'fieldorder' => [ qw(prorate_defer_bill prorate_round_day 
+                       add_full_period prorate_verbose) ],
 );
 
 sub fieldorder {
@@ -65,6 +71,7 @@
 instead of using the exact time.
 - prorate_defer_bill: Don't bill the prorate interval until the prorate 
 day arrives.
+- prorate_verbose: Generate details to explain the prorate calculations.
 
 =cut
 
@@ -73,6 +80,8 @@
   die "no cutoff_day" unless $cutoff_day;
   die "can't prorate non-monthly package\n" if $self->freq =~ /\D/;
 
+  my $money_char = FS::Conf->new->config('money_char') || '$';
+
   my $charge = $self->base_recur($cust_pkg, $sdate) || 0;
 
   my $add_period = $self->option('add_full_period',1);
@@ -103,12 +112,28 @@
   my $permonth = $charge / $self->freq;
   my $months = ( ( $self->freq - 1 ) + ($mend-$mnow) / ($mend-$mstart) );
 
+  if ( $self->option('prorate_verbose',1) 
+      and $months > 0 and $months < $self->freq ) {
+    push @$details, 
+          'Prorated (' . time2str('%b %d', $mnow) .
+            ' - ' . time2str('%b %d', $mend) . '): ' . $money_char . 
+            sprintf('%.2f', $permonth * $months + 0.00000001 );
+  }
+
   # add a full period if currently billing for a partial period
   # or periods up to freq_override if billing for an override interval
   if ( ($param->{'freq_override'} || 0) > 1 ) {
     $months += $param->{'freq_override'} - 1;
   } 
   elsif ( $add_period && $months < $self->freq) {
+
+    if ( $self->option('prorate_verbose',1) ) {
+      # calculate the prorated and add'l period charges
+      push @$details,
+        'First full month: ' . $money_char . 
+          sprintf('%.2f', $permonth);
+    }
+
     $months += $self->freq;
     $$sdate = $self->add_freq($mstart);
   }



More information about the freeside-commits mailing list