X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=SL%2FGL.pm;h=e6c87b31420ae0033c4b344768dac2b625e40641;hb=dbda14c263efd93aca3b7114015a47d86b8581e3;hp=7bcb475090160ffea5c79d6e06d6991953c4dcbc;hpb=493457086f727b713cca06c25c1c3bedb92185af;p=kivitendo-erp.git diff --git a/SL/GL.pm b/SL/GL.pm index 7bcb47509..e6c87b314 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -109,7 +109,6 @@ sub post_transaction { } my ($null, $department_id) = split(/--/, $form->{department}); - $department_id *= 1; $form->{ob_transaction} *= 1; $form->{cb_transaction} *= 1; @@ -122,7 +121,7 @@ sub post_transaction { WHERE id = ?|; @values = ($form->{reference}, $form->{description}, $form->{notes}, - conv_date($form->{transdate}), $department_id, $form->{taxincluded} ? 't' : 'f', + conv_date($form->{transdate}), conv_i($department_id), $form->{taxincluded} ? 't' : 'f', $form->{storno} ? 't' : 'f', conv_i($form->{storno_id}), $form->{ob_transaction} ? 't' : 'f', $form->{cb_transaction} ? 't' : 'f', conv_i($form->{id})); do_query($form, $dbh, $query, @values); @@ -158,11 +157,11 @@ sub post_transaction { 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, chart_link) VALUES (?, (SELECT id FROM chart WHERE accno = ?), - ?, ?, ?, ?, ?, ?, ?, ?)|; + ?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT link 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"}), $accno); do_query($form, $dbh, $query, @values); } @@ -170,12 +169,16 @@ sub post_transaction { # 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, chart_link) VALUES (?, (SELECT chart_id FROM tax WHERE id = ?), - ?, ?, ?, ?, ?, ?)|; + ?, ?, ?, ?, ?, ?, ?, (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"}, - $form->{"memo_$i"}, $project_id, $taxkey); + $form->{"memo_$i"}, $project_id, $taxkey, conv_i($form->{"tax_id_$i"}), conv_i($form->{"tax_id_$i"})); do_query($form, $dbh, $query, @values); } } @@ -195,6 +198,7 @@ sub post_transaction { dbh => $dbh, from => $transdate, to => $transdate, + trans_id => $form->{id}, ); $datev->export; @@ -281,10 +285,8 @@ sub all_transactions { push(@arvalues, '%' . $form->{description} . '%'); push(@apvalues, '%' . $form->{description} . '%'); } - - if ($form->{employee} =~ /--/) { - ($form->{employee_id},$form->{employee_name}) = split(/--/,$form->{employee}); - #if ($form->{employee_id}) { + + if ($form->{employee_id}) { $glwhere .= " AND g.employee_id = ? "; $arwhere .= " AND a.employee_id = ? "; $apwhere .= " AND a.employee_id = ? "; @@ -352,8 +354,6 @@ sub all_transactions { } } - my $false = ($myconfig->{dbdriver} eq 'Pg') ? "FALSE" : q|'0'|; - my %sort_columns = ( 'id' => [ qw(id) ], 'transdate' => [ qw(transdate id) ], @@ -367,7 +367,7 @@ sub all_transactions { 'source' => { 'gl' => 'ac.source', 'arap' => 'ac.source', }, 'description' => { 'gl' => 'g.description', 'arap' => 'ct.name', }, ); - + # sortdir = sort direction (ascending or descending) my $sortdir = !defined $form->{sortdir} ? 'ASC' : $form->{sortdir} ? 'ASC' : 'DESC'; my $sortkey = $sort_columns{$form->{sort}} ? $form->{sort} : $form->{datesort}; # default used to be transdate @@ -383,7 +383,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 @@ -800,5 +800,24 @@ sub get_chart_balances { $main::lxdebug->leave_sub(); } +sub get_tax_dropdown { + 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}); + + $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} = []; + while (my $ref = $sth->fetchrow_hashref("NAME_lc")) { + push(@{ $form->{TAX_ACCOUNTS} }, $ref); + } + +} 1;