X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FGL.pm;h=ef04d9ad61fa6b5b0b008ba677c1b08d92e04ece;hb=a4f92ff17d2572ec3a0465fe4444c741d80ecc77;hp=eda712813b1110552f9e8444ec29024f54691a80;hpb=322b14b7c67d81ce1ca0d88d337c83824df488e7;p=kivitendo-erp.git diff --git a/SL/GL.pm b/SL/GL.pm index eda712813..ef04d9ad6 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -70,13 +70,6 @@ sub post_transaction { my $i; - # check if debit and credit balances - - if ($form->{storno}) { - $form->{reference} = "Storno-" . $form->{reference}; - $form->{description} = "Storno-" . $form->{description}; - } - # connect to database, turn off AutoCommit my $dbh = $form->dbconnect_noauto($myconfig); @@ -119,11 +112,13 @@ sub post_transaction { $query = qq|UPDATE gl SET reference = ?, description = ?, notes = ?, - transdate = ?, department_id = ?, taxincluded = ? + transdate = ?, department_id = ?, taxincluded = ?, + storno = ?, storno_id = ? WHERE id = ?|; @values = ($form->{reference}, $form->{description}, $form->{notes}, conv_date($form->{transdate}), $department_id, $form->{taxincluded}, + $form->{storno} ? 't' : 'f', conv_i($form->{storno_id}), conv_i($form->{id})); do_query($form, $dbh, $query, @values); @@ -180,6 +175,10 @@ sub post_transaction { } } + if ($form->{storno} && $form->{storno_id}) { + do_query($form, $dbh, qq|UPDATE gl SET storno = 't' WHERE id = ?|, conv_i($form->{storno_id})); + } + # commit and redirect my $rc = $dbh->commit; $dbh->disconnect; @@ -278,7 +277,7 @@ sub all_transactions { (SELECT id FROM chart c2 WHERE c2.category = ?))|; $apwhere .= qq| AND ap.id in (SELECT trans_id FROM acc_trans ac2 WHERE ac2.chart_id IN - (SELECT id FROM chart c2 WHERE c2.category = ?))"|; + (SELECT id FROM chart c2 WHERE c2.category = ?))|; push(@glvalues, $form->{category}); push(@arvalues, $form->{category}); push(@apvalues, $form->{category}); @@ -556,9 +555,14 @@ sub transaction { $query = qq|SELECT closedto, revtrans FROM defaults|; ($form->{closedto}, $form->{revtrans}) = selectrow_query($form, $dbh, $query); + $query = qq|SELECT id, gldate + FROM gl + WHERE id = (SELECT max(id) FROM gl)|; + ($form->{previous_id}, $form->{previous_gldate}) = selectrow_query($form, $dbh, $query); + if ($form->{id}) { $query = - qq|SELECT g.reference, g.description, g.notes, g.transdate, + qq|SELECT g.reference, g.description, g.notes, g.transdate, g.storno, g.storno_id, d.description AS department, e.name AS employee, g.taxincluded, g.gldate FROM gl g LEFT JOIN department d ON (d.id = g.department_id)