X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;f=bin%2Fmozilla%2Fgl.pl;h=da2da5b37dc84cca62c6141a1a0c3bde72be2ba1;hb=32ebe005ef3be63e188a653c7a831a39eb0f8e63;hp=4a2d9792bad08cc4218e93ac59a04c16fba60d1d;hpb=b1253e4fa3f2a31c7452894439386d43951f5bc8;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index 4a2d9792b..da2da5b37 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -122,19 +122,11 @@ 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}--$_->{taxkey_id}\">$_->{accno}--$_->{description}" } @{ $form->{chart} }; + map { $tax .= qq|$_->{taxdescription} | @@ -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,36 @@ 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->{taxkey} . "--" . $ref->{taxrate}; } else { - $form->{totalcredit} += $ref->{amount}; - $form->{"credit_$i"} = $ref->{amount}; + $form->{"accno_$i"} = "$ref->{accno}--$ref->{accnotaxkey}"; + 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}; + } + $i++; + } + if ($ref->{taxaccno} && !$tax) { + $taxaccno = $ref->{taxaccno}; + $tax = 1; + } else { + $taxaccno = ""; + $tax = 0; } - $i++; } $form->{rowcount} = $i; @@ -227,14 +229,12 @@ sub search { $button1 = qq| text('button') - . qq|> + . $locale->text('button') . qq|> |; $button2 = qq| text('button') - . qq|> + . $locale->text('button') . qq|> |; #write Trigger @@ -391,7 +391,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 +465,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,18 +616,18 @@ 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') { if ($sameitem ne $ref->{ $form->{sort} }) { &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 +639,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 +652,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 +666,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 +680,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 = ""; @@ -770,7 +773,7 @@ sub generate_report { "{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++; @@ -900,11 +903,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,6 +925,36 @@ 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"} @@ -1000,18 +1038,15 @@ sub display_rows { $source = qq| |; + . ($i + 11 + (($i - 1) * 8)) . qq|>|; $memo = qq| |; + . ($i + 12 + (($i - 1) * 8)) . qq|>|; if ($init) { $accno = qq| $form->{chartinit}|; + . ($i + 5 + (($i - 1) * 8)) . qq|>$form->{chartinit}|; $tax = qq|{totaldebit} += $form->{"debit_$i"}; - $form->{totalcredit} += $form->{"credit_$i"}; + if ($form->{"debit_$i"} != 0) { + $form->{totaldebit} += $form->{"debit_$i"}; + $form->{totaldebit} += $form->{"tax_$i"}; + } else { + $form->{totalcredit} += $form->{"credit_$i"}; + $form->{totalcredit} += $form->{"tax_$i"}; + } for (qw(debit credit tax)) { $form->{"${_}_$i"} = @@ -1087,12 +1126,10 @@ sub display_rows { $accno = qq| $chart|; + . ($i + 5 + (($i - 1) * 8)) . qq|>$chart|; $tax = qq| $taxchart|; + . ($i + 10 + (($i - 1) * 8)) . qq|>$taxchart|; if ($form->{selectprojectnumber}) { $project = qq| $form->{selectprojectnumber}|; @@ -1108,19 +1145,25 @@ sub display_rows { } } } + my $debitreadonly = ""; + my $creditreadonly = ""; + if ($i == $form->{rowcount}) { + if ($debitlock) { + $debitreadonly = "readonly"; + } elsif ($creditlock) { + $creditreadonly = "readonly"; + } + } print qq| $accno $fx_transaction + . ($i + 6 + (($i - 1) * 8)) . qq| $debitreadonly> + . ($i + 7 + (($i - 1) * 8)) . qq| $creditreadonly> + . ($i + 8 + (($i - 1) * 8)) . qq|> $korrektur $tax $source @@ -1189,9 +1232,6 @@ sub form_header { $taxincluded = "checked"; } - $amount = - qq||; - $department = qq| | . $locale->text('Department') . qq| @@ -1214,8 +1254,7 @@ sub form_header { $button1 = qq| {transdate} tabindex="2" $readonly> text('button') - . qq|> + . $locale->text('button') . qq|> |; #write Trigger @@ -1254,10 +1293,10 @@ sub form_header { - | . $locale->text('Reference') . qq| + | . $locale->text('Reference') . qq| - + | . $locale->text('Date') . qq| $button1 @@ -1271,7 +1310,7 @@ sub form_header { | . $locale->text('Belegnummer') . qq| - + | . $locale->text('Buchungsdatum') . qq| {gldate} $readonly> @@ -1285,8 +1324,16 @@ sub form_header { if ($form->{id}) { print qq| - | . $locale->text('Description') . qq| - $description + | . $locale->text('Description') . qq| + $description + + + + | . $locale->text('MwSt. inkl.') . qq| + + + + @@ -1299,15 +1346,9 @@ sub form_header { } else { print qq| - | . $locale->text('Description') . qq| - $description - |; - } - print qq| - - | . $locale->text('Betrag') . qq| - $amount - + | . $locale->text('Description') . qq| + $description + | . $locale->text('MwSt. inkl.') . qq| @@ -1315,31 +1356,27 @@ sub form_header { - + |; + } + print qq| + | - . $locale->text('Account') - . qq| + . $locale->text('Account') . qq| | - . $locale->text('Debit') - . qq| + . $locale->text('Debit') . qq| | - . $locale->text('Credit') - . qq| + . $locale->text('Credit') . qq| | - . $locale->text('Tax') - . qq| + . $locale->text('Tax') . qq| | - . $locale->text('Korrektur') - . qq| + . $locale->text('Korrektur') . qq| | - . $locale->text('Taxkey') - . qq| + . $locale->text('Taxkey') . qq| | - . $locale->text('Source') - . qq| + . $locale->text('Source') . qq| | . $locale->text('Memo') . qq| $project @@ -1359,11 +1396,19 @@ sub form_footer { map { $form->{$_} = - $form->format_amount(\%myconfig, $form->{$_}, $decimalplaces, " ") + $form->format_amount(\%myconfig, $form->{$_}, 2, " ") } qw(totaldebit totalcredit); print qq| + + + $form->{totaldebit} + $form->{totalcredit} + + + + {path}> @@ -1388,8 +1433,7 @@ sub form_footer { if (!$form->{locked} && $radieren) { print qq| + . $locale->text('Post') . qq|" accesskey="b"> |; } @@ -1480,11 +1524,16 @@ sub post { # check project &check_project; - 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; + $creditlock = 0; + $debitlock = 0; + + my @flds = qw(accno debit credit projectnumber fx_transaction source memo tax taxchart); for my $i (1 .. $form->{rowcount}) { @@ -1497,6 +1546,37 @@ sub post { 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"}