X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fgl.pl;h=d54dc705fd09745413c417815ba5f6c56b13abc8;hb=3686bb31d623aaef632060fbdd9d7447c310e279;hp=6ed1e4c448fd69f8944662030f81761f3d60fc58;hpb=eca3a47857617e4283e53c30bba3588f5cf0d31c;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 6ed1e4c44..d54dc705f 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -217,12 +217,10 @@ sub search { $::form->all_departments(\%::myconfig); $::form->get_lists( projects => { key => "ALL_PROJECTS", all => 1 }, - employees => "ALL_EMPLOYEES", ); + $::form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]); - my $onload = "focus()" - . qq|;setupDateFormat('|. $::myconfig{dateformat} . qq|', '| . $::locale->text("Falsches Datumsformat!") . qq|')| - . qq|;setupPoints('|. $::myconfig{numberformat} . qq|', '| . $::locale->text("wrongformat") . qq|')|; + my $onload = "focus()"; $::form->header; print $::form->parse_html_template('gl/search', { @@ -466,7 +464,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 +475,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 +493,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; @@ -849,385 +848,73 @@ sub display_rows { } sub form_header { - my ($init) = @_; - $main::lxdebug->enter_sub(); - - $main::auth->assert('general_ledger'); + $::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}/; + map { $::form->{$_} =~ s/\"/"/g } + qw(chart taxchart); - my $description; - if ((my $rows = $form->numtextrows($form->{description}, 50)) > 1) { - $description = - qq||; - } else { - $description = - qq||; - } - - my $taxincluded = ($form->{taxincluded}) ? "checked" : ""; - - 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"; + $::form->{fokus} = "gl.reference"; + $::form->{taxincluded} = "1"; } else { - $form->{fokus} = qq|gl.accno_$form->{rowcount}|; + $::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"); - } else { - - # without JavaScript Calendar - $button1 = - qq||; - } - - $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)); - - 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| - - - -|; - } + $::form->{previous_id} ||= "--"; + $::form->{previous_gldate} ||= "--"; - print qq| - + $::form->header; + print $::form->parse_html_template('gl/form_header', { + hide_title => $title, + }); -$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 " - + my $radieren = $::form->current_date(\%::myconfig) eq $::form->{gldate}; - - -"; - $main::lxdebug->leave_sub(); + print $::form->parse_html_template('gl/form_footer', { + radieren => $radieren, + follow_ups => $follow_ups, + follow_ups_due => $follow_ups_due, + }); + $::lxdebug->leave_sub; } sub delete { @@ -1239,8 +926,6 @@ sub delete { $form->header; print qq| - -
|; @@ -1312,6 +997,7 @@ sub post_transaction { my $debitcount = 0; my $creditcount = 0; my $debitcredit; + my %split_safety = (); my @flds = qw(accno debit credit projectnumber fx_transaction source memo tax taxchart); @@ -1325,6 +1011,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 { @@ -1388,6 +1077,10 @@ 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 Lx-Office does not allow these.")); + } + for my $i (1 .. $count) { my $j = $i - 1; for (@flds) { $form->{"${_}_$i"} = $a[$j]->{$_} }