GetModels: Funktion zum Setzen zusätzlicher URL-Parameter
[kivitendo-erp.git] / SL / IR.pm
index b3c99b8..931df6b 100644 (file)
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -42,6 +42,7 @@ use SL::DATEV qw(:CONSTANTS);
 use SL::DBUtils;
 use SL::DO;
 use SL::GenericTranslations;
+use SL::HTML::Restrict;
 use SL::IO;
 use SL::MoreCommon;
 use SL::DB::Default;
@@ -56,6 +57,8 @@ sub post_invoice {
 
   # connect to database, turn off autocommit
   my $dbh = $provided_dbh ? $provided_dbh : $form->dbconnect_noauto($myconfig);
+  my $restricter = SL::HTML::Restrict->create;
+
   $form->{defaultcurrency} = $form->get_default_currency($myconfig);
   my $defaultcurrency = $form->{defaultcurrency};
 
@@ -210,7 +213,7 @@ sub post_invoice {
 
       # update parts table by setting lastcost to current price, don't allow negative values by using abs
       $query = qq|UPDATE parts SET lastcost = ? WHERE id = ?|;
-      @values = (abs($fxsellprice / $basefactor), conv_i($form->{"id_$i"}));
+      @values = (abs($fxsellprice * $form->{exchangerate} / $basefactor), conv_i($form->{"id_$i"}));
       do_query($form, $dbh, $query, @values);
 
       # check if we sold the item already and
@@ -378,7 +381,7 @@ sub post_invoice {
                               project_id, serialnumber, price_factor_id, price_factor, marge_price_factor)
          VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, (SELECT factor FROM price_factors WHERE id = ?), ?)|;
     @values = ($invoice_id, conv_i($form->{id}), conv_i($form->{"id_$i"}),
-               $form->{"description_$i"}, $form->{"longdescription_$i"}, $form->{"qty_$i"} * -1,
+               $form->{"description_$i"}, $restricter->process($form->{"longdescription_$i"}), $form->{"qty_$i"} * -1,
                $baseqty * -1, $form->{"sellprice_$i"}, $fxsellprice, $form->{"discount_$i"}, $allocated,
                $form->{"unit_$i"}, conv_date($form->{deliverydate}),
                conv_i($form->{"project_id_$i"}), $form->{"serialnumber_$i"},
@@ -717,9 +720,10 @@ sub post_invoice {
   }
 
 
-  # add shipto
   $form->{name} = $form->{vendor};
   $form->{name} =~ s/--\Q$form->{vendor_id}\E//;
+
+  # add shipto
   $form->add_shipto($dbh, $form->{id}, "AP");
 
   # delete zero entries
@@ -1123,16 +1127,6 @@ sub get_vendor {
   }
   $sth->finish();
 
-  # get shipto if we do not convert an order or invoice
-  if (!$params->{shipto}) {
-    delete @{$params}{qw(shiptoname shiptostreet shiptozipcode shiptocity shiptocountry shiptocontact shiptophone shiptofax shiptoemail)};
-
-    $query = qq|SELECT * FROM shipto WHERE (trans_id = ?) AND (module= 'CT')|;
-    $ref = selectfirst_hashref_query($form, $dbh, $query, $vid);
-    @{$params}{keys %$ref} = @{$ref}{keys %$ref};
-    map { $params->{$_} = $ref->{$_} } keys %$ref;
-  }
-
   if (!$params->{id} && $params->{type} !~ /_(order|quotation)/) {
     # setup last accounts used
     $query =