[freeside-commits] branch master updated. d03d9432be02de2abb9ff3d978ad1bdd67ea89d9

Christopher Burger burgerc at freeside.biz
Wed Jan 9 17:20:18 PST 2019


The branch, master has been updated
       via  d03d9432be02de2abb9ff3d978ad1bdd67ea89d9 (commit)
      from  057fc61586d26199005660b908ece68a7a1da681 (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 d03d9432be02de2abb9ff3d978ad1bdd67ea89d9
Author: Christopher Burger <burgerc at freeside.biz>
Date:   Wed Jan 9 20:19:26 2019 -0500

    RT# 81249 - Fixed error where empty field becomes 0.

diff --git a/FS/FS/part_pkg.pm b/FS/FS/part_pkg.pm
index 356c0c038..05cbf1b57 100644
--- a/FS/FS/part_pkg.pm
+++ b/FS/FS/part_pkg.pm
@@ -695,12 +695,23 @@ sub replace {
 
 sub validate_number {
   my ($option, $valref) = @_;
+
   $$valref = 0 unless $$valref;
   return "Invalid $option"
     unless ($$valref) = ($$valref =~ /^\s*(\d+)\s*$/);
   return '';
 }
 
+sub validate_number_blank {
+  my ($option, $valref) = @_;
+
+  if ($$valref) {
+    return "Invalid $option"
+      unless ($$valref) = ($$valref =~ /^\s*(\d+)\s*$/);
+  }
+  return '';
+}
+
 =item check
 
 Checks all fields to make sure this is a valid package definition.  If
diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm
index 715d5c09b..74deb8bb3 100644
--- a/FS/FS/part_pkg/voip_cdr.pm
+++ b/FS/FS/part_pkg/voip_cdr.pm
@@ -166,13 +166,13 @@ tie my %accountcode_tollfree_field, 'Tie::IxHash',
                          },
 
     'use_cdrtypenum' => { 'name' => 'Only charge for CDRs where the CDR Type is set to this cdrtypenum: ',
-                          'validate' => \&FS::part_pkg::validate_number,
-                          'js_validate' => 'digits',
+                          'validate' => \&FS::part_pkg::validate_number_blank,
+                          'js_validate' => 'digits: true',
                          },
     
     'ignore_cdrtypenum' => { 'name' => 'Do not charge for CDRs where the CDR Type is set to this cdrtypenum: ',
-                             'validate' => \&FS::part_pkg::validate_number,
-                             'js_validate' => 'digits',
+                             'validate' => \&FS::part_pkg::validate_number_blank,
+                             'js_validate' => 'digits: true',
                          },
 
     'use_calltypenum' => { 'name' => 'Only charge for CDRs where the CDR Call Type is set to this calltypenum: ',
diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm
index 67c53af25..6358af200 100644
--- a/FS/FS/part_pkg/voip_inbound.pm
+++ b/FS/FS/part_pkg/voip_inbound.pm
@@ -64,13 +64,13 @@ tie my %granularity, 'Tie::IxHash', FS::rate_detail::granularities();
                          },
 
     'use_cdrtypenum' => { 'name' => 'Only charge for CDRs where the CDR Type is set to this cdrtypenum: ',
-                          'validate' => \&FS::part_pkg::validate_number,
-                          'js_validate' => 'digits',
+                          'validate' => \&FS::part_pkg::validate_number_blank,
+                          'js_validate' => 'digits: true',
                          },
     
     'ignore_cdrtypenum' => { 'name' => 'Do not charge for CDRs where the CDR Type is set to this cdrtypenum: ',
-                             'validate' => \&FS::part_pkg::validate_number,
-                             'js_validate' => 'digits',
+                             'validate' => \&FS::part_pkg::validate_number_blank,
+                             'js_validate' => 'digits: true',
                          },
 
     'use_calltypenum' => { 'name' => 'Only charge for CDRs where the CDR Call Type is set to this cdrtypenum: ',
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index 5e7b30674..53f68cac5 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -823,13 +823,13 @@ Example:
 %     ## set extra field values for validation.  ie price plan fields
 %     my $extra_fields_to_validate = $opt{'extra_fields_validate'};
 %     my %validate_error_messages = (
-%       'digits' => 'Please only enter numbers here.',
-%       'email'  => 'Please enter a valid email here.',
+%       'digits: true' => 'Please only enter numbers here.',
+%       'email: true'  => 'Please enter a valid email here.',
 %     );
 %     foreach my $extra_fields (keys %$extra_fields_to_validate) {
 %       my $validate_type = $extra_fields_to_validate->{$extra_fields};
-%       $js_form_validate->{edit_topform}->{validate_fields}{$extra_fields} = $validate_type.': true';
-%       $js_form_validate->{edit_topform}->{error_message}{$extra_fields} = $validate_error_messages{$validate_type};
+%       $js_form_validate->{edit_topform}->{validate_fields}{$extra_fields} = $validate_type;
+%      $js_form_validate->{edit_topform}->{error_message}{$extra_fields} = $validate_error_messages{$validate_type};
 %     }
 
 % unless ($opt{'embed'}) {

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

Summary of changes:
 FS/FS/part_pkg.pm                  | 11 +++++++++++
 FS/FS/part_pkg/voip_cdr.pm         |  8 ++++----
 FS/FS/part_pkg/voip_inbound.pm     |  8 ++++----
 httemplate/edit/elements/edit.html |  8 ++++----
 4 files changed, 23 insertions(+), 12 deletions(-)




More information about the freeside-commits mailing list