X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FGL.pm;h=01417aac969da255b598151596d548a7dc0f5e47;hb=c51601f019f963dcdc875469514aa40802b5c574;hp=864c02eabcecd09130cf0b9b5fa602d16a5b4e72;hpb=e04c32d3d5702636c2ad0fc25d27532c9eb853b0;p=kivitendo-erp.git diff --git a/SL/GL.pm b/SL/GL.pm index 864c02eab..01417aac9 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -104,7 +104,7 @@ sub post_transaction { $query = qq|INSERT INTO gl (id, employee_id) | . qq|VALUES (?, (SELECT id FROM employee WHERE login = ?))|; - @values = ($form->{id}, $form->{login}); + @values = ($form->{id}, $::myconfig{login}); do_query($form, $dbh, $query, @values); } @@ -171,10 +171,10 @@ sub post_transaction { qq|INSERT INTO acc_trans (trans_id, chart_id, amount, transdate, source, memo, project_id, taxkey, tax_id, chart_link) VALUES (?, (SELECT chart_id FROM tax WHERE id = ?), - ?, ?, ?, ?, ?, ?, ?, (SELECT link - FROM chart - WHERE id = (SELECT chart_id - FROM tax + ?, ?, ?, ?, ?, ?, ?, (SELECT link + FROM chart + WHERE id = (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"}, @@ -196,8 +196,6 @@ sub post_transaction { exporttype => DATEV_ET_BUCHUNGEN, format => DATEV_FORMAT_KNE, dbh => $dbh, - from => $transdate, - to => $transdate, trans_id => $form->{id}, ); @@ -354,8 +352,6 @@ sub all_transactions { } } - my $false = ($myconfig->{dbdriver} eq 'Pg') ? "FALSE" : q|'0'|; - my %sort_columns = ( 'id' => [ qw(id) ], 'transdate' => [ qw(transdate id) ], @@ -385,7 +381,7 @@ sub all_transactions { $query = qq|SELECT - ac.acc_trans_id, g.id, 'gl' AS type, $false AS invoice, g.reference, ac.taxkey, c.link, + ac.acc_trans_id, g.id, 'gl' AS type, FALSE AS invoice, g.reference, ac.taxkey, c.link, g.description, ac.transdate, ac.gldate, ac.source, ac.trans_id, ac.amount, c.accno, g.notes, t.chart_id, CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee @@ -672,19 +668,7 @@ sub transaction { FROM acc_trans a JOIN chart c ON (c.id = a.chart_id) LEFT JOIN project p ON (p.id = a.project_id) - LEFT JOIN tax t ON - (t.id = - (SELECT tk.tax_id - FROM taxkeys tk - WHERE (tk.taxkey_id = a.taxkey) AND - ((CASE WHEN a.chart_id IN - (SELECT chart_id FROM taxkeys WHERE taxkey_id = a.taxkey) - THEN tk.chart_id = a.chart_id - ELSE 1 = 1 - END) - OR (c.link LIKE '%tax%')) - AND (startdate <= a.transdate) - ORDER BY startdate DESC LIMIT 1)) + LEFT JOIN tax t ON (t.id = a.tax_id) WHERE (a.trans_id = ?) AND (a.fx_transaction = '0') ORDER BY a.acc_trans_id, a.transdate|; @@ -738,10 +722,14 @@ sub storno { $query = qq|SELECT * FROM gl WHERE id = ?|; $storno_row = selectfirst_hashref_query($form, $dbh, $query, $id); - $storno_row->{id} = $new_id; - $storno_row->{storno_id} = $id; - $storno_row->{storno} = 't'; - $storno_row->{reference} = 'Storno-' . $storno_row->{reference}; + $storno_row->{id} = $new_id; + $storno_row->{storno_id} = $id; + $storno_row->{storno} = 't'; + $storno_row->{reference} = 'Storno-' . $storno_row->{reference}; + + $query = qq|SELECT id FROM employee WHERE login = ?|; + my ($employee_id) = selectrow_query($form, $dbh, $query, $::myconfig{login}); + $storno_row->{employee_id} = $employee_id; delete @$storno_row{qw(itime mtime gldate)}; @@ -803,23 +791,26 @@ sub get_chart_balances { } sub get_tax_dropdown { + my ($self, $accno) = @_; + my $myconfig = \%main::myconfig; my $form = $main::form; my $dbh = $form->get_standard_dbh($myconfig); my $query = qq|SELECT category FROM chart WHERE accno = ?|; - my ($category) = selectrow_query($form, $dbh, $query, $form->{accno}); + my ($category) = selectrow_query($form, $dbh, $query, $accno); $query = qq|SELECT * FROM tax WHERE chart_categories like '%$category%' order by taxkey, rate|; my $sth = prepare_execute_query($form, $dbh, $query); - $form->{TAX_ACCOUNTS} = []; + my @tax_accounts = (); while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { - push(@{ $form->{TAX_ACCOUNTS} }, $ref); + push(@tax_accounts, $ref); } + return @tax_accounts; } 1;