projects
/
freeside.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
3cb93a3
)
correct ordering and other bugs in tax updates
author
jeff
<jeff>
Mon, 13 Jul 2009 16:02:32 +0000
(16:02 +0000)
committer
jeff
<jeff>
Mon, 13 Jul 2009 16:02:32 +0000
(16:02 +0000)
FS/FS/tax_rate.pm
patch
|
blob
|
history
FS/FS/tax_rate_location.pm
patch
|
blob
|
history
diff --git
a/FS/FS/tax_rate.pm
b/FS/FS/tax_rate.pm
index
9a25f94
..
d55b09b
100644
(file)
--- a/
FS/FS/tax_rate.pm
+++ b/
FS/FS/tax_rate.pm
@@
-917,6
+917,7
@@
sub process_batch_import {
my $error = '';
my @insert_list = ();
my @delete_list = ();
my $error = '';
my @insert_list = ();
my @delete_list = ();
+ my @predelete_list = ();
my @list = ( 'GEOCODE', 'geofile', \&FS::tax_rate_location::batch_import,
'CODE', 'codefile', \&FS::tax_class::batch_import,
my @list = ( 'GEOCODE', 'geofile', \&FS::tax_rate_location::batch_import,
'CODE', 'codefile', \&FS::tax_class::batch_import,
@@
-972,9
+973,26
@@
sub process_batch_import {
close $dfh;
push @insert_list, $name, $ifh->filename, $import_sub;
close $dfh;
push @insert_list, $name, $ifh->filename, $import_sub;
- unshift @delete_list, $name, $dfh->filename, $import_sub;
+ if ( $name eq 'GEOCODE' ) { #handle this whole ordering issue better
+ unshift @predelete_list, $name, $dfh->filename, $import_sub;
+ } else {
+ unshift @delete_list, $name, $dfh->filename, $import_sub;
+ }
}
}
+
+ while( scalar(@predelete_list) ) {
+ my ($name, $file, $import_sub) =
+ (shift @predelete_list, shift @predelete_list, shift @predelete_list);
+
+ my $fmt = $format. ( $name eq 'ZIP' ? '-zip' : '' );
+ open my $fh, "< $file" or $error ||= "Can't open $name file $file: $!";
+ $error ||=
+ &{$import_sub}({ 'filehandle' => $fh, 'format' => $fmt }, $job);
+ close $fh;
+ unlink $file or warn "Can't delete $file: $!";
+ }
+
while( scalar(@insert_list) ) {
my ($name, $file, $import_sub) =
(shift @insert_list, shift @insert_list, shift @insert_list);
while( scalar(@insert_list) ) {
my ($name, $file, $import_sub) =
(shift @insert_list, shift @insert_list, shift @insert_list);
@@
-1316,7
+1334,7
@@
sub process_download_and_update {
if (-d $dir) {
if (-d "$dir.4") {
if (-d $dir) {
if (-d "$dir.4") {
- opendir(my $dirh,
$dir
) or die "failed to open $dir.4: $!\n";
+ opendir(my $dirh,
"$dir.4"
) or die "failed to open $dir.4: $!\n";
foreach my $file (readdir($dirh)) {
unlink "$dir.4/$file" if (-f "$dir.4/$file");
}
foreach my $file (readdir($dirh)) {
unlink "$dir.4/$file" if (-f "$dir.4/$file");
}
@@
-1426,6
+1444,7
@@
sub process_download_and_update {
my @insert_list = ();
my @delete_list = ();
my @insert_list = ();
my @delete_list = ();
+ my @predelete_list = ();
my @list = (
'geocode', \&FS::tax_rate_location::batch_import,
my @list = (
'geocode', \&FS::tax_rate_location::batch_import,
@@
-1491,13
+1510,31
@@
sub process_download_and_update {
%oldlines = ();
push @insert_list, $name, $ifh->filename, $method;
%oldlines = ();
push @insert_list, $name, $ifh->filename, $method;
- unshift @delete_list, $name, $dfh->filename, $method
- unless $name eq 'detail';
+ if ( $name eq 'geocode' ) {
+ unshift @predelete_list, $name, $dfh->filename, $method
+ unless $name eq 'detail';
+ } else {
+ unshift @delete_list, $name, $dfh->filename, $method
+ unless $name eq 'detail';
+ }
close $dfh;
close $ifh;
}
close $dfh;
close $ifh;
}
+ while( scalar(@predelete_list) ) {
+ my ($name, $file, $method) =
+ (shift @predelete_list, shift @predelete_list, shift @predelete_list);
+
+ my $fmt = "$format-update";
+ $fmt = $fmt. ( $name eq 'zip' ? '-zip' : '' );
+ open my $fh, "< $file" or $error ||= "Can't open $name file $file: $!";
+ $error ||=
+ &{$method}({ 'filehandle' => $fh, 'format' => $fmt }, $job);
+ close $fh;
+ #unlink $file or warn "Can't delete $file: $!";
+ }
+
while( scalar(@insert_list) ) {
my ($name, $file, $method) =
(shift @insert_list, shift @insert_list, shift @insert_list);
while( scalar(@insert_list) ) {
my ($name, $file, $method) =
(shift @insert_list, shift @insert_list, shift @insert_list);
diff --git
a/FS/FS/tax_rate_location.pm
b/FS/FS/tax_rate_location.pm
index
0e0dafe
..
218ed97
100644
(file)
--- a/
FS/FS/tax_rate_location.pm
+++ b/
FS/FS/tax_rate_location.pm
@@
-125,11
+125,18
@@
sub check {
;
return $error if $error;
;
return $error if $error;
- my $t = qsearchs( 'tax_rate_location',
- { map { $_ => $self->$_ } qw( data_vendor geocode ) },
- );
-
- return "geocode already in use for this vendor"
+ my $t;
+ $t = qsearchs( 'tax_rate_location',
+ { disabled => '',
+ ( map { $_ => $self->$_ } qw( data_vendor geocode ) ),
+ },
+ )
+ unless $self->disabled;
+
+ $t = $self->by_key( $self->taxratelocationnum )
+ if ( !$t && $self->taxratelocationnum );
+
+ return "geocode ". $self->geocode. " already in use for this vendor"
if ( $t && $t->taxratelocationnum != $self->taxratelocationnum );
return "may only be disabled"
if ( $t && $t->taxratelocationnum != $self->taxratelocationnum );
return "may only be disabled"
@@
-194,7
+201,7
@@
sub batch_import {
if (exists($hash->{'actionflag'}) && $hash->{'actionflag'} eq 'D') {
delete($hash->{actionflag});
if (exists($hash->{'actionflag'}) && $hash->{'actionflag'} eq 'D') {
delete($hash->{actionflag});
- $hash->{d
elet
ed} = '';
+ $hash->{d
isabl
ed} = '';
my $tax_rate_location = qsearchs('tax_rate_location', $hash);
return "Can't find tax_rate_location to delete: ".
join(" ", map { "$_ => ". $hash->{$_} } @fields)
my $tax_rate_location = qsearchs('tax_rate_location', $hash);
return "Can't find tax_rate_location to delete: ".
join(" ", map { "$_ => ". $hash->{$_} } @fields)
@@
-279,7
+286,7
@@
sub batch_import {
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
- return "can't insert tax_rate for $line: $error";
+ return "can't insert tax_rate
_location
for $line: $error";
}
}
}
}