Revision 36d861c1
Von wernerh vor mehr als 1 Jahr hinzugefügt
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 | ||
---|---|---|
92 | 92 |
|
93 | 93 |
__PACKAGE__->meta->initialize; |
94 | 94 |
|
95 |
use Rose::Object::MakeMethods::Generic ( |
|
96 |
'scalar --get_set_init' => [ qw(onhandqty stockqty get_open_ordered_qty) ], |
|
97 |
); |
|
95 | 98 |
__PACKAGE__->attr_html('notes'); |
96 | 99 |
__PACKAGE__->attr_sorted({ unsorted => 'makemodels', position => 'sortorder' }); |
97 | 100 |
__PACKAGE__->attr_sorted({ unsorted => 'customerprices', position => 'sortorder' }); |
... | ... | |
100 | 103 |
__PACKAGE__->before_save('_before_save_set_partnumber'); |
101 | 104 |
__PACKAGE__->before_save('_before_save_set_assembly_weight'); |
102 | 105 |
|
106 |
sub onhandqty_as_number { |
|
107 |
my ($self, $string) = @_; |
|
108 |
$self->onhandqty($::form->parse_amount(\%::myconfig, $string)) if @_ > 1; |
|
109 |
return $::form->format_amount(\%::myconfig, $self->onhandqty, 2); |
|
110 |
} |
|
111 |
|
|
112 |
sub init_onhandqty{ |
|
113 |
my ($self) = @_; |
|
114 |
my $qty = SL::Helper::Inventory::get_onhand(part => $self->id); |
|
115 |
return $qty; |
|
116 |
} |
|
117 |
|
|
118 |
sub stockqty_as_number { |
|
119 |
my ($self, $string) = @_; |
|
120 |
$self->stockqty($::form->parse_amount(\%::myconfig, $string)) if @_ > 1; |
|
121 |
return $::form->format_amount(\%::myconfig, $self->stockqty, 2); |
|
122 |
} |
|
123 |
|
|
124 |
sub init_stockqty{ |
|
125 |
my ($self) = @_; |
|
126 |
my $qty = SL::Helper::Inventory::get_stock(part => $self->id); |
|
127 |
return $qty; |
|
128 |
} |
|
129 |
|
|
130 |
sub get_open_ordered_qty_as_number { |
|
131 |
my ($self, $string) = @_; |
|
132 |
$self->get_open_ordered_qty($::form->parse_amount(\%::myconfig, $string)) if @_ > 1; |
|
133 |
return $::form->format_amount(\%::myconfig, $self->get_open_ordered_qty, 2); |
|
134 |
} |
|
135 |
|
|
136 |
sub init_get_open_ordered_qty { |
|
137 |
my $self = shift; |
|
138 |
my $result = SL::DB::Manager::Part->get_open_ordered_qty($self->id); |
|
139 |
|
|
140 |
return $result; |
|
141 |
} |
|
142 |
#sub reservedqty_as_number { |
|
143 |
# my ($self, $string) = @_; |
|
144 |
# $self->reservedqty($::form->parse_amount(\%::myconfig, $string)) if @_ > 1; |
|
145 |
# return $::form->format_amount(\%::myconfig, $self->reservedqty, $self->places); |
|
146 |
#} |
|
147 |
|
|
148 |
#sub init_onhandqty{ |
|
149 |
# my ($self) = @_; |
|
150 |
# my $qty = get_onhand(part => $self->id); |
|
151 |
# return $qty; |
|
152 |
#} |
|
153 |
>>>>>>> cf3ff322d1 (Einkaufshelfer/Dispositionsmanager bescheleunigt) |
|
154 |
|
|
103 | 155 |
sub _before_save_set_partnumber { |
104 | 156 |
my ($self) = @_; |
105 | 157 |
|
... | ... | |
279 | 331 |
return $result{ $self->id }; |
280 | 332 |
} |
281 | 333 |
|
282 |
sub get_open_ordered_qty { |
|
283 |
my $self = shift; |
|
284 |
my %result = SL::DB::Manager::Part->get_open_ordered_qty($self->id); |
|
334 |
sub is_parts_first_order { |
|
285 | 335 |
|
286 |
return $result{ $self->id }; |
|
336 |
my ($self, %params) = @_; |
|
337 |
|
|
338 |
require SL::DB::OrderItem; |
|
339 |
my $orders_count = SL::DB::Manager::OrderItem->get_all_count( where => [ %params ], with_objects => 'order' ); |
|
340 |
|
|
341 |
return $orders_count == 1 ? 1 : 0; |
|
287 | 342 |
} |
288 | 343 |
|
289 | 344 |
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
Einkaufshelfer/Dispositionsmanager bescheleunigt