X-Git-Url: http://wagnertech.de/git?a=blobdiff_plain;ds=sidebyside;f=bin%2Fmozilla%2Fgl.pl;h=7516cf8d11e5d42e995ff0c53766396127f2f713;hb=f75b552e93cc451f08caa845e7e0e5f34aaf44cf;hp=faaad58280a10c687612e0da15401241730be696;hpb=d629acd82a27e980899a044ca8b0f4becc8e94bb;p=kivitendo-erp.git
diff --git a/bin/mozilla/gl.pl b/bin/mozilla/gl.pl
index faaad5828..7516cf8d1 100644
--- a/bin/mozilla/gl.pl
+++ b/bin/mozilla/gl.pl
@@ -31,11 +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;
@@ -72,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);
@@ -104,14 +113,18 @@ sub add {
} (@{ $form->{all_departments} });
}
+ $form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details};
+
&display_form(1);
$lxdebug->leave_sub();
}
-sub edit {
+sub prepare_transaction {
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
GL->transaction(\%myconfig, \%$form);
map {
@@ -178,19 +191,34 @@ sub edit {
($form->datetonum($form->{transdate}, \%myconfig) <=
$form->datetonum($form->{closedto}, \%myconfig));
+ $lxdebug->leave_sub();
+}
+
+sub edit {
+ $lxdebug->enter_sub();
+
+ $auth->assert('general_ledger');
+
+ prepare_transaction();
+
$form->{title} = "Edit";
- &form_header;
- &display_rows;
- &form_footer;
- $lxdebug->leave_sub();
+ $form->{show_details} = $myconfig{show_form_details} unless defined $form->{show_details};
+ form_header();
+ display_rows();
+ form_footer();
+
+ $lxdebug->leave_sub();
}
+
sub search {
$lxdebug->enter_sub();
- $form->{title} = $locale->text('Buchungsjournal');
+ $auth->assert('general_ledger');
+
+ $form->{title} = $locale->text('Journal');
$form->all_departments(\%myconfig);
@@ -227,7 +255,7 @@ sub search {
'-labels' => \%project_labels));
# use JavaScript Calendar or not
- $form->{jsscript} = $jscalendar;
+ $form->{jsscript} = 1;
$jsscript = "";
if ($form->{jsscript}) {
@@ -235,7 +263,7 @@ sub search {
$button1 = qq|
text('button') . qq|> |
+ . $locale->text('button') . qq|>
|;
$button2 = qq|
@@ -263,7 +291,7 @@ sub search {
print qq|
-
+ $report->add_data($row);
-
-
-|;
- $lxdebug->leave_sub();
+ my $raw_bottom_info_text;
-}
-
-sub gl_subtotal {
- $lxdebug->enter_sub();
-
- $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 = ();
@@ -984,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 {
- $form->{"tax_$i"} = 0;
+ $credittax = 1;
}
+ if ($form->{taxincluded}) {
+ $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
+ } else {
+ $form->{"tax_$i"} = $amount * $rate;
+ }
+ } else {
+ $form->{"tax_$i"} = 0;
}
for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
@@ -1027,6 +758,8 @@ sub display_form {
my ($init) = @_;
$lxdebug->enter_sub();
+ $auth->assert('general_ledger');
+
&form_header($init);
# for $i (1 .. $form->{rowcount}) {
@@ -1045,20 +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"} }) {
@@ -1071,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;
}
@@ -1082,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"});
@@ -1113,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,
@@ -1137,8 +867,6 @@ sub display_rows {
. qq| | |;
if ($init) {
- $korrektur =
- qq||;
if ($form->{transfer}) {
$fx_transaction = qq|
| |
@@ -1173,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|
|
@@ -1204,20 +927,29 @@ sub display_rows {
'-labels' => \%project_labels,
'-default' => $form->{"project_id_$i"} ));
+ my $copy2credit = 'onkeyup="copy_debit_to_credit()"' if $i == 1;
+
print qq|
$accno
+ |
$fx_transaction
- |
+ |
|
- |
- $korrektur
- $tax
+ $form->{"tax_$i"} |
+ $tax|;
+
+ if ($form->{show_details}) {
+ print qq|
$source
$memo
$projectnumber |
+|;
+ }
+ print qq|
+ $source_hidden
+ $memo_hidden
-
- |;
+|;
}
$form->hide_form(qw(rowcount selectaccno));
@@ -1229,18 +961,41 @@ 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')
map { $form->{$_} =~ s/\"/"/g }
qw(reference description chart taxchart);
+
$form->{javascript} = qq||;
+
+
+
+|;
$form->{selectdepartment} =~ s/ selected//;
$form->{selectdepartment} =~
@@ -1290,7 +1053,7 @@ sub form_header {
}
# use JavaScript Calendar or not
- $form->{jsscript} = $jscalendar;
+ $form->{jsscript} = 1;
$jsscript = "";
if ($form->{jsscript}) {
@@ -1298,7 +1061,7 @@ sub form_header {
$button1 = qq|
text('button') . qq|> |
+ . $locale->text('button') . qq|>
|;
#write Trigger
@@ -1311,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|
-
+
-