add calc_units to plans other than voip_cdr, #39639
[freeside.git] / FS / FS / part_pkg / global_Mixin.pm
index 2318c3e..59eaaaa 100644 (file)
@@ -14,16 +14,39 @@ tie my %a2billing_simultaccess, 'Tie::IxHash', (
   1 => 'Enabled',
 );
 
+# much false laziness with FS::Record::ut_money
+sub validate_moneyn {
+  my ($option, $valref) = @_;
+  if ( $$valref eq '' ) {
+    return '';
+  } elsif ( $$valref =~ /^\s*(\d*)(\.\d{1})\s*$/ ) {
+    #handle one decimal place without barfing out
+    $$valref = ( ($1||''). ($2.'0') ) || 0;
+  } elsif ( $$valref =~ /^\s*(\d*)(\.\d{2})?\s*$/ ) {
+    $$valref = ( ($1||''). ($2||'') ) || 0;
+  } else {
+    return "Illegal (money) $option: ". $$valref;
+  }
+  return '';
+}
+
+tie my %count_available_phones, 'Tie::IxHash', (
+  0 => 'Provisioned phone services',
+  1 => 'All available phone services',
+);
+
 %info = (
   'disabled' => 1,
   'fields' => {
     'setup_fee' => { 
       'name' => 'Setup fee for this package',
       'default' => 0,
+      'validate' => \&validate_moneyn,
     },
     'recur_fee' => { 
       'name' => 'Recurring fee for this package',
       'default' => 0,
+      'validate' => \&validate_moneyn,
     },
     'unused_credit_cancel' => {
       'name' => 'Credit the customer for the unused portion of service at '.
@@ -41,9 +64,14 @@ tie my %a2billing_simultaccess, 'Tie::IxHash', (
       'type' => 'checkbox',
     },
     'delay_cancel' => {
-      'name' => 'Automatically suspend for one day before cancelling',
+      '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?
 
@@ -115,6 +143,8 @@ tie my %a2billing_simultaccess, 'Tie::IxHash', (
     unused_credit_change
     delay_cancel
 
+    count_available_phones
+
     a2billing_tariff
     a2billing_type
     a2billing_simultaccess