X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=inline;f=bin%2Fmozilla%2Fgl.pl;h=7516cf8d11e5d42e995ff0c53766396127f2f713;hb=ab875da135e7c44abb05eae5a136f6df4e09078c;hp=fd75c2ed2c0931293d68e29fe0d52559dafc934a;hpb=2424e0523dacae4c9a1d72fa19738f9109e2d048;p=kivitendo-erp.git
diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl
index fd75c2ed2..7516cf8d1 100644
--- a/bin/mozilla/gl.pl
+++ b/bin/mozilla/gl.pl
@@ -31,12 +31,18 @@
#
#======================================================================
+use POSIX qw(strftime);
+use List::Util qw(sum);
+
+use SL::FU;
use SL::GL;
use SL::IS;
use SL::PE;
+use SL::ReportGenerator;
-require "bin/mozilla/arap.pl";
require "bin/mozilla/common.pl";
+require "bin/mozilla/drafts.pl";
+require "bin/mozilla/reportgenerator.pl";
1;
@@ -73,11 +79,13 @@ require "bin/mozilla/common.pl";
sub add {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
+ return $lxdebug->leave_sub() if (load_draft_maybe());
+
$form->{title} = "Add";
- $form->{callback} =
- "$form->{script}?action=add&login=$form->{login}&password=$form->{password}"
- unless $form->{callback};
+ $form->{callback} = "gl.pl?action=add" unless $form->{callback};
# we use this only to set a default date
GL->transaction(\%myconfig, \%$form);
@@ -115,6 +123,8 @@ sub add {
sub prepare_transaction {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
GL->transaction(\%myconfig, \%$form);
map {
@@ -187,6 +197,8 @@ sub prepare_transaction {
sub edit {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
prepare_transaction();
$form->{title} = "Edit";
@@ -204,7 +216,9 @@ sub edit {
sub search {
$lxdebug->enter_sub();
- $form->{title} = $locale->text('Buchungsjournal');
+ $auth->assert('general_ledger');
+
+ $form->{title} = $locale->text('Journal');
$form->all_departments(\%myconfig);
@@ -241,7 +255,7 @@ sub search {
'-labels' => \%project_labels));
# use JavaScript Calendar or not
- $form->{jsscript} = $jscalendar;
+ $form->{jsscript} = 1;
$jsscript = "";
if ($form->{jsscript}) {
@@ -249,7 +263,7 @@ sub search {
$button1 = qq|
text('button') . qq|> |
+ . $locale->text('button') . qq|>
|;
$button2 = qq|
@@ -277,7 +291,7 @@ sub search {
print qq|
-
+ $row->{balance}->{data} = $data;
-
-
-|;
- $lxdebug->leave_sub();
-
-}
+ $report->add_data($row);
-sub gl_subtotal {
- $lxdebug->enter_sub();
+ my $raw_bottom_info_text;
- $subtotaldebit =
- $form->format_amount(\%myconfig, $subtotaldebit, 2, " ");
- $subtotalcredit =
- $form->format_amount(\%myconfig, $subtotalcredit, 2, " ");
+ if (!$form->{accno} && (abs($balanced_ledger) > 0.001)) {
+ $raw_bottom_info_text .=
+ ' '
+ . $locale->text('Unbalanced Ledger')
+ . ': '
+ . $form->format_amount(\%myconfig, $balanced_ledger, 3)
+ . ' ';
+ }
- map { $column_data{$_} = " | | " }
- qw(transdate id reference source description accno);
- $column_data{debit} = "$subtotaldebit";
- $column_data{credit} = " | $subtotalcredit";
+ $raw_bottom_info_text .= $form->parse_html_template('gl/generate_report_bottom');
- print " | ";
- map { print "$column_data{$_}\n" } @column_index;
- print "
";
+ $report->set_options('raw_bottom_info_text' => $raw_bottom_info_text);
- $subtotaldebit = 0;
- $subtotalcredit = 0;
+ $report->generate_with_headers();
- $sameitem = $ref->{ $form->{sort} };
$lxdebug->leave_sub();
-
}
sub update {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
$form->{oldtransdate} = $form->{transdate};
my @a = ();
@@ -998,22 +717,20 @@ sub update {
$form->{"taxchart_$i"} = "0--0.00";
$form->{"tax_$i"} = 0;
}
- if (!$form->{"korrektur_$i"}) {
- ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
- if ($taxkey > 1) {
- if ($debitcredit) {
- $debittax = 1;
- } else {
- $credittax = 1;
- }
- if ($form->{taxincluded}) {
- $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
- } else {
- $form->{"tax_$i"} = $amount * $rate;
- }
+ ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
+ if ($taxkey > 1) {
+ if ($debitcredit) {
+ $debittax = 1;
+ } else {
+ $credittax = 1;
+ }
+ if ($form->{taxincluded}) {
+ $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
} else {
- $form->{"tax_$i"} = 0;
+ $form->{"tax_$i"} = $amount * $rate;
}
+ } else {
+ $form->{"tax_$i"} = 0;
}
for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
@@ -1041,6 +758,8 @@ sub display_form {
my ($init) = @_;
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
&form_header($init);
# for $i (1 .. $form->{rowcount}) {
@@ -1059,21 +778,12 @@ sub display_rows {
my ($init) = @_;
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
$form->{debit_1} = 0 if !$form->{"debit_1"};
$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"} }) {
@@ -1086,10 +796,10 @@ sub display_rows {
my %charts = ();
my $taxchart_init;
foreach my $item (@{ $form->{ALL_CHARTS} }) {
- my $key = Q($item->{accno}) . "--" . Q($item->{tax_id});
- $taxchart_init = $item->{taxkey_id} unless (@chart_values);
+ my $key = $item->{accno} . "--" . $item->{tax_id};
+ $taxchart_init = $item->{tax_id} unless (@chart_values);
push(@chart_values, $key);
- $chart_labels{$key} = H($item->{accno}) . "--" . H($item->{description});
+ $chart_labels{$key} = $item->{accno} . "--" . $item->{description};
$charts{$item->{accno}} = $item;
}
@@ -1097,20 +807,25 @@ sub display_rows {
my @taxchart_values = ();
my %taxcharts = ();
foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
- my $key = Q($item->{id}) . "--" . Q($item->{rate});
- $taxchart_init = $key if ($taxchart_init eq $item->{taxkey});
+ my $key = $item->{id} . "--" . $item->{rate};
+ $taxchart_init = $key if ($taxchart_init == $item->{id});
push(@taxchart_values, $key);
- $taxchart_labels{$key} = H($item->{taxdescription}) . " " .
- H($item->{rate} * 100) . ' %';
+ $taxchart_labels{$key} = $item->{taxdescription} . " " . $item->{rate} * 100 . ' %';
$taxcharts{$item->{id}} = $item;
}
for $i (1 .. $form->{rowcount}) {
-
- $source = qq|
- | |;
- $memo = qq|
- | |;
+ if ($form->{show_details}) {
+ $source = qq|
+ | |;
+ $memo = qq|
+ | |;
+ } else {
+ $source_hidden = qq|
+ |;
+ $memo_hidden = qq|
+ |;
+ }
my $selected_accno_full;
my ($accno_row) = split(/--/, $form->{"accno_$i"});
@@ -1128,13 +843,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,
@@ -1152,8 +867,6 @@ sub display_rows {
. qq| | |;
if ($init) {
- $korrektur =
- qq||;
if ($form->{transfer}) {
$fx_transaction = qq|
| |
@@ -1188,14 +901,9 @@ sub display_rows {
$x |
|;
}
- $checked = ($form->{"korrektur_$i"}) ? "checked" : "";
- $korrektur =
- qq| | |;
$form->hide_form("accno_$i");
} else {
- $korrektur =
- qq| | |;
if ($form->{transfer}) {
$fx_transaction = qq|
|
@@ -1223,11 +931,11 @@ sub display_rows {
print qq|
$accno
+ |
$fx_transaction
|
|
- |
- $korrektur
+ $form->{"tax_$i"} |
$tax|;
if ($form->{show_details}) {
@@ -1238,6 +946,8 @@ sub display_rows {
|;
}
print qq|
+ $source_hidden
+ $memo_hidden
|;
}
@@ -1251,12 +961,31 @@ sub display_rows {
sub form_header {
my ($init) = @_;
$lxdebug->enter_sub();
+
+ $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" : "";
$show_details_checked = "checked" if $form->{show_details};
+ $ob_transaction_checked = "checked" if $form->{ob_transaction};
+ $cb_transaction_checked = "checked" if $form->{cb_transaction};
+
# $locale->text('Add General Ledger Transaction')
# $locale->text('Edit General Ledger Transaction')
@@ -1265,7 +994,8 @@ sub form_header {
$form->{javascript} = qq||;
- $form->{javascript} .= qq||;
+
+
+
+|;
$form->{selectdepartment} =~ s/ selected//;
$form->{selectdepartment} =~
@@ -1330,7 +1061,7 @@ sub form_header {
$button1 = qq|
text('button') . qq|> |
+ . $locale->text('button') . qq|>
|;
#write Trigger
@@ -1343,19 +1074,30 @@ sub form_header {
qq| | |;
}
+ $form->{previous_id} ||= "--";
+ $form->{previous_gldate} ||= "--";
+
+ $jsscript .= $form->parse_html_template('gl/form_header_chart_balances_js');
+
$form->header;
print qq|
-
+
+
+
-