Revision c591d7cc
Von Sven Schöling vor etwa 4 Jahren hinzugefügt
SL/Helper/Inventory.pm | ||
---|---|---|
388 | 388 |
# stock, get "what's there" for a part with various conditions: |
389 | 389 |
my $qty = get_stock(part => $part); # how much is on stock? |
390 | 390 |
my $qty = get_stock(part => $part, date => $date); # how much was on stock at a specific time? |
391 |
my $qty = get_stock(part => $part, bin => $bin); # how is on stock in a specific bin? |
|
392 |
my $qty = get_stock(part => $part, warehouse => $warehouse); # how is on stock in a specific warehouse? |
|
393 |
my $qty = get_stock(part => $part, chargenumber => $chargenumber); # how is on stock of a specific chargenumber? |
|
391 |
my $qty = get_stock(part => $part, bin => $bin); # how much is on stock in a specific bin?
|
|
392 |
my $qty = get_stock(part => $part, warehouse => $warehouse); # how much is on stock in a specific warehouse?
|
|
393 |
my $qty = get_stock(part => $part, chargenumber => $chargenumber); # how much is on stock of a specific chargenumber?
|
|
394 | 394 |
|
395 | 395 |
# onhand, get "what's available" for a part with various conditions: |
396 | 396 |
my $qty = get_onhand(part => $part); # how much is available? |
... | ... | |
407 | 407 |
); |
408 | 408 |
|
409 | 409 |
# allocate: |
410 |
my @allocations, allocate(
|
|
410 |
my @allocations = allocate(
|
|
411 | 411 |
part => $part, # part_id works too |
412 | 412 |
qty => $qty, # must be positive |
413 | 413 |
chargenumber => $chargenumber, # optional, may be arrayref. if provided these charges will be used first |
... | ... | |
416 | 416 |
); |
417 | 417 |
|
418 | 418 |
# shortcut to allocate all that is needed for producing an assembly, will use chargenumbers as appropriate |
419 |
my @allocations, allocate_for_assembly(
|
|
419 |
my @allocations = allocate_for_assembly(
|
|
420 | 420 |
part => $assembly, # part_id works too |
421 | 421 |
qty => $qty, # must be positive |
422 | 422 |
); |
423 | 423 |
|
424 |
# create allocation manually, bypassing checks, all of these need to be passed, even undefs
|
|
424 |
# create allocation manually, bypassing checks. all of these need to be passed, even undefs
|
|
425 | 425 |
my $allocation = SL::Helper::Inventory::Allocation->new( |
426 | 426 |
part_id => $part->id, |
427 | 427 |
qty => 15, |
... | ... | |
443 | 443 |
chargenumber => $chargenumber, # optional |
444 | 444 |
bestbefore => $datetime, # optional |
445 | 445 |
comment => $comment, # optional |
446 |
|
|
447 |
# links, all optional |
|
448 | 446 |
); |
449 | 447 |
|
450 | 448 |
=head1 DESCRIPTION |
451 | 449 |
|
452 | 450 |
New functions for the warehouse and inventory api. |
453 | 451 |
|
454 |
The WH api currently has three large shortcomings. It is very hard to just get
|
|
452 |
The WH api currently has three large shortcomings: It is very hard to just get
|
|
455 | 453 |
the current stock for an item, it's extremely complicated to use it to produce |
456 | 454 |
assemblies while ensuring that no stock ends up negative, and it's very hard to |
457 | 455 |
use it to get an overview over the actual contents of the inventory. |
... | ... | |
468 | 466 |
there. |
469 | 467 |
|
470 | 468 |
=item * Onhand is what is available, which means things that are stocked, |
471 |
not expired and not reserved for other uses. |
|
469 |
not expired and not in any other way reserved for other uses.
|
|
472 | 470 |
|
473 | 471 |
=back |
474 | 472 |
|
... | ... | |
491 | 489 |
target of the production, and requires allocations to complete the request. The |
492 | 490 |
allocations can be supplied manually, or can be generated automatically. |
493 | 491 |
C<produce_assembly> will check whether enough allocations are given to create |
494 |
the recipe, but will not check whether the allocations are backed. If the
|
|
492 |
the assembly, but will not check whether the allocations are backed. If the
|
|
495 | 493 |
allocations are not sufficient or if the auto-allocation fails an exception |
496 | 494 |
is returned. If you need to produce something that is not in the inventory, you |
497 | 495 |
can bypass those checks by creating the allocations yourself (see |
... | ... | |
765 | 763 |
the internal ordering of the hints is fixed and more complex preferentials |
766 | 764 |
are not supported. |
767 | 765 |
* bestbefore handling is untested |
766 |
* interaction with config option "transfer_default_ignore_onhand" is |
|
767 |
currently undefined (and implicitly ignores it) |
|
768 | 768 |
|
769 | 769 |
=head1 TODO |
770 | 770 |
|
771 | 771 |
* define and describe error classes |
772 | 772 |
* define wrapper classes for stock/onhand batch mode return values |
773 | 773 |
* handle extra arguments in produce: shippingdate, project |
774 |
* clean up allocation helper class |
|
775 | 774 |
* document no_ check |
776 | 775 |
* tests |
777 | 776 |
|
... | ... | |
781 | 780 |
|
782 | 781 |
=head1 AUTHOR |
783 | 782 |
|
784 |
Sven Schöling E<lt>sven.schoeling@opendynamic.deE<gt>
|
|
783 |
Sven Schöling E<lt>sven.schoeling@googlemail.comE<gt>
|
|
785 | 784 |
|
786 | 785 |
=cut |
Auch abrufbar als: Unified diff
Inventory Helper: Doku Update