[freeside-commits] branch FREESIDE_3_BRANCH updated. 2a95a4cd4d79dcf1450e8ff3ee63b82c1416cc8d

Ivan ivan at 420.am
Tue Jul 2 20:02:48 PDT 2013


The branch, FREESIDE_3_BRANCH has been updated
       via  2a95a4cd4d79dcf1450e8ff3ee63b82c1416cc8d (commit)
      from  44824b823129157a89147bb34fc563d5373d7a0a (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 2a95a4cd4d79dcf1450e8ff3ee63b82c1416cc8d
Author: Ivan Kohler <ivan at freeside.biz>
Date:   Tue Jul 2 20:02:47 2013 -0700

    fix discounts vs. quantities for prorate packages, RT#23530

diff --git a/FS/FS/part_pkg/cdr_termination.pm b/FS/FS/part_pkg/cdr_termination.pm
index 37fa47e..54bce2c 100644
--- a/FS/FS/part_pkg/cdr_termination.pm
+++ b/FS/FS/part_pkg/cdr_termination.pm
@@ -182,7 +182,7 @@ sub calc_recur {
     
   # eotermiation calculation
 
-  $charges += $self->calc_recur_Common(@_);
+  $charges += ($cust_pkg->quantity || 1) * $self->calc_recur_Common(@_);
 
   $charges;
 }
diff --git a/FS/FS/part_pkg/prorate.pm b/FS/FS/part_pkg/prorate.pm
index ac86f39..a5f9ef6 100644
--- a/FS/FS/part_pkg/prorate.pm
+++ b/FS/FS/part_pkg/prorate.pm
@@ -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 {
diff --git a/FS/FS/part_pkg/prorate_Mixin.pm b/FS/FS/part_pkg/prorate_Mixin.pm
index 9efc7e8..e8d42b9 100644
--- a/FS/FS/part_pkg/prorate_Mixin.pm
+++ b/FS/FS/part_pkg/prorate_Mixin.pm
@@ -169,9 +169,6 @@ sub calc_prorate {
                                                   #so 1.005 rounds to 1.01
   $charge = sprintf('%.2f', $permonth * $months + 0.00000001 );
 
-  my $quantity = $cust_pkg->quantity || 1;
-  $charge *= $quantity;
-
   return sprintf('%.2f', $charge);
 }
 
diff --git a/FS/FS/part_pkg/sql_external.pm b/FS/FS/part_pkg/sql_external.pm
index 4bf9ecb..813e808 100644
--- a/FS/FS/part_pkg/sql_external.pm
+++ b/FS/FS/part_pkg/sql_external.pm
@@ -71,7 +71,7 @@ sub calc_recur {
   }
 
   $param->{'override_charges'} = $price;
-  $self->calc_recur_Common($cust_pkg,$sdate,$details,$param);
+  ($cust_pkg->quantity || 1) * $self->calc_recur_Common($cust_pkg,$sdate,$details,$param);
 }
 
 sub can_discount { 1; }
diff --git a/FS/FS/part_pkg/subscription.pm b/FS/FS/part_pkg/subscription.pm
index bf88f51..0dfe049 100644
--- a/FS/FS/part_pkg/subscription.pm
+++ b/FS/FS/part_pkg/subscription.pm
@@ -102,7 +102,7 @@ sub calc_recur {
 
   my $discount = $self->calc_discount($cust_pkg, $sdate, $details, $param);
 
-  sprintf('%.2f', $br - $discount);
+  sprintf('%.2f', ($cust_pkg->quantity || 1) * ($br - $discount) );
 }
 
 1;
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 21c6a8a..1a97186 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -31,6 +31,11 @@ tie my %rating_method, 'Tie::IxHash',
   'single_price' => 'A single price per minute for all calls.',
 ;
 
+tie my %rounding, 'Tie::IxHash',
+  '2' => 'Two decimal places (cent)',
+  '4' => 'Four decimal places (100th of a cent)',
+;
+
 #tie my %cdr_location, 'Tie::IxHash',
 #  'internal' => 'Internal: CDR records imported into the internal CDR table',
 #  'external' => 'External: CDR records queried directly from an external '.
@@ -92,6 +97,11 @@ tie my %detail_formats, 'Tie::IxHash',
                          'options' => \%rating_method,
                        },
 
+    'rounding' => { 'name' => 'Rounding for destination prefix rating',
+                    'type' => 'select',
+                    'select_options' => \%rounding,
+                  },
+
     'ratenum'   => { 'name' => 'Rate plan',
                      'type' => 'select',
                      'select_table' => 'rate',
@@ -304,7 +314,7 @@ tie my %detail_formats, 'Tie::IxHash',
                        FS::part_pkg::prorate_Mixin::fieldorder,
                     qw(
                        cdr_svc_method
-                       rating_method ratenum intrastate_ratenum 
+                       rating_method rounding ratenum intrastate_ratenum 
                        calls_included
                        min_charge min_included sec_granularity
                        ignore_unrateable
@@ -352,7 +362,7 @@ sub calc_recur {
   my $charges = 0;
 
   $charges += $self->calc_usage(@_);
-  $charges += $self->calc_recur_Common(@_);
+  $charges += ($cust_pkg->quantity || 1) * $self->calc_recur_Common(@_);
 
   $charges;
 
@@ -423,6 +433,11 @@ sub calc_usage {
       $svc_x = $cust_svc->svc_x;
     }
 
+    unless ( $svc_x ) {
+      my $h = $self->option('bill_inactive_svcs',1) ? 'h_' : '';
+      warn "WARNING: no $h$svc_table for svcnum ". $cust_svc->svcnum. "\n";
+    }
+
     my %options = (
         'disable_src'    => $self->option('disable_src'),
         'default_prefix' => $self->option('default_prefix'),
diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm
index 525db80..811329d 100644
--- a/FS/FS/part_pkg/voip_inbound.pm
+++ b/FS/FS/part_pkg/voip_inbound.pm
@@ -179,7 +179,7 @@ sub calc_recur {
   my $charges = 0;
 
   $charges += $self->calc_usage(@_);
-  $charges += $self->calc_recur_Common(@_);
+  $charges += ($cust_pkg->quantity || 1) * $self->calc_recur_Common(@_);
 
   $charges;
 

-----------------------------------------------------------------------

Summary of changes:
 FS/FS/part_pkg/cdr_termination.pm |    2 +-
 FS/FS/part_pkg/prorate.pm         |    8 ++++++--
 FS/FS/part_pkg/prorate_Mixin.pm   |    3 ---
 FS/FS/part_pkg/sql_external.pm    |    2 +-
 FS/FS/part_pkg/subscription.pm    |    2 +-
 FS/FS/part_pkg/voip_cdr.pm        |   19 +++++++++++++++++--
 FS/FS/part_pkg/voip_inbound.pm    |    2 +-
 7 files changed, 27 insertions(+), 11 deletions(-)




More information about the freeside-commits mailing list