diff options
Diffstat (limited to 'FS')
-rw-r--r-- | FS/FS/Schema.pm | 22 | ||||
-rw-r--r-- | FS/FS/TicketSystem.pm | 28 | ||||
-rw-r--r-- | FS/FS/cust_main/Credit_Limit.pm | 11 | ||||
-rw-r--r-- | FS/FS/part_event/Action/pkg_sales_credit_pkg.pm | 9 | ||||
-rw-r--r-- | FS/FS/rate_detail.pm | 3 | ||||
-rw-r--r-- | FS/FS/tower_sector.pm | 2 | ||||
-rw-r--r-- | FS/FS/vend_main.pm | 60 | ||||
-rwxr-xr-x | FS/bin/freeside-upgrade | 16 |
8 files changed, 119 insertions, 32 deletions
diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 12064afe2..4e67cf7ad 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -4548,16 +4548,16 @@ sub tables_hashref { 'tower_sector' => { 'columns' => [ - 'sectornum', 'serial', '', '', '', '', - 'towernum', 'int', '', '', '', '', - 'sectorname', 'varchar', '', $char_d, '', '', - 'ip_addr', 'varchar', 'NULL', 15, '', '', - 'height', 'decimal', 'NULL', '', '', '', - 'freq_mhz', 'int', 'NULL', '', '', '', - 'direction', 'int', 'NULL', '', '', '', - 'width', 'int', 'NULL', '', '', '', + 'sectornum', 'serial', '', '', '', '', + 'towernum', 'int', '', '', '', '', + 'sectorname', 'varchar', '', $char_d, '', '', + 'ip_addr', 'varchar', 'NULL', 15, '', '', + 'height', 'decimal', 'NULL', '', '', '', + 'freq_mhz', 'int', 'NULL', '', '', '', + 'direction', 'int', 'NULL', '', '', '', + 'width', 'int', 'NULL', '', '', '', #downtilt etc? rfpath has profile files for devices/antennas you upload? - 'range', 'decimal', 'NULL', '', '', '', #? + 'sector_range', 'decimal', 'NULL', '', '', '', #? ], 'primary_key' => 'sectornum', 'unique' => [ [ 'towernum', 'sectorname' ], [ 'ip_addr' ], ], @@ -4772,13 +4772,15 @@ sub tables_hashref { 'dest_regionnum', 'int', '', '', '', '', 'min_included', 'int', '', '', '', '', 'conn_charge', 'decimal', '', '10,4', '0.0000', '', + 'conn_cost', 'decimal', '', '10,4', '0.0000', '', 'conn_sec', 'int', '', '', '0', '', 'min_charge', 'decimal', '', '10,5', '', '', + 'min_cost', 'decimal', '', '10,5','0.00000', '', 'sec_granularity', 'int', '', '', '', '', 'ratetimenum', 'int', 'NULL', '', '', '', 'classnum', 'int', 'NULL', '', '', '', 'cdrtypenum', 'int', 'NULL', '', '', '', - 'region_group', 'char', 'NULL', 1, '', '', + 'region_group', 'char', 'NULL', 1, '', '', ], 'primary_key' => 'ratedetailnum', 'unique' => [ [ 'ratenum', 'orig_regionnum', 'dest_regionnum' ] ], diff --git a/FS/FS/TicketSystem.pm b/FS/FS/TicketSystem.pm index 3c972d0bd..7339d74f7 100644 --- a/FS/FS/TicketSystem.pm +++ b/FS/FS/TicketSystem.pm @@ -331,16 +331,24 @@ sub _upgrade_data { } } - #Pg-specific - my $cve_2013_3373_sql = q( - UPDATE Tickets SET Subject = REPLACE(Subject,E'\n','') - ); - #need this for mysql - #UPDATE Tickets SET Subject = REPLACE(Subject,'\n',''); - - my $cve_2013_3373_sth = $dbh->prepare( $cve_2013_3373_sql) - or die $dbh->errstr; - $cve_2013_3373_sth->execute or die $cve_2013_3373_sth->errstr; + my $cve_2013_3373_sql = ''; + if ( driver_name =~ /^Pg/i ) { + $cve_2013_3373_sql = q( + UPDATE Tickets SET Subject = REPLACE(Subject,E'\n','') + ); + } elsif ( driver_name =~ /^mysql/i ) { + $cve_2013_3373_sql = q( + UPDATE Tickets SET Subject = REPLACE(Subject,'\n',''); + ); + } else { + warn "WARNING: Don't know how to update RT Ticket Subjects for your database driver for CVE-2013-3373"; + } + if ( $cve_2013_3373_sql ) { + my $cve_2013_3373_sth = $dbh->prepare($cve_2013_3373_sql) + or die $dbh->errstr; + $cve_2013_3373_sth->execute + or die $cve_2013_3373_sth->errstr; + } # Remove dangling customer links, if any my %target_pkey = ('cust_main' => 'custnum', 'cust_svc' => 'svcnum'); diff --git a/FS/FS/cust_main/Credit_Limit.pm b/FS/FS/cust_main/Credit_Limit.pm index 238d8852f..4b2fbdfe4 100644 --- a/FS/FS/cust_main/Credit_Limit.pm +++ b/FS/FS/cust_main/Credit_Limit.pm @@ -42,13 +42,10 @@ sub check_credit_limit { #false laziness w/svc_phone->sum_cdrs / psearch_cdrs my $sum = qsearchs( { - 'select' => 'SUM(rated_price) AS rated_price', - 'table' => 'cdr', - 'hashref' => { 'status' => 'rated', - 'svcnum' => { op => 'IN', - value => '('. join(',',@svcnum). ')', - }, - }, + 'select' => 'SUM(rated_price) AS rated_price', + 'table' => 'cdr', + 'hashref' => { 'status' => 'rated', }, + 'extra_sql' => ' AND svcnum IN ('. join(',',@svcnum). ') ', } ); return '' unless $sum->rated_price > $credit_limit; diff --git a/FS/FS/part_event/Action/pkg_sales_credit_pkg.pm b/FS/FS/part_event/Action/pkg_sales_credit_pkg.pm new file mode 100644 index 000000000..1e3c2b322 --- /dev/null +++ b/FS/FS/part_event/Action/pkg_sales_credit_pkg.pm @@ -0,0 +1,9 @@ +package FS::part_event::Action::pkg_sales_credit_pkg; + +use strict; +use base qw( FS::part_event::Action::Mixin::credit_pkg + FS::part_event::Action::pkg_sales_credit ); + +sub description { 'Credit the package sales person an amount based on the referred package'; } + +1; diff --git a/FS/FS/rate_detail.pm b/FS/FS/rate_detail.pm index 66c5c9740..d81d9dbda 100644 --- a/FS/FS/rate_detail.pm +++ b/FS/FS/rate_detail.pm @@ -129,7 +129,10 @@ sub check { #|| $self->ut_money('min_charge') #good enough for now... + || $self->ut_floatn('conn_charge') + || $self->ut_floatn('conn_cost') || $self->ut_float('min_charge') + || $self->ut_floatn('min_cost') || $self->ut_number('sec_granularity') diff --git a/FS/FS/tower_sector.pm b/FS/FS/tower_sector.pm index 7e6819a3d..4fbd89ca2 100644 --- a/FS/FS/tower_sector.pm +++ b/FS/FS/tower_sector.pm @@ -109,7 +109,7 @@ sub check { || $self->ut_numbern('freq_mhz') || $self->ut_numbern('direction') || $self->ut_numbern('width') - || $self->ut_floatn('range') + || $self->ut_floatn('sector_range') ; return $error if $error; diff --git a/FS/FS/vend_main.pm b/FS/FS/vend_main.pm index 2e5e1505a..22ac0bf70 100644 --- a/FS/FS/vend_main.pm +++ b/FS/FS/vend_main.pm @@ -101,6 +101,66 @@ sub check { =item vend_class +=item search + +=cut + +sub search { + my ($class, $param) = @_; + + my @where = (); + my $addl_from = ''; + + #_date + if ( $param->{_date} ) { + my($beginning, $ending) = @{$param->{_date}}; + + push @where, "vend_bill._date >= $beginning", + "vend_bill._date < $ending"; + } + + #payment_date + if ( $param->{payment_date} ) { + my($beginning, $ending) = @{$param->{payment_date}}; + + push @where, "vend_pay._date >= $beginning", + "vend_pay._date < $ending"; + } + + if ( $param->{'classnum'} =~ /^(\d+)$/ ) { + push @where, "vend_main.classnum = $1"; + } + + my $extra_sql = scalar(@where) ? ' WHERE '. join(' AND ', @where) : ''; + + my $group_by = ' GROUP BY vend_main.vendnum '; + + my $addl_from_vend_bill = ' LEFT JOIN vend_bill_pay USING (vendbillnum) '. + ' LEFT JOIN vend_pay USING (vendpaynum) '; + + $addl_from .= " LEFT JOIN vend_bill USING ( vendnum ) $addl_from_vend_bill"; + + #simplistic, but how we are for now + + my $count_query = " + SELECT COUNT(*), + ( SELECT SUM(charged) from vend_bill $addl_from_vend_bill $extra_sql + ) AS sum_charged + FROM vend_main "; #XXX classnum, sum_charged > 0 + + +{ + 'table' => 'vend_main', + 'select' => 'vend_main.*, sum(vend_bill.charged) as sum_charged', + 'addl_from' => $addl_from, + 'hashref' => {}, + 'extra_sql' => "$extra_sql $group_by", + 'order_by' => 'ORDER BY sum_charged desc', + 'count_query' => $count_query, + #'extra_headers' => \@extra_headers, + #'extra_fields' => \@extra_fields, + }; +} + =back =head1 BUGS diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade index b2cd3db49..5b94c4775 100755 --- a/FS/bin/freeside-upgrade +++ b/FS/bin/freeside-upgrade @@ -94,10 +94,18 @@ if ( dbdef->table('areacode') and } if ( dbdef->table('upgrade_journal') ) { - push @bugfix, "SELECT SETVAL( 'upgrade_journal_upgradenum_seq', - ( SELECT MAX(upgradenum) FROM upgrade_journal ) - ) - "; + if ( driver_name =~ /^Pg/i ) { + push @bugfix, " + SELECT SETVAL( 'upgrade_journal_upgradenum_seq', + ( SELECT MAX(upgradenum) FROM upgrade_journal ) + ) + "; + } elsif ( driver_name =~ /^mysql/i ) { + push @bugfix, " + ALTER TABLE upgrade_journal AUTO_INCREMENT = + ( ( SELECT MAX(upgradenum) FROM upgrade_journal ) + 1 ) + "; + } } if ( $DRY_RUN ) { |