prorate_round_day options to round up / down only, #42108
[freeside.git] / FS / FS / part_pkg / prorate.pm
index ac86f39..44f2f25 100644 (file)
@@ -24,9 +24,9 @@ use FS::part_pkg::flat;
                           'type' => 'checkbox',
                         },
     'prorate_round_day'=> {
-                          'name' => 'Round the prorated period to the nearest '.
-                                    'full day',
-                          'type' => 'checkbox',
+                          'name' => 'Round the prorated period',
+                          'type' => 'select',
+                          'select_options' => \%FS::part_pkg::prorate_Mixin::prorate_round_day_opts,
                         },
     'prorate_defer_bill'=> {
                         'name' => 'Defer the first bill until the billing day',
@@ -45,8 +45,12 @@ use FS::part_pkg::flat;
 sub calc_recur {
   my $self = shift;
   my $cust_pkg = $_[0];
-  $self->calc_prorate(@_, $self->cutoff_day($cust_pkg))
-    - $self->calc_discount(@_);
+
+  my $charge = $self->calc_prorate(@_, $self->cutoff_day($cust_pkg));
+  my $discount = $self->calc_discount(@_);
+
+  sprintf( '%.2f', ($cust_pkg->quantity || 1) * ($charge - $discount) );
+
 }
 
 sub cutoff_day {