X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fglobal_Mixin.pm;h=0281a51f81d59c60293bc5681e53009e1ead7b67;hb=5c3409b2a987a9a6fc6ca77bcaceb4b7cefa03de;hp=2637729554bdbb94b8b619836d4579097d9f49c8;hpb=786cc8367ea7c504a762eb698ae4f93fc76b0dc1;p=freeside.git diff --git a/FS/FS/part_pkg/global_Mixin.pm b/FS/FS/part_pkg/global_Mixin.pm index 263772955..0281a51f8 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*(\d*)(\.\d{1})\s*$/ ) { + #handle one decimal place without barfing out + $$valref = ( ($1||''). ($2||''). ($3.'0') ) || 0; + } elsif ( $$valref =~ /^\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 '. @@ -40,6 +59,10 @@ tie my %a2billing_simultaccess, 'Tie::IxHash', ( 'changing packages', 'type' => 'checkbox', }, + 'delay_cancel' => { + 'name' => 'Automatic suspension period before cancelling (configuration setting part_pkg-delay_cancel-days)', + 'type' => 'checkbox', + }, # miscellany--maybe put this in a separate module? @@ -109,6 +132,7 @@ tie my %a2billing_simultaccess, 'Tie::IxHash', ( unused_credit_cancel unused_credit_suspend unused_credit_change + delay_cancel a2billing_tariff a2billing_type