package GL;
use Data::Dumper;
+use SL::DATEV qw(:CONSTANTS);
use SL::DBUtils;
use strict;
if ($amount != 0) {
$query =
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
- source, memo, project_id, taxkey, ob_transaction, cb_transaction)
+ source, memo, project_id, taxkey, ob_transaction, cb_transaction, tax_id)
VALUES (?, (SELECT id FROM chart WHERE accno = ?),
- ?, ?, ?, ?, ?, ?, ?, ?)|;
+ ?, ?, ?, ?, ?, ?, ?, ?, ?)|;
@values = (conv_i($form->{id}), $accno, $amount, conv_date($form->{transdate}),
- $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $taxkey, $form->{ob_transaction} ? 't' : 'f', $form->{cb_transaction} ? 't' : 'f');
+ $form->{"source_$i"}, $form->{"memo_$i"}, $project_id, $taxkey, $form->{ob_transaction} ? 't' : 'f', $form->{cb_transaction} ? 't' : 'f', conv_i($form->{"tax_id_$i"}));
do_query($form, $dbh, $query, @values);
}
# add taxentry
$query =
qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate,
- source, memo, project_id, taxkey)
+ source, memo, project_id, taxkey, tax_id)
VALUES (?, (SELECT chart_id FROM tax WHERE id = ?),
- ?, ?, ?, ?, ?, ?)|;
+ ?, ?, ?, ?, ?, ?, ?)|;
@values = (conv_i($form->{id}), conv_i($form->{"tax_id_$i"}),
$tax, conv_date($form->{transdate}), $form->{"source_$i"},
- $form->{"memo_$i"}, $project_id, $taxkey);
+ $form->{"memo_$i"}, $project_id, $taxkey, conv_i($form->{"tax_id_$i"}));
do_query($form, $dbh, $query, @values);
}
}
do_query($form, $dbh, qq|UPDATE gl SET storno = 't' WHERE id = ?|, conv_i($form->{storno_id}));
}
+ # safety check datev export
+ if ($::instance_conf->get_datev_check_on_gl_transaction) {
+ my $transdate = $::form->{transdate} ? DateTime->from_lxoffice($::form->{transdate}) : undef;
+ $transdate ||= DateTime->today;
+
+ my $datev = SL::DATEV->new(
+ exporttype => DATEV_ET_BUCHUNGEN,
+ format => DATEV_FORMAT_KNE,
+ dbh => $dbh,
+ from => $transdate,
+ to => $transdate,
+ );
+
+ $datev->export;
+
+ if ($datev->errors) {
+ $dbh->rollback;
+ die join "\n", $::locale->text('DATEV check returned errors:'), $datev->errors;
+ }
+ }
+
# commit and redirect
my $rc = $dbh->commit;
$dbh->disconnect;