Revision cbc6d493
Von Jan Büren vor mehr als 3 Jahren hinzugefügt
t/wh/inventory.t | ||
---|---|---|
330 | 330 |
|
331 | 331 |
# assembly with service non default tests (services will be consumed) |
332 | 332 |
|
333 |
local $::instance_conf->data->{produce_assembly_transfer_service} = 1; |
|
334 |
|
|
335 |
set_stock( |
|
336 |
part => $part1, |
|
337 |
qty => 12, |
|
338 |
bin => $bin2, |
|
339 |
); |
|
340 |
set_stock( |
|
341 |
part => $part2, |
|
342 |
qty => 6.34, |
|
343 |
bin => $bin2, |
|
344 |
); |
|
345 |
|
|
346 |
throws_ok{ |
|
347 |
SL::Helper::Inventory::produce_assembly( |
|
348 |
part => $assembly_service, |
|
349 |
qty => 1, |
|
350 |
auto_allocate => 1, |
|
351 |
# where to put it |
|
352 |
bin => $bin1, |
|
353 |
); |
|
354 |
} qr/can not allocate 1,2 units of service number 1 We really need this service, missing 1,2 units/, "producing assembly with services and unstocked service throws correct error message"; |
|
355 |
|
|
356 |
is(SL::Helper::Inventory::get_stock(part => $assembly_service), "1.00000", 'produce without service does not work'); |
|
357 |
is(SL::Helper::Inventory::get_stock(part => $part1), "12.00000", 'and does not consume...'); |
|
358 |
is(SL::Helper::Inventory::get_stock(part => $part2), "6.34000", '..the materials'); |
|
359 |
|
|
360 |
|
|
361 |
# ok, now add the missing service |
|
362 |
is('SL::DB::Part', ref $service1); |
|
363 |
set_stock( |
|
364 |
part => $service1, |
|
365 |
qty => 1.2, |
|
366 |
bin => $bin2, |
|
367 |
); |
|
368 |
|
|
369 |
SL::Helper::Inventory::produce_assembly( |
|
370 |
part => $assembly_service, |
|
371 |
qty => 1, |
|
372 |
auto_allocate => 1, |
|
373 |
# where to put it |
|
374 |
bin => $bin1, |
|
375 |
); |
|
376 |
|
|
377 |
is(SL::Helper::Inventory::get_stock(part => $assembly_service), "2.00000", 'produce with service does work if services is needed and stocked'); |
|
378 |
is(SL::Helper::Inventory::get_stock(part => $part1), "0.00000", 'and does consume...'); |
|
379 |
is(SL::Helper::Inventory::get_stock(part => $part2), "0.00000", '..the materials'); |
|
380 |
is(SL::Helper::Inventory::get_stock(part => $service1), "0.00000", '..and service'); |
|
381 |
|
|
382 |
# check comments and warehouses for assembly with service |
|
383 |
$::form->{l_comment} = 'Y'; |
|
384 |
$::form->{l_warehouse_from} = 'Y'; |
|
385 |
$::form->{l_warehouse_to} = 'Y'; |
|
386 |
local $::instance_conf->data->{produce_assembly_same_warehouse} = 1; |
|
387 |
|
|
388 |
@contents = WH->get_warehouse_journal(sort => 'date'); |
|
389 |
#use Data::Dumper; |
|
390 |
#diag("hier" . Dumper(@contents)); |
|
391 |
cmp_deeply(\@contents, |
|
392 |
[ ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), |
|
393 |
superhashof({ |
|
394 |
'comment' => 'Used for assembly '. $assembly_service->partnumber .' Ein Erzeugnis mit Dienstleistungen', |
|
395 |
'warehouse_from' => 'Warehouse' |
|
396 |
}), |
|
397 |
superhashof({ |
|
398 |
'comment' => 'Used for assembly '. $assembly_service->partnumber .' Ein Erzeugnis mit Dienstleistungen', |
|
399 |
'warehouse_from' => 'Warehouse' |
|
400 |
}), |
|
401 |
superhashof({ |
|
402 |
'comment' => 'Used for assembly '. $assembly_service->partnumber .' Ein Erzeugnis mit Dienstleistungen', |
|
403 |
'warehouse_from' => 'Warehouse', |
|
404 |
'part_type' => 'service', |
|
405 |
'qty' => '1.20000', |
|
406 |
}), |
|
407 |
superhashof({ |
|
408 |
'part_type' => 'assembly', |
|
409 |
'warehouse_to' => 'Warehouse' |
|
410 |
}), |
|
411 |
], |
|
412 |
"Comments for assembly with service productions are ok" |
|
413 |
); |
|
414 |
|
|
415 |
|
|
333 | 416 |
|
334 | 417 |
# bestbefore tests |
335 | 418 |
|
... | ... | |
402 | 485 |
$assembly1 = new_assembly(number_of_parts => 2)->save; |
403 | 486 |
($part1, $part2) = map { $_->part } $assembly1->assemblies; |
404 | 487 |
|
405 |
my $service1 = new_service(partnumber => "service number 1",
|
|
406 |
description => "We really need this service",
|
|
407 |
)->save;
|
|
488 |
$service1 = new_service(partnumber => "service number 1", |
|
489 |
description => "We really need this service", |
|
490 |
)->save; |
|
408 | 491 |
my $assembly_items; |
409 | 492 |
push( @{$assembly_items}, SL::DB::Assembly->new(parts_id => $part1->id, |
410 | 493 |
qty => 12, |
Auch abrufbar als: Unified diff
Testfall für: Erzeugnisse fertigen, kann auch Dienstleistungen verbrauchen