Weitere Positionen verknüpft
authorJan Büren <jan@kivitendo-premium.de>
Fri, 23 Jan 2015 13:03:02 +0000 (14:03 +0100)
committerJan Büren <jan@kivitendo-premium.de>
Fri, 23 Jan 2015 13:03:02 +0000 (14:03 +0100)
Alle Workflows von Angebot bis Rechnung im Einkauf und Verkauf umgesetzt

Offen: Gutschrift und Rückwartsverknüpfungen

SL/DO.pm
SL/IR.pm
SL/IS.pm
bin/mozilla/do.pl
bin/mozilla/io.pl
bin/mozilla/oe.pl

index 5309c15..7659ffe 100644 (file)
--- a/SL/DO.pm
+++ b/SL/DO.pm
@@ -404,15 +404,15 @@ SQL
                                 name_postfix => "_$i",
                                 dbh          => $dbh);
     # link order items with doi
-    if ($form->{"converted_from_order_orderitems_id_$i"}) {
+    if ($form->{"converted_from_orderitems_id_$i"}) {
       RecordLinks->create_links('dbh'        => $dbh,
                                 'mode'       => 'ids',
                                 'from_table' => 'orderitems',
-                                'from_ids'   => $form->{"converted_from_order_orderitems_id_$i"},
+                                'from_ids'   => $form->{"converted_from_orderitems_id_$i"},
                                 'to_table'   => 'delivery_order_items',
                                 'to_id'      =>  $form->{"delivery_order_items_id_$i"},
       );
-      delete $form->{"converted_from_order_orderitems_id_$i"};
+      delete $form->{"converted_from_orderitems_id_$i"};
     }
   }
 
index 98dcc86..457c481 100644 (file)
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -407,6 +407,28 @@ 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"};
+    }
   }
 
   $h_item_unit->finish();
index 3603618..e2358ea 100644 (file)
--- a/SL/IS.pm
+++ b/SL/IS.pm
@@ -796,6 +796,28 @@ SQL
                                   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"};
+    }
   }
 
   # total payments, don't move we need it here
index fd46ed7..d4fa816 100644 (file)
@@ -785,6 +785,7 @@ sub invoice {
     }
     map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"} } qw(ship qty sellprice listprice lastcost basefactor);
     $form->{"donumber_$i"} = $form->{donumber};
+    $form->{"converted_from_delivery_order_items_id_$i"} = delete $form->{"delivery_order_items_id_$i"};
   }
 
   $form->{type} = "invoice";
@@ -922,6 +923,7 @@ sub invoice_multi {
     $ref->{reqdate} ||= $ref->{dord_transdate}; # copy transdates into each invoice row
     map { $form->{"${_}_$form->{rowcount}"} = $ref->{$_} } keys %{ $ref };
     map { $form->{"${_}_$form->{rowcount}"} = $form->format_amount(\%myconfig, $ref->{$_}) } qw(qty sellprice lastcost);
+    $form->{"converted_from_delivery_order_items_id_$form->{rowcount}"} = delete $form->{"delivery_order_items_id_$form->{rowcount}"};
 
     if ($vc_discount){ # falls wir einen Lieferanten/Kundenrabatt haben
       # und keinen anderen discount wert an $i ...
index 0b0d772..6a55560 100644 (file)
@@ -442,8 +442,7 @@ sub display_row {
       push @hidden_vars, qw(orderitems_id converted_from_quotation_orderitems_id);
     }
     if ($is_invoice) {
-      push @hidden_vars, qw(invoice_id converted_from_quotation_orderitems_id converted_from_order_orderitems_id
-                            converted_from_delivery_order_items_id);
+      push @hidden_vars, qw(invoice_id converted_from_orderitems_id converted_from_delivery_order_items_id);
     }
     if ($::form->{type} =~ /credit_note/) {
       push @hidden_vars, qw(invoice_id converted_from_invoice_id);
@@ -452,7 +451,7 @@ sub display_row {
       map { $form->{"${_}_${i}"} = $form->format_amount(\%myconfig, $form->{"${_}_${i}"}) } qw(sellprice discount lastcost);
       push @hidden_vars, grep { defined $form->{"${_}_${i}"} } qw(sellprice discount not_discountable price_factor_id lastcost);
       push @hidden_vars, "stock_${stock_in_out}_sum_qty", "stock_${stock_in_out}";
-      push @hidden_vars, qw(delivery_order_items_id converted_from_order_orderitems_id);
+      push @hidden_vars, qw(delivery_order_items_id converted_from_orderitems_id);
     }
 
     my @HIDDENS = map { value => $_}, (
@@ -744,7 +743,7 @@ sub remove_emptied_rows {
                 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_order_orderitems_id converted_from_delivery_order_items_id);
+                converted_from_orderitems_id converted_from_delivery_order_items_id);
 
   my $ic_cvar_configs = CVar->get_configs(module => 'IC');
   push @flds, map { "ic_cvar_$_->{name}" } @{ $ic_cvar_configs };
index 09eb52a..a313fb3 100644 (file)
@@ -1423,6 +1423,7 @@ sub invoice {
     for (qw(ship qty sellprice listprice basefactor)) {
       $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if $form->{"${_}_${i}"};
     }
+    $form->{"converted_from_orderitems_id_$i"} = delete $form->{"orderitems_id_$i"};
   }
 
   my ($buysell, $orddate, $exchangerate);
@@ -1472,7 +1473,6 @@ sub invoice {
 
   # bo creates the id, reset it
   map { delete $form->{$_} } qw(id subject message cc bcc printed emailed queued);
-  delete $form->{"orderitems_id_$_"} for 1 .. $form->{"rowcount"};
   $form->{ $form->{vc} } =~ s/--.*//g;
   $form->{type} = "invoice";
 
@@ -1896,8 +1896,7 @@ sub delivery_order {
 
   for my $i (1 .. $form->{rowcount}) {
     map { $form->{"${_}_${i}"} = $form->parse_amount(\%myconfig, $form->{"${_}_${i}"}) if ($form->{"${_}_${i}"}) } qw(ship qty sellprice listprice lastcost basefactor discount);
-    $form->{"converted_from_order_orderitems_id_$i"} = $form->{"orderitems_id_$i"};
-    delete $form->{"orderitems_id_$i"}; # even if they don't exist in form. cvars checks them before display_row
+    $form->{"converted_from_orderitems_id_$i"} = delete $form->{"orderitems_id_$i"};
   }
 
   my %old_values = map { $_ => $form->{$_} } qw(customer_id oldcustomer customer vendor_id oldvendor vendor shipto_id);