Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 81868e7f

Von Werner Hahn vor mehr als 8 Jahren hinzugefügt

  • ID 81868e7f846213fed39c9398d65256c1deac8ab6
  • Vorgänger 2803b3fd
  • Nachfolger 415437ab

Shoporder automatischer Auftrag Backgroundjob anfang

Unterschiede anzeigen:

SL/BackgroundJob/ShopOrder.pm
5 5

  
6 6
use parent qw(SL::BackgroundJob::Base);
7 7

  
8
#
8 9
# Workflow Dreschflegel Shoporder import -> wo geht automatisch nach Order(Auftrag) und DeliveryOrder (Lieferschein) mit auslagern transferieren
9 10
#
10 11

  
......
20 21
# Data format:
21 22
# my $data                  = {
22 23
#     shop_order_record_ids       => [ 603, 604, 605],
23
#     transdate                   => $today,
24 24
#     num_order_created           => 0,
25 25
#     num_delivery_order_created  => 0,
26 26
#     conversation_errors         => [ { id => 603 , item => 2, message => "Out of stock"}, ],
......
29 29

  
30 30
sub create_order {
31 31
  my ( $self ) = @_;
32
  $::lxdebug->dump(0, 'WH: ', \$self);
32
  $::lxdebug->dump(0, 'WH: Taskmanager: ', \$self);
33 33
  my $job_obj = $self->{job_obj};
34
  my $db      = $job_obj->db;
35
  foreach my $shop_order_id (@{ $job_obj->data_as_hash->{shop_order_record_ids} }) {
36
    #my $shop_order = SL::DB::Manager::ShopOrder->find_by( id => $shop_order_id );
37
    my $shop_order = SL::DB::ShopOrder->new(id => $shop_order_id)->load;
38
    die "can't find shoporder with id $shop_order_id" unless $shop_order;
39
    my $customer = SL::DB::Manager::Customer->find_by(id => $::form->{customer});
40
    die "Can't find customer" unless $customer;
41
    my $employee = SL::DB::Manager::Employee->current;
42
    my $items = SL::DB::Manager->ShopOrderItem->get_all( where => [shop_order_id => $shop_order_id] );
43
    $::lxdebug->dump(0, 'WH: CREATE:I ', \$shop_order);
44
    $::lxdebug->dump(0, 'WH: CREATE:II ', \$items);
45

  
46
  }
34 47
}
35 48

  
36 49
sub create_delivery_order {
37 50
  my ( $self ) = @_;
38 51
}
52

  
53
sub run {
54
  my ($self, $job_obj) = @_;
55

  
56
  $self->{job_obj}         = $job_obj;
57
  $self->create_order;
58

  
59
  $job_obj->set_data(status => DONE())->save;
60

  
61
  return 1;
62
}
39 63
1;
SL/Controller/ShopOrder.pm
67 67
  my $id = $::form->{id} || {};
68 68
  my $shop_order = SL::DB::Manager::ShopOrder->find_by( id => $id );
69 69
  die "can't find shoporder with id $id" unless $shop_order;
70

  
70
$main::lxdebug->dump(0, 'WH:ORDER: ', \$shop_order);
71 71
  # the different importaddresscheck if there complete in the customer table to prevent duplicats inserts
72 72
  my %customer_address = ( 'name'    => $shop_order->customer_lastname,
73 73
                           'company' => $shop_order->customer_company,
......
139 139

  
140 140
sub action_mass_transfer {
141 141
  my ($self) = @_;
142
  my $today = DateTime->today_local;
143 142
  my @shop_orders =  @{ $::form->{id} || [] };
144 143
  $::lxdebug->dump(0, 'WH: MT II', \@shop_orders);
145 144

  
......
148 147
    active                  => 1,
149 148
    package_name            => 'ShopOrder',
150 149
  )->set_data(
151
     shop_order_record_ids       => [ 603, 604, 605],
152
     transdate                   => $today,
150
     shop_order_record_ids       => [ 606, 604, 605],
153 151
     num_order_created           => 0,
154 152
     num_delivery_order_created  => 0,
155 153
     conversation_errors         => [ ],

Auch abrufbar als: Unified diff