summaryrefslogtreecommitdiff
path: root/FS/FS/part_pkg
diff options
context:
space:
mode:
authorJonathan Prykop <jonathan@freeside.biz>2016-04-25 16:18:10 -0500
committerJonathan Prykop <jonathan@freeside.biz>2016-04-25 16:21:50 -0500
commit17082fbc034dac221ff1748f19a9114306a829cf (patch)
treefb8142ffbf9c4722f417d964c58513aa91d54834 /FS/FS/part_pkg
parent0ea99482851f5c4d7afa6cfc9c08c3b29f0732a8 (diff)
RT#41866: Punctuation prevented package from billing
Diffstat (limited to 'FS/FS/part_pkg')
-rw-r--r--FS/FS/part_pkg/global_Mixin.pm19
1 files changed, 19 insertions, 0 deletions
diff --git a/FS/FS/part_pkg/global_Mixin.pm b/FS/FS/part_pkg/global_Mixin.pm
index 9faddf0..31d178d 100644
--- a/FS/FS/part_pkg/global_Mixin.pm
+++ b/FS/FS/part_pkg/global_Mixin.pm
@@ -14,16 +14,35 @@ 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*(\-)?\s*(\d*)(\.\d{1})\s*$/ ) {
+ #handle one decimal place without barfing out
+ $$valref = ( ($1||''). ($2||''). ($3.'0') ) || 0;
+ } elsif ( $$valref =~ /^\s*(\-)?\s*(\d*)(\.\d{2})?\s*$/ ) {
+ $$valref = ( ($1||''). ($2||''). ($3||'') ) || 0;
+ } else {
+ return "Illegal (money) $option: ". $$valref;
+ }
+ return '';
+}
+
+
%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 '.