[freeside-commits] freeside/FS/FS/part_pkg prorate_Mixin.pm, 1.3, 1.4 prorate.pm, 1.21, 1.22

Mark Wells mark at wavetail.420.am
Fri Oct 29 01:51:53 PDT 2010


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

Modified Files:
	prorate_Mixin.pm prorate.pm 
Log Message:
prorate option to round to full day, RT#7353

Index: prorate.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/part_pkg/prorate.pm,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -w -d -r1.21 -r1.22
--- prorate.pm	29 Sep 2010 23:41:34 -0000	1.21
+++ prorate.pm	29 Oct 2010 08:51:51 -0000	1.22
@@ -83,7 +83,11 @@
                                     'for one full period after that',
                           'type' => 'checkbox',
                         },
-
+    'prorate_round_day'=> {
+                          'name' => 'When prorating first month, round to '.
+                                    'the nearest full day',
+                          'type' => 'checkbox',
+                        },
 
     #it would be better if this had to be turned on, its confusing
     'externalid' => { 'name'   => 'Optional External ID',
@@ -95,7 +99,7 @@
                     'recharge_amount', 'recharge_seconds', 'recharge_upbytes',
                     'recharge_downbytes', 'recharge_totalbytes',
                     'usage_rollover', 'recharge_reset', 'add_full_period',
-                    'externalid', ],
+                    'prorate_round_day', 'externalid', ],
   '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.3
retrieving revision 1.4
diff -u -w -d -r1.3 -r1.4
--- prorate_Mixin.pm	29 Sep 2010 23:41:34 -0000	1.3
+++ prorate_Mixin.pm	29 Oct 2010 08:51:51 -0000	1.4
@@ -66,6 +66,10 @@
     # only works for freq >= 1 month; probably can't be fixed
     my $mnow = $$sdate;
     my ($sec, $min, $hour, $mday, $mon, $year) = (localtime($mnow))[0..5];
+    if ( $self->option('prorate_round_day',1) ) {
+      $mday++ if $hour >= 12;
+      $mnow = timelocal(0,0,0,$mday,$mon,$year);
+    }
     my $mend;
     my $mstart;
     if ( $mday >= $cutoff_day ) {



More information about the freeside-commits mailing list