Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 9854c20c

Von wernerh vor mehr als 1 Jahr hinzugefügt

  • ID 9854c20cf1ae30dc5b5dfb18a583e35e6d2306a2
  • Vorgänger 6a052cbb
  • Nachfolger 43819438

Einkaufshelfer/Dispositionsmanager bescheleunigt

Unterschiede anzeigen:

SL/Controller/DispositionManager.pm
9 9
use SL::PriceSource;
10 10
use SL::Locale::String qw(t8);
11 11
use SL::Helper::Flash qw(flash);
12
use SL::DBUtils;
12 13

  
13 14
use Data::Dumper;
14 15

  
15 16
sub action_list_parts {
16 17
  my ( $self ) = @_;
17

  
18 18
  my $parts = $self->_get_parts;
19
  my $parts_tmp;
20
  for my $part(@{ $parts }) {
21
    my $openitems = SL::DB::Manager::OrderItem->get_all(where => [ parts_id => $part->id, 'order.closed' => 0 ],
22
                                                         with_objects => ['order'],);
23
    my ($not_delivered, $ordered) = 0;
24
    for my $openitem (@{ $openitems }) {
25
      if($openitem->order->type eq 'sales_order') {
26
        $not_delivered += $openitem->qty - $openitem->shipped_qty;
27
      } elsif ( $openitem->order->type eq 'purchase_order' ) {
28
        $ordered += $openitem->qty - $openitem->delivered_qty;
29
      }
30
    }
31
    $part->assign_attributes( gv => $ordered );
32
    push @{ $parts_tmp }, $part;
33
  }
34 19
  $self->_setup_list_action_bar;
35
  $self->render('disposition_manager/list_parts', title => t8('Parts short onhand'), PARTS => $parts_tmp);
20
  $self->render('disposition_manager/list_parts', title => t8('Parts short onhand'), PARTS => $parts);
36 21
}
37 22

  
38 23
sub action_add_to_purchase_basket{
SL/DB/Manager/Part.pm
95 95
  my $class    = shift;
96 96
  my $part_id  = shift;
97 97
  return () unless $part_id;
98
  my $openitems = SL::DB::Manager::OrderItem->get_all(where => [ parts_id => $part_id, 'order.closed' => 0 ],
99
                                                       with_objects => ['order'],);
100
  return () unless $openitems;
101
  my %ordered;
102
  my %delivered;
103
  my $open            = 0;
104
  my $ordered_qty     = 0;
105
  my $delivered_qty   = 0;
106
  for my $openitem (@{ $openitems }) {
107
    if($openitem->order->type eq 'purchase_order') {
108
      $ordered_qty   += $openitem->qty;
109
      $delivered_qty += $openitem->delivered_qty;
110
    }
111
  }
112
  if( $ordered_qty - $delivered_qty > 0 ) {
113
    $open = $ordered_qty - $delivered_qty;
114
    %ordered = ($part_id => $open);
115
  } else {
116
    $open = $ordered_qty - $delivered_qty;
117
    %ordered = ($part_id => $open);
118
  }
119
  return %ordered;
98

  
99
  my $query = <<SQL;
100
 SELECT
101
   sum(oi.qty) as sum
102
   FROM
103
   orderitems oi
104
   LEFT OUTER JOIN oe o ON (oi.trans_id = o.id)
105
   WHERE
106
   (   o.closed = 'F' OR
107
     o.closed IS NULL) AND
108
   oi.parts_id = ? AND
109
   o.vendor_id IS NOT NULL
110
   GROUP BY oi.parts_id
111
SQL
112

  
113
  my ($ordered_qty) = selectrow_query($::form, $class->object_class->init_db->dbh, $query, $part_id);
114
  return $ordered_qty;
120 115
}
121 116

  
122 117
sub _sort_spec {
SL/DB/Part.pm
87 87

  
88 88
__PACKAGE__->meta->initialize;
89 89

  
90
use Rose::Object::MakeMethods::Generic (
91
  'scalar --get_set_init' => [ qw(onhandqty stockqty get_open_ordered_qty) ],
92
);
90 93
__PACKAGE__->attr_html('notes');
91 94
__PACKAGE__->attr_sorted({ unsorted => 'makemodels',     position => 'sortorder' });
92 95
__PACKAGE__->attr_sorted({ unsorted => 'customerprices', position => 'sortorder' });
......
94 97
__PACKAGE__->before_save('_before_save_set_partnumber');
95 98
__PACKAGE__->before_save('_before_save_set_assembly_weight');
96 99

  
100
sub onhandqty_as_number {
101
  my ($self, $string) = @_;
102
  $self->onhandqty($::form->parse_amount(\%::myconfig, $string)) if @_ > 1;
103
  return $::form->format_amount(\%::myconfig, $self->onhandqty, 2);
104
}
105

  
106
sub init_onhandqty{
107
  my ($self) = @_;
108
  my $qty = SL::Helper::Inventory::get_onhand(part => $self->id);
109
  return $qty;
110
}
111

  
112
sub stockqty_as_number {
113
  my ($self, $string) = @_;
114
  $self->stockqty($::form->parse_amount(\%::myconfig, $string)) if @_ > 1;
115
  return $::form->format_amount(\%::myconfig, $self->stockqty, 2);
116
}
117

  
118
sub init_stockqty{
119
  my ($self) = @_;
120
  my $qty = SL::Helper::Inventory::get_stock(part => $self->id);
121
  return $qty;
122
}
123

  
124
sub get_open_ordered_qty_as_number {
125
  my ($self, $string) = @_;
126
  $self->get_open_ordered_qty($::form->parse_amount(\%::myconfig, $string)) if @_ > 1;
127
  return $::form->format_amount(\%::myconfig, $self->get_open_ordered_qty, 2);
128
}
129

  
130
sub init_get_open_ordered_qty {
131
  my $self   = shift;
132
  my $result = SL::DB::Manager::Part->get_open_ordered_qty($self->id);
133

  
134
  return $result;
135
}
136
#sub reservedqty_as_number {
137
#  my ($self, $string) = @_;
138
#  $self->reservedqty($::form->parse_amount(\%::myconfig, $string)) if @_ > 1;
139
#  return $::form->format_amount(\%::myconfig, $self->reservedqty, $self->places);
140
#}
141

  
142
#sub init_onhandqty{
143
#  my ($self) = @_;
144
#  my $qty = get_onhand(part => $self->id);
145
#  return $qty;
146
#}
147
>>>>>>> cf3ff322d1 (Einkaufshelfer/Dispositionsmanager bescheleunigt)
148

  
97 149
sub _before_save_set_partnumber {
98 150
  my ($self) = @_;
99 151

  
......
273 325
  return $result{ $self->id };
274 326
}
275 327

  
276
sub get_open_ordered_qty {
277
  my $self   = shift;
278
  my %result = SL::DB::Manager::Part->get_open_ordered_qty($self->id);
328
sub is_parts_first_order {
279 329

  
280
  return $result{ $self->id };
330
  my ($self, %params) = @_;
331

  
332
  require SL::DB::OrderItem;
333
  my $orders_count = SL::DB::Manager::OrderItem->get_all_count( where => [ %params ], with_objects => 'order' );
334

  
335
  return $orders_count == 1 ? 1 : 0;
281 336
}
282 337

  
283 338
sub available_units {
templates/webpages/disposition_manager/list_parts.html
19 19
     </tr>
20 20
    </thead>
21 21
    [% FOREACH part = PARTS %]
22
      [% IF !part.gv %]
22
      [% IF !part.get_open_ordered_qty %]
23 23
      <tr class="listrow">
24 24
        <td>[% IF part.makemodels.size %][% L.checkbox_tag('ids[+]', "data-checkall"=1, checked = '1', value=part.id) %][% ELSE %][% 'No Vendor' | $T8 %][% END %]</td>
25 25
        <td>[% HTML.escape(part.partnumber) %]</td>
......
48 48
   </tr>
49 49
  </thead>
50 50
  [% FOREACH part = PARTS %]
51
    [% IF part.gv %]
51
    [% IF part.get_open_ordered_qty %]
52 52
    <tr class="listrow">
53 53
      <td>[% HTML.escape(part.partnumber) %]</td>
54 54
      <td>[% HTML.escape(part.description) %] </td>
55 55
      <td class="numeric">[% part.onhand_as_number %]         </td>
56 56
      <td class="numeric">[% part.rop_as_number %]            </td>
57
      <td class="numeric">[% part.gv %] </td>
57
      <td class="numeric">[% part.get_open_ordered_qty_as_number %] </td>
58 58
    </tr>
59 59
    [% END %]
60 60
  [% END %]

Auch abrufbar als: Unified diff