From 60540a339512bf608553e5c54ec9bfbb5bc6edbc Mon Sep 17 00:00:00 2001 From: Mark Wells Date: Wed, 20 Nov 2013 16:23:31 -0800 Subject: package quantities + CCH per-available-line taxes, #25918 --- FS/FS/part_pkg/voip_cdr.pm | 9 ++++++--- FS/FS/part_pkg/voip_inbound.pm | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/FS/FS/part_pkg/voip_cdr.pm b/FS/FS/part_pkg/voip_cdr.pm index 5a27f064f..f23b7a77c 100644 --- a/FS/FS/part_pkg/voip_cdr.pm +++ b/FS/FS/part_pkg/voip_cdr.pm @@ -611,9 +611,12 @@ sub calc_units { my($self, $cust_pkg ) = @_; my $count = 0; if ( $self->option('count_available_phones', 1)) { - map { $count += ( $_->quantity || 0 ) } - grep { $_->part_svc->svcdb eq 'svc_phone' } - $cust_pkg->part_pkg->pkg_svc; + foreach my $pkg_svc ($cust_pkg->part_pkg->pkg_svc) { + if ($pkg_svc->part_svc->svcdb eq 'svc_phone') { # svc_pbx? + $count += $pkg_svc->quantity || 0; + } + } + $count *= $cust_pkg->quantity; } else { $count = scalar(grep { $_->part_svc->svcdb eq 'svc_phone' } $cust_pkg->cust_svc); diff --git a/FS/FS/part_pkg/voip_inbound.pm b/FS/FS/part_pkg/voip_inbound.pm index 811329d9f..ec95c9040 100644 --- a/FS/FS/part_pkg/voip_inbound.pm +++ b/FS/FS/part_pkg/voip_inbound.pm @@ -399,6 +399,7 @@ sub is_free { # This equates svc_phone records; perhaps svc_phone should have a field # to indicate it represents a line +# #XXX no count_available_phones? sub calc_units { my($self, $cust_pkg ) = @_; my $count = -- cgit v1.2.1 From 90a3e43ea63ddb412b5a958e394fdf09f8ca47f2 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Wed, 27 Nov 2013 13:16:15 -0500 Subject: #25336 external_shellcommands.pm --- FS/FS/part_export/external_shellcommands.pm | 130 ++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 FS/FS/part_export/external_shellcommands.pm diff --git a/FS/FS/part_export/external_shellcommands.pm b/FS/FS/part_export/external_shellcommands.pm new file mode 100644 index 000000000..033724902 --- /dev/null +++ b/FS/FS/part_export/external_shellcommands.pm @@ -0,0 +1,130 @@ +package FS::part_export::external_shellcommands; + +use strict; +use vars qw(@ISA %info); +use Tie::IxHash; +use String::ShellQuote; +use FS::part_export; + +@ISA = qw(FS::part_export); + +tie my %options, 'Tie::IxHash', + 'user' => { label=>'Remote username', default=>'root', }, + 'useradd' => { label=>'Insert command', }, + 'userdel' => { label=>'Delete command', }, + 'usermod' => { label=>'Modify command', }, + 'suspend' => { label=>'Suspension command', }, + 'unsuspend' => { label=>'Unsuspension command', }, +; + +%info = ( + 'svc' => 'svc_external', + 'desc' => 'Run remote commands via SSH, for external Service', + 'options' => \%options, + 'notes' => <<'END' +Run remote commands via SSH, for . You will need to +setup SSH for unattended operation. +
+The following variables are available for interpolation (prefixed with new_ or +old_ for replace operations): + +END +); + +sub rebless { shift; } + +sub _export_insert { + my($self) = shift; + $self->_export_command('useradd', @_); +} + +sub _export_delete { + my($self) = shift; + $self->_export_command('userdel', @_); +} + +sub _export_suspend { + my($self) = shift; + $self->_export_command('suspend', @_); +} + +sub _export_unsuspend { + my($self) = shift; + $self->_export_command('unsuspend', @_); +} + +sub _export_command { + my ( $self, $action, $svc_external) = (shift, shift, shift); + my $command = $self->option($action); + return '' if $command =~ /^\s*$/; + + #set variable for the command + no strict 'vars'; + { + no strict 'refs'; + ${$_} = $svc_external->getfield($_) foreach $svc_external->fields; + } + my $cust_pkg = $svc_external->cust_svc->cust_pkg; + my $cust_name = $cust_pkg ? $cust_pkg->cust_main->name : ''; + my $title = shell_quote $svc_external->title; + my $pkgnum = shell_quote $cust_pkg->pkgnum; + my $custnum = shell_quote $cust_pkg->custnum; + #done setting variables for the command + + $self->shellcommands_queue( $svc_external->svcnum, + user => $self->option('user')||'root', + host => $self->machine, + command => eval(qq("$command")), + ); +} + +sub _export_replace { + my($self, $new, $old ) = (shift, shift, shift); + my $command = $self->option('usermod'); + + #set variable for the command + no strict 'vars'; + { + no strict 'refs'; + ${"old_$_"} = $old->getfield($_) foreach $old->fields; + ${"new_$_"} = $new->getfield($_) foreach $new->fields; + } + + my $new_cust_pkg = $new->cust_svc->cust_pkg; + my $old_cust_pkg = $old->cust_svc->cust_pkg; + $new_title = shell_quote $new->title; + $old_title = shell_quote $old->title; + my $new_cust_name = $new_cust_pkg ? $new_cust_pkg->cust_main->name : ''; + my $old_cust_name = $old_cust_pkg ? $old_cust_pkg->cust_main->name : ''; + my $new_pkgnum = shell_quote $new_cust_pkg->pkgnum; + my $new_custnum = shell_quote $new_cust_pkg->custnum; + my $old_pkgnum = shell_quote $old_cust_pkg->pkgnum; + my $old_custnum = shell_quote $old_cust_pkg->custnum; + #done setting variables for the command + + $self->shellcommands_queue( $new->svcnum, + user => $self->option('user')||'root', + host => $self->machine, + command => eval(qq("$command")), + ); +} + +#a good idea to queue anything that could fail or take any time +sub shellcommands_queue { + my( $self, $svcnum ) = (shift, shift); + my $queue = new FS::queue { + 'svcnum' => $svcnum, + 'job' => "FS::part_export::external_shellcommands::ssh_cmd", + }; + $queue->insert( @_ ); +} + +sub ssh_cmd { #subroutine, not method + use Net::SSH '0.08'; + &Net::SSH::ssh_cmd( { @_ } ); +} -- cgit v1.2.1 From b02c42c401382cdf35bfb81abd4ffabbbacfd5c9 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Wed, 27 Nov 2013 13:33:18 -0500 Subject: #22636 Import accountcodes on CDR --- FS/FS/cdr/qwest.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS/FS/cdr/qwest.pm b/FS/FS/cdr/qwest.pm index dd2385851..b28b05210 100644 --- a/FS/FS/cdr/qwest.pm +++ b/FS/FS/cdr/qwest.pm @@ -133,7 +133,7 @@ my $enddate = _cdr_date_parser_maker('enddate'); '', # termmem (same?) '', # fintkgrp 'charged_party', # billnum (empty for "normal" calls) - '', # acctcd + 'accountcode', # acctcd '', # swid '', # orig_bill_file_id '', # orig_trunk_group_name -- cgit v1.2.1