X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=FS%2FFS%2Fpart_pkg%2Fglobal_Mixin.pm;h=59eaaaaec6469f9b02b174b5520b22df18b9e7ab;hp=56f160247aaa392433486ec6c26a14e907bd97a9;hb=d82acd06f8f8a431c69c3b14e3c5cb8252edb02d;hpb=d3ce5efd1ec0e1a715a154696e2b0aa86e51c27b diff --git a/FS/FS/part_pkg/global_Mixin.pm b/FS/FS/part_pkg/global_Mixin.pm index 56f160247..59eaaaaec 100644 --- a/FS/FS/part_pkg/global_Mixin.pm +++ b/FS/FS/part_pkg/global_Mixin.pm @@ -1,9 +1,39 @@ package FS::part_pkg::global_Mixin; use strict; -use vars qw(@ISA %info); -use FS::part_pkg; -@ISA = qw(FS::part_pkg); +use vars qw(%info); + +use Tie::IxHash; +tie my %a2billing_types, 'Tie::IxHash', ( + 0 => 'Prepaid', + 1 => 'Postpaid', +); + +tie my %a2billing_simultaccess, 'Tie::IxHash', ( + 0 => 'Disabled', + 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, @@ -11,27 +41,119 @@ use FS::part_pkg; '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 '. 'cancellation', 'type' => 'checkbox', }, + 'unused_credit_suspend' => { + 'name' => 'Credit the customer for the unused portion of service when '. + 'suspending', + 'type' => 'checkbox', + }, 'unused_credit_change' => { 'name' => 'Credit the customer for the unused portion of service when '. 'changing packages', 'type' => 'checkbox', }, - }, + 'delay_cancel' => { + '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? + + 'a2billing_tariff' => { + 'name' => 'A2Billing tariff group ID', + 'display_if' => sub { + FS::part_export->count("exporttype = 'a2billing'") > 0; + } + }, + 'a2billing_type' => { + 'name' => 'A2Billing card type', + 'display_if' => sub { + FS::part_export->count("exporttype = 'a2billing'") > 0; + }, + 'type' => 'select', + 'select_options' => \%a2billing_types, + }, + 'a2billing_simultaccess' => { + 'name' => 'A2Billing Simultaneous Access', + 'display_if' => sub { + FS::part_export->count("exporttype = 'a2billing'") > 0; + }, + 'type' => 'select', + 'select_options' => \%a2billing_simultaccess, + }, + 'a2billing_carrier_cost_min' => { + 'name' => 'A2Billing inbound carrier cost', + 'display_if' => sub { + FS::part_export->count("exporttype = 'a2billing'") > 0; + }, + }, + 'a2billing_carrer_initblock_offp' => { + 'name' => 'A2Billing inbound carrier min duration', + 'display_if' => sub { + FS::part_export->count("exporttype = 'a2billing'") > 0; + }, + }, + 'a2billing_carrier_increment_offp' => { + 'name' => 'A2Billing inbound carrier billing block', + 'display_if' => sub { + FS::part_export->count("exporttype = 'a2billing'") > 0; + }, + }, + 'a2billing_retail_cost_min_offp' => { + 'name' => 'A2Billing inbound retail cost', + 'display_if' => sub { + FS::part_export->count("exporttype = 'a2billing'") > 0; + }, + }, + 'a2billing_retail_initblock_offp' => { + 'name' => 'A2Billing inbound retail min duration', + 'display_if' => sub { + FS::part_export->count("exporttype = 'a2billing'") > 0; + }, + }, + 'a2billing_retail_increment_offp' => { + 'name' => 'A2Billing inbound retail billing block', + 'display_if' => sub { + FS::part_export->count("exporttype = 'a2billing'") > 0; + }, + }, + + }, 'fieldorder' => [ qw( setup_fee recur_fee unused_credit_cancel + unused_credit_suspend unused_credit_change + delay_cancel + + count_available_phones + + a2billing_tariff + a2billing_type + a2billing_simultaccess + a2billing_carrier_cost_min + a2billing_carrer_initblock_offp + a2billing_carrier_increment_offp + a2billing_retail_cost_min_offp + a2billing_retail_initblock_offp + a2billing_retail_increment_offp )], );