X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fgl.pl;h=2ffccd39be5db60682571704dd1b43c5df7faf4d;hb=864b73ffb0964215f287a393ea37ec2eef6eb8eb;hp=e0a5811d24525ad81de0b84c2d53761593acfffe;hpb=0576299f2aa98125991c4ffcd2f75073ea583d7d;p=kivitendo-erp.git diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl index e0a5811d2..2ffccd39b 100644 --- a/bin/mozilla/gl.pl +++ b/bin/mozilla/gl.pl @@ -34,8 +34,6 @@ use SL::GL; use SL::PE; -use Data::Dumper; - require "$form->{path}/arap.pl"; 1; @@ -84,15 +82,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 +102,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 +113,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 +150,58 @@ sub edit { } (@{ $form->{all_departments} }); } - $form->{locked} = + my $i = 1; + my $tax = 0; + my $taxaccno = ""; + foreach $ref (@{ $form->{GL} }) { + $form->{"projectnumber_$i"} = "$ref->{projectnumber}--$ref->{project_id}"; + + $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 { @@ -247,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 @@ -305,6 +293,7 @@ sub search { | . $locale->text('From') . qq| $button1 + | . $locale->text('To (time)') . qq| $button2 @@ -317,7 +306,7 @@ sub search { . $locale->text('All') . qq| | . $locale->text('Asset') . qq| - | + | . $locale->text('Liability') . qq| | . $locale->text('Revenue') . qq| @@ -407,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} }); @@ -481,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; @@ -633,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') { @@ -642,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} })) { @@ -656,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 = ""; @@ -668,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 = ""; @@ -681,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 = ""; @@ -694,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 = ""; @@ -702,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}; } @@ -720,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}; } @@ -736,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}"; } } @@ -747,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}"; } } @@ -758,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"; @@ -785,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; @@ -854,22 +856,15 @@ sub generate_report { |; - - if ($form->{menubar}) { - require "$form->{path}/menu.pl"; - &menubar; - } - - print qq| + . $locale->text('Vendor Invoice') . qq|">