use SL::Webdav;
use SL::Locale::String qw(t8);
use SL::Helper::GlAttachments qw(count_gl_attachments);
-
require "bin/mozilla/common.pl";
require "bin/mozilla/reportgenerator.pl";
die "invalid template type" unless $template->template_type eq 'gl_transaction';
$template->substitute_variables;
+ my $payment_suggestion = $::form->{form_defaults}->{amount_1};
# Clean the current $::form before rebuilding it from the template.
my $form_defaults = delete $::form->{form_defaults};
$::form->{"accno_id_${row}"} = $item->chart_id;
$::form->{"previous_accno_id_${row}"} = $item->chart_id;
- $::form->{"debit_${row}"} = $::form->format_amount(\%::myconfig, $item->amount1, 2) if $item->amount1 * 1;
- $::form->{"credit_${row}"} = $::form->format_amount(\%::myconfig, $item->amount2, 2) if $item->amount2 * 1;
+ $::form->{"debit_${row}"} = $::form->format_amount(\%::myconfig, ($payment_suggestion ? $payment_suggestion : $item->amount1), 2) if $item->amount1 * 1;
+ $::form->{"credit_${row}"} = $::form->format_amount(\%::myconfig, ($payment_suggestion ? $payment_suggestion : $item->amount2), 2) if $item->amount2 * 1;
$::form->{"taxchart_${row}"} = $item->tax_id . '--' . $tax->rate;
$::form->{"${_}_${row}"} = $item->$_ for qw(source memo project_id);
}
type => 'general_ledger',
number => $form->{id},
);
- my $webdav_path = $webdav->webdav_path;
my @all_objects = $webdav->get_all_objects;
@{ $form->{WEBDAV} } = map { { name => $_->filename,
type => t8('File'),
my $ml = ($form->{ml} =~ /(A|E|Q)/) ? -1 : 1;
my @columns = qw(
- gldate transdate id reference description
+ transdate gldate id reference description
notes source doccnt debit debit_accno
credit credit_accno debit_tax debit_tax_accno
credit_tax credit_tax_accno projectnumbers balance employee
);
# 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 description notes project_id datefrom dateto employee_id datesort category l_subtotal);
+ my @hidden_variables = qw(accno source reference description notes project_id datefrom dateto employee_id datesort category l_subtotal department_id);
push @hidden_variables, map { "l_${_}" } @columns;
my $employee = $form->{employee_id} ? SL::DB::Employee->new(id => $form->{employee_id})->load->name : '';
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') . " : $employee" if $employee;
- my $datesorttext = $form->{datesort} eq 'transdate' ? $locale->text('Invoice Date') : $locale->text('Booking Date');
+ my $datesorttext = $form->{datesort} eq 'transdate' ? $locale->text('Transdate') : $locale->text('Gldate');
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});
push @date_options, $locale->text('Bis'), $locale->date(\%myconfig, $form->{dateto}, 1) if ($form->{dateto});
my %column_defs = (
'id' => { 'text' => $locale->text('ID'), },
- 'transdate' => { 'text' => $locale->text('Invoice Date'), },
- 'gldate' => { 'text' => $locale->text('Booking Date'), },
+ 'transdate' => { 'text' => $locale->text('Transdate'), },
+ 'gldate' => { 'text' => $locale->text('Gldate'), },
'reference' => { 'text' => $locale->text('Reference'), },
'source' => { 'text' => $locale->text('Source'), },
'doccnt' => { 'text' => $locale->text('Document Count'), },
setup_gl_transactions_action_bar(num_rows => scalar(@{$form->{GL}}));
- $report->generate_with_headers(action_bar => 1);
+ $report->generate_with_headers();
$main::lxdebug->leave_sub();
}
my %taxchart_labels = ();
my @taxchart_values = ();
- my $accno_id = $::form->{"accno_id_$i"};
- my $chart = $charts_by_id{$accno_id} // $default_chart;
- $accno_id = $chart->{id};
- my $chart_has_changed = $::form->{"previous_accno_id_$i"} && ($accno_id != $::form->{"previous_accno_id_$i"});
+ my $accno_id = $::form->{"accno_id_$i"};
+ my $chart = $charts_by_id{$accno_id} // $default_chart;
+ $accno_id = $chart->{id};
my ($first_taxchart, $default_taxchart, $taxchart_to_use);
foreach my $item ( GL->get_active_taxes_for_chart($accno_id, $transdate) ) {
$taxchart_labels{$key} = $item->taxdescription . " " . $item->rate * 100 . ' %';
}
- $taxchart_to_use = $default_taxchart // $first_taxchart if $chart_has_changed || !$taxchart_to_use;
+ $taxchart_to_use //= $default_taxchart // $first_taxchart;
my $selected_taxchart = $taxchart_to_use->id . '--' . $taxchart_to_use->rate;
my $accno = qq|<td>| .
"charts" => { "key" => "ALL_CHARTS",
"transdate" => $::form->{transdate} });
+ # we cannot book on charttype header
+ @{ $::form->{ALL_CHARTS} } = grep { $_->{charttype} ne 'H' } @{ $::form->{ALL_CHARTS} };
$::form->{ALL_DEPARTMENTS} = SL::DB::Manager::Department->get_all;
my $title = $::form->{title};
$form->error($err[$errno]);
}
- undef($form->{callback});
# saving the history
if(!exists $form->{addition} && $form->{id} ne "") {
$form->{snumbers} = qq|gltransaction_| . $form->{id};
}
# /saving the history
+ if ($form->{callback} =~ /BankTransaction/) {
+ print $form->redirect_header($form->{callback});
+ $form->redirect($locale->text('GL transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id});
+ }
+ # remove or clarify
+ undef($form->{callback});
$main::lxdebug->leave_sub();
}
my $locale = $main::locale;
if ($::myconfig{mandatory_departments} && !$form->{department_id}) {
- $form->{saved_message} = $::locale->text('You have to specify a department.');
- update();
- exit;
+ $form->error($locale->text('You have to specify a department.'));
}
$form->{title} = $locale->text("$form->{title} General Ledger Transaction");