X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FGoBD.pm;h=45f055f8545536e40067370968143573af71d397;hb=a5e4f9ca835489c2250db39f2c3abe6ac4ba04e6;hp=680cc9463002cf8067cd7159d4c251ead5360af8;hpb=39fc13904e592cf12936cf18aa21f83c79f7d524;p=kivitendo-erp.git diff --git a/SL/GoBD.pm b/SL/GoBD.pm index 680cc9463..45f055f85 100644 --- a/SL/GoBD.pm +++ b/SL/GoBD.pm @@ -419,6 +419,10 @@ sub do_datev_csv_export { $datev->_get_transactions(from_to => $datev->fromto); + if ($datev->errors) { + die [ $datev->errors ]; + } + for my $transaction (@{ $datev->{DATEV} }) { for my $entry (@{ $transaction }) { $entry->{sortkey} = join '-', map { lc } (DateTime->from_kivitendo($entry->{transdate})->strftime('%Y%m%d'), $entry->{name}, $entry->{reference}); @@ -449,21 +453,21 @@ sub do_datev_csv_export { $haben->{notes} //= ''; $haben->{notes} = SL::HTML::Util->strip($haben->{notes}); - my $tax_amount = defined $amount->{net_amount} - ? $::form->format_amount($myconfig, abs($amount->{amount}) - abs($amount->{net_amount}), 5) - : 0; + my $tax_amount = defined $amount->{net_amount} ? abs($amount->{amount}) - abs($amount->{net_amount}) : 0; + + $tax = {} if abs($tax_amount) < 0.001; my %row = ( amount => $::form->format_amount($myconfig, abs($amount->{amount}),5), debit_accno => $soll->{accno}, debit_accname => $soll->{accname}, debit_amount => $::form->format_amount($myconfig, abs(-$soll->{amount}),5), - debit_tax => $soll->{tax_accno} ? $tax_amount : 0, + debit_tax => $soll->{tax_accno} ? $::form->format_amount($myconfig, $tax_amount, 5) : 0, credit_accno => $haben->{accno}, credit_accname => $haben->{accname}, credit_amount => $::form->format_amount($myconfig, abs($haben->{amount}),5),, - credit_tax => $haben->{tax_accno} ? $tax_amount : 0, - tax => $tax_amount, + credit_tax => $haben->{tax_accno} ? $::form->format_amount($myconfig, $tax_amount, 5) : 0, + tax => $::form->format_amount($myconfig, $tax_amount, 5), notes => $haben->{notes}, (map { ($_ => $tax->{$_}) } qw(taxkey tax_accname tax_accno taxdescription)), (map { ($_ => ($haben->{$_} // $soll->{$_})) } qw(trans_id invnumber name vcnumber transdate gldate itime customer_id vendor_id)), @@ -545,7 +549,7 @@ sub do_csv_export { my $query = "SELECT " . join(', ', @select_tokens) . " FROM $table $where_clause"; my $sth = $::form->get_standard_dbh->prepare($query); - $sth->execute(@values) or die "error executing query $query: " . $sth->errstr; + $sth->execute(@values) or $::form->dberror($query); while (my $row = $sth->fetch) { for my $keep_col (@{ $known_tables{$table}{keep} || [] }) {