add anniversary-rollback option to roll the anniversary date back to the 28th instead...
authorIvan Kohler <ivan@freeside.biz>
Mon, 13 May 2013 21:19:07 +0000 (14:19 -0700)
committerIvan Kohler <ivan@freeside.biz>
Mon, 13 May 2013 21:19:07 +0000 (14:19 -0700)
FS/FS/Conf.pm
FS/FS/part_pkg.pm

index 3c44520..0a9b781 100644 (file)
@@ -866,6 +866,13 @@ sub reason_type_options {
   },
 
   {
+    'key'         => 'anniversary-rollback',
+    'section'     => 'billing',
+    'description' => 'When billing an anniversary package ordered after the 28th, roll the anniversary date back to the 28th instead of forward into the following month.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'encryption',
     'section'     => 'billing',
     'description' => 'Enable encryption of credit cards and echeck numbers',
index e788269..605c84f 100644 (file)
@@ -1081,6 +1081,9 @@ sub add_freq {
   if ( $freq =~ /^\d+$/ ) {
     $mon += $freq;
     until ( $mon < 12 ) { $mon -= 12; $year++; }
+
+    $mday = 28 if $mday > 28 && FS::Conf->new->exists('anniversary-rollback');
+
   } elsif ( $freq =~ /^(\d+)w$/ ) {
     my $weeks = $1;
     $mday += $weeks * 7;