projects
/
freeside.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix problems using inventory for UID (and other fields controlled by check in svc_acc...
[freeside.git]
/
FS
/
FS
/
pay_batch.pm
diff --git
a/FS/FS/pay_batch.pm
b/FS/FS/pay_batch.pm
index
ffa6e20
..
e0531f4
100644
(file)
--- a/
FS/FS/pay_batch.pm
+++ b/
FS/FS/pay_batch.pm
@@
-4,7
+4,6
@@
use strict;
use vars qw( @ISA $DEBUG %import_info %export_info $conf );
use Time::Local;
use Text::CSV_XS;
use vars qw( @ISA $DEBUG %import_info %export_info $conf );
use Time::Local;
use Text::CSV_XS;
-use XML::Simple qw(XMLin XMLout);
use FS::Record qw( dbh qsearch qsearchs );
use FS::cust_pay;
use FS::Conf;
use FS::Record qw( dbh qsearch qsearchs );
use FS::cust_pay;
use FS::Conf;
@@
-197,7
+196,7
@@
sub import_results {
or die "unknown format $format";
my $filetype = $info->{'filetype'}; # CSV or fixed
or die "unknown format $format";
my $filetype = $info->{'filetype'}; # CSV or fixed
- my @fields = @{ $info->{'fields'}
};
+ my @fields = @{ $info->{'fields'}};
my $formatre = $info->{'formatre'}; # for fixed
my @all_values;
my $begin_condition = $info->{'begin_condition'};
my $formatre = $info->{'formatre'}; # for fixed
my @all_values;
my $begin_condition = $info->{'begin_condition'};
@@
-241,11
+240,13
@@
sub import_results {
# process one line at a time.
if ($filetype eq 'XML') {
# process one line at a time.
if ($filetype eq 'XML') {
+ eval "use XML::Simple";
+ die $@ if $@;
my @xmlkeys = @{ $info->{'xmlkeys'} }; # for XML
my $xmlrow = $info->{'xmlrow'}; # also for XML
# Do everything differently.
my @xmlkeys = @{ $info->{'xmlkeys'} }; # for XML
my $xmlrow = $info->{'xmlrow'}; # also for XML
# Do everything differently.
- my $data = XMLin($fh, KeepRoot => 1);
+ my $data = XML
::Simple::XML
in($fh, KeepRoot => 1);
my $rows = $data;
# $xmlrow = [ RootKey, FirstLevelKey, SecondLevelKey... ]
$rows = $rows->{$_} foreach( @$xmlrow );
my $rows = $data;
# $xmlrow = [ RootKey, FirstLevelKey, SecondLevelKey... ]
$rows = $rows->{$_} foreach( @$xmlrow );
@@
-255,7
+256,7
@@
sub import_results {
}
$rows = [ $rows ] if ref($rows) ne 'ARRAY';
foreach my $row (@$rows) {
}
$rows = [ $rows ] if ref($rows) ne 'ARRAY';
foreach my $row (@$rows) {
- push @all_values, [ @{$row}{@xmlkeys} ];
+ push @all_values, [ @{$row}{@xmlkeys}
, $row
];
}
}
else {
}
}
else {
@@
-268,9
+269,9
@@
sub import_results {
$dbh->rollback if $oldAutoCommit;
return "can't parse: ". $csv->error_input();
};
$dbh->rollback if $oldAutoCommit;
return "can't parse: ". $csv->error_input();
};
- push @all_values, [ $csv->fields() ];
+ push @all_values, [ $csv->fields()
, $line
];
}elsif ($filetype eq 'fixed'){
}elsif ($filetype eq 'fixed'){
- my @values =
$line =~ /$formatre/
;
+ my @values =
( $line =~ /$formatre/, $line )
;
unless (@values) {
$dbh->rollback if $oldAutoCommit;
return "can't parse: ". $line;
unless (@values) {
$dbh->rollback if $oldAutoCommit;
return "can't parse: ". $line;
@@
-287,15
+288,20
@@
sub import_results {
my @values = @$_;
my %hash;
my @values = @$_;
my %hash;
+ my $line = pop @values;
foreach my $field ( @fields ) {
my $value = shift @values;
next unless $field;
$hash{$field} = $value;
}
foreach my $field ( @fields ) {
my $value = shift @values;
next unless $field;
$hash{$field} = $value;
}
- if ( defined($end_condition) and &{$end_condition}(\%hash) ) {
+ if ( defined($begin_condition) and &{$begin_condition}(\%hash, $line)) {
+ undef $begin_condition;
+ }
+
+ if ( defined($end_condition) and &{$end_condition}(\%hash, $line) ) {
my $error;
my $error;
- $error = &{$end_hook}(\%hash, $total) if defined($end_hook);
+ $error = &{$end_hook}(\%hash, $total
, $line
) if defined($end_hook);
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;
if ( $error ) {
$dbh->rollback if $oldAutoCommit;
return $error;