X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fgl.pl;h=0d9a92b5de005bc4bc90313aefe2c8cedd84ce0a;hb=3f4f01dcd306d7ebb51a1186d722e6aecd237003;hp=6ed1e4c448fd69f8944662030f81761f3d60fc58;hpb=eca3a47857617e4283e53c30bba3588f5cf0d31c;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 6ed1e4c44..0d9a92b5d 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -217,16 +217,11 @@ sub search { $::form->all_departments(\%::myconfig); $::form->get_lists( projects => { key => "ALL_PROJECTS", all => 1 }, - employees => "ALL_EMPLOYEES", ); - - my $onload = "focus()" - . qq|;setupDateFormat('|. $::myconfig{dateformat} . qq|', '| . $::locale->text("Falsches Datumsformat!") . qq|')| - . qq|;setupPoints('|. $::myconfig{numberformat} . qq|', '| . $::locale->text("wrongformat") . qq|')|; + $::form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]); $::form->header; print $::form->parse_html_template('gl/search', { - onload => $onload, department_label => sub { ("$_[0]{description}--$_[0]{id}")x2 }, employee_label => sub { "$_[0]{id}--$_[0]{name}" }, }); @@ -309,19 +304,21 @@ sub generate_report { ); # 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 department description notes project_id datefrom dateto employee datesort category l_subtotal); + my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto employee_id datesort category l_subtotal); push @hidden_variables, map { "l_${_}" } @columns; foreach ( @hidden_variables ) { print URL "$_\n"; }; + 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') . " : $form->{employee_name}" if ($form->{employee_name}); + push @options, $locale->text('Employee') . " : $employee" if $employee; my $datesorttext = $form->{datesort} eq 'transdate' ? $locale->text('Invoice Date') : $locale->text('Booking Date'); 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}); @@ -466,7 +463,7 @@ sub generate_report { my $row_set = [ $row ]; - if (($form->{l_subtotal} eq 'Y') + if ( ($form->{l_subtotal} eq 'Y' && !$form->{report_generator_csv_options_for_import} ) && (($idx == (scalar @{ $form->{GL} } - 1)) || ($ref->{ $form->{sort} } ne $form->{GL}->[$idx + 1]->{ $form->{sort} }))) { push @{ $row_set }, create_subtotal_row(\%subtotals, \@columns, \%column_alignment, [ qw(debit credit) ], 'listsubtotal'); @@ -477,8 +474,6 @@ sub generate_report { $idx++; } - $report->add_separator(); - # = 0 for balanced ledger my $balanced_ledger = $totals{debit} + $totals{debit_tax} - $totals{credit} - $totals{credit_tax}; @@ -497,7 +492,10 @@ sub generate_report { $row->{balance}->{data} = $data; - $report->add_data($row); + if ( !$form->{report_generator_csv_options_for_import} ) { + $report->add_separator(); + $report->add_data($row); + } my $raw_bottom_info_text; @@ -848,386 +846,77 @@ sub display_rows { } -sub form_header { - my ($init) = @_; - $main::lxdebug->enter_sub(); +sub _get_radieren { + return ($::instance_conf->get_gl_changeable == 2) ? ($::form->current_date(\%::myconfig) eq $::form->{gldate}) : ($::instance_conf->get_gl_changeable == 1); +} - $main::auth->assert('general_ledger'); +sub form_header { + $::lxdebug->enter_sub; + $::auth->assert('general_ledger'); - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; + my ($init) = @_; - my @old_project_ids = (); - map({ push(@old_project_ids, $form->{"project_id_$_"}) - if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); + my @old_project_ids = grep { $_ } map{ $::form->{"project_id_$_"} } 1..$::form->{rowcount}; - $form->get_lists("projects" => { "key" => "ALL_PROJECTS", + $::form->get_lists("projects" => { "key" => "ALL_PROJECTS", "all" => 0, "old_id" => \@old_project_ids }, "charts" => { "key" => "ALL_CHARTS", - "transdate" => $form->{transdate} }, + "transdate" => $::form->{transdate} }, "taxcharts" => "ALL_TAXCHARTS"); - GL->get_chart_balances('charts' => $form->{ALL_CHARTS}); - - my $title = $form->{title}; - $form->{title} = $locale->text("$title General Ledger Transaction"); - my $readonly = ($form->{id}) ? "readonly" : ""; - - my $show_details_checked = $form->{show_details} ? "checked" : ''; - my $ob_transaction_checked = $form->{ob_transaction} ? "checked" : ''; - my $cb_transaction_checked = $form->{cb_transaction} ? "checked" : ''; + GL->get_chart_balances('charts' => $::form->{ALL_CHARTS}); + my $title = $::form->{title}; + $::form->{title} = $::locale->text("$title General Ledger Transaction"); # $locale->text('Add General Ledger Transaction') # $locale->text('Edit General Ledger Transaction') - map { $form->{$_} =~ s/\"/"/g } - qw(reference description chart taxchart); - - $form->{javascript} = qq| - - -|; - - $form->{selectdepartment} =~ s/ selected//; - $form->{selectdepartment} =~ - s/option>\Q$form->{department}\E/option selected>$form->{department}/; - - my $description; - if ((my $rows = $form->numtextrows($form->{description}, 50)) > 1) { - $description = - qq||; - } else { - $description = - qq||; - } - - my $taxincluded = ($form->{taxincluded}) ? "checked" : ""; + map { $::form->{$_} =~ s/\"/"/g } + qw(chart taxchart); - if ($init) { - $taxincluded = "checked"; - } + $::form->{selectdepartment} =~ s/ selected//; + $::form->{selectdepartment} =~ + s/option>\Q$::form->{department}\E/option selected>$::form->{department}/; - my $department; - $department = qq| - - | . $locale->text('Department') . qq| - - - -| if $form->{selectdepartment}; if ($init) { - $form->{fokus} = "gl.reference"; - } else { - $form->{fokus} = qq|gl.accno_$form->{rowcount}|; - } - - # use JavaScript Calendar or not - $form->{jsscript} = 1; - my $jsscript = ""; - my ($button1, $button2); - if ($form->{jsscript}) { - - # with JavaScript Calendar - $button1 = qq| - - text('button') . qq|> - |; - - #write Trigger - $jsscript = - Form->write_trigger(\%myconfig, "1", "transdate", "BL", "trigger1"); + $::request->{layout}->focus("#reference"); + $::form->{taxincluded} = "1"; } else { - - # without JavaScript Calendar - $button1 = - qq||; + $::request->{layout}->focus("#accno_$::form->{rowcount}"); } - $form->{previous_id} ||= "--"; - $form->{previous_gldate} ||= "--"; - - $jsscript .= $form->parse_html_template('gl/form_header_chart_balances_js'); - - $form->header; - - print qq| - - - - -
-|; - - $form->hide_form(qw(id closedto locked storno storno_id previous_id previous_gldate)); + $::form->{previous_id} ||= "--"; + $::form->{previous_gldate} ||= "--"; - print qq| - - - - - - - - - - - | . - - ($form->{saved_message} ? qq| - - | : '') . - -qq| - - -
$form->{title}
$form->{saved_message} -
- - - - - - - - - |; - if ($form->{id}) { - print qq| - - - - - |; - } - print qq| - $department|; - if ($form->{id}) { - print qq| - - - - - - |; - } else { - print qq| - - - - - |; - } - - print qq| - - - - - - |; - - print qq| - - - -
| - . $locale->text("Previous transnumber text") - . " $form->{previous_id} " - . $locale->text("Previous transdate text") - . " $form->{previous_gldate}" - . qq|
| . $locale->text('Reference') . qq| - - - - $button1 - -
| . $locale->text('Date') . qq|
-
| . $locale->text('Belegnummer') . qq| - - - - - -
| . $locale->text('Buchungsdatum') . qq|{gldate} $readonly onBlur=\"check_right_date_format(this)\">
-
| . $locale->text('Description') . qq|$description - - - - - -
| . $locale->text('MwSt. inkl.') . qq|
-
- - - - - -
| . $locale->text('Mitarbeiter') . qq|
-
| . $locale->text('Description') . qq|$description - - - - - -
| . $locale->text('MwSt. inkl.') . qq|
-
- - -
- | . $locale->text('OB Transaction') . qq| - - | . $locale->text('CB Transaction') . qq| -
| . $locale->text('Show details') . qq|
- - - - - - - - |; - - if ($form->{show_details}) { - print qq| - - - -|; - } - - print qq| - + $::form->header; + print $::form->parse_html_template('gl/form_header', { + hide_title => $title, + readonly => $::form->{id} && ($::form->{locked} || !_get_radieren()), + }); -$jsscript -|; - $main::lxdebug->leave_sub(); + $::lxdebug->leave_sub; } sub form_footer { - $main::lxdebug->enter_sub(); - - $main::auth->assert('general_ledger'); - - my $form = $main::form; - my %myconfig = %main::myconfig; - my $locale = $main::locale; - my $cgi = $::request->{cgi}; - - my $follow_ups_block; - if ($form->{id}) { - my $follow_ups = FU->follow_ups('trans_id' => $form->{id}); - - if (@{ $follow_ups} ) { - my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups }; - $follow_ups_block = qq|

| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|

|; - } - } - - my ($dec) = ($form->{totaldebit} =~ /\.(\d+)/); - $dec = length $dec; - my $decimalplaces = ($dec > 2) ? $dec : 2; - my $radieren = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0; - - map { - $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 2, " ") - } qw(totaldebit totalcredit); - - print qq| - - - - - -
| - . $locale->text('Account') . qq|| . $locale->text('Chart balance') . qq|| - . $locale->text('Debit') . qq|| - . $locale->text('Credit') . qq|| - . $locale->text('Tax') . qq|| - . $locale->text('Taxkey') . qq|| . $locale->text('Source') . qq|| . $locale->text('Memo') . qq|| . $locale->text('Project Number') . qq|
$form->{totaldebit} $form->{totalcredit}
-
- - - -$follow_ups_block - -
-|; - - my $transdate = $form->datetonum($form->{transdate}, \%myconfig); - my $closedto = $form->datetonum($form->{closedto}, \%myconfig); - - if ($form->{id}) { - - if (!$form->{storno}) { - print qq||; - } - - # Löschen und Ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich - if (!$form->{locked} && $radieren) { - print qq| - - |; - } - - print qq| - - |; + $::lxdebug->enter_sub; + $::auth->assert('general_ledger'); - } else { - if ($form->{draft_id}) { - my $remove_draft_checked = $form->{remove_draft} ? 'checked' : ''; - print qq|

\n| - . qq| | - . qq| \n| - . qq|

\n|; - } + my ($follow_ups, $follow_ups_due); - print qq| - - | - . NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit')) - . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}]) - . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]); + if ($::form->{id}) { + $follow_ups = FU->follow_ups('trans_id' => $::form->{id}); + $follow_ups_due = sum map { $_->{due} * 1 } @{ $follow_ups || [] }; } - print " - - - - -"; - $main::lxdebug->leave_sub(); + print $::form->parse_html_template('gl/form_footer', { + radieren => _get_radieren(), + follow_ups => $follow_ups, + follow_ups_due => $follow_ups_due, + }); + $::lxdebug->leave_sub; } sub delete { @@ -1239,8 +928,6 @@ sub delete { $form->header; print qq| - -
|; @@ -1312,6 +999,11 @@ sub post_transaction { my $debitcount = 0; my $creditcount = 0; my $debitcredit; + my %split_safety = (); + + my $dbh = $form->dbconnect_noauto(\%myconfig); + my ($notax_id) = selectrow_query($form, $dbh, "SELECT id FROM tax WHERE taxkey = 0 LIMIT 1", ); + $dbh->disconnect; my @flds = qw(accno debit credit projectnumber fx_transaction source memo tax taxchart); @@ -1325,6 +1017,9 @@ sub post_transaction { push @a, {}; $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1"; + $split_safety{ $form->{"debit_$i"} <=> 0 }++; + $split_safety{ - $form->{"credit_$i"} <=> 0 }++; + if ($debitcredit) { $debitcount++; } else { @@ -1350,17 +1045,17 @@ sub post_transaction { $form->{debitlock} = 1; } if ($debitcredit && $credittax) { - $form->{"taxchart_$i"} = "0--0.00"; + $form->{"taxchart_$i"} = "$notax_id--0.00"; } if (!$debitcredit && $debittax) { - $form->{"taxchart_$i"} = "0--0.00"; + $form->{"taxchart_$i"} = "$notax_id--0.00"; } my $amount = ($form->{"debit_$i"} == 0) ? $form->{"credit_$i"} : $form->{"debit_$i"}; my $j = $#a; if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) { - $form->{"taxchart_$i"} = "0--0.00"; + $form->{"taxchart_$i"} = "$notax_id--0.00"; $form->{"tax_$i"} = 0; } my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"}); @@ -1388,6 +1083,11 @@ sub post_transaction { $count++; } + if ($split_safety{-1} > 1 && $split_safety{1} > 1) { + $::form->error($::locale->text("Split entry detected. The values you have entered will result in an entry with more than one position on both debit and credit. " . + "Due to known problems involving accounting software kivitendo does not allow these.")); + } + for my $i (1 .. $count) { my $j = $i - 1; for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }