X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fgl.pl;h=faca8ce0d256b84c0fa535427d870a6a64e3dc31;hb=08e48f66590f580cbe2c8e3df76883d88b4c0fef;hp=551937bb0fd811011ea6f5523ffede6892454010;hpb=c7172f34ff94490977366ca8cad6c057ddc3da91;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 551937bb0..faca8ce0d 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -40,6 +40,7 @@ use List::Util qw(first sum); use SL::DB::ApGl; use SL::DB::RecordTemplate; +use SL::DB::ReconciliationLink; use SL::DB::BankTransactionAccTrans; use SL::DB::Tax; use SL::FU; @@ -113,7 +114,7 @@ sub load_record_template { $::form->{duedate} = $today->to_kivitendo; $::form->{rowcount} = @{ $template->items }; $::form->{paidaccounts} = 1; - $::form->{$_} = $template->$_ for qw(department_id taxincluded ob_transaction cb_transaction reference description show_details); + $::form->{$_} = $template->$_ for qw(department_id taxincluded ob_transaction cb_transaction reference description show_details transaction_description); $::form->{$_} = $dummy_form->{$_} for qw(closedto revtrans previous_id previous_gldate); my $row = 0; @@ -185,15 +186,16 @@ sub save_record_template { template_type => 'gl_transaction', template_name => $new_name, - currency_id => $::instance_conf->get_currency_id, - department_id => $::form->{department_id} || undef, - project_id => $::form->{globalproject_id} || undef, - taxincluded => $::form->{taxincluded} ? 1 : 0, - ob_transaction => $::form->{ob_transaction} ? 1 : 0, - cb_transaction => $::form->{cb_transaction} ? 1 : 0, - reference => $::form->{reference}, - description => $::form->{description}, - show_details => $::form->{show_details}, + currency_id => $::instance_conf->get_currency_id, + department_id => $::form->{department_id} || undef, + project_id => $::form->{globalproject_id} || undef, + taxincluded => $::form->{taxincluded} ? 1 : 0, + ob_transaction => $::form->{ob_transaction} ? 1 : 0, + cb_transaction => $::form->{cb_transaction} ? 1 : 0, + reference => $::form->{reference}, + description => $::form->{description}, + show_details => $::form->{show_details}, + transaction_description => $::form->{transaction_description}, items => \@items, ); @@ -426,26 +428,28 @@ sub generate_report { my $ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1; my @columns = qw( - transdate gldate id reference description - notes source doccnt debit debit_accno - credit credit_accno debit_tax debit_tax_accno - credit_tax credit_tax_accno balance projectnumbers - department employee + transdate gldate id reference + description notes transaction_description source + doccnt debit debit_accno + credit credit_accno debit_tax debit_tax_accno + credit_tax credit_tax_accno balance projectnumbers + department employee ); # add employee here, so that variable is still known and passed in url when choosing a different sort order in resulting table - my @hidden_variables = qw(accno source reference description notes project_id datefrom dateto employee_id datesort category l_subtotal department_id); + my @hidden_variables = qw(accno source reference description notes project_id datefrom dateto employee_id datesort category l_subtotal department_id transaction_description); push @hidden_variables, map { "l_${_}" } @columns; my $employee = $form->{employee_id} ? SL::DB::Employee->new(id => $form->{employee_id})->load->name : ''; my (@options, @date_options); - push @options, $locale->text('Account') . " : $form->{accno} $form->{account_description}" if ($form->{accno}); - push @options, $locale->text('Source') . " : $form->{source}" if ($form->{source}); - push @options, $locale->text('Reference') . " : $form->{reference}" if ($form->{reference}); - push @options, $locale->text('Description') . " : $form->{description}" if ($form->{description}); - push @options, $locale->text('Notes') . " : $form->{notes}" if ($form->{notes}); - push @options, $locale->text('Employee') . " : $employee" if $employee; + push @options, $locale->text('Account') . " : $form->{accno} $form->{account_description}" if ($form->{accno}); + push @options, $locale->text('Source') . " : $form->{source}" if ($form->{source}); + push @options, $locale->text('Reference') . " : $form->{reference}" if ($form->{reference}); + push @options, $locale->text('Description') . " : $form->{description}" if ($form->{description}); + push @options, $locale->text('Notes') . " : $form->{notes}" if ($form->{notes}); + push @options, $locale->text('Transaction description') . " : $form->{transaction_description}" if $form->{transaction_description}; + push @options, $locale->text('Employee') . " : $employee" if $employee; my $datesorttext = $form->{datesort} eq 'transdate' ? $locale->text('Transdate') : $locale->text('Gldate'); push @date_options, "$datesorttext" if ($form->{datesort} and ($form->{datefrom} or $form->{dateto})); push @date_options, $locale->text('From'), $locale->date(\%myconfig, $form->{datefrom}, 1) if ($form->{datefrom}); @@ -471,29 +475,30 @@ sub generate_report { $form->{l_doccnt} = $form->{l_source} ? 'Y' : ''; my %column_defs = ( - 'id' => { 'text' => $locale->text('ID'), }, - 'transdate' => { 'text' => $locale->text('Transdate'), }, - 'gldate' => { 'text' => $locale->text('Gldate'), }, - 'reference' => { 'text' => $locale->text('Reference'), }, - 'source' => { 'text' => $locale->text('Source'), }, - 'doccnt' => { 'text' => $locale->text('Document Count'), }, - 'description' => { 'text' => $locale->text('Description'), }, - 'notes' => { 'text' => $locale->text('Notes'), }, - 'debit' => { 'text' => $locale->text('Debit'), }, - 'debit_accno' => { 'text' => $locale->text('Debit Account'), }, - 'credit' => { 'text' => $locale->text('Credit'), }, - 'credit_accno' => { 'text' => $locale->text('Credit Account'), }, - 'debit_tax' => { 'text' => $locale->text('Debit Tax'), }, - 'debit_tax_accno' => { 'text' => $locale->text('Debit Tax Account'), }, - 'credit_tax' => { 'text' => $locale->text('Credit Tax'), }, - 'credit_tax_accno' => { 'text' => $locale->text('Credit Tax Account'), }, - 'balance' => { 'text' => $locale->text('Balance'), }, - 'projectnumbers' => { 'text' => $locale->text('Project Numbers'), }, - 'department' => { 'text' => $locale->text('Department'), }, - 'employee' => { 'text' => $locale->text('Employee'), }, + 'id' => { 'text' => $locale->text('ID'), }, + 'transdate' => { 'text' => $locale->text('Transdate'), }, + 'gldate' => { 'text' => $locale->text('Gldate'), }, + 'reference' => { 'text' => $locale->text('Reference'), }, + 'source' => { 'text' => $locale->text('Source'), }, + 'doccnt' => { 'text' => $locale->text('Document Count'), }, + 'description' => { 'text' => $locale->text('Description'), }, + 'notes' => { 'text' => $locale->text('Notes'), }, + 'debit' => { 'text' => $locale->text('Debit'), }, + 'debit_accno' => { 'text' => $locale->text('Debit Account'), }, + 'credit' => { 'text' => $locale->text('Credit'), }, + 'credit_accno' => { 'text' => $locale->text('Credit Account'), }, + 'debit_tax' => { 'text' => $locale->text('Debit Tax'), }, + 'debit_tax_accno' => { 'text' => $locale->text('Debit Tax Account'), }, + 'credit_tax' => { 'text' => $locale->text('Credit Tax'), }, + 'credit_tax_accno' => { 'text' => $locale->text('Credit Tax Account'), }, + 'balance' => { 'text' => $locale->text('Balance'), }, + 'projectnumbers' => { 'text' => $locale->text('Project Numbers'), }, + 'department' => { 'text' => $locale->text('Department'), }, + 'employee' => { 'text' => $locale->text('Employee'), }, + 'transaction_description' => { 'text' => $locale->text('Transaction description'), }, ); - foreach my $name (qw(id transdate gldate reference description debit_accno credit_accno debit_tax_accno credit_tax_accno department)) { + foreach my $name (qw(id transdate gldate reference description debit_accno credit_accno debit_tax_accno credit_tax_accno department transaction_description)) { my $sortname = $name =~ m/accno/ ? 'accno' : $name; my $sortdir = $sortname eq $form->{sort} ? 1 - $form->{sortdir} : $form->{sortdir}; $column_defs{$name}->{link} = $callback . "&sort=$sortname&sortdir=$sortdir"; @@ -581,7 +586,7 @@ sub generate_report { $row->{balance}->{data} = $data; $row->{projectnumbers}->{data} = join ", ", sort { lc($a) cmp lc($b) } keys %{ $ref->{projectnumbers} }; - map { $row->{$_}->{data} = $ref->{$_} } qw(id reference description notes gldate employee department); + map { $row->{$_}->{data} = $ref->{$_} } qw(id reference description notes gldate employee department transaction_description); map { $row->{$_}->{data} = \@{ $rows{$_} }; } qw(transdate debit credit debit_accno credit_accno debit_tax_accno credit_tax_accno source); @@ -970,7 +975,7 @@ sub setup_gl_action_bar { my $form = $::form; my $change_never = $::instance_conf->get_gl_changeable == 0; my $change_on_same_day_only = $::instance_conf->get_gl_changeable == 2 && ($form->current_date(\%::myconfig) ne $form->{gldate}); - my ($is_linked_bank_transaction, $is_linked_ap_transaction); + my ($is_linked_bank_transaction, $is_linked_ap_transaction, $is_reconciled_bank_transaction); if ($form->{id} && SL::DB::Manager::BankTransactionAccTrans->find_by(gl_id => $form->{id})) { $is_linked_bank_transaction = 1; @@ -978,8 +983,13 @@ sub setup_gl_action_bar { if ($form->{id} && SL::DB::Manager::ApGl->find_by(gl_id => $form->{id})) { $is_linked_ap_transaction = 1; } - - + # dont edit reconcilated bookings! + if ($form->{id}) { + my @acc_trans = map { $_->acc_trans_id } @{ SL::DB::Manager::AccTransaction->get_all( where => [ trans_id => $form->{id} ] ) }; + if (scalar @acc_trans && scalar @{ SL::DB::Manager::ReconciliationLink->get_all(where => [ acc_trans_id => [ @acc_trans ] ]) }) { + $is_reconciled_bank_transaction = 1; + } + } my $create_post_action = sub { # $_[0]: description # $_[1]: after_action @@ -992,6 +1002,7 @@ sub setup_gl_action_bar { : ($form->{id} && $change_on_same_day_only) ? t8('General ledger transactions can only be changed on the day they are posted.') : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.') : $is_linked_ap_transaction ? t8('This transaction is linked with a AP transaction. Please undo and redo the AP transaction booking if needed.') + : $is_reconciled_bank_transaction ? t8('This transaction is reconciled with a bank transaction. Please undo the reconciliation if needed.') : undef, ], }; @@ -1024,6 +1035,7 @@ sub setup_gl_action_bar { : $form->{storno} ? t8('A canceled general ledger transaction cannot be canceled again.') : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.') : $is_linked_ap_transaction ? t8('This transaction is linked with a AP transaction. Please undo and redo the AP transaction booking if needed.') + : $is_reconciled_bank_transaction ? t8('This transaction is reconciled with a bank transaction. Please undo the reconciliation if needed.') : undef, ], action => [ t8('Delete'), @@ -1035,6 +1047,7 @@ sub setup_gl_action_bar { : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.') : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.') : $is_linked_ap_transaction ? t8('This transaction is linked with a AP transaction. Please undo and redo the AP transaction booking if needed.') + : $is_reconciled_bank_transaction ? t8('This transaction is reconciled with a bank transaction. Please undo the reconciliation if needed.') : $form->{storno} ? t8('A canceled general ledger transaction cannot be deleted.') : undef, ], @@ -1215,9 +1228,10 @@ sub post_transaction { my $locale = $main::locale; # check if there is something in reference and date - $form->isblank("reference", $locale->text('Reference missing!')); - $form->isblank("transdate", $locale->text('Transaction Date missing!')); - $form->isblank("description", $locale->text('Description missing!')); + $form->isblank("reference", $locale->text('Reference missing!')); + $form->isblank("transdate", $locale->text('Transaction Date missing!')); + $form->isblank("description", $locale->text('Description missing!')); + $form->isblank("transaction_description", $locale->text('A transaction description is required.')) if $::instance_conf->get_require_transaction_description_ps; my $transdate = $form->datetonum($form->{transdate}, \%myconfig); my $closedto = $form->datetonum($form->{closedto}, \%myconfig);