]> wagnertech.de Git - mfinanz.git/blobdiff - bin/mozilla/gl.pl
Übersetzungen: Aktualisierung
[mfinanz.git] / bin / mozilla / gl.pl
index 8623153209d80129bc93a75e3b890eaac1744ce4..6dfa457cd81e5f7a495a6f113628406ed4e8eba6 100644 (file)
@@ -49,7 +49,6 @@ use SL::DBUtils qw(selectrow_query selectall_hashref_query);
 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";
 
@@ -94,6 +93,7 @@ sub load_record_template {
   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};
@@ -133,8 +133,8 @@ sub load_record_template {
 
     $::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);
   }
@@ -1082,6 +1082,8 @@ sub form_header {
                    "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};
@@ -1315,7 +1317,6 @@ sub post_transaction {
 
     $form->error($err[$errno]);
   }
-  undef($form->{callback});
   # saving the history
   if(!exists $form->{addition} && $form->{id} ne "") {
     $form->{snumbers} = qq|gltransaction_| . $form->{id};
@@ -1325,6 +1326,12 @@ sub post_transaction {
   }
   # /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();
 }
 
@@ -1337,9 +1344,7 @@ sub post {
   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");