]> wagnertech.de Git - mfinanz.git/blobdiff - SL/IR.pm
Beim Umwandeln von Angeboten/Preisanfragen in Aufträge die IDs in record_links speich...
[mfinanz.git] / SL / IR.pm
index b8f22cd31a556ce68ee4e4780171634e70a54c75..f3c2674b05d493f3fd3791a66bc69f1753038a8c 100644 (file)
--- a/SL/IR.pm
+++ b/SL/IR.pm
@@ -539,10 +539,28 @@ sub post_invoice {
 
   Common::webdav_folder($form) if ($main::webdav);
 
-  my @close_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{close_do_ids};
-  if (scalar @close_do_ids) {
+  # Link this record to the records it was created from.
+  RecordLinks->create_links('dbh'        => $dbh,
+                            'mode'       => 'ids',
+                            'from_table' => 'oe',
+                            'from_ids'   => $form->{convert_from_oe_ids},
+                            'to_table'   => 'ap',
+                            'to_id'      => $form->{id},
+    );
+  delete $form->{convert_from_oe_ids};
+
+  my @convert_from_do_ids = map { $_ * 1 } grep { $_ } split m/\s+/, $form->{convert_from_do_ids};
+  if (scalar @convert_from_do_ids) {
     DO->close_orders('dbh' => $dbh,
-                     'ids' => \@close_do_ids);
+                     'ids' => \@convert_from_do_ids);
+
+    RecordLinks->create_links('dbh'        => $dbh,
+                              'mode'       => 'ids',
+                              'from_table' => 'delivery_orders',
+                              'from_ids'   => \@convert_from_do_ids,
+                              'to_table'   => 'ap',
+                              'to_id'      => $form->{id},
+      );
   }
 
   my $rc = 1;