Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7f94d4ee

Von Werner Hahn vor mehr als 8 Jahren hinzugefügt

  • ID 7f94d4ee4e1e07e7cb976fd6db4b490d71aea803
  • Vorgänger 415437ab
  • Nachfolger 211de7dc

Shopordermasstrnsfer mit auslagern

Unterschiede anzeigen:

SL/BackgroundJob/ShopOrderMassTransfer.pm
9 9
# Workflow Dreschflegel Shoporder import -> wo geht automatisch nach Order(Auftrag) und DeliveryOrder (Lieferschein) mit auslagern transferieren
10 10
#
11 11

  
12
use SL::DBUtils;
12 13
use SL::DB::ShopOrder;
13 14
use SL::DB::ShopOrderItem;
14 15
use SL::DB::Order;
......
17 18
use Sort::Naturally ();
18 19

  
19 20
use constant WAITING_FOR_EXECUTION        => 0;
20
use constant CONVERTING_TO_DELIVERY_ORDER => 1;
21
use constant DONE                         => 5;
21
use constant CONVERTING_TO_ORDER          => 1;
22
use constant CONVERTING_TO_DELIVERY_ORDER => 2;
23
use constant DONE                         => 3;
22 24

  
23 25
# Data format:
24 26
# my $data                  = {
......
31 33

  
32 34
sub create_order {
33 35
  my ( $self ) = @_;
34
  $::lxdebug->dump(0, 'WH: Taskmanager: ', \$self);
35 36
  my $job_obj = $self->{job_obj};
36 37
  my $db      = $job_obj->db;
38

  
37 39
  foreach my $shop_order_id (@{ $job_obj->data_as_hash->{shop_order_record_ids} }) {
38
    #my $shop_order = SL::DB::Manager::ShopOrder->find_by( id => $shop_order_id );
39 40
    my $shop_order = SL::DB::ShopOrder->new(id => $shop_order_id)->load;
40 41
    die "can't find shoporder with id $shop_order_id" unless $shop_order;
41 42
    $::lxdebug->dump(0, 'WH: CREATE:I ', \$shop_order);
......
89 90
      my @transfers;
90 91
      my @errors;
91 92
      my $qty;
92
      my @stock_out;
93
      my $stock_out;
93 94
      require SL::WH;
94 95
      require SL::IS;
95 96
      require SL::DB::DeliveryOrderItemsStock;
......
100 101
                                                           $item->{unit}
101 102
                                                           );
102 103
        if (!@{ $err } && $wh_id && $bin_id) {
103
          push @transfers, {
104
            'bestbefore' => undef,
105
            'chargenumber' => '',
106
            'shippingdate' => 'current_date',
107
            'delivery_order_items_stock_id' => undef,
108
            'project_id' => '',
109
            'parts_id'         => $item->{parts_id},
110
            'qty'              => $item->{qty},
111
            'unit'             => $item->{unit},
112
            'transfer_type'    => 'shipped',
113
            'src_warehouse_id' => $wh_id,
114
            'src_bin_id'       => $bin_id,
115
            'comment' => $main::locale->text("Default transfer delivery order"),
116
            'oe_id' => $delivery_order->{id},
117
          };
118
          $main::lxdebug->dump(0, 'WH: ITEM',\$item);
119
          push @stock_out, {
104
          my $delivery_order_items_stock = SL::DB::DeliveryOrderItemsStock->new;
105
          $delivery_order_items_stock->assign_attributes (
120 106
            'delivery_order_item_id'  => $item->{id},
121 107
            'qty'                     => $item->{qty},
122 108
            'unit'                    => $item->{unit},
123 109
            'warehouse_id'            => $wh_id,
124 110
            'bin_id'                  => $bin_id,
125
          };
111
          );
112
          $delivery_order_items_stock->save;
126 113

  
127
          push @errors, @{ $err };
114
          my ($trans_id) = selectrow_query($::form, $::form->get_standard_dbh, qq|SELECT nextval('id')|);
115
          my $wh_transfer = SL::DB::Inventory->new;
116
          $wh_transfer->assign_attributes (
117
            'trans_id'                      => $trans_id,
118
            'employee'                      => $employee->{id},
119
            'bestbefore'                    => undef,
120
            'chargenumber'                  => '',
121
            'shippingdate'                  => DateTime->today,
122
            'delivery_order_items_stock_id' => $delivery_order_items_stock->id,
123
            'project_id'                    => '',
124
            'parts_id'                      => $item->{parts_id},
125
            'qty'                           => $item->{qty} * -1,
126
            'trans_type_id'              => 889,#hardcodiert
127
            'warehouse_id'                  => $wh_id,
128
            'bin_id'                        => $bin_id,
129
            'comment'                       => $main::locale->text("Default transfer delivery order"),
130
            'oe_id'                         => $delivery_order->{id},
131
          );
132
          $wh_transfer->save;
128 133
        }
134
        push @errors, @{ $err };
129 135
      }
130 136
      $main::lxdebug->dump(0, 'WH: LAGER II ', \@transfers);
131 137
      $main::lxdebug->dump(0, 'WH: LAGER III ', \@errors);
132 138
      if (!@errors) {
133
        WH->transfer(@transfers);
134
        foreach my $stock_out_item(@stock_out) {
135
          $main::lxdebug->dump(0, "WH: LAGER IV ",\$stock_out_item);
136
          my $delivery_order_items_stock = SL::DB::DeliveryOrderItemsStock->new(%$stock_out_item);
137
          $delivery_order_items_stock->save;
138 139
          $delivery_order->delivered(1);
139 140
          $delivery_order->save;
140
        }
141 141
      }
142 142
    }
143 143
  }
SL/IS.pm
1446 1446
sub _determine_wh_and_bin {
1447 1447
  $::lxdebug->enter_sub(2);
1448 1448
  if (@_ == 6) {my $dummy = shift;}
1449
$main::lxdebug->dump(0, 'WH:WAREHOUSE ',\@_);
1450 1449
  my ($dbh, $conf, $part_id, $qty, $unit) = @_;
1451 1450
  my @errors;
1452 1451

  
......
1510 1509
    }
1511 1510
  }
1512 1511

  
1513
  $main::lxdebug->dump(0, "WH: BIN: $bin_id -- $wh_id", \@errors);
1514 1512
  $::lxdebug->leave_sub(2);
1515 1513
  return (\@errors, $wh_id, $bin_id);
1516 1514
}
SL/ShopConnector/Shopware.pm
20 20
  my ($self, $id) = @_;
21 21

  
22 22
  my $url = $self->url;
23
  my $ordnumber = 61101;
23
  my $ordnumber = 61141;
24 24
  # Muss noch angepasst werden
25
  for(my $i=1;$i<=20;$i++) {
25
  for(my $i=1;$i<=50;$i++) {
26 26
    my $data = $self->connector->get("http://$url/api/orders/$ordnumber?useNumberAsId=true");
27 27
    $ordnumber++;
28 28
    $::lxdebug->dump(0, "WH: DATA ", \$data);
SL/WH.pm
47 47

  
48 48
  my ($self, @args) = @_;
49 49

  
50
      $main::lxdebug->dump(0, 'WH: TRANSFER @_',\@_);
51
      $main::lxdebug->dump(0, 'WH: TRANSFER SELF',\$self);
52 50
  if (!@args) {
53 51
    $::lxdebug->leave_sub;
54 52
    return;
......
65 63

  
66 64
  my $objectify = sub {
67 65
    my ($transfer, $field, $class, @find_by) = @_;
68
      $main::lxdebug->dump(0, 'WH: TRANSFER II @_',\@_);
69
      $main::lxdebug->dump(0, 'WH: TRANSFER II TRANSFER',\$transfer);
70 66

  
71 67
    @find_by = (description => $transfer->{$field}) unless @find_by;
72 68

  
......
83 79
  my $db = SL::DB::Inventory->new->db;
84 80
  $db->with_transaction(sub{
85 81
    while (my $transfer = shift @args) {
86
      $main::lxdebug->dump(0, 'WH: WAREHOUSE TRANSFER ',\$transfer);
87 82
      my ($trans_id) = selectrow_query($::form, $::form->get_standard_dbh, qq|SELECT nextval('id')|);
88 83

  
89 84
      my $part          = $objectify->($transfer, 'parts',         'SL::DB::Part');
......
115 110
                              ? $now : $transfer->{shippingdate},
116 111
          map { $_ => $transfer->{$_} } qw(chargenumber bestbefore oe_id delivery_order_items_stock_id invoice_id comment),
117 112
      );
118
      my $unit_obj = $part->unit_obj;##
119
$main::lxdebug->dump(0, 'WH: WAREHOUSE PART:', \$part);
120
$main::lxdebug->dump(0, "WH: WAREHOUSE I QTY: $qty --", \$unit);
113

  
121 114
      if ($unit) {
122
        $main::lxdebug->message(0, "WH: WAREHOUSE $qty -- $unit -- $part->unit_obj");
123 115
        $qty = $unit->convert_to($qty, $part->unit_obj);
124 116
      }
125 117

  

Auch abrufbar als: Unified diff