Revision 68cfa9b9
Von Bernd Bleßmann vor 10 Monaten hinzugefügt
t/wh/inventory.t | ||
---|---|---|
294 | 294 |
is(SL::Helper::Inventory::get_stock(part => $part1), "0.00000", 'and consumes...'); |
295 | 295 |
is(SL::Helper::Inventory::get_stock(part => $part2), "0.00000", '..the materials'); |
296 | 296 |
|
297 |
|
|
298 |
# check with own allocations |
|
299 |
set_stock( |
|
300 |
part => $part1, |
|
301 |
qty => 12, |
|
302 |
bin => $bin2, |
|
303 |
); |
|
304 |
set_stock( |
|
305 |
part => $part2, |
|
306 |
qty => 6.34, |
|
307 |
bin => $bin2, |
|
308 |
); |
|
309 |
@alloc1 = SL::Helper::Inventory::allocate(part => $part1, qty => 12); |
|
310 |
@alloc2 = SL::Helper::Inventory::allocate(part => $part2, qty => 6.34); |
|
311 |
|
|
312 |
lives_ok { |
|
313 |
SL::Helper::Inventory::produce_assembly( |
|
314 |
part => $assembly_service, |
|
315 |
qty => 1, |
|
316 |
allocations => [ @alloc1, @alloc2 ], |
|
317 |
|
|
318 |
# where to put it |
|
319 |
bin => $bin1, |
|
320 |
); |
|
321 |
} 'no exception on produce_assembly with own allocations (no service)'; |
|
322 |
|
|
323 |
is(SL::Helper::Inventory::get_stock(part => $assembly_service), "2.00000", 'produce with own allocations works'); |
|
324 |
is(SL::Helper::Inventory::get_stock(part => $part1), "0.00000", 'and consumes...'); |
|
325 |
is(SL::Helper::Inventory::get_stock(part => $part2), "0.00000", '..the materials'); |
|
326 |
|
|
297 | 327 |
# check comments and warehouses |
298 | 328 |
$::form->{l_comment} = 'Y'; |
299 | 329 |
$::form->{l_warehouse_from} = 'Y'; |
... | ... | |
316 | 346 |
'part_type' => 'assembly', |
317 | 347 |
'warehouse_to' => 'Warehouse' |
318 | 348 |
}), |
349 |
ignore(), ignore(), |
|
350 |
superhashof({ |
|
351 |
'comment' => 'Used for assembly '. $assembly_service->partnumber .' Ein Erzeugnis mit Dienstleistungen', |
|
352 |
'warehouse_from' => 'Warehouse' |
|
353 |
}), |
|
354 |
superhashof({ |
|
355 |
'comment' => 'Used for assembly '. $assembly_service->partnumber .' Ein Erzeugnis mit Dienstleistungen', |
|
356 |
'warehouse_from' => 'Warehouse' |
|
357 |
}), |
|
358 |
superhashof({ |
|
359 |
'part_type' => 'assembly', |
|
360 |
'warehouse_to' => 'Warehouse' |
|
361 |
}), |
|
319 | 362 |
], |
320 | 363 |
"Comments for assembly with service productions are ok" |
321 | 364 |
); |
... | ... | |
349 | 392 |
like $e->errors->[0]->message, qr/can not allocate 1,2 units of service number 1 We really need this service, missing 1,2 units/, |
350 | 393 |
"producing assembly with services and unstocked service throws correct error message"; |
351 | 394 |
|
352 |
is(SL::Helper::Inventory::get_stock(part => $assembly_service), "1.00000", 'produce without service does not work');
|
|
395 |
is(SL::Helper::Inventory::get_stock(part => $assembly_service), "2.00000", 'produce without service does not work');
|
|
353 | 396 |
is(SL::Helper::Inventory::get_stock(part => $part1), "12.00000", 'and does not consume...'); |
354 | 397 |
is(SL::Helper::Inventory::get_stock(part => $part2), "6.34000", '..the materials'); |
355 | 398 |
|
... | ... | |
370 | 413 |
bin => $bin1, |
371 | 414 |
); |
372 | 415 |
|
373 |
is(SL::Helper::Inventory::get_stock(part => $assembly_service), "2.00000", 'produce with service does work if services is needed and stocked'); |
|
416 |
is(SL::Helper::Inventory::get_stock(part => $assembly_service), "3.00000", 'produce with service does work if services is needed and stocked'); |
|
417 |
is(SL::Helper::Inventory::get_stock(part => $part1), "0.00000", 'and does consume...'); |
|
418 |
is(SL::Helper::Inventory::get_stock(part => $part2), "0.00000", '..the materials'); |
|
419 |
is(SL::Helper::Inventory::get_stock(part => $service1), "0.00000", '..and service'); |
|
420 |
|
|
421 |
# check with own allocations |
|
422 |
set_stock( |
|
423 |
part => $part1, |
|
424 |
qty => 12, |
|
425 |
bin => $bin2, |
|
426 |
); |
|
427 |
set_stock( |
|
428 |
part => $part2, |
|
429 |
qty => 6.34, |
|
430 |
bin => $bin2, |
|
431 |
); |
|
432 |
is('SL::DB::Part', ref $service1); |
|
433 |
set_stock( |
|
434 |
part => $service1, |
|
435 |
qty => 1.2, |
|
436 |
bin => $bin2, |
|
437 |
); |
|
438 |
|
|
439 |
@alloc1 = SL::Helper::Inventory::allocate(part => $part1, qty => 12); |
|
440 |
@alloc2 = SL::Helper::Inventory::allocate(part => $part2, qty => 6.34); |
|
441 |
my @alloc3 = SL::Helper::Inventory::allocate(part => $service1, qty => 1.2); |
|
442 |
|
|
443 |
lives_ok { |
|
444 |
SL::Helper::Inventory::produce_assembly( |
|
445 |
part => $assembly_service, |
|
446 |
qty => 1, |
|
447 |
allocations => [ @alloc1, @alloc2, @alloc3 ], |
|
448 |
|
|
449 |
# where to put it |
|
450 |
bin => $bin1, |
|
451 |
); |
|
452 |
} 'no exception on produce_assembly with own allocations (with service)'; |
|
453 |
|
|
454 |
is(SL::Helper::Inventory::get_stock(part => $assembly_service), "4.00000", 'produce with own allocations and service does work if services is needed and stocked'); |
|
374 | 455 |
is(SL::Helper::Inventory::get_stock(part => $part1), "0.00000", 'and does consume...'); |
375 | 456 |
is(SL::Helper::Inventory::get_stock(part => $part2), "0.00000", '..the materials'); |
376 | 457 |
is(SL::Helper::Inventory::get_stock(part => $service1), "0.00000", '..and service'); |
... | ... | |
385 | 466 |
#use Data::Dumper; |
386 | 467 |
#diag("hier" . Dumper(@contents)); |
387 | 468 |
cmp_deeply(\@contents, |
388 |
[ ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), |
|
469 |
[ ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), ignore(), |
|
470 |
superhashof({ |
|
471 |
'comment' => 'Used for assembly '. $assembly_service->partnumber .' Ein Erzeugnis mit Dienstleistungen', |
|
472 |
'warehouse_from' => 'Warehouse' |
|
473 |
}), |
|
474 |
superhashof({ |
|
475 |
'comment' => 'Used for assembly '. $assembly_service->partnumber .' Ein Erzeugnis mit Dienstleistungen', |
|
476 |
'warehouse_from' => 'Warehouse' |
|
477 |
}), |
|
478 |
superhashof({ |
|
479 |
'comment' => 'Used for assembly '. $assembly_service->partnumber .' Ein Erzeugnis mit Dienstleistungen', |
|
480 |
'warehouse_from' => 'Warehouse', |
|
481 |
'part_type' => 'service', |
|
482 |
'qty' => '1.20000', |
|
483 |
}), |
|
389 | 484 |
superhashof({ |
485 |
'part_type' => 'assembly', |
|
486 |
'warehouse_to' => 'Warehouse' |
|
487 |
}), |
|
488 |
ignore(), ignore(), ignore(), |
|
489 |
superhashof({ |
|
390 | 490 |
'comment' => 'Used for assembly '. $assembly_service->partnumber .' Ein Erzeugnis mit Dienstleistungen', |
391 | 491 |
'warehouse_from' => 'Warehouse' |
392 | 492 |
}), |
Auch abrufbar als: Unified diff
t:inventory: Test f. produce_assembly mit Diensleistungen bei eigener Allokierung