[freeside-commits] branch FREESIDE_4_BRANCH updated. 40f3374957a5b709df2a54a69f7c9883d4b9ca38

Mark Wells mark at 420.am
Thu Oct 27 12:19:56 PDT 2016


The branch, FREESIDE_4_BRANCH has been updated
       via  40f3374957a5b709df2a54a69f7c9883d4b9ca38 (commit)
      from  840c45f3ae5661130f9a6068ae5c9e03c47c9f39 (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 40f3374957a5b709df2a54a69f7c9883d4b9ca38
Author: Mark Wells <mark at freeside.biz>
Date:   Thu Oct 27 12:19:32 2016 -0700

    add calc_units to plans other than voip_cdr, #39639

diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index 008ba8a..35f178e 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -1917,13 +1917,27 @@ sub calc_remain { 0; }
 =item calc_units CUST_PKG
 
 This returns the number of provisioned svc_phone records, or, of the package
-count_available_phones option is set, the number available to be provisoined
+count_available_phones option is set, the number available to be provisioned
 in the package.
 
 =cut
 
-#fallback that returns 0 for old legacy packages with no plan
-sub calc_units  { 0; }
+sub calc_units {
+  my($self, $cust_pkg ) = @_;
+  my $count = 0;
+  if ( $self->option('count_available_phones', 1)) {
+    foreach my $pkg_svc ($cust_pkg->part_pkg->pkg_svc) {
+      if ($pkg_svc->part_svc->svcdb eq 'svc_phone') { # svc_pbx?
+        $count += $pkg_svc->quantity || 0;
+      }
+    }
+    $count *= $cust_pkg->quantity;
+  } else {
+    $count =
+      scalar(grep { $_->part_svc->svcdb eq 'svc_phone' } $cust_pkg->cust_svc);
+  }
+  $count;
+}
 
 #fallback for everything not based on flat.pm
 sub recur_temporality { 'upcoming'; }
diff --git a/FS/FS/part_pkg/global_Mixin.pm b/FS/FS/part_pkg/global_Mixin.pm
index e82602e..59eaaaa 100644
--- a/FS/FS/part_pkg/global_Mixin.pm
+++ b/FS/FS/part_pkg/global_Mixin.pm
@@ -30,6 +30,10 @@ sub validate_moneyn {
   return '';
 }
 
+tie my %count_available_phones, 'Tie::IxHash', (
+  0 => 'Provisioned phone services',
+  1 => 'All available phone services',
+);
 
 %info = (
   'disabled' => 1,
@@ -63,6 +67,11 @@ sub validate_moneyn {
       'name' => 'Automatic suspension period before cancelling (configuration setting part_pkg-delay_cancel-days)',
       'type' => 'checkbox',
     },
+    'count_available_phones' => { 'name' => 'Count taxable phone lines',
+      'type' => 'radio',
+      'options' => \%count_available_phones,
+      'default' => 0,
+    },
 
     # miscellany--maybe put this in a separate module?
 
@@ -134,6 +143,8 @@ sub validate_moneyn {
     unused_credit_change
     delay_cancel
 
+    count_available_phones
+
     a2billing_tariff
     a2billing_type
     a2billing_simultaccess
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 420026d..9ecdba6 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -289,10 +289,6 @@ tie my %accountcode_tollfree_field, 'Tie::IxHash',
                                'type' => 'checkbox',
                              },
 
-    'count_available_phones' => { 'name' => 'Consider for tax purposes the number of lines to be svc_phones that may be provisioned rather than those that actually are.',
-                           'type' => 'checkbox',
-                         },
-
     #XXX also have option for an external db?  these days we suck them into ours
 #    'cdr_location' => { 'name' => 'CDR database location'
 #                        'type' => 'select',
@@ -353,7 +349,7 @@ tie my %accountcode_tollfree_field, 'Tie::IxHash',
                        usage_mandate usage_section summarize_usage 
                        usage_showzero bill_every_call bill_inactive_svcs
                        bill_only_pkg_dates
-                       count_available_phones suspend_bill 
+                       suspend_bill 
                      )
                   ],
   'weight' => 41,
@@ -656,25 +652,6 @@ sub is_free {
   0;
 }
 
-#  This equates svc_phone records; perhaps svc_phone should have a field
-#  to indicate it represents a line
-sub calc_units {    
-  my($self, $cust_pkg ) = @_;
-  my $count = 0;
-  if ( $self->option('count_available_phones', 1)) {
-    foreach my $pkg_svc ($cust_pkg->part_pkg->pkg_svc) {
-      if ($pkg_svc->part_svc->svcdb eq 'svc_phone') { # svc_pbx?
-        $count += $pkg_svc->quantity || 0;
-      }
-    }
-    $count *= $cust_pkg->quantity;
-  } else {
-    $count = 
-      scalar(grep { $_->part_svc->svcdb eq 'svc_phone' } $cust_pkg->cust_svc);
-  }
-  $count;
-}
-
 sub reset_usage {
   my ($self, $cust_pkg, %opt) = @_;
   my @part_pkg_usage = $self->part_pkg_usage or return '';
diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm
index e911439..15af706 100644
--- a/FS/FS/part_pkg/voip_inbound.pm
+++ b/FS/FS/part_pkg/voip_inbound.pm
@@ -399,15 +399,5 @@ sub is_free {
   0;
 }
 
-#  This equates svc_phone records; perhaps svc_phone should have a field
-#  to indicate it represents a line
-#  #XXX no count_available_phones?
-sub calc_units {    
-  my($self, $cust_pkg ) = @_;
-  my $count = 
-      scalar(grep { $_->part_svc->svcdb eq 'svc_phone' } $cust_pkg->cust_svc);
-  $count;
-}
-
 1;
 

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

Summary of changes:
 FS/FS/part_pkg.pm              |   20 +++++++++++++++++---
 FS/FS/part_pkg/global_Mixin.pm |   11 +++++++++++
 FS/FS/part_pkg/voip_cdr.pm     |   25 +------------------------
 FS/FS/part_pkg/voip_inbound.pm |   10 ----------
 4 files changed, 29 insertions(+), 37 deletions(-)




More information about the freeside-commits mailing list