Testfall: Erzeugnis fertigen aufm Mond, aber Einzelteile im Lager Erde
[kivitendo-erp.git] / bin / mozilla / gl.pl
index 16aaf77..dbaddc5 100644 (file)
@@ -158,9 +158,15 @@ sub save_record_template {
   my $template = $::form->{record_template_id} ? SL::DB::RecordTemplate->new(id => $::form->{record_template_id})->load : SL::DB::RecordTemplate->new;
   my $js       = SL::ClientJS->new(controller => SL::Controller::Base->new);
   my $new_name = $template->template_name_to_use($::form->{record_template_new_template_name});
-
   $js->dialog->close('#record_template_dialog');
 
+
+  # bank transactions need amounts for assignment
+  my $can_save = 0;
+  $can_save    = 1 if ($::form->{credit_1} > 0 && $::form->{debit_2} > 0 && $::form->{credit_2} == 0 && $::form->{debit_1} == 0);
+  $can_save    = 1 if ($::form->{credit_2} > 0 && $::form->{debit_1} > 0 && $::form->{credit_1} == 0 && $::form->{debit_2} == 0);
+  return $js->flash('error', t8('Can only save template if amounts,i.e. 1 for debit and credit are set.'))->render unless $can_save;
+
   my @items = grep {
     $_->{chart_id} && (($_->{tax_id} // '') ne '')
   } map {
@@ -1395,6 +1401,10 @@ sub post_transaction {
   if ($form->{callback} =~ /BankTransaction/ && $form->{bt_id}) {
     print $form->redirect_header($form->{callback});
     $form->redirect($locale->text('GL transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id});
+  } elsif ($::instance_conf->get_gl_add_doc && $::instance_conf->get_doc_storage) {
+    my $add_doc_url = build_std_url("script=gl.pl", 'action=edit', 'id=' . E($form->{id}));
+    print $form->redirect_header($add_doc_url);
+    $form->redirect($locale->text('GL transaction posted.') . ' ' . $locale->text('ID') . ': ' . $form->{id});
   }
 
   # remove or clarify