$auth->assert('general_ledger');
- $form->{sort} ||= "transdate";
+ report_generator_set_default_sort('transdate', 1);
GL->all_transactions(\%myconfig, \%$form);
my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto category l_subtotal);
push @hidden_variables, map { "l_${_}" } @columns;
- my (@options, $date_option);
- if ($form->{accno}) {
- push @options, $locale->text('Account') . " : $form->{accno} $form->{account_description}";
- }
- if ($form->{source}) {
- push @options, $locale->text('Source') . " : $form->{source}";
- }
- if ($form->{reference}) {
- push @options, $locale->text('Reference') . " : $form->{reference}";
- }
+ my (@options, @date_options);
+ push @options, $locale->text('Account') . " : $form->{accno} $form->{account_description}" if ($form->{accno});
+ push @options, $locale->text('Source') . " : $form->{source}" if ($form->{source});
+ push @options, $locale->text('Reference') . " : $form->{reference}" if ($form->{reference});
+ push @options, $locale->text('Description') . " : $form->{description}" if ($form->{description});
+ push @options, $locale->text('Notes') . " : $form->{notes}" if ($form->{notes});
+
+ push @date_options, $locale->text('From'), $locale->date(\%myconfig, $form->{datefrom}, 1) if ($form->{datefrom});
+ push @date_options, $locale->text('Bis'), $locale->date(\%myconfig, $form->{dateto}, 1) if ($form->{dateto});
+ push @options, join(' ', @date_options) if (scalar @date_options);
+
if ($form->{department}) {
my ($department) = split /--/, $form->{department};
push @options, $locale->text('Department') . " : $department";
}
- if ($form->{description}) {
- push @options, $locale->text('Description') . " : $form->{description}";
- }
- if ($form->{notes}) {
- push @options, $locale->text('Notes') . " : $form->{notes}";
- }
- if ($form->{datefrom}) {
- $date_option = $locale->text('From') . " " . $locale->date(\%myconfig, $form->{datefrom}, 1);
- }
- if ($form->{dateto}) {
- if ($form->{datefrom}) {
- $date_option .= " ";
- }
- $date_option .= $locale->text('Bis') . " " . $locale->date(\%myconfig, $form->{dateto}, 1);
- }
- push @options, $date_option if $date_option;
- my $callback = build_std_url('action=generate_report', @hidden_variables);
+
+ my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
$form->{l_credit_accno} = 'Y';
$form->{l_debit_accno} = 'Y';
'projectnumbers' => { 'text' => $locale->text('Project Numbers'), },
);
- map { $column_defs{$_}->{link} = $callback . "&sort=${_}" } qw(id transdate reference source description);
- map { $column_defs{$_}->{link} = $callback . "&sort=accno" } qw(debit_accno credit_accno debit_tax_accno credit_tax_accno debit_tax credit_tax);
+ foreach my $name (qw(id transdate reference source description debit_accno credit_accno debit_tax_accno credit_tax_accno)) {
+ my $sortname = $name =~ m/accno/ ? 'accno' : $name;
+ my $sortdir = $sortname eq $name ? 1 - $form->{sortdir} : $form->{sortdir};
+ $column_defs{$name}->{link} = $callback . "&sort=$sortname&sortdir=$sortdir";
+ }
+
map { $column_defs{$_}->{visible} = $form->{"l_${_}"} ? 1 : 0 } @columns;
map { $column_defs{$_}->{visible} = 0 } qw(debit_accno credit_accno debit_tax_accno credit_tax_accno) if $form->{accno};
my %column_alignment;
- map { $column_alignment{$_} = 'right' } qw(balance id debit credit debit_tax credit_tax);
- map { $column_alignment{$_} = 'center' } qw(transdate reference description source notes debit_accno credit_accno debit_tax_accno credit_tax_accno);
+ map { $column_alignment{$_} = 'right' } qw(balance id debit credit debit_tax credit_tax);
+ map { $column_alignment{$_} = 'center' } qw(transdate reference description source notes debit_accno credit_accno debit_tax_accno credit_tax_accno);
+ map { $column_defs{$_}->{align} = $column_alignment{$_} } keys %column_alignment;
my $report = SL::ReportGenerator->new(\%myconfig, $form);
$report->set_export_options('generate_report', @hidden_variables);
- $report->set_sort_indicator($form->{sort}, 1);
+ $report->set_sort_indicator($form->{sort} eq 'accno' ? 'debit_accno' : $form->{sort}, $form->{sortdir});
$report->set_options('top_info_text' => join("\n", @options),
'output_format' => 'HTML',
$report->set_options_from_form();
# add sort to callback
- $form->{callback} = "$callback&sort=" . E($form->{sort});
+ $form->{callback} = "$callback&sort=" . E($form->{sort}) . "&sortdir=" . E($form->{sortdir});
$form->{balance} *= $ml;
$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"} }
my %charts = ();
my $taxchart_init;
foreach my $item (@{ $form->{ALL_CHARTS} }) {
- my $key = Q($item->{accno}) . "--" . Q($item->{tax_id});
+ my $key = $item->{accno} . "--" . $item->{tax_id};
$taxchart_init = $item->{taxkey_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;
}
my @taxchart_values = ();
my %taxcharts = ();
foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
- my $key = Q($item->{id}) . "--" . Q($item->{rate});
+ my $key = $item->{id} . "--" . $item->{rate};
$taxchart_init = $key if ($taxchart_init eq $item->{taxkey});
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;
}
<td><input name="source_$i" value="$form->{"source_$i"}" size="16"></td>|;
$memo = qq|
<td><input name="memo_$i" value="$form->{"memo_$i"}" size="16"></td>|;
+ $source_hidden = qq|
+ <input type="hidden" name="source_$i" value="$form->{"source_$i"}" size="16">|;
+ $memo_hidden = qq|
+ <input type="hidden" name="memo_$i" value="$form->{"memo_$i"}" size="16">|;
my $selected_accno_full;
my ($accno_row) = split(/--/, $form->{"accno_$i"});
. qq|</td>|;
if ($init) {
- $korrektur =
- qq|<td><input type="checkbox" name="korrektur_$i" value="1"></td>|;
if ($form->{transfer}) {
$fx_transaction = qq|
<td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
<td><input type=hidden name="fx_transaction_$i" value="$checked">$x</td>
|;
}
- $checked = ($form->{"korrektur_$i"}) ? "checked" : "";
- $korrektur =
- qq|<td><input type="checkbox" name="korrektur_$i" value="1" $checked></td>|;
$form->hide_form("accno_$i");
} else {
- $korrektur =
- qq|<td><input type="checkbox" name="korrektur_$i" value="1"></td>|;
if ($form->{transfer}) {
$fx_transaction = qq|
<td><input name="fx_transaction_$i" class=checkbox type=checkbox value=1></td>
$fx_transaction
<td><input name="debit_$i" size="8" value="$form->{"debit_$i"}" accesskey=$i $copy2credit $debitreadonly></td>
<td><input name="credit_$i" size=8 value="$form->{"credit_$i"}" $creditreadonly></td>
- <td><input name="tax_$i" size=6 value="$form->{"tax_$i"}"></td>
- $korrektur
+ <td><input type="hidden" name="tax_$i" value="$form->{"tax_$i"}">$form->{"tax_$i"}</td>
$tax|;
if ($form->{show_details}) {
|;
}
print qq|
+ $source_hidden
+ $memo_hidden
</tr>
|;
}
$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')
$form->header;
print qq|
-<body onLoad="fokus()">
+<body onLoad="focus()">
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript" src="js/follow_up.js"></script>
</tr>|;
}
- print qq|<tr>
+ print qq|
+ <tr>
+ <tr><td colspan=4><table><tr>
+ <td>
+ | . $locale->text('OB Transaction') . qq|<input type="checkbox" name="ob_transaction" value="1" $ob_transaction_checked>
+ </td>
+ <td>
+ | . $locale->text('CB Transaction') . qq|<input type="checkbox" name="cb_transaction" value="1" $cb_transaction_checked>
+ </td>
+ </tr></table></td></tr>
+ <tr>
<td width="1%" align="right" nowrap>| . $locale->text('Show details') . qq|</td>
<td width="1%"><input type="checkbox" onclick="show_form_details();" name="show_details" value="1" $show_details_checked></td>
</tr>|;
<th class=listheading style="width:10%">|
. $locale->text('Tax') . qq|</th>
<th class=listheading style="width:5%">|
- . $locale->text('Korrektur') . qq|</th>
- <th class=listheading style="width:10%">|
. $locale->text('Taxkey') . qq|</th>|;
if ($form->{show_details}) {
<input class=submit type=submit name=action value="| . $locale->text('Delete') . qq|">|;
}
- print qq|
+ print qq|
+ <input class=submit type=submit name=action id=update_button value="| . $locale->text('Update') . qq|">
<input type="button" class="submit" onclick="follow_up_window()" value="|
. $locale->text('Follow-Up')
. qq|"> |;
} else {
- if ($transdate > $closedto) {
print qq|
<input class=submit type=submit name=action id=update_button value="| . $locale->text('Update') . qq|">
<input class=submit type=submit name=action value="| . $locale->text('Post') . qq|">|;
- }
}
print "
$form->{"taxchart_$i"} = "0--0.00";
$form->{"tax_$i"} = 0;
}
- if (!$form->{"korrektur_$i"}) {
- ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
- if ($taxkey > 1) {
+ ($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;
if ($debitcredit) {
- $debittax = 1;
- } else {
- $credittax = 1;
- }
- if ($form->{taxincluded}) {
- $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
- if ($debitcredit) {
- $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
- } else {
- $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
- }
+ $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
} else {
- $form->{"tax_$i"} = $amount * $rate;
+ $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
}
} else {
- $form->{"tax_$i"} = 0;
- }
- } elsif ($form->{taxincluded}) {
- if ($debitcredit) {
- $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
- } else {
- $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
+ $form->{"tax_$i"} = $amount * $rate;
}
+ } else {
+ $form->{"tax_$i"} = 0;
}
for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
# this is just for the wise guys
$form->error($locale->text('Cannot post transaction for a closed period!'))
- if ($transdate <= $closedto);
+ if ($form->date_closed($form->{"transdate"}, \%myconfig));
if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
$form->error($locale->text('Out of balance transaction!'));
}