epic-ts
[kivitendo-erp.git] / bin / mozilla / gl.pl
index a4ee01d..026cf6a 100644 (file)
@@ -306,9 +306,6 @@ sub generate_report {
   # 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_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 : '';
 
@@ -332,8 +329,6 @@ sub generate_report {
 
 
   my $callback = build_std_url('action=generate_report', grep { $form->{$_} } @hidden_variables);
-  print URL $callback;
-  close URL;
 
   $form->{l_credit_accno}     = 'Y';
   $form->{l_debit_accno}      = 'Y';
@@ -594,14 +589,9 @@ sub update {
         } else {
           $credittax = 1;
         }
-        if ($form->{taxincluded}) {
-          $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
-        } else {
-          $form->{"tax_$i"} = $amount * $rate;
-        }
-      } else {
-        $form->{"tax_$i"} = 0;
-      }
+      };
+      my ($tmpnetamount,$tmpdiff);
+      ($tmpnetamount,$form->{"tax_$i"},$tmpdiff) = $form->calculate_tax($amount,$rate,$form->{taxincluded} *= 1,2);
 
       for (@flds) { $a[$j]->{$_} = $form->{"${_}_$i"} }
       $count++;
@@ -967,8 +957,9 @@ sub yes {
   if (GL->delete_transaction(\%myconfig, \%$form)){
     # saving the history
       if(!exists $form->{addition} && $form->{id} ne "") {
-        $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
+        $form->{snumbers} = qq|gltransaction_| . $form->{id};
         $form->{addition} = "DELETED";
+        $form->{what_done} = "gl_transaction";
         $form->save_history;
       }
     # /saving the history
@@ -1067,16 +1058,15 @@ sub post_transaction {
       } else {
         $credittax = 1;
       }
-      if ($form->{taxincluded}) {
-        $form->{"tax_$i"} = $amount / ($rate + 1) * $rate;
-        if ($debitcredit) {
-          $form->{"debit_$i"} = $form->{"debit_$i"} - $form->{"tax_$i"};
-        } else {
-          $form->{"credit_$i"} = $form->{"credit_$i"} - $form->{"tax_$i"};
-        }
+
+      my ($tmpnetamount,$tmpdiff);
+      ($tmpnetamount,$form->{"tax_$i"},$tmpdiff) = $form->calculate_tax($amount,$rate,$form->{taxincluded} *= 1,2);
+      if ($debitcredit) {
+        $form->{"debit_$i"} = $tmpnetamount;
       } else {
-        $form->{"tax_$i"} = $amount * $rate;
+        $form->{"credit_$i"} = $tmpnetamount;
       }
+
     } else {
       $form->{"tax_$i"} = 0;
     }
@@ -1140,9 +1130,9 @@ sub post_transaction {
   undef($form->{callback});
   # saving the history
   if(!exists $form->{addition} && $form->{id} ne "") {
-    $form->{snumbers} = qq|ordnumber_| . $form->{ordnumber};
-    $form->{addition} = "SAVED";
-    $form->{what_done} = $locale->text("Buchungsnummer") . " = " . $form->{id};
+    $form->{snumbers} = qq|gltransaction_| . $form->{id};
+    $form->{addition} = "POSTED";
+    $form->{what_done} = "gl transaction";
     $form->save_history;
   }
   # /saving the history
@@ -1209,8 +1199,9 @@ sub storno {
 
   # saving the history
   if(!exists $form->{addition} && $form->{id} ne "") {
-    $form->{snumbers} = "ordnumber_$form->{ordnumber}";
+    $form->{snumbers} = qq|gltransaction_| . $form->{id};
     $form->{addition} = "STORNO";
+    $form->{what_done} = "gl_transaction";
     $form->save_history;
   }
   # /saving the history