+ push @header, [ @header_row_1 ];
+
+ # second header row, just the column names
+ push @header, [ map { $_->{csv_header_name} } _kivitendo_to_datev() ];
+
+ return \@header;
+}
+
+sub lines {
+ my ($self) = @_;
+
+ my (@array_of_datev, @warnings);
+ my @csv_columns = _kivitendo_to_datev();
+
+ foreach my $row (@{ $self->datev_lines }) {
+ my @current_datev_row;
+
+ # 1. check all datev_lines and see if we have a defined value
+ # 2. if we don't have a defined value set a default if exists
+ # 3. otherwise die
+ foreach my $column (@csv_columns) {
+ if ($column->{kivi_datev_name} eq 'not yet implemented') {
+ push @current_datev_row, '';
+ next;
+ }
+ my $data = $row->{$column->{kivi_datev_name}};
+ if (!defined $data) {
+ if (defined $column->{default}) {
+ $data = $column->{default};
+ } else {
+ die 'No sensible value or a sensible default found for the entry: ' . $column->{kivi_datev_name};
+ }
+ }
+ # checkpoint a: no undefined data. All strict checks now!
+ if (exists $column->{input_check} && !$column->{input_check}->($data)) {
+ die t8("Wrong field value '#1' for field '#2' for the transaction with amount '#3'",
+ $data, $column->{kivi_datev_name}, $row->{umsatz});
+ }
+ # checkpoint b: we can safely format the input
+ if ($column->{formatter}) {
+ $data = $column->{formatter}->($data);
+ }
+ # checkpoint c: all soft checks now, will pop up as a user warning
+ if (exists $column->{valid_check} && !$column->{valid_check}->($data)) {
+ push @warnings, t8("Wrong field value '#1' for field '#2' for the transaction" .
+ " with amount '#3'", $data, $column->{kivi_datev_name}, $row->{umsatz});
+ }
+ push @current_datev_row, $data;
+ }
+ push @array_of_datev, \@current_datev_row;
+ }
+ $self->warnings(\@warnings);
+ return \@array_of_datev;
+}
+
+# helper