Locale: eq-overload für t8 Objekte
[kivitendo-erp.git] / SL / IR.pm
index 7a7f57c..8bd2f5f 100644 (file)
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -369,6 +369,12 @@ sub post_invoice {
 
     next if $payments_only;
 
+    CVar->get_non_editable_ic_cvars(form               => $form,
+                                    dbh                => $dbh,
+                                    row                => $i,
+                                    sub_module         => 'invoice',
+                                    may_converted_from => ['delivery_order_items', 'orderitems', 'invoice']);
+
     if (!$form->{"invoice_id_$i"}) {
       # there is no persistent id, therefore create one with all necessary constraints
       my $q_invoice_id = qq|SELECT nextval('invoiceid')|;
@@ -410,9 +416,10 @@ SQL
                                 name_prefix  => 'ic_',
                                 name_postfix => "_$i",
                                 dbh          => $dbh);
+
     # link previous items with invoice items See IS.pm (no credit note -> no invoice item)
     foreach (qw(delivery_order_items orderitems)) {
-      if ($form->{"converted_from_${_}_id_$i"}) {
+      if (!$form->{useasnew} && $form->{"converted_from_${_}_id_$i"}) {
         RecordLinks->create_links('dbh'        => $dbh,
                                   'mode'       => 'ids',
                                   'from_table' => $_,
@@ -420,8 +427,8 @@ SQL
                                   'to_table'   => 'invoice',
                                   'to_id'      => $form->{"invoice_id_$i"},
         );
-        delete $form->{"converted_from_${_}_id_$i"};
       }
+      delete $form->{"converted_from_${_}_id_$i"};
     }
   }
 
@@ -715,7 +722,7 @@ SQL
                 $form->{invnumber},          $form->{ordnumber},           $form->{quonumber},      conv_date($form->{invdate}),
       conv_date($form->{orddate}), conv_date($form->{quodate}),     conv_i($form->{vendor_id}),               $amount,
                 $netamount,                  $form->{paid},      conv_date($form->{duedate}),
-            '1',                             $taxzone_id,                  $form->{notes},          $form->{taxincluded} ? 't' : 'f',
+            '1',                             $taxzone_id, $restricter->process($form->{notes}),               $form->{taxincluded} ? 't' : 'f',
                 $form->{intnotes},           conv_i($form->{storno_id}),     $form->{storno}      ? 't' : 'f',
          conv_i($form->{cp_id}),      conv_i($form->{employee_id}), conv_i($form->{department_id}), conv_i($form->{delivery_term_id}),
          conv_i($form->{globalproject_id}),
@@ -800,8 +807,6 @@ SQL
       exporttype => DATEV_ET_BUCHUNGEN,
       format     => DATEV_FORMAT_KNE,
       dbh        => $dbh,
-      from       => $transdate,
-      to         => $transdate,
       trans_id   => $form->{id},
     );
 
@@ -1128,7 +1133,7 @@ sub get_vendor {
          v.email, v.cc, v.bcc, v.language_id, v.payment_id, v.delivery_term_id,
          v.street, v.zipcode, v.city, v.country, v.taxzone_id, cu.name AS curr, v.direct_debit,
          $duedate + COALESCE(pt.terms_netto, 0) AS duedate,
-         b.description AS business
+         b.discount AS tradediscount, b.description AS business
        FROM vendor v
        LEFT JOIN business b       ON (b.id = v.business_id)
        LEFT JOIN payment_terms pt ON (v.payment_id = pt.id)
@@ -1640,5 +1645,4 @@ sub get_duedate {
   return $duedate;
 }
 
-
 1;