Revision c22e188b
Von Jan Büren vor mehr als 3 Jahren hinzugefügt
SL/Helper/ShippedQty.pm | ||
---|---|---|
26 | 26 |
ORDER BY oi.trans_id, oi.position |
27 | 27 |
|
28 | 28 |
# oi not item linked. takes about 250ms for 100k hits |
29 |
# obsolete since 3.5.6 |
|
29 | 30 |
my $fill_up_oi_query = <<''; |
30 | 31 |
SELECT oi.id, oi.trans_id, oi.position, oi.parts_id, oi.description, oi.reqdate, oi.serialnumber, oi.qty, oi.unit |
31 | 32 |
FROM orderitems oi |
... | ... | |
33 | 34 |
ORDER BY oi.trans_id, oi.position |
34 | 35 |
|
35 | 36 |
# doi linked by record, but not by items; 250ms for 100k hits |
37 |
# obsolete since 3.5.6 |
|
36 | 38 |
my $no_stock_fill_up_doi_query = <<''; |
37 | 39 |
SELECT doi.id, doi.delivery_order_id, doi.position, doi.parts_id, doi.description, doi.reqdate, doi.serialnumber, doi.qty, doi.unit |
38 | 40 |
FROM delivery_order_items doi |
... | ... | |
219 | 221 |
} elsif ('SL::DB::Order' eq ref $obj) { |
220 | 222 |
if (defined $obj->{orderitems}) { |
221 | 223 |
$self->write_to($obj->{orderitems}); |
222 |
$obj->{delivered} = all { $_->{delivered} } @{ $obj->{orderitems} }; |
|
224 |
$obj->{delivered} = all { $_->{delivered} } grep { !$_->{optional} || $_->{optional} == 0 } @{ $obj->{orderitems} };
|
|
223 | 225 |
} else { |
224 | 226 |
# don't force a load on items. just compute by oe_id directly |
225 | 227 |
$obj->{delivered} = $self->delivered->{$obj->id}; |
doc/changelog | ||
---|---|---|
54 | 54 |
Innerhalb der Druckvorlagen steht das Attribut mit <%optional%> als Variable zu Verfügung. |
55 | 55 |
Beim Status setzen eines Auftrags (offen oder geschlossen) werden optionale Position |
56 | 56 |
ignoriert. D.h. ein Auftrag gilt als geschlossen, wenn alle nicht optionalen |
57 |
Positionen fakturiert worden sind. Das Attribut optional steht auch nur in |
|
58 |
den Angeboten/Aufträgen zu Verfügung. Sobald über den Workflow ein neuer Beleg |
|
59 |
erstellt wird, wird die vorher optionale Position zu einer normalen Position |
|
57 |
Positionen fakturiert worden sind. |
|
58 |
Das Gleiche gilt für Lieferscheine. Sollten alles bis auf optionale Artikel |
|
59 |
geliefert worden sein, gilt der Auftrag als komplett geliefert. |
|
60 |
Das Attribut optional steht auch nur in den Angeboten/Aufträgen zu Verfügung. |
|
61 |
Sobald über den Workflow ein neuer Beleg erstellt wird, |
|
62 |
wird die vorher optionale Position zu einer normalen Position |
|
60 | 63 |
und wird dann auch entsprechend bei dem Rechnungsbeleg mit fakturiert und im |
61 | 64 |
Druckvorlagen-System entfällt das Attribut <%optional%>. |
62 | 65 |
Entsprechend exemplarisch im aktuellen Druckvorlagensatz RB ergänzt. |
t/helper/shipped_qty.t | ||
---|---|---|
204 | 204 |
my $number_of_linked_items = SL::DB::Manager::RecordLink->get_all_count( where => [ from_table => 'orderitems', to_table => 'delivery_order_items' ] ); |
205 | 205 |
is ($number_of_linked_items , 6, "6 record_links for items, 3 from sales order, 3 from purchase order"); |
206 | 206 |
|
207 |
note('testing optional orderitems'); |
|
208 |
|
|
209 |
my $item_optional = create_order_item(part => $part3, qty => 7, optional => 1); |
|
210 |
ok($item_optional->{optional}, "optional order item"); |
|
211 |
|
|
212 |
my $sales_order_opt = create_sales_order( |
|
213 |
save => 1, |
|
214 |
orderitems => [ create_order_item(part => $part1, qty => 5), |
|
215 |
create_order_item(part => $part2, qty => 6), |
|
216 |
$item_optional, |
|
217 |
] |
|
218 |
); |
|
219 |
|
|
220 |
|
|
221 |
SL::Helper::ShippedQty |
|
222 |
->new(require_stock_out => 1) # should make no difference while there is no delivery order |
|
223 |
->calculate($sales_order_opt) |
|
224 |
->write_to_objects; |
|
225 |
|
|
226 |
is($sales_order_opt->items_sorted->[2]->{shipped_qty}, 0, "third optional sales orderitem has no shipped_qty"); |
|
227 |
ok(!$sales_order_opt->items_sorted->[2]->{delivered}, "third optional sales orderitem is not delivered"); |
|
228 |
ok($sales_order_opt->items_sorted->[2]->{optional}, "third optional sales orderitem is optional"); |
|
229 |
|
|
230 |
my $orderitem_part3_opt = SL::DB::Manager::OrderItem->find_by(parts_id => $part3->id, trans_id => $sales_order_opt->id); |
|
231 |
is($orderitem_part3_opt->shipped_qty, 0, "OrderItem shipped_qty method ok"); |
|
232 |
|
|
233 |
# create sales delivery order from sales order |
|
234 |
my $sales_delivery_order_opt = $sales_order_opt->convert_to_delivery_order; |
|
235 |
is(scalar @{ $sales_delivery_order_opt->items_sorted }, 3, "third optional sales delivery orderitem is there"); |
|
236 |
|
|
237 |
# and delete third item |
|
238 |
my $optional = SL::DB::Manager::DeliveryOrderItem->find_by(parts_id => $part3->id, delivery_order_id => $sales_delivery_order_opt->id); |
|
239 |
SL::DB::DeliveryOrderItem->new(id => $optional->id)->delete; |
|
240 |
$sales_delivery_order_opt->save(cascade => 1); |
|
241 |
my $new_sales_delivery_order_opt = SL::DB::Manager::DeliveryOrder->find_by(id => $sales_delivery_order_opt->id); |
|
242 |
is(scalar @{ $new_sales_delivery_order_opt->items_sorted }, 2, "third optional sales delivery orderitem is undef"); |
|
243 |
|
|
244 |
SL::Helper::ShippedQty |
|
245 |
->new(require_stock_out => 0) |
|
246 |
->calculate($sales_order_opt) |
|
247 |
->write_to_objects; |
|
248 |
|
|
249 |
is($sales_order_opt->items_sorted->[0]->{shipped_qty}, 5, "require_stock_out => 0: first sales orderitem has shipped_qty"); |
|
250 |
ok($sales_order_opt->items_sorted->[0]->{delivered}, "require_stock_out => 0: first sales orderitem is delivered"); |
|
251 |
ok($sales_order_opt->items_sorted->[1]->{delivered}, "require_stock_out => 0: second sales orderitem is delivered"); |
|
252 |
ok(!$sales_order_opt->items_sorted->[2]->{delivered}, "require_stock_out => 0: third sales orderitem is NOT delivered"); |
|
253 |
is($sales_order_opt->items_sorted->[2]->{shipped_qty}, 0, "require_stock_out => 0: third sales orderitem has no shipped_qty"); |
|
254 |
ok($sales_order_opt->{delivered}, "require_stock_out => 0: order IS delivered"); |
|
255 |
|
|
207 | 256 |
clear_up(); |
208 | 257 |
|
209 | 258 |
{ |
Auch abrufbar als: Unified diff
ShippedQty: Optionale OrderItems nicht für Status Order->delivered auswerten
S.a.: Testfall und Changelog