X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fgl.pl;h=185e2a5878dae3bb1ac58ed8ba54c552a0b41f64;hb=bfa7bf60b133969eb754d4506485c7132711f43f;hp=d2c9d8d2cfbc959e0bb0168aa02d82dac49d9e87;hpb=4f80334ff167dc64b410e30a5a657cd37d31e98e;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index d2c9d8d2c..185e2a587 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -260,7 +260,7 @@ sub search { $button1 = qq| text('button') . qq|> + . $locale->text('button') . qq|> |; $button2 = qq| @@ -497,9 +497,9 @@ sub generate_report { 'projectnumbers' => { 'text' => $locale->text('Project Numbers'), }, ); - foreach my $name (qw(id transdate reference source description debit_accno credit_accno debit_tax_accno credit_tax_accno)) { + foreach my $name (qw(id transdate reference description debit_accno credit_accno debit_tax_accno credit_tax_accno)) { my $sortname = $name =~ m/accno/ ? 'accno' : $name; - my $sortdir = $sortname eq $name ? 1 - $form->{sortdir} : $form->{sortdir}; + my $sortdir = $sortname eq $form->{sort} ? 1 - $form->{sortdir} : $form->{sortdir}; $column_defs{$name}->{link} = $callback . "&sort=$sortname&sortdir=$sortdir"; } @@ -507,7 +507,7 @@ sub generate_report { map { $column_defs{$_}->{visible} = 0 } qw(debit_accno credit_accno debit_tax_accno credit_tax_accno) if $form->{accno}; my %column_alignment; - map { $column_alignment{$_} = 'right' } qw(balance id debit credit debit_tax credit_tax); + map { $column_alignment{$_} = 'right' } qw(balance id debit credit debit_tax credit_tax balance); map { $column_alignment{$_} = 'center' } qw(transdate reference description source notes debit_accno credit_accno debit_tax_accno credit_tax_accno); map { $column_defs{$_}->{align} = $column_alignment{$_} } keys %column_alignment; @@ -516,7 +516,7 @@ sub generate_report { $report->set_columns(%column_defs); $report->set_column_order(@columns); - $report->set_export_options('generate_report', @hidden_variables); + $report->set_export_options('generate_report', @hidden_variables, qw(sort sortdir)); $report->set_sort_indicator($form->{sort} eq 'accno' ? 'debit_accno' : $form->{sort}, $form->{sortdir}); @@ -530,18 +530,6 @@ sub generate_report { # add sort to callback $form->{callback} = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir}); - $form->{balance} *= $ml; - - if ($form->{accno} && $form->{balance}) { - my $row = { - 'balance' => { - 'data' => $form->format_amount(\%myconfig, $form->{balance}, 2), - 'align' => 'right', - }, - }; - - $report->add_data($row); - } my @totals_columns = qw(debit credit debit_tax credit_tax); my %subtotals = map { $_ => 0 } @totals_columns; @@ -549,7 +537,6 @@ sub generate_report { my $idx = 0; foreach $ref (@{ $form->{GL} }) { - $form->{balance} *= $ml; my %rows; @@ -559,12 +546,17 @@ sub generate_report { my $value = $ref->{$key}->{$idx}; $subtotals{$key} += $value; $totals{$key} += $value; - $form->{balance} = abs($form->{balance}) - abs($value); + if ($key =~ /debit.*/) { + $ml = -1; + } else { + $ml = 1; + } + $form->{balance} = $form->{balance} + $value * $ml; push @{ $rows{$key} }, $form->format_amount(\%myconfig, $value, 2); } } - foreach my $key (qw(debit_accno credit_accno debit_tax_accno credit_tax_accno ac_transdate)) { + foreach my $key (qw(debit_accno credit_accno debit_tax_accno credit_tax_accno ac_transdate source)) { my $col = $key eq 'ac_transdate' ? 'transdate' : $key; $rows{$col} = [ map { $ref->{$key}->{$_} } sort keys(%{ $ref->{$key} }) ]; } @@ -572,12 +564,23 @@ sub generate_report { my $row = { }; map { $row->{$_} = { 'data' => '', 'align' => $column_alignment{$_} } } @columns; - $row->{balance}->{data} = $form->format_amount(\%myconfig, $form->{balance}, 2); + my $sh = ""; + if ($form->{balance} < 0) { + $sh = " S"; + $ml = -1; + } elsif ($form->{balance} > 0) { + $sh = " H"; + $ml = 1; + } + my $data = $form->format_amount(\%myconfig, ($form->{balance} * $ml), 2); + $data .= $sh; + + $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 source notes); + map { $row->{$_}->{data} = $ref->{$_} } qw(id reference description notes); - map { $row->{$_}->{data} = \@{ $rows{$_} }; } qw(transdate debit credit debit_accno credit_accno debit_tax_accno credit_tax_accno); + map { $row->{$_}->{data} = \@{ $rows{$_} }; } qw(transdate debit credit debit_accno credit_accno debit_tax_accno credit_tax_accno source); foreach my $col (qw(debit_accno credit_accno debit_tax_accno credit_tax_accno)) { $row->{$col}->{link} = [ map { "${callback}&accno=" . E($_) } @{ $rows{$col} } ]; @@ -606,11 +609,20 @@ sub generate_report { my $balanced_ledger = $totals{debit} + $totals{debit_tax} - $totals{credit} - $totals{credit_tax}; my $row = create_subtotal_row(\%totals, \@columns, \%column_alignment, [ qw(debit credit debit_tax credit_tax) ], 'listtotal'); - $row->{balance} = { - 'data' => $form->format_amount(\%myconfig, $form->{balance} * $ml, 2), - 'align' => 'right', - 'class' => 'listtotal', - }; + + my $sh = ""; + if ($form->{balance} < 0) { + $sh = " S"; + $ml = -1; + } elsif ($form->{balance} > 0) { + $sh = " H"; + $ml = 1; + } + my $data = $form->format_amount(\%myconfig, ($form->{balance} * $ml), 2); + $data .= $sh; + + $row->{balance}->{data} = $data; + $report->add_data($row); my $raw_bottom_info_text; @@ -768,17 +780,6 @@ sub display_rows { $form->{totaldebit} = 0; $form->{totalcredit} = 0; - my @old_project_ids = (); - map({ push(@old_project_ids, $form->{"project_id_$_"}) - if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); - - $form->get_lists("projects" => { "key" => "ALL_PROJECTS", - "all" => 0, - "old_id" => \@old_project_ids }, - "charts" => { "key" => "ALL_CHARTS", - "transdate" => $form->{transdate} }, - "taxcharts" => "ALL_TAXCHARTS"); - my %project_labels = (); my @project_values = (""); foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { @@ -792,7 +793,7 @@ sub display_rows { my $taxchart_init; foreach my $item (@{ $form->{ALL_CHARTS} }) { my $key = $item->{accno} . "--" . $item->{tax_id}; - $taxchart_init = $item->{taxkey_id} unless (@chart_values); + $taxchart_init = $item->{tax_id} unless (@chart_values); push(@chart_values, $key); $chart_labels{$key} = $item->{accno} . "--" . $item->{description}; $charts{$item->{accno}} = $item; @@ -803,14 +804,13 @@ sub display_rows { my %taxcharts = (); foreach my $item (@{ $form->{ALL_TAXCHARTS} }) { my $key = $item->{id} . "--" . $item->{rate}; - $taxchart_init = $key if ($taxchart_init eq $item->{taxkey}); + $taxchart_init = $key if ($taxchart_init == $item->{id}); push(@taxchart_values, $key); $taxchart_labels{$key} = $item->{taxdescription} . " " . $item->{rate} * 100 . ' %'; $taxcharts{$item->{id}} = $item; } for $i (1 .. $form->{rowcount}) { - if ($form->{show_details}) { $source = qq| |; @@ -839,13 +839,13 @@ sub display_rows { $selected_taxchart = "$item->{id}--$item->{rate}"; } - $selected_accno = '' if ($init); - $selected_taxchart = $taxchart_init unless ($selected_taxchart ne ""); + $selected_accno = '' if ($init); + $selected_taxchart ||= $taxchart_init; $accno = qq|| . NTI($cgi->popup_menu('-name' => "accno_$i", '-id' => "accno_$i", - '-onChange' => "setTaxkey(this, $i)", + '-onChange' => "setTaxkey($i)", '-style' => 'width:200px', '-values' => \@chart_values, '-labels' => \%chart_labels, @@ -927,6 +927,7 @@ sub display_rows { print qq| $accno +   $fx_transaction @@ -959,6 +960,19 @@ sub form_header { $auth->assert('general_ledger'); + my @old_project_ids = (); + map({ push(@old_project_ids, $form->{"project_id_$_"}) + if ($form->{"project_id_$_"}); } (1..$form->{"rowcount"})); + + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", + "all" => 0, + "old_id" => \@old_project_ids }, + "charts" => { "key" => "ALL_CHARTS", + "transdate" => $form->{transdate} }, + "taxcharts" => "ALL_TAXCHARTS"); + + GL->get_chart_balances('charts' => $form->{ALL_CHARTS}); + $title = $form->{title}; $form->{title} = $locale->text("$title General Ledger Transaction"); $readonly = ($form->{id}) ? "readonly" : ""; @@ -976,7 +990,8 @@ sub form_header { $form->{javascript} = qq||; - $form->{javascript} .= qq||; + + + +|; $form->{selectdepartment} =~ s/ selected//; $form->{selectdepartment} =~ @@ -1041,7 +1057,7 @@ sub form_header { $button1 = qq| text('button') . qq|> + . $locale->text('button') . qq|> |; #write Trigger @@ -1057,12 +1073,13 @@ sub form_header { $form->{previous_id} ||= "--"; $form->{previous_gldate} ||= "--"; + $jsscript .= $form->parse_html_template('gl/form_header_chart_balances_js'); + $form->header; print qq| -
@@ -1121,7 +1138,7 @@ sub form_header { |; } - print qq| + print qq| $department|; if ($form->{id}) { print qq| @@ -1183,6 +1200,7 @@ sub form_header { | . $locale->text('Account') . qq| + | . $locale->text('Chart balance') . qq| | . $locale->text('Debit') . qq| | @@ -1235,9 +1253,8 @@ sub form_footer { print qq| - - $form->{totaldebit} - $form->{totalcredit} + $form->{totaldebit} + $form->{totalcredit} @@ -1268,14 +1285,14 @@ $follow_ups_block |; } - print qq| + print qq| |; } else { - print qq| + print qq| |; } @@ -1334,7 +1351,7 @@ sub yes { $form->{addition} = "DELETED"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /saving the history $form->redirect($locale->text('Transaction deleted!')) } $form->error($locale->text('Cannot delete transaction!')); @@ -1457,7 +1474,7 @@ sub post_transaction { $credit += $cr + $tax if $cr; $taxtotal += $tax if $form->{taxincluded} } - + $form->{taxincluded} = 0 if !$taxtotal; # this is just for the wise guys @@ -1466,11 +1483,11 @@ sub post_transaction { if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) { $form->error($locale->text('Out of balance transaction!')); } - + if ($form->round_amount($debit, 2) + $form->round_amount($credit, 2) == 0) { $form->error($locale->text('Empty transaction!')); } - + if (($errno = GL->post_transaction(\%myconfig, \%$form)) <= -1) { $errno *= -1; $err[1] = $locale->text('Cannot have a value in both Debit and Credit!'); @@ -1484,10 +1501,10 @@ sub post_transaction { if(!exists $form->{addition} && $form->{id} ne "") { $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber}; $form->{addition} = "SAVED"; - $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id}; + $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id}; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /saving the history $lxdebug->leave_sub(); } @@ -1538,9 +1555,9 @@ sub storno { $form->{addition} = "STORNO"; $form->save_history($form->dbconnect(\%myconfig)); } - # /saving the history + # /saving the history - $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); + $form->redirect(sprintf $locale->text("Transaction %d cancelled."), $form->{storno_id}); $lxdebug->leave_sub(); }