-
-
-
- | |
- . $locale->text("Previous transnumber text")
- . " $form->{previous_id} "
- . $locale->text("Previous transdate text")
- . " $form->{previous_gldate}"
- . qq| |
-
-
- | | . $locale->text('Reference') . qq| |
- |
-
-
-
- | | . $locale->text('Date') . qq| |
- $button1
-
-
- |
- |;
+ # dont edit reconcilated bookings!
if ($form->{id}) {
- print qq|
-
- | | . $locale->text('Belegnummer') . qq| |
- |
-
-
- |
- |;
+ my @acc_trans = map { $_->acc_trans_id } @{ SL::DB::Manager::AccTransaction->get_all( where => [ trans_id => $form->{id} ] ) };
+ if (scalar @acc_trans && scalar @{ SL::DB::Manager::ReconciliationLink->get_all(where => [ acc_trans_id => [ @acc_trans ] ]) }) {
+ $is_reconciled_bank_transaction = 1;
+ }
}
- print qq|
- $department|;
- if ($form->{id}) {
- print qq|
-
- | | . $locale->text('Description') . qq| |
- $description |
-
-
- |
-
-
- |
- |;
+ my $create_post_action = sub {
+ # $_[0]: description
+ # $_[1]: after_action
+ action => [
+ $_[0],
+ submit => [ '#form', { action => 'post', after_action => $_[1] } ],
+ disabled => $form->{locked} ? t8('The billing period has already been locked.')
+ : $form->{storno} ? t8('A canceled general ledger transaction cannot be posted.')
+ : ($form->{id} && $change_never) ? t8('Changing general ledger transaction has been disabled in the configuration.')
+ : ($form->{id} && $change_on_same_day_only) ? t8('General ledger transactions can only be changed on the day they are posted.')
+ : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.')
+ : $is_linked_ap_transaction ? t8('This transaction is linked with a AP transaction. Please undo and redo the AP transaction booking if needed.')
+ : $is_reconciled_bank_transaction ? t8('This transaction is reconciled with a bank transaction. Please undo the reconciliation if needed.')
+ : undef,
+ ],
+ };
+
+ my %post_entry;
+ if ($::instance_conf->get_gl_add_doc && $::instance_conf->get_doc_storage) {
+ %post_entry = (combobox => [ $create_post_action->(t8('Post'), 'doc-tab'),
+ $create_post_action->(t8('Post and new booking')) ]);
+ } elsif ($::instance_conf->get_doc_storage) {
+ %post_entry = (combobox => [ $create_post_action->(t8('Post')),
+ $create_post_action->(t8('Post and upload document'), 'doc-tab') ]);
} else {
- print qq|
-
- | | . $locale->text('Description') . qq| |
- $description |
-
-
- |
- |;
+ %post_entry = $create_post_action->(t8('Post'));
}
- print qq|
-
- |
-
- | | . $locale->text('Show details') . qq| |
- |
- |;
-
- print qq|
-
-
-
-
- | |
- . $locale->text('Account') . qq| |
- | . $locale->text('Chart balance') . qq| |
- |
- . $locale->text('Debit') . qq| |
- |
- . $locale->text('Credit') . qq| |
- |
- . $locale->text('Tax') . qq| |
- |
- . $locale->text('Taxkey') . qq| | |;
-
- if ($form->{show_details}) {
- print qq|
- | . $locale->text('Source') . qq| |
- | . $locale->text('Memo') . qq| |
- | . $locale->text('Project Number') . qq| |
-|;
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Update'),
+ submit => [ '#form', { action => 'update' } ],
+ id => 'update_button',
+ accesskey => 'enter',
+ ],
+ %post_entry,
+ combobox => [
+ action => [ t8('Storno'),
+ submit => [ '#form', { action => 'storno' } ],
+ confirm => t8('Do you really want to cancel this general ledger transaction?'),
+ disabled => !$form->{id} ? t8('This general ledger transaction has not been posted yet.')
+ : $form->{storno} ? t8('A canceled general ledger transaction cannot be canceled again.')
+ : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.')
+ : $is_linked_ap_transaction ? t8('This transaction is linked with a AP transaction. Please undo and redo the AP transaction booking if needed.')
+ : $is_reconciled_bank_transaction ? t8('This transaction is reconciled with a bank transaction. Please undo the reconciliation if needed.')
+ : undef,
+ ],
+ action => [ t8('Delete'),
+ submit => [ '#form', { action => 'delete' } ],
+ confirm => t8('Do you really want to delete this object?'),
+ disabled => !$form->{id} ? t8('This invoice has not been posted yet.')
+ : $form->{locked} ? t8('The billing period has already been locked.')
+ : $change_never ? t8('Changing invoices has been disabled in the configuration.')
+ : $change_on_same_day_only ? t8('Invoices can only be changed on the day they are posted.')
+ : $is_linked_bank_transaction ? t8('This transaction is linked with a bank transaction. Please undo and redo the bank transaction booking if needed.')
+ : $is_linked_ap_transaction ? t8('This transaction is linked with a AP transaction. Please undo and redo the AP transaction booking if needed.')
+ : $is_reconciled_bank_transaction ? t8('This transaction is reconciled with a bank transaction. Please undo the reconciliation if needed.')
+ : $form->{storno} ? t8('A canceled general ledger transaction cannot be deleted.')
+ : undef,
+ ],
+ ], # end of combobox "Storno"
+
+ combobox => [
+ action => [ t8('more') ],
+ action => [
+ t8('History'),
+ call => [ 'set_history_window', $form->{id} * 1, 'glid' ],
+ disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ action => [
+ t8('Follow-Up'),
+ call => [ 'follow_up_window' ],
+ disabled => !$form->{id} ? t8('This invoice has not been posted yet.') : undef,
+ ],
+ action => [
+ t8('Record templates'),
+ call => [ 'kivi.RecordTemplate.popup', 'gl_transaction' ],
+ ],
+ action => [
+ t8('Drafts'),
+ call => [ 'kivi.Draft.popup', 'gl', 'unknown', $form->{draft_id}, $form->{draft_description} ],
+ disabled => $form->{id} ? t8('This invoice has already been posted.')
+ : $form->{locked} ? t8('The billing period has already been locked.')
+ : undef,
+ ],
+ ], # end of combobox "more"
+ );
}
-
- print qq|
-
-
-$jsscript
-|;
- $main::lxdebug->leave_sub();
-
}
-sub form_footer {
- $main::lxdebug->enter_sub();
-
- $main::auth->assert('general_ledger');
+sub setup_gl_search_action_bar {
+ my %params = @_;
- 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|| . $locale->text("There are #1 unfinished follow-ups of which #2 are due.", scalar @{ $follow_ups }, $num_due) . qq| |;
- }
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ action => [
+ t8('Search'),
+ submit => [ '#form', { action => 'continue', nextsub => 'generate_report' } ],
+ accesskey => 'enter',
+ ],
+ );
}
+}
- 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|
-
- | $form->{totaldebit} |
- $form->{totalcredit} |
- |
-
-
- |
-
-
+sub setup_gl_transactions_action_bar {
+ my %params = @_;
+
+ for my $bar ($::request->layout->get('actionbar')) {
+ $bar->add(
+ combobox => [
+ action => [ $::locale->text('Create new') ],
+ action => [
+ $::locale->text('GL Transaction'),
+ submit => [ '#create_new_form', { action => 'gl_transaction' } ],
+ ],
+ action => [
+ $::locale->text('AR Transaction'),
+ submit => [ '#create_new_form', { action => 'ar_transaction' } ],
+ ],
+ action => [
+ $::locale->text('AP Transaction'),
+ submit => [ '#create_new_form', { action => 'ap_transaction' } ],
+ ],
+ action => [
+ $::locale->text('Sales Invoice'),
+ submit => [ '#create_new_form', { action => 'sales_invoice' } ],
+ ],
+ action => [
+ $::locale->text('Vendor Invoice'),
+ submit => [ '#create_new_form', { action => 'vendor_invoice' } ],
+ ],
+ ], # end of combobox "Create new"
+ );
+ }
+}
-
+sub form_header {
+ $::lxdebug->enter_sub;
+ $::auth->assert('gl_transactions');
-$follow_ups_block
+ my ($init) = @_;
-
-|;
+ $::request->layout->add_javascripts("autocomplete_chart.js", "autocomplete_project.js", "kivi.File.js", "kivi.GL.js", "kivi.RecordTemplate.js", "kivi.Validator.js", "show_history.js");
- my $transdate = $form->datetonum($form->{transdate}, \%myconfig);
- my $closedto = $form->datetonum($form->{closedto}, \%myconfig);
+ my @old_project_ids = grep { $_ } map{ $::form->{"project_id_$_"} } 1..$::form->{rowcount};
+ my @conditions = @old_project_ids ? (id => \@old_project_ids) : ();
+ $::form->{ALL_PROJECTS} = SL::DB::Manager::Project->get_all_sorted(query => [ or => [ active => 1, @conditions ]]);
- if ($form->{id}) {
+ $::form->get_lists(
+ "charts" => { "key" => "ALL_CHARTS", "transdate" => $::form->{transdate} },
+ );
- if (!$form->{storno}) {
- print qq||;
- }
+ # 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_sorted;
- # Löschen und Ãndern von Buchungen nicht mehr möglich (GoB) nur am selben Tag möglich
- if (!$form->{locked} && $radieren) {
- print qq|
-
- |;
- }
+ my $title = $::form->{title};
+ $::form->{title} = $::locale->text("$title General Ledger Transaction");
+ # $locale->text('Add General Ledger Transaction')
+ # $locale->text('Edit General Ledger Transaction')
- print qq|
-
- |;
+ map { $::form->{$_} =~ s/\"/"/g }
+ qw(chart taxchart);
+ if ($init) {
+ $::request->{layout}->focus("#reference");
+ $::form->{taxincluded} = "1";
} else {
- if ($form->{draft_id}) {
- my $remove_draft_checked = $form->{remove_draft} ? 'checked' : '';
- print qq|\n|
- . qq| |
- . qq| \n|
- . qq| \n|;
- }
-
- print 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}]);
+ $::request->{layout}->focus("#accno_id_$::form->{rowcount}_name");
}
- print "
-
+ $::form->{previous_id} ||= "--";
+ $::form->{previous_gldate} ||= "--";
-
- |