package GL;
use Data::Dumper;
+use SL::DATEV qw(:CONSTANTS);
use SL::DBUtils;
use strict;
do_query($form, $dbh, qq|UPDATE gl SET storno = 't' WHERE id = ?|, conv_i($form->{storno_id}));
}
+ # safety check datev export
+ if ($::lx_office_conf{datev_check}{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;
if ($form->{employee} =~ /--/) {
($form->{employee_id},$form->{employee_name}) = split(/--/,$form->{employee});
- $query .= " AND o.employee_id = ?";
- push @values, conv_i($form->{employee_id});
#if ($form->{employee_id}) {
$glwhere .= " AND g.employee_id = ? ";
$arwhere .= " AND a.employee_id = ? ";
CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee
$project_columns
$columns_for_sorting{gl}
- FROM gl g, acc_trans ac $project_join, chart c
+ FROM gl g
+ LEFT JOIN employee e ON (g.employee_id = e.id),
+ acc_trans ac $project_join, chart c
LEFT JOIN tax t ON (t.chart_id = c.id)
WHERE $glwhere
AND (ac.chart_id = c.id)
CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee
$project_columns
$columns_for_sorting{arap}
- FROM ar a, acc_trans ac $project_join, customer ct, chart c
+ FROM ar a
+ LEFT JOIN employee e ON (a.employee_id = e.id),
+ acc_trans ac $project_join, customer ct, chart c
LEFT JOIN tax t ON (t.chart_id=c.id)
WHERE $arwhere
AND (ac.chart_id = c.id)
CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee
$project_columns
$columns_for_sorting{arap}
- FROM ap a, acc_trans ac $project_join, vendor ct, chart c
+ FROM ap a
+ LEFT JOIN employee e ON (a.employee_id = e.id),
+ acc_trans ac $project_join, vendor ct, chart c
LEFT JOIN tax t ON (t.chart_id=c.id)
WHERE $apwhere
AND (ac.chart_id = c.id)
$storno_row->{storno} = 't';
$storno_row->{reference} = 'Storno-' . $storno_row->{reference};
- delete @$storno_row{qw(itime mtime)};
+ delete @$storno_row{qw(itime mtime gldate)};
$query = sprintf 'INSERT INTO gl (%s) VALUES (%s)', join(', ', keys %$storno_row), join(', ', map '?', values %$storno_row);
do_query($form, $dbh, $query, (values %$storno_row));
my $rowref = selectall_hashref_query($form, $dbh, $query, $id);
for my $row (@$rowref) {
- delete @$row{qw(itime mtime acc_trans_id)};
+ delete @$row{qw(itime mtime acc_trans_id gldate)};
$query = sprintf 'INSERT INTO acc_trans (%s) VALUES (%s)', join(', ', keys %$row), join(', ', map '?', values %$row);
$row->{trans_id} = $new_id;
$row->{amount} *= -1;