X-Git-Url: http://wagnertech.de/gitweb/gitweb.cgi/mfinanz.git/blobdiff_plain/eacebf8a165d03444aeff7a2897b4cd7a5cbcc9c..f217d072d76183bc07723dcc29503b732bd2022d:/SL/GL.pm diff --git a/SL/GL.pm b/SL/GL.pm index 4edd9f1f3..57aa145a1 100644 --- a/SL/GL.pm +++ b/SL/GL.pm @@ -46,6 +46,8 @@ use SL::DATEV qw(:CONSTANTS); use SL::DBUtils; use SL::DB::Chart; use SL::DB::Draft; +use SL::DB::ValidityToken; +use SL::DB::GLTransaction; use SL::Util qw(trim); use SL::DB; @@ -77,6 +79,16 @@ sub _post_transaction { my ($self, $myconfig, $form) = @_; $main::lxdebug->enter_sub(); + my $validity_token; + if (!$form->{id}) { + $validity_token = SL::DB::Manager::ValidityToken->fetch_valid_token( + scope => SL::DB::ValidityToken::SCOPE_GL_TRANSACTION_POST(), + token => $form->{form_validity_token}, + ); + + die $::locale->text('The form is not valid anymore.') if !$validity_token; + } + my ($debit, $credit) = (0, 0); my $project_id; @@ -213,6 +225,9 @@ sub _post_transaction { } } + $validity_token->delete if $validity_token; + delete $form->{form_validity_token}; + return 1; } @@ -301,6 +316,15 @@ sub all_transactions { push(@apvalues, like($form->{notes})); } + if (trim($form->{transaction_description})) { + $glwhere .= " AND g.transaction_description ILIKE ?"; + $arwhere .= " AND a.transaction_description ILIKE ?"; + $apwhere .= " AND a.transaction_description ILIKE ?"; + push(@glvalues, like($form->{transaction_description})); + push(@arvalues, like($form->{transaction_description})); + push(@apvalues, like($form->{transaction_description})); + } + if ($form->{accno}) { $glwhere .= " AND c.accno = '$form->{accno}'"; $arwhere .= " AND c.accno = '$form->{accno}'"; @@ -357,18 +381,20 @@ sub all_transactions { } my %sort_columns = ( - 'id' => [ qw(id) ], - 'transdate' => [ qw(transdate id) ], - 'gldate' => [ qw(gldate id) ], - 'reference' => [ qw(lower_reference id) ], - 'description' => [ qw(lower_description id) ], - 'accno' => [ qw(accno transdate id) ], - 'department' => [ qw(department transdate id) ], + 'id' => [ qw(id) ], + 'transdate' => [ qw(transdate id) ], + 'gldate' => [ qw(gldate id) ], + 'reference' => [ qw(lower_reference id) ], + 'description' => [ qw(lower_description id) ], + 'accno' => [ qw(accno transdate id) ], + 'department' => [ qw(department transdate id) ], + 'transaction_description' => [ qw(lower_transaction_description id) ], ); my %lowered_columns = ( - 'reference' => { 'gl' => 'g.reference', 'arap' => 'a.invnumber', }, - 'source' => { 'gl' => 'ac.source', 'arap' => 'ac.source', }, - 'description' => { 'gl' => 'g.description', 'arap' => 'ct.name', }, + 'reference' => { 'gl' => 'g.reference', 'arap' => 'a.invnumber', }, + 'source' => { 'gl' => 'ac.source', 'arap' => 'ac.source', }, + 'description' => { 'gl' => 'g.description', 'arap' => 'ct.name', }, + 'transaction_description' => { 'gl' => 'g.transaction_description', 'arap' => 'a.transaction_description', }, ); # sortdir = sort direction (ascending or descending) @@ -389,7 +415,7 @@ sub all_transactions { 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, - d.description AS department, + d.description AS department, g.transaction_description, CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee $project_columns $gl_globalproject_columns $columns_for_sorting{gl} @@ -407,7 +433,7 @@ sub all_transactions { SELECT ac.acc_trans_id, a.id, 'ar' AS type, a.invoice, a.invnumber, ac.taxkey, c.link, ct.name, ac.transdate, ac.gldate, ac.source, ac.trans_id, ac.amount, c.accno, a.notes, t.chart_id, - d.description AS department, + d.description AS department, a.transaction_description, CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee $project_columns $arap_globalproject_columns $columns_for_sorting{arap} @@ -427,7 +453,7 @@ sub all_transactions { SELECT ac.acc_trans_id, a.id, 'ap' AS type, a.invoice, a.invnumber, ac.taxkey, c.link, ct.name, ac.transdate, ac.gldate, ac.source, ac.trans_id, ac.amount, c.accno, a.notes, t.chart_id, - d.description AS department, + d.description AS department, a.transaction_description, CASE WHEN (COALESCE(e.name, '') = '') THEN e.login ELSE e.name END AS employee $project_columns $arap_globalproject_columns $columns_for_sorting{arap} @@ -659,8 +685,8 @@ sub transaction { g.storno, g.storno_id, g.department_id, d.description AS department, e.name AS employee, g.taxincluded, g.gldate, - g.ob_transaction, g.cb_transaction, - g.transaction_description + g.ob_transaction, g.cb_transaction, + g.transaction_description FROM gl g LEFT JOIN department d ON (d.id = g.department_id) LEFT JOIN employee e ON (e.id = g.employee_id) @@ -772,6 +798,19 @@ sub _storno { do_query($form, $dbh, $query, (values %$row)); } + if ($form->{workflow_email_journal_id}) { + my $ar_transaction_storno = SL::DB::GLTransaction->new(id => $new_id)->load; + my $email_journal = SL::DB::EmailJournal->new( + id => delete $form->{workflow_email_journal_id} + )->load; + $email_journal->link_to_record_with_attachment( + $ar_transaction_storno, + delete $form->{workflow_email_attachment_id} + ); + $form->{callback} = delete $form->{workflow_email_callback}; + } + + $form->{storno_id} = $id; return 1; }