X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fgl.pl;h=2d8d31d3abcaddfabc57e15fedc10f190bcaeeff;hb=e6f429e42da71c71b6416727216302a87a254fde;hp=e0a5811d24525ad81de0b84c2d53761593acfffe;hpb=ee072e4f077213bf6f8792ca8f0a1afebbb6282f;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index e0a5811d2..2d8d31d3a 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -34,9 +34,8 @@ use SL::GL; use SL::PE; -use Data::Dumper; - require "$form->{path}/arap.pl"; +require "bin/mozilla/common.pl"; 1; @@ -84,15 +83,17 @@ sub add { map { $chart .= - "{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}" + "{accno}--$_->{tax_id}\">$_->{accno}--$_->{description}" } @{ $form->{chart} }; map { $tax .= - qq|$_->{taxdescription} | + qq|$_->{taxdescription} | . ($_->{rate} * 100) . qq| %| } @{ $form->{TAX} }; - $form->{chart} = $chart; + $form->{chart} = $chart; + $form->{chartinit} = $chart; + $form->{rowcount} = 2; $form->{debitchart} = $chart; $form->{creditchart} = $chart; @@ -102,9 +103,6 @@ sub add { $form->{credit} = 0; $form->{tax} = 0; - $form->{creditrowcount} = 2; - $form->{debitrowcount} = 2; - # departments $form->all_departments(\%myconfig); if (@{ $form->{all_departments} }) { @@ -116,77 +114,29 @@ sub add { } (@{ $form->{all_departments} }); } - &display_form; - + &display_form(1); $lxdebug->leave_sub(); + } sub edit { $lxdebug->enter_sub(); GL->transaction(\%myconfig, \%$form); - map { - if ($form->{debitaccno} eq $_->{accno}) { - $form->{debitchart} .= - "{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}"; - } - } @{ $form->{chart} }; - map { - if ($form->{creditaccno} eq $_->{accno}) { - $form->{creditchart} .= - "{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}"; - } + $chart .= + "{accno}--$_->{tax_id}\">$_->{accno}--$_->{description}" } @{ $form->{chart} }; + map { $tax .= - qq|$_->{taxdescription} | + qq|$_->{taxdescription} | . ($_->{rate} * 100) . qq| %| } @{ $form->{TAX} }; - if ($form->{creditrowcount} > 2) { - for $i (2 .. $form->{creditrowcount}) { - map { - if ($form->{"creditchartselected_$i"} eq $_->{accno}) { - $form->{"creditchartselected_$i"} = "$_->{accno}--$_->{taxkey_id}"; - } - } @{ $form->{chart} }; - map { - if ($form->{"taxchartselected_$i"} eq $_->{taxkey}) { - $form->{"taxchartselected_$i"} = "$_->{taxkey}--$_->{rate}"; - } - } @{ $form->{TAX} }; - } - } - if ($form->{debitrowcount} > 2) { - for $i (2 .. $form->{debitrowcount}) { - map { - if ($form->{"debitchartselected_$i"} eq $_->{accno}) { - $form->{"debitchartselected_$i"} = "$_->{accno}--$_->{taxkey_id}"; - } - } @{ $form->{chart} }; - map { - if ($form->{"taxchartselected_$i"} eq $_->{taxkey}) { - $form->{"taxchartselected_$i"} = "$_->{taxkey}--$_->{rate}"; - } - } @{ $form->{TAX} }; - } - } - map { - $chart .= - "{accno}--$_->{taxkey_id}\">$_->{accno}--$_->{description}" - } @{ $form->{chart} }; $form->{chart} = $chart; - map { - $tax .= - qq|$_->{taxdescription} | - . ($_->{rate} * 100) . qq| %| - } @{ $form->{TAX} }; - $form->{taxchart} = $tax; - if ($form->{tax} < 0) { - $form->{tax} = $form->{tax} * (-1); - } + $form->{taxchart} = $tax; $form->{amount} = $form->format_amount(\%myconfig, $form->{amount}, 2); @@ -201,17 +151,56 @@ sub edit { } (@{ $form->{all_departments} }); } - $form->{locked} = + my $i = 1; + my $tax = 0; + my $taxaccno = ""; + foreach $ref (@{ $form->{GL} }) { + $j = $i - 1; + if ($tax && ($ref->{accno} eq $taxaccno)) { + $form->{"tax_$j"} = abs($ref->{amount}); + $form->{"taxchart_$j"} = $ref->{id} . "--" . $ref->{taxrate}; + if ($form->{taxincluded}) { + if ($ref->{amount} < 0) { + $form->{"debit_$j"} += $form->{"tax_$j"}; + } else { + $form->{"credit_$j"} += $form->{"tax_$j"}; + } + } + } else { + $form->{"accno_$i"} = "$ref->{accno}--$ref->{tax_id}"; + for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} } + if ($ref->{amount} < 0) { + $form->{totaldebit} -= $ref->{amount}; + $form->{"debit_$i"} = $ref->{amount} * -1; + } else { + $form->{totalcredit} += $ref->{amount}; + $form->{"credit_$i"} = $ref->{amount}; + } + $form->{"taxchart_$i"} = "0--0.00"; + $i++; + } + if ($ref->{taxaccno} && !$tax) { + $taxaccno = $ref->{taxaccno}; + $tax = 1; + } else { + $taxaccno = ""; + $tax = 0; + } + + } + + $form->{rowcount} = $i; + $form->{locked} = ($form->datetonum($form->{transdate}, \%myconfig) <= $form->datetonum($form->{closedto}, \%myconfig)); $form->{title} = "Edit"; &form_header; - + &display_rows; &form_footer; - $lxdebug->leave_sub(); + } sub search { @@ -238,6 +227,21 @@ sub search { | if $form->{selectdepartment}; + $form->get_lists("projects" => { "key" => "ALL_PROJECTS", + "all" => 1 }); + + my %project_labels = (); + my @project_values = (""); + foreach my $item (@{ $form->{"ALL_PROJECTS"} }) { + push(@project_values, $item->{"id"}); + $project_labels{$item->{"id"}} = $item->{"projectnumber"}; + } + + my $projectnumber = + NTI($cgi->popup_menu('-name' => "project_id", + '-values' => \@project_values, + '-labels' => \%project_labels)); + # use JavaScript Calendar or not $form->{jsscript} = $jscalendar; $jsscript = ""; @@ -247,14 +251,12 @@ sub search { $button1 = qq| text('button') - . qq|> + . $locale->text('button') . qq|> |; $button2 = qq| text('button') - . qq|> + . $locale->text('button') . qq|> |; #write Trigger @@ -302,9 +304,14 @@ sub search { | . $locale->text('Notes') . qq| + + | . $locale->text('Project Number') . qq| + $projectnumber + | . $locale->text('From') . qq| $button1 + | . $locale->text('To (time)') . qq| $button2 @@ -317,7 +324,7 @@ sub search { . $locale->text('All') . qq| | . $locale->text('Asset') . qq| - | + | . $locale->text('Liability') . qq| | . $locale->text('Revenue') . qq| @@ -354,6 +361,8 @@ sub search { | . $locale->text('Subtotal') . qq| + + | . $locale->text('Project Number') . qq| @@ -407,7 +416,7 @@ sub generate_report { $form->{title} = $locale->text('General Ledger'); - $ml = ($form->{ml} =~ /(A|E)/) ? -1 : 1; + $ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1; unless ($form->{category} eq 'X') { $form->{title} .= " : " . $locale->text($acctype{ $form->{category} }); @@ -459,6 +468,10 @@ sub generate_report { $option .= "\n" if $option; $option .= $locale->text('Notes') . " : $form->{notes}"; } + if ($form->{project_id}) { + $href .= "&project_id=" . $form->escape($form->{project_id}); + $callback .= "&project_id=" . $form->escape($form->{project_id}); + } if ($form->{datefrom}) { $href .= "&datefrom=$form->{datefrom}"; @@ -481,10 +494,14 @@ sub generate_report { . $locale->date(\%myconfig, $form->{dateto}, 1); } - @columns = - $form->sort_columns( - qw(transdate id reference description notes source debit debit_accno credit credit_accno debit_tax debit_tax_accno credit_tax credit_tax_accno accno gifi_accno) - ); + @columns = $form->sort_columns( qw( + transdate id reference description + notes source debit debit_accno + credit credit_accno debit_tax debit_tax_accno + credit_tax credit_tax_accno accno gifi_accno + projectnumbers + ) + ); if ($form->{accno} || $form->{gifi_accno}) { @columns = grep !/(accno|gifi_accno)/, @columns; @@ -573,6 +590,8 @@ sub generate_report { . $locale->text('GIFI') . ""; $column_header{balance} = "" . $locale->text('Balance') . ""; + $column_header{projectnumbers} = + "" . $locale->text('Project Numbers') . ""; $form->{landscape} = 1; @@ -633,8 +652,9 @@ sub generate_report { |; } - + $form->{balance} *= $ml; foreach $ref (@{ $form->{GL} }) { + $form->{balance} *= $ml; # if item ne sort print subtotal if ($form->{l_subtotal} eq 'Y') { @@ -642,9 +662,10 @@ sub generate_report { &gl_subtotal; } } - foreach $key (sort keys(%{ $ref->{amount} })) { - $form->{balance} += $ref->{amount}{$key}; - } + + #foreach $key (sort keys(%{ $ref->{amount} })) { + # $form->{balance} += $ref->{amount}{$key}; + #} $debit = ""; foreach $key (sort keys(%{ $ref->{debit} })) { @@ -656,6 +677,7 @@ sub generate_report { $debit .= "" . $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0); } + $form->{balance} = abs($form->{balance}) - abs($ref->{debit}{$key}); } $credit = ""; @@ -668,6 +690,7 @@ sub generate_report { $credit .= "" . $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0); } + $form->{balance} = abs($form->{balance}) - abs($ref->{credit}{$key}); } $debittax = ""; @@ -681,6 +704,7 @@ sub generate_report { $debittax .= "" . $form->format_amount(\%myconfig, $ref->{debit_tax}{$key}, 2, 0); } + $form->{balance} = abs($form->{balance}) - abs($ref->{debit_tax}{$key}); } $credittax = ""; @@ -694,6 +718,7 @@ sub generate_report { $credittax .= "" . $form->format_amount(\%myconfig, $ref->{credit_tax}{$key}, 2, 0); } + $form->{balance} = abs($form->{balance}) - abs($ref->{credit_tax}{$key}); } $debitaccno = ""; @@ -702,14 +727,15 @@ sub generate_report { foreach $key (sort keys(%{ $ref->{debit_accno} })) { if ($key == 0) { $debitaccno = - "{accno}&callback=$callback>$ref->{debit_accno}{$key}"; + "{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}"; } else { $debitaccno .= - "{accno}&callback=$callback>$ref->{debit_accno}{$key}"; - } - if ($ref->{debit_taxkey}{$key} eq $debittaxkey) { - $ref->{debit_tax_accno}{$key} = $taxaccno; + "{debit_accno}{$key}&callback=$callback>$ref->{debit_accno}{$key}"; } + + # if ($ref->{debit_taxkey}{$key} eq $debittaxkey) { + # $ref->{debit_tax_accno}{$key} = $taxaccno; + # } $taxaccno = $ref->{debit_tax_accno}{$key}; $debittaxkey = $ref->{debit_taxkey}{$key}; } @@ -720,14 +746,15 @@ sub generate_report { foreach $key (sort keys(%{ $ref->{credit_accno} })) { if ($key == 0) { $creditaccno = - "{accno}&callback=$callback>$ref->{credit_accno}{$key}"; + "{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}"; } else { $creditaccno .= - "{accno}&callback=$callback>$ref->{credit_accno}{$key}"; - } - if ($ref->{credit_taxkey}{$key} eq $credittaxkey) { - $ref->{credit_tax_accno}{$key} = $taxaccno; + "{credit_accno}{$key}&callback=$callback>$ref->{credit_accno}{$key}"; } + + # if ($ref->{credit_taxkey}{$key} eq $credittaxkey) { + # $ref->{credit_tax_accno}{$key} = $taxaccno; + # } $taxaccno = $ref->{credit_tax_accno}{$key}; $credittaxkey = $ref->{credit_taxkey}{$key}; } @@ -736,10 +763,10 @@ sub generate_report { foreach $key (sort keys(%{ $ref->{debit_tax_accno} })) { if ($key == 0) { $debittaxaccno = - "{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}"; + "{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}"; } else { $debittaxaccno .= - "{accno}&callback=$callback>$ref->{debit_tax_accno}{$key}"; + "{debit_tax_accno}{$key}&callback=$callback>$ref->{debit_tax_accno}{$key}"; } } @@ -747,10 +774,19 @@ sub generate_report { foreach $key (sort keys(%{ $ref->{credit_tax_accno} })) { if ($key == 0) { $credittaxaccno = - "{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}"; + "{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}"; } else { $credittaxaccno .= - "{accno}&callback=$callback>$ref->{credit_tax_accno}{$key}"; + "{credit_tax_accno}{$key}&callback=$callback>$ref->{credit_tax_accno}{$key}"; + } + } + + $transdate = ""; + foreach $key (sort keys(%{ $ref->{transdate} })) { + if ($key == 0) { + $transdate = "$ref->{transdate}{$key}"; + } else { + $transdate .= "$ref->{transdate}{$key}"; } } @@ -758,12 +794,10 @@ sub generate_report { # $ref->{credit} = $form->format_amount(\%myconfig, $ref->{credit}, 2, " "); $column_data{id} = " $ref->{id} "; - $column_data{transdate} = - " $ref->{transdate} "; + $column_data{transdate} = "$transdate"; $column_data{reference} = "{module}.pl?action=edit&id=$ref->{id}&path=$form->{path}&login=$form->{login}&password=$form->{password}&callback=$callback>$ref->{reference}"; - $column_data{description} = - "$ref->{description} "; + $column_data{description} = "$ref->{description} "; $column_data{source} = "$ref->{source} "; $column_data{notes} = "$ref->{notes} "; $column_data{debit} = "$debit"; @@ -785,9 +819,10 @@ sub generate_report { $column_data{gifi_accno} = "{gifi_accno}&callback=$callback>$ref->{gifi_accno} "; $column_data{balance} = - "" - . $form->format_amount(\%myconfig, $form->{balance} * $ml, 2, 0) - . ""; + "" + . $form->format_amount(\%myconfig, $form->{balance}, 2, 0) . ""; + $column_data{projectnumbers} = + "" . join(", ", sort({ lc($a) cmp lc($b) } keys(%{ $ref->{projectnumbers} }))) . ""; $i++; $i %= 2; @@ -802,6 +837,12 @@ sub generate_report { map { $column_data{$_} = " " } @column_index; + my $balanced_ledger = $totaldebit + + $totaldebittax + - $totalcredit + - $totalcredittax; + # = 0 for balanced ledger + $column_data{debit} = "" . $form->format_amount(\%myconfig, $totaldebit, 2, " ") . ""; @@ -826,6 +867,27 @@ sub generate_report { print qq| + |; + + + if ( abs($balanced_ledger) > 0.001 ) { + + print qq|| + . $locale->text('Unbalanced Ledger') + . ": " + . $form->format_amount(\%myconfig, $balanced_ledger, 3, " ") + + } elsif ( abs($balanced_ledger) <= 0.001 ) { + + print qq|| + . $locale->text('Balanced Ledger') + + } + + + print qq| + + @@ -854,22 +916,15 @@ sub generate_report { |; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| + . $locale->text('Vendor Invoice') . qq|">