return $self->{trans_id};
}
+sub warnings {
+ my $self = shift;
+
+ if (@_) {
+ $self->{warnings} = \@_;
+ } else {
+ return $self->{warnings};
+ }
+}
+
sub accnofrom {
my $self = shift;
push @array_of_datev, \@csv_headers;
push @array_of_datev, [ map { $_->{csv_header_name} } @csv_columns ];
+ my @warnings;
foreach my $row ( @datev_lines ) {
my @current_datev_row;
die "Incorrect lenght of field" if length($row->{ $column->{kivi_datev_name} }) > $column->{max_length};
}
if (exists $column->{valid_check} && $column->{kivi_datev_name} ne 'not yet implemented') {
- # more checks
- die "Not a valid value: '$row->{ $column->{kivi_datev_name} }'" .
- " for '$column->{kivi_datev_name}' with amount '$row->{umsatz}'"
- unless ($column->{valid_check}->($row->{ $column->{kivi_datev_name} }));
+ # more checks, listed as user warnings
+ push @warnings, t8("Wrong field value '#1' for field '#2' for the transaction" .
+ " with amount '#3'",$row->{ $column->{kivi_datev_name} },
+ $column->{kivi_datev_name},$row->{umsatz})
+ unless ($column->{valid_check}->($row->{ $column->{kivi_datev_name} }));
}
push @current_datev_row, $row->{ $column->{kivi_datev_name} };
}
push @array_of_datev, \@current_datev_row;
}
+ $self->warnings(@warnings) if @warnings;
return \@array_of_datev;
}
setup_datev_export3_action_bar(download_token => $datev->download_token);
$::form->header;
- print $::form->parse_html_template('datev/export3');
+ print $::form->parse_html_template('datev/export3', { WARNINGS => $datev->warnings });
} else {
$::form->error("Export schlug fehl.\n" . join "\n", $datev->errors);
}
'Warn before saving orders with duplicate parts (new controller only)' => 'Beim Speichern warnen, wenn doppelte Artikel in einem Auftrag sind',
'Warning' => 'Warnung',
'Warning! Loading a draft will discard unsaved data!' => 'Achtung! Beim Laden eines Entwurfs werden ungespeicherte Daten verworfen!',
+ 'Warning: One or more field value are not in valid DATEV format at:' => 'Warnung: Ein oder mehere Felder haben ungültige Feldwerte laut DATEV-Spezifikation bei:',
'Warnings and errors' => 'Warnungen und Fehler',
'Watch status' => 'Hintergrund-Job Status',
'WebDAV' => 'WebDAV',
'Working copy; no description yet' => 'Arbeitskopie; noch keine Beschreibung',
'Working on export' => 'Generiere Export',
'Write bin to default bin in part?' => 'Diesen Lagerplatz als Standardlagerplatz im Artikel setzen?',
+ 'Wrong field value \'#1\' for field \'#2\' for the transaction with amount \'#3\'' => 'Falscher Feldwert \'#1\' für Feld \'#2\' bei der Transaktion mit dem Umsatz von \'#3\'',
'Wrong tax keys recorded' => 'Gespeicherte Steuerschlüssel sind falsch',
'Wrong taxes recorded' => 'Gespeicherte Steuern passen nicht zum Steuerschlüssel',
'X' => 'X',
# check conversion to csv
$datev1->from($startdate);
$datev1->to($enddate);
-eval {
- $datev1->csv_buchungsexport();
- 1; };
-like($@, qr/^Not a valid value: '' for 'belegfeld1' with .*/, "wrong encoding");
+$datev1->csv_buchungsexport();
+my @warnings = $datev1->warnings;
+is(@warnings[0]->[0]->{untranslated},
+ 'Wrong field value \'#1\' for field \'#2\' for the transaction with amount \'#3\'', 'wrong_encoding');
-# redefine invnumber, but still broken
+
+# redefine invnumber, we have mixed encodings, should still generate a warning
$invoice->invnumber('ݗݘݰݶmuh');
$invoice->save();
-$datev1->generate_datev_data;
-$datev1->generate_datev_lines;
-eval {
- $datev1->csv_buchungsexport();
- 1; };
-like($@, qr/^Not a valid value: '' for 'belegfeld1' with amount/, "mixed encoding");
+
+my $datev3 = SL::DATEV->new(
+ dbh => $dbh,
+ trans_id => $invoice->id,
+);
+
+$datev3->from($startdate);
+$datev3->to($enddate);
+$datev3->generate_datev_data;
+$datev3->generate_datev_lines;
+$datev3->csv_buchungsexport;
+@warnings = [];
+@warnings = $datev3->warnings;
+is(@warnings[0]->[0]->{untranslated},
+ 'Wrong field value \'#1\' for field \'#2\' for the transaction with amount \'#3\'', 'mixed_wrong_encoding');
+
# create one haben buchung with GLTransaction today
[% END %]
</b>
- <br>
+<br/><br/>
+[% IF WARNINGS.size %]
+ <b>[% 'Warning: One or more field value are not in valid DATEV format at:' | $T8 %]</b><br /><br />
+ [%- FOREACH warning = WARNINGS %]
+ [% warning | $T8 %]<br/>
+ [%- END %]
+<br />
+[% END %]
[% IF datev.net_gross_differences.size %]
[% INCLUDE 'datev/net_gross_difference.html'