X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Ftax_rate.pm;h=75e72c5428600c7fcd08d00b53a8d7ca8d7d00e5;hb=9bb7341f570bcffa83ce244d1ef6e6fdbadc035b;hp=9b79b61bbd2d13feb774a5919e26e12a2e2c3116;hpb=1f036801a2595981d4cb712d4202c7d154d39027;p=freeside.git diff --git a/FS/FS/tax_rate.pm b/FS/FS/tax_rate.pm index 9b79b61bb..75e72c542 100644 --- a/FS/FS/tax_rate.pm +++ b/FS/FS/tax_rate.pm @@ -502,7 +502,9 @@ given customer (see L) =cut + #hot sub tax_on_tax { + #akshun my $self = shift; my $cust_main = shift; @@ -959,9 +961,9 @@ sub _perform_batch_import { unless $keep_cch_files; push @insert_list, $name, $insertname, $import_sub, $format; if ( $name eq 'GEOCODE' ) { #handle this whole ordering issue better - unshift @predelete_list, $name, $deletename, $import_sub; + unshift @predelete_list, $name, $deletename, $import_sub, $format; } else { - unshift @delete_list, $name, $deletename, $import_sub; + unshift @delete_list, $name, $deletename, $import_sub, $format; } } else { @@ -1263,7 +1265,7 @@ sub _remember_tax_products { if $part_pkg_taxproduct && $part_pkg_taxproduct->data_vendor eq $format; foreach my $option ( $part_pkg->part_pkg_option ) { - next unless $option->optionname =~ /^usage_taxproductnum_(\w)$/; + next unless $option->optionname =~ /^usage_taxproductnum_(\w+)$/; my $class = $1; $part_pkg_taxproduct = $part_pkg->taxproduct($class); @@ -1655,10 +1657,9 @@ sub process_download_and_update { warn "processing $dir.new/$name.txt\n" if $DEBUG; my $olddir = $update ? "$dir.1" : ""; $difffile = _perform_cch_diff( $name, "$dir.new", $olddir ); - } else { - $difffile =~ s/^$cache_dir//; - push @list, "${name}file:$difffile"; } + $difffile =~ s/^$cache_dir//; + push @list, "${name}file:$difffile"; } # perform the import @@ -1756,111 +1757,6 @@ sub browse_queries { return ($query, "SELECT COUNT(*) FROM tax_rate $extra_sql"); } -# _upgrade_data -# -# Used by FS::Upgrade to migrate to a new database. -# -# - -sub _upgrade_data { # class method - my ($self, %opts) = @_; - my $dbh = dbh; - - warn "$me upgrading $self\n" if $DEBUG; - - my @column = qw ( tax excessrate usetax useexcessrate fee excessfee - feebase feemax ); - - if ( $dbh->{Driver}->{Name} eq 'Pg' ) { - - eval "use DBI::Const::GetInfoType;"; - die $@ if $@; - - my $major_version = 0; - $dbh->get_info( $GetInfoType{SQL_DBMS_VER} ) =~ /^(\d{2})/ - && ( $major_version = sprintf("%d", $1) ); - - if ( $major_version > 7 ) { - - # ideally this would be supported in DBIx-DBSchema and friends - - foreach my $column ( @column ) { - my $columndef = dbdef->table($self->table)->column($column); - unless ($columndef->type eq 'numeric') { - - warn "updating tax_rate column $column to numeric\n" if $DEBUG; - my $sql = "ALTER TABLE tax_rate ALTER $column TYPE numeric(14,8)"; - my $sth = $dbh->prepare($sql) or die $dbh->errstr; - $sth->execute or die $sth->errstr; - - warn "updating h_tax_rate column $column to numeric\n" if $DEBUG; - $sql = "ALTER TABLE h_tax_rate ALTER $column TYPE numeric(14,8)"; - $sth = $dbh->prepare($sql) or die $dbh->errstr; - $sth->execute or die $sth->errstr; - - } - } - - } elsif ( $dbh->{pg_server_version} =~ /^704/ ) { - - # ideally this would be supported in DBIx-DBSchema and friends - - foreach my $column ( @column ) { - my $columndef = dbdef->table($self->table)->column($column); - unless ($columndef->type eq 'numeric') { - - warn "updating tax_rate column $column to numeric\n" if $DEBUG; - - foreach my $table ( qw( tax_rate h_tax_rate ) ) { - - my $sql = "ALTER TABLE $table RENAME $column TO old_$column"; - my $sth = $dbh->prepare($sql) or die $dbh->errstr; - $sth->execute or die $sth->errstr; - - my $def = dbdef->table($table)->column($column); - $def->type('numeric'); - $def->length('14,8'); - my $null = $def->null; - $def->null('NULL'); - - $sql = "ALTER TABLE $table ADD COLUMN ". $def->line($dbh); - $sth = $dbh->prepare($sql) or die $dbh->errstr; - $sth->execute or die $sth->errstr; - - $sql = "UPDATE $table SET $column = CAST( old_$column AS numeric )"; - $sth = $dbh->prepare($sql) or die $dbh->errstr; - $sth->execute or die $sth->errstr; - - unless ( $null eq 'NULL' ) { - $sql = "ALTER TABLE $table ALTER $column SET NOT NULL"; - $sth = $dbh->prepare($sql) or die $dbh->errstr; - $sth->execute or die $sth->errstr; - } - - $sql = "ALTER TABLE $table DROP old_$column"; - $sth = $dbh->prepare($sql) or die $dbh->errstr; - $sth->execute or die $sth->errstr; - - } - } - } - - } else { - - warn "WARNING: tax_rate table upgrade unsupported for this Pg version\n"; - - } - - } else { - - warn "WARNING: tax_rate table upgrade only supported for Pg 8+\n"; - - } - - ''; - -} - =back =head1 BUGS