$::form->all_departments(\%::myconfig);
$::form->get_lists(
projects => { key => "ALL_PROJECTS", all => 1 },
- employees => "ALL_EMPLOYEES",
);
-
- my $onload = "focus()"
- . qq|;setupDateFormat('|. $::myconfig{dateformat} . qq|', '| . $::locale->text("Falsches Datumsformat!") . qq|')|
- . qq|;setupPoints('|. $::myconfig{numberformat} . qq|', '| . $::locale->text("wrongformat") . qq|')|;
+ $::form->{ALL_EMPLOYEES} = SL::DB::Manager::Employee->get_all(query => [ deleted => 0 ]);
$::form->header;
print $::form->parse_html_template('gl/search', {
- onload => $onload,
department_label => sub { ("$_[0]{description}--$_[0]{id}")x2 },
employee_label => sub { "$_[0]{id}--$_[0]{name}" },
});
my %myconfig = %main::myconfig;
my $locale = $main::locale;
- # generate_report wird beim ersten Aufruf per Weiter-Knopf und POST mit der hidden Variablen sort mit Wert "datesort" (früher "transdate" als Defaultsortiervariable) übertragen
+ # generate_report wird beim ersten Aufruf per Weiter-Knopf und POST mit der hidden Variablen sort mit Wert "datesort" (früher "transdate" als Defaultsortiervariable) übertragen
# <form method=post action=gl.pl>
# <input type=hidden name=sort value=datesort> # form->{sort} setzen
# <input type=hidden name=nextsub value=generate_report>
# anhand von neuer Variable datesort wird jetzt $form->{sort} auf transdate oder gldate gesetzt
- # damit ist die Hidden Variable "sort" wahrscheinlich sogar überflüssig
+ # damit ist die Hidden Variable "sort" wahrscheinlich sogar überflüssig
- # ändert man die Sortierreihenfolge per Klick auf eine der Überschriften wird die Variable "sort" per GET übergeben, z.B. id,transdate, gldate, ...
+ # ändert man die Sortierreihenfolge per Klick auf eine der Überschriften wird die Variable "sort" per GET übergeben, z.B. id,transdate, gldate, ...
# gl.pl?action=generate_report&employee=18383--Jan%20B%c3%bcren&datesort=transdate&category=X&l_transdate=Y&l_gldate=Y&l_id=Y&l_reference=Y&l_description=Y&l_source=Y&l_debit=Y&l_credit=Y&sort=gldate&sortdir=0
if ( $form->{sort} eq 'datesort' ) { # sollte bei einem Post (Aufruf aus Suchmaske) immer wahr sein
);
# add employee here, so that variable is still known and passed in url when choosing a different sort order in resulting table
- my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto employee datesort category l_subtotal);
+ my @hidden_variables = qw(accno source reference department description notes project_id datefrom dateto employee_id datesort category l_subtotal);
push @hidden_variables, map { "l_${_}" } @columns;
foreach ( @hidden_variables ) {
print URL "$_\n";
};
+ my $employee = $form->{employee_id} ? SL::DB::Employee->new(id => $form->{employee_id})->load->name : '';
+
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 @options, $locale->text('Employee') . " : $form->{employee_name}" if ($form->{employee_name});
+ push @options, $locale->text('Employee') . " : $employee" if $employee;
my $datesorttext = $form->{datesort} eq 'transdate' ? $locale->text('Invoice Date') : $locale->text('Booking Date');
push @date_options, "$datesorttext" if ($form->{datesort} and ($form->{datefrom} or $form->{dateto}));
push @date_options, $locale->text('From'), $locale->date(\%myconfig, $form->{datefrom}, 1) if ($form->{datefrom});
my $row_set = [ $row ];
- if (($form->{l_subtotal} eq 'Y')
+ if ( ($form->{l_subtotal} eq 'Y' && !$form->{report_generator_csv_options_for_import} )
&& (($idx == (scalar @{ $form->{GL} } - 1))
|| ($ref->{ $form->{sort} } ne $form->{GL}->[$idx + 1]->{ $form->{sort} }))) {
push @{ $row_set }, create_subtotal_row(\%subtotals, \@columns, \%column_alignment, [ qw(debit credit) ], 'listsubtotal');
$idx++;
}
- $report->add_separator();
-
# = 0 for balanced ledger
my $balanced_ledger = $totals{debit} + $totals{debit_tax} - $totals{credit} - $totals{credit_tax};
$row->{balance}->{data} = $data;
- $report->add_data($row);
+ if ( !$form->{report_generator_csv_options_for_import} ) {
+ $report->add_separator();
+ $report->add_data($row);
+ }
my $raw_bottom_info_text;
my %charts = ();
my $taxchart_init;
foreach my $item (@{ $form->{ALL_CHARTS} }) {
- if ($item->{charttype} eq 'H'){ #falls überschrift
- next; #überspringen (Bug 1150)
+ if ($item->{charttype} eq 'H'){ #falls Ã\83Å\92berschrift
+ next; #Ã\83Å\92berspringen (Bug 1150)
}
my $key = $item->{accno} . "--" . $item->{tax_id};
$taxchart_init = $item->{tax_id} unless (@chart_values);
$charts{$item->{accno}} = $item;
}
- my %taxchart_labels = ();
- my @taxchart_values = ();
- my %taxcharts = ();
- foreach my $item (@{ $form->{ALL_TAXCHARTS} }) {
- my $key = $item->{id} . "--" . $item->{rate};
- $taxchart_init = $key if ($taxchart_init == $item->{id});
- push(@taxchart_values, $key);
- $taxchart_labels{$key} = $item->{taxdescription} . " " . $item->{rate} * 100 . ' %';
- $taxcharts{$item->{id}} = $item;
- }
-
my ($source, $memo, $source_hidden, $memo_hidden);
for my $i (1 .. $form->{rowcount}) {
if ($form->{show_details}) {
my ($selected_accno, $selected_tax_id) = split(/--/, $selected_accno_full);
my ($previous_accno, $previous_tax_id) = split(/--/, $form->{"previous_accno_$i"});
+ my %taxchart_labels = ();
+ my @taxchart_values = ();
+ my %taxcharts = ();
+ my $filter_accno;
+ $filter_accno = $::form->{ALL_CHARTS}[0]->{accno};
+ $filter_accno = $selected_accno if (!$init and $i < $form->{rowcount});
+ foreach my $item ( GL->get_tax_dropdown($filter_accno) ) {
+ my $key = $item->{id} . "--" . $item->{rate};
+ $taxchart_init = $key if ($taxchart_init == $item->{id});
+ push(@taxchart_values, $key);
+ $taxchart_labels{$key} = $item->{taxdescription} . " " . $item->{rate} * 100 . ' %';
+ $taxcharts{$item->{id}} = $item;
+ }
+
if ($previous_accno &&
($previous_accno eq $selected_accno) &&
($previous_tax_id ne $selected_tax_id)) {
my $accno = qq|<td>| .
NTI($cgi->popup_menu('-name' => "accno_$i",
'-id' => "accno_$i",
- '-onChange' => "setTaxkey($i)",
+ '-onChange' => "updateTaxes($i);",
'-style' => 'width:200px',
'-values' => \@chart_values,
'-labels' => \%chart_labels,
. qq|</td>|;
my $tax_ddbox = qq|<td>| .
NTI($cgi->popup_menu('-name' => "taxchart_$i",
- '-id' => "taxchart_$i",
- '-style' => 'width:200px',
- '-values' => \@taxchart_values,
- '-labels' => \%taxchart_labels,
- '-default' => $selected_taxchart))
+ '-id' => "taxchart_$i",
+ '-style' => 'width:200px',
+ '-values' => \@taxchart_values,
+ '-labels' => \%taxchart_labels,
+ '-default' => $selected_taxchart))
. qq|</td>|;
my ($fx_transaction, $checked);
}
+sub _get_radieren {
+ return ($::instance_conf->get_gl_changeable == 2) ? ($::form->current_date(\%::myconfig) eq $::form->{gldate}) : ($::instance_conf->get_gl_changeable == 1);
+}
+
sub form_header {
$::lxdebug->enter_sub;
$::auth->assert('general_ledger');
"all" => 0,
"old_id" => \@old_project_ids },
"charts" => { "key" => "ALL_CHARTS",
- "transdate" => $::form->{transdate} },
- "taxcharts" => "ALL_TAXCHARTS");
+ "transdate" => $::form->{transdate} });
GL->get_chart_balances('charts' => $::form->{ALL_CHARTS});
s/option>\Q$::form->{department}\E/option selected>$::form->{department}/;
if ($init) {
- $::form->{fokus} = "gl.reference";
+ $::request->{layout}->focus("#reference");
$::form->{taxincluded} = "1";
} else {
- $::form->{fokus} = qq|gl.accno_$::form->{rowcount}|;
+ $::request->{layout}->focus("#accno_$::form->{rowcount}");
}
$::form->{previous_id} ||= "--";
$::form->header;
print $::form->parse_html_template('gl/form_header', {
hide_title => $title,
+ readonly => $::form->{id} && ($::form->{locked} || !_get_radieren()),
});
$::lxdebug->leave_sub;
}
sub form_footer {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('general_ledger');
-
- my $form = $main::form;
- my %myconfig = %main::myconfig;
- my $locale = $main::locale;
- my $cgi = $::request->{cgi};
-
- my $follow_ups_block;
- if ($form->{id}) {
- my $follow_ups = FU->follow_ups('trans_id' => $form->{id});
-
- if (@{ $follow_ups} ) {
- my $num_due = sum map { $_->{due} * 1 } @{ $follow_ups };
- $follow_ups_block = qq|<p>| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq|</p>|;
- }
- }
-
- my ($dec) = ($form->{totaldebit} =~ /\.(\d+)/);
- $dec = length $dec;
- my $decimalplaces = ($dec > 2) ? $dec : 2;
- my $radieren = ($form->current_date(\%myconfig) eq $form->{gldate}) ? 1 : 0;
-
- map {
- $form->{$_} = $form->format_amount(\%myconfig, $form->{$_}, 2, " ")
- } qw(totaldebit totalcredit);
-
- print qq|
- <tr class=listtotal>
- <th colspan="3" align=right class=listtotal> $form->{totaldebit}</th>
- <th align=right class=listtotal> $form->{totalcredit}</th>
- <td colspan=6></td>
- </tr>
- </table>
- </td>
- </tr>
-</table>
-
-<input name=callback type=hidden value="$form->{callback}">
-
-$follow_ups_block
-
-<br>
-|;
-
- my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
- my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
-
- if ($form->{id}) {
-
- if (!$form->{storno}) {
- print qq|<input class=submit type=submit name=action value="| . $locale->text('Storno') . qq|">|;
- }
-
- # Löschen und Ändern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
- if (!$form->{locked} && $radieren) {
- print qq|
- <input class=submit type=submit name=action value="| . $locale->text('Post') . qq|" accesskey="b">
- <input class=submit type=submit name=action value="| . $locale->text('Delete') . 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|"> |;
+ $::lxdebug->enter_sub;
+ $::auth->assert('general_ledger');
- } else {
- if ($form->{draft_id}) {
- my $remove_draft_checked = $form->{remove_draft} ? 'checked' : '';
- print qq|<p>\n|
- . qq| <input name="remove_draft" id="remove_draft" type="checkbox" class="checkbox" ${remove_draft_checked}>|
- . qq| <label for="remove_draft">| . $locale->text('Remove Draft') . qq|</label>\n|
- . qq|</p>\n|;
- }
+ my ($follow_ups, $follow_ups_due);
- 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|"> |
- . NTI($cgi->submit('-name' => 'action', '-value' => $locale->text('Save draft'), '-class' => 'submit'))
- . $cgi->hidden('-name' => 'draft_id', '-default' => [$form->{draft_id}])
- . $cgi->hidden('-name' => 'draft_description', '-default' => [$form->{draft_description}]);
+ if ($::form->{id}) {
+ $follow_ups = FU->follow_ups('trans_id' => $::form->{id});
+ $follow_ups_due = sum map { $_->{due} * 1 } @{ $follow_ups || [] };
}
- print "
- </form>
-
-</body>
-</html>
-";
- $main::lxdebug->leave_sub();
+ print $::form->parse_html_template('gl/form_footer', {
+ radieren => _get_radieren(),
+ follow_ups => $follow_ups,
+ follow_ups_due => $follow_ups_due,
+ });
+ $::lxdebug->leave_sub;
}
sub delete {
$form->header;
print qq|
-<body>
-
<form method=post action=gl.pl>
|;
my $debitcredit;
my %split_safety = ();
+ my $dbh = $form->dbconnect_noauto(\%myconfig);
+ my ($notax_id) = selectrow_query($form, $dbh, "SELECT id FROM tax WHERE taxkey = 0 LIMIT 1", );
+ $dbh->disconnect;
+
my @flds = qw(accno debit credit projectnumber fx_transaction source memo tax taxchart);
for my $i (1 .. $form->{rowcount}) {
$form->{debitlock} = 1;
}
if ($debitcredit && $credittax) {
- $form->{"taxchart_$i"} = "0--0.00";
+ $form->{"taxchart_$i"} = "$notax_id--0.00";
}
if (!$debitcredit && $debittax) {
- $form->{"taxchart_$i"} = "0--0.00";
+ $form->{"taxchart_$i"} = "$notax_id--0.00";
}
my $amount = ($form->{"debit_$i"} == 0)
? $form->{"credit_$i"}
: $form->{"debit_$i"};
my $j = $#a;
if (($debitcredit && $credittax) || (!$debitcredit && $debittax)) {
- $form->{"taxchart_$i"} = "0--0.00";
+ $form->{"taxchart_$i"} = "$notax_id--0.00";
$form->{"tax_$i"} = 0;
}
my ($taxkey, $rate) = split(/--/, $form->{"taxchart_$i"});
}
if ($split_safety{-1} > 1 && $split_safety{1} > 1) {
- $::form->error($::locale->text("Split entry detected. The values you have entered will result in an entry with more than one position on both debit and credit. Due to known problems involving accounting software Lx-Office does not allow these."));
+ $::form->error($::locale->text("Split entry detected. The values you have entered will result in an entry with more than one position on both debit and credit. " .
+ "Due to known problems involving accounting software kivitendo does not allow these."));
}
for my $i (1 .. $count) {
$form->{taxincluded} = 0 if !$taxtotal;
# this is just for the wise guys
+
+ $form->error($locale->text('Cannot post transaction above the maximum future booking date!'))
+ if ($form->date_max_future($form->{"transdate"}, \%myconfig));
$form->error($locale->text('Cannot post transaction for a closed period!'))
if ($form->date_closed($form->{"transdate"}, \%myconfig));
if ($form->round_amount($debit, 2) != $form->round_amount($credit, 2)) {
call_sub($main::form->{nextsub});
}
+sub get_tax_dropdown {
+ $main::lxdebug->enter_sub();
+
+ my $form = $main::form;
+ my @tax_accounts = GL->get_tax_dropdown($form->{accno});
+
+ foreach my $item (@tax_accounts) {
+ $item->{taxdescription} = $::locale->{iconv_utf8}->convert($item->{taxdescription});
+ $item->{taxdescription} .= ' ' . $form->round_amount($item->{rate} * 100);
+ }
+
+ $form->{TAX_ACCOUNTS} = [ @tax_accounts ];
+
+ print $form->ajax_response_header, $form->parse_html_template("gl/update_tax_accounts");
+
+ $main::lxdebug->leave_sub();
+
+}
+
1;