Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision f0ddfbfe

Von Moritz Bunkus vor etwa 3 Jahren hinzugefügt

  • ID f0ddfbfe848f0d94a7a28b8b5593786217c5dd39
  • Vorgänger c488d6f1
  • Nachfolger bebdc2ce

Pflichtenhefte: bei Pflichtenheft → Angebot → Auftrag auch PH mit Auftrag verknüpfen

Unterschiede anzeigen:

SL/OE.pm
44 44
use SL::DB::PeriodicInvoicesConfig;
45 45
use SL::DB::Project;
46 46
use SL::DB::ProjectType;
47
use SL::DB::RequirementSpecOrder;
47 48
use SL::DB::Status;
48 49
use SL::DB::Tax;
49 50
use SL::DBUtils;
......
479 480
  my $number_field         = $form->{type} =~ m{order} ? 'ordnumber' : 'quonumber';
480 481
  my $trans_number         = SL::TransNumber->new(type => $form->{type}, dbh => $dbh, number => $form->{$number_field}, id => $form->{id});
481 482
  $form->{$number_field} ||= $trans_number->create_unique; # set $form->{ordnumber} or $form->{quonumber}
483
  my $is_new               = !$form->{id};
482 484

  
483 485
  if ($form->{id}) {
484 486
    $query = qq|DELETE FROM custom_variables
......
832 834
                                       config_yaml => $form->{periodic_invoices_config})
833 835
    if ($form->{type} eq 'sales_order');
834 836

  
837
  $self->_link_created_sales_order_to_requirement_specs_for_sales_quotations(
838
    type               => $form->{type},
839
    converted_from_ids => \@convert_from_oe_ids,
840
    sales_order_id     => $form->{id},
841
    is_new             => $is_new,
842
  );
843

  
835 844
  $main::lxdebug->leave_sub();
836 845

  
837 846
  return 1;
838 847
}
839 848

  
849
sub _link_created_sales_order_to_requirement_specs_for_sales_quotations {
850
  my ($self, %params) = @_;
851

  
852
  # If this is a sales order created from a sales quotation and if
853
  # that sales quotation was created from a requirement spec document
854
  # then link the newly created sales order to the requirement spec
855
  # document, too.
856

  
857
  return if !$params{is_new};
858
  return if  $params{type} ne 'sales_order';
859
  return if !@{ $params{converted_from_ids} };
860

  
861
  my $oe_objects       = SL::DB::Manager::Order->get_all(where => [ id => $params{converted_from_ids} ]);
862
  my @sales_quotations = grep { $_->is_type('sales_quotation') } @{ $oe_objects };
863

  
864
  return if !@sales_quotations;
865

  
866
  my $rs_orders = SL::DB::Manager::RequirementSpecOrder->get_all(where => [ order_id => [ map { $_->id } @sales_quotations ] ]);
867

  
868
  return if !@{ $rs_orders };
869

  
870
  $rs_orders->[0]->db->with_transaction(sub {
871
    foreach my $rs_order (@{ $rs_orders }) {
872
      SL::DB::RequirementSpecOrder->new(
873
        order_id            => $params{sales_order_id},
874
        requirement_spec_id => $rs_order->requirement_spec_id,
875
        version_id          => $rs_order->version_id,
876
      )->save;
877
    }
878

  
879
    1;
880
  });
881
}
882

  
840 883
sub save_periodic_invoices_config {
841 884
  my ($self, %params) = @_;
842 885

  

Auch abrufbar als: Unified diff