Aufräumarbeiten verknüpfte Positionen
authorJan Büren <jan@kivitendo-premium.de>
Mon, 26 Jan 2015 13:08:31 +0000 (14:08 +0100)
committerJan Büren <jan@kivitendo-premium.de>
Mon, 26 Jan 2015 13:08:31 +0000 (14:08 +0100)
  - converted_from_quotation_orderitems_id entfernt, da es keine
    tabelle quotation_orderitems gibt und die variable langfristig nur
    verwirrend in der form ist.
  - IR.pm auch auf foreach $table_name umgestellt

SL/IR.pm
SL/OE.pm
bin/mozilla/io.pl
bin/mozilla/oe.pl

index 0dd0ee8..083c342 100644 (file)
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -407,27 +407,18 @@ SQL
                                 name_prefix  => 'ic_',
                                 name_postfix => "_$i",
                                 dbh          => $dbh);
-    # link oe items with invoice
-    if ($form->{"converted_from_orderitems_id_$i"}) {
-      RecordLinks->create_links('dbh'        => $dbh,
-                                'mode'       => 'ids',
-                                'from_table' => 'orderitems',
-                                'from_ids'   => $form->{"converted_from_orderitems_id_$i"},
-                                'to_table'   => 'invoice',
-                                'to_id'      => $form->{"invoice_id_$i"},
-      );
-      delete $form->{"converted_from_orderitems_id_$i"};
-    }
-    # link doi items with invoice
-    if ($form->{"converted_from_delivery_order_items_id_$i"}) {
-      RecordLinks->create_links('dbh'        => $dbh,
-                                'mode'       => 'ids',
-                                'from_table' => 'delivery_order_items',
-                                'from_ids'   => $form->{"converted_from_delivery_order_items_id_$i"},
-                                'to_table'   => 'invoice',
-                                'to_id'      => $form->{"invoice_id_$i"},
-      );
-      delete $form->{"converted_from_delivery_order_items_id_$i"};
+    # 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"}) {
+        RecordLinks->create_links('dbh'        => $dbh,
+                                  'mode'       => 'ids',
+                                  'from_table' => $_,
+                                  'from_ids'   => $form->{"converted_from_${_}_id_$i"},
+                                  'to_table'   => 'invoice',
+                                  'to_id'      => $form->{"invoice_id_$i"},
+        );
+        delete $form->{"converted_from_${_}_id_$i"};
+      }
     }
   }
 
index 3dd91bb..5e2551b 100644 (file)
--- a/SL/OE.pm
+++ b/SL/OE.pm
@@ -579,13 +579,11 @@ SQL
                                   name_postfix => "_$i",
                                   dbh          => $dbh);
       # link previous items with orderitems
-      foreach (qw(quotation_orderitems orderitems invoice)) {
+      foreach (qw(orderitems invoice)) {
         if ($form->{"converted_from_${_}_id_$i"}) {
-          my $table = $_;
-          $table    = 'orderitems' if $table eq 'quotation_orderitems';
           RecordLinks->create_links('dbh'        => $dbh,
                                     'mode'       => 'ids',
-                                    'from_table' => $table,
+                                    'from_table' => $_,
                                     'from_ids'   => $form->{"converted_from_${_}_id_$i"},
                                     'to_table'   => 'orderitems',
                                     'to_id'      => $orderitems_id,
index 3840cba..e411fb5 100644 (file)
@@ -439,7 +439,7 @@ sub display_row {
       push @hidden_vars, qw(orderitems_id converted_from_orderitems_id);
     }
     if ($is_s_p_order) {
-      push @hidden_vars, qw(orderitems_id converted_from_quotation_orderitems_id converted_from_invoice_id);
+      push @hidden_vars, qw(orderitems_id converted_from_orderitems_id converted_from_invoice_id);
     }
     if ($is_invoice) {
       push @hidden_vars, qw(invoice_id converted_from_orderitems_id converted_from_delivery_order_items_id);
@@ -742,9 +742,8 @@ sub remove_emptied_rows {
                 marge_price_factor lastcost price_factor_id partnotes
                 stock_out stock_in has_sernumber reqdate orderitems_id
                 active_price_source active_discount_source delivery_order_items_id
-                invoice_id converted_from_quotation_orderitems_id
-                converted_from_orderitems_id converted_from_delivery_order_items_id
-                converted_from_invoice_id);
+                invoice_id converted_from_orderitems_id
+                converted_from_delivery_order_items_id converted_from_invoice_id);
 
   my $ic_cvar_configs = CVar->get_configs(module => 'IC');
   push @flds, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
index e28ff87..fd12a2d 100644 (file)
@@ -1821,7 +1821,7 @@ sub poso {
   # reset
   map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued customer vendor creditlimit creditremaining discount tradediscount oldinvtotal delivered ordnumber);
   # this converted variable is also used for sales_order to purchase order and vice versa
-  $form->{"converted_from_quotation_orderitems_id_$_"} = delete $form->{"orderitems_id_$_"} for 1 .. $form->{"rowcount"};
+  $form->{"converted_from_orderitems_id_$_"} = delete $form->{"orderitems_id_$_"} for 1 .. $form->{"rowcount"};
 
   # if purchase_order was generated from sales_order, use  lastcost_$i as sellprice_$i
   # also reset discounts