X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fgl.pl;h=87e20d13b1c2ff2efa5d683a7ffb44e57fea0041;hb=30531673553bc83a944806586bd4226cd6ec336c;hp=4a2d9792bad08cc4218e93ac59a04c16fba60d1d;hpb=b1253e4fa3f2a31c7452894439386d43951f5bc8;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 4a2d9792b..87e20d13b 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -82,11 +82,11 @@ 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} }; @@ -122,22 +122,14 @@ 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} }; @@ -145,10 +137,6 @@ sub edit { $form->{taxchart} = $tax; - if ($form->{tax} < 0) { - $form->{tax} = $form->{tax} * (-1); - } - $form->{amount} = $form->format_amount(\%myconfig, $form->{amount}, 2); # departments @@ -162,22 +150,44 @@ sub edit { } (@{ $form->{all_departments} }); } - $i = 1; + my $i = 1; + my $tax = 0; + my $taxaccno = ""; foreach $ref (@{ $form->{GL} }) { - $form->{"accno_$i"} = "$ref->{accno}--$ref->{description}"; - $form->{"projectnumber_$i"} = "$ref->{projectnumber}--$ref->{project_id}"; - for (qw(fx_transaction source memo)) { $form->{"${_}_$i"} = $ref->{$_} } - if ($ref->{amount} < 0) { - $form->{totaldebit} -= $ref->{amount}; - $form->{"debit_$i"} = $ref->{amount} * -1; + $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->{totalcredit} += $ref->{amount}; - $form->{"credit_$i"} = $ref->{amount}; + $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; } - $i++; } $form->{rowcount} = $i; @@ -227,14 +237,12 @@ sub search { $button1 = qq| text('button') - . qq|> + . $locale->text('button') . qq|> |; $button2 = qq| text('button') - . qq|> + . $locale->text('button') . qq|> |; #write Trigger @@ -285,6 +293,7 @@ sub search { | . $locale->text('From') . qq| $button1 + | . $locale->text('To (time)') . qq| $button2 @@ -297,12 +306,8 @@ sub search { . $locale->text('All') . qq| | . $locale->text('Asset') . qq| - | - . $locale->text('Contra') . qq| | . $locale->text('Liability') . qq| - | - . $locale->text('Equity') . qq| | . $locale->text('Revenue') . qq| | @@ -391,7 +396,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} }); @@ -465,10 +470,9 @@ sub generate_report { . $locale->date(\%myconfig, $form->{dateto}, 1); } - @columns = - $form->sort_columns( + @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) - ); + ); if ($form->{accno} || $form->{gifi_accno}) { @columns = grep !/(accno|gifi_accno)/, @columns; @@ -617,8 +621,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') { @@ -626,9 +631,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} })) { @@ -640,6 +646,7 @@ sub generate_report { $debit .= "" . $form->format_amount(\%myconfig, $ref->{debit}{$key}, 2, 0); } + $form->{balance} = abs($form->{balance}) - abs($ref->{debit}{$key}); } $credit = ""; @@ -652,6 +659,7 @@ sub generate_report { $credit .= "" . $form->format_amount(\%myconfig, $ref->{credit}{$key}, 2, 0); } + $form->{balance} = abs($form->{balance}) - abs($ref->{credit}{$key}); } $debittax = ""; @@ -665,6 +673,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 = ""; @@ -678,6 +687,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 = ""; @@ -686,14 +696,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}; } @@ -704,14 +715,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}; } @@ -720,10 +732,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}"; } } @@ -731,10 +743,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}"; } } @@ -742,12 +763,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"; @@ -769,9 +788,8 @@ 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) . ""; $i++; $i %= 2; @@ -838,14 +856,7 @@ sub generate_report { |; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| + . $locale->text('Vendor Invoice') . qq|"> @@ -900,11 +911,16 @@ sub update { $form->{oldtransdate} = $form->{transdate}; } - my @a = (); - my $count = 0; - my $debittax = 0; - my $credittax = 0; - my @flds = + my @a = (); + my $count = 0; + my $debittax = 0; + my $credittax = 0; + my $debitcount = 0; + my $creditcount = 0; + $debitlock = 0; + $creditlock = 0; + + my @flds = qw(accno debit credit projectnumber fx_transaction source memo tax taxchart); for my $i (1 .. $form->{rowcount}) { @@ -917,13 +933,43 @@ sub update { push @a, {}; $debitcredit = ($form->{"debit_$i"} == 0) ? "0" : "1"; + if ($debitcredit) { + $debitcount++; + } else { + $creditcount++; + } + + if (($debitcount >= 2) && ($creditcount == 2)) { + $form->{"credit_$i"} = 0; + $form->{"tax_$i"} = 0; + $creditcount--; + $creditlock = 1; + } + if (($creditcount >= 2) && ($debitcount == 2)) { + $form->{"debit_$i"} = 0; + $form->{"tax_$i"} = 0; + $debitcount--; + $debitlock = 1; + } + if (($creditcount == 1) && ($debitcount == 2)) { + $creditlock = 1; + } + if (($creditcount == 2) && ($debitcount == 1)) { + $debitlock = 1; + } + if ($debitcredit && $credittax) { + $form->{"taxchart_$i"} = "0--0.00"; + } + if (!$debitcredit && $debittax) { + $form->{"taxchart_$i"} = "0--0.00"; + } $amount = ($form->{"debit_$i"} == 0) ? $form->{"credit_$i"} : $form->{"debit_$i"}; $j = $#a; if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) { - $form->{"taxchart_$i"} = "0--"; + $form->{"taxchart_$i"} = "0--0.00"; $form->{"tax_$i"} = 0; } if (!$form->{"korrektur_$i"}) { @@ -999,27 +1045,25 @@ sub display_rows { for $i (1 .. $form->{rowcount}) { $source = qq| - |; + |; $memo = qq| - |; + |; if ($init) { $accno = qq| - $form->{chartinit}|; + $form->{chartinit}|; $tax = - qq|$form->{taxchart}|; - if ($form->{selectprojectnumber}) { - $project = qq| - $form->{selectprojectnumber}|; - } + + # if ($form->{selectprojectnumber}) { + # $project = qq| + # $form->{selectprojectnumber}|; + # } $korrektur = qq|{totaldebit} += $form->{"debit_$i"}; - $form->{totalcredit} += $form->{"credit_$i"}; + if ($form->{"debit_$i"} != 0) { + $form->{totaldebit} += $form->{"debit_$i"}; + if (!$form->{taxincluded}) { + $form->{totaldebit} += $form->{"tax_$i"}; + } + } else { + $form->{totalcredit} += $form->{"credit_$i"}; + if (!$form->{taxincluded}) { + $form->{totalcredit} += $form->{"tax_$i"}; + } + } for (qw(debit credit tax)) { $form->{"${_}_$i"} = @@ -1049,7 +1101,7 @@ sub display_rows { $accno =~ s/value=\"$chart_selected\"/value=\"$chart_selected\" selected/; $accno = - qq|$accno|; $tax = $taxchart; @@ -1060,14 +1112,14 @@ sub display_rows { . ($i + 10 + (($i - 1) * 8)) . qq|>$tax|; - if ($form->{selectprojectnumber}) { - $form->{"projectnumber_$i"} = "" - if $form->{selectprojectnumber} !~ /$form->{"projectnumber_$i"}/; - - $project = $form->{"projectnumber_$i"}; - $project =~ s/--.*//; - $project = qq|$project|; - } + # if ($form->{selectprojectnumber}) { + # $form->{"projectnumber_$i"} = "" + # if $form->{selectprojectnumber} !~ /$form->{"projectnumber_$i"}/; + # + # $project = $form->{"projectnumber_$i"}; + # $project =~ s/--.*//; + # $project = qq|$project|; + # } if ($form->{transfer}) { $checked = ($form->{"fx_transaction_$i"}) ? "1" : ""; @@ -1081,22 +1133,21 @@ sub display_rows { qq||; - $form->hide_form("accno_$i", "projectnumber_$i"); + $form->hide_form("accno_$i"); } else { $accno = qq| $chart|; + . ($i + 5 + (($i - 1) * 8)) . qq|>$chart|; $tax = qq| $taxchart|; - if ($form->{selectprojectnumber}) { - $project = qq| - $form->{selectprojectnumber}|; - } + . ($i + 10 + (($i - 1) * 8)) . qq|>$taxchart|; + + # if ($form->{selectprojectnumber}) { + # $project = qq| + # $form->{selectprojectnumber}|; + # } $korrektur = qq|{rowcount}) { + if ($debitlock) { + $debitreadonly = "readonly"; + } elsif ($creditlock) { + $creditreadonly = "readonly"; + } + } print qq| $accno $fx_transaction - - - + + + $korrektur $tax $source $memo - $project |; } $form->hide_form(qw(rowcount selectaccno)); - print qq| -|; + + # print qq| + # |; $lxdebug->leave_sub(); } @@ -1155,7 +1212,7 @@ sub form_header {