Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 78c1cb32

Von Sven Schöling vor mehr als 7 Jahren hinzugefügt

  • ID 78c1cb3235240552968d2501bf18e8b7db7f5171
  • Vorgänger e80aa4c8
  • Nachfolger d1f44c84

DO: mark_orders_if_delivered mit SL::Helper::ShippedQty berechnen

Unterschiede anzeigen:

SL/DO.pm
44 44
use SL::DB::DeliveryOrder;
45 45
use SL::DB::Status;
46 46
use SL::DBUtils;
47
use SL::Helper::ShippedQty;
47 48
use SL::HTML::Restrict;
48 49
use SL::RecordLinks;
49 50
use SL::IC;
......
561 562
}
562 563

  
563 564
sub mark_orders_if_delivered {
564
  $main::lxdebug->enter_sub();
565

  
566
  my $self   = shift;
567
  my %params = @_;
565
  my ($self, %params) = @_;
568 566

  
569 567
  Common::check_params(\%params, qw(do_id type));
570 568

  
571
  my $myconfig = \%main::myconfig;
572
  my $form     = $main::form;
569
  my $do     = SL::DB::Manager::DeliveryOrder->find_by(id => $params{do_id});
570
  my $orders = $do->linked_records(from => 'Order');
573 571

  
574
  SL::DB->client->with_transaction(sub {
575
    my $dbh      = $params{dbh} || SL::DB->client->dbh;
572
  SL::Helper::ShippedQty->new->calculate($orders)->write_to_objects;
576 573

  
577
    my %ship = $self->get_shipped_qty('dbh' => $dbh, 'do_id' => $form->{id}, 'delivered' => 1);
574
  SL::DB->client->with_transaction(sub {
575
    for my $oe (@$orders) {
576
      next if $params{type} eq 'sales'    && !$oe->customer_id;
577
      next if $params{type} eq 'purchase' && !$oe->vendor_id;
578 578

  
579
    foreach my $oe_id (keys %ship) {
580
        do_query($form, $dbh,"UPDATE oe SET delivered = ".($ship{$oe_id}->{delivered}?"TRUE":"FALSE")." WHERE id = ?", $oe_id);
579
      $oe->update_attributes(delivered => $oe->{delivered});
581 580
    }
582 581
    1;
583 582
  }) or do { die SL::DB->client->error };
584

  
585
  $main::lxdebug->leave_sub();
586 583
}
587 584

  
588 585
sub close_orders {

Auch abrufbar als: Unified diff