Bug 25541: Add ability to prevent checkin via SIP of items with holds
[koha.git] / Koha / StockRotationItems.pm
blob080876a8f24d75d11caef00296c90c2b2cd07c09
1 package Koha::StockRotationItems;
3 # Copyright PTFS Europe 2016
5 # This file is part of Koha.
7 # Koha is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3 of the License, or
10 # (at your option) any later version.
12 # Koha is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with Koha; if not, see <http://www.gnu.org/licenses>.
20 use Modern::Perl;
22 use Koha::Database;
23 use Koha::StockRotationItem;
25 use base qw(Koha::Objects);
27 =head1 NAME
29 StockRotationItems - Koha StockRotationItems Object class
31 =head1 SYNOPSIS
33 StockRotationItems class used primarily by stockrotation .pls and the stock
34 rotation cron script.
36 =head1 DESCRIPTION
38 Standard Koha::Objects definitions, and additional methods.
40 =head1 API
42 =head2 Class Methods
44 =cut
46 =head3 _type
48 =cut
50 sub _type {
51 return 'Stockrotationitem';
54 =head3 object_class
56 =cut
58 sub object_class {
59 return 'Koha::StockRotationItem';
62 =head3 investigate
64 my $report = $items->investigate;
66 Return a stockrotation report about this set of stockrotationitems.
68 In this part of the overall investigation process we split individual item
69 reports into appropriate action segments of our items report and increment
70 some counters.
72 The report generated here will be used on the stage level to slot our item
73 reports into appropriate sections of the branched report.
75 For details of intent and context of this procedure, please see
76 Koha::StockRotationRota->investigate.
78 =cut
80 sub investigate {
81 my ( $self ) = @_;
83 my $items_report = {
84 items => [],
85 log => [],
86 initiable_items => [],
87 repatriable_items => [],
88 advanceable_items => [],
89 indemand_items => [],
90 actionable => 0,
91 stationary => 0,
93 while ( my $item = $self->next ) {
94 my $report = $item->investigate;
95 if ( $report->{reason} eq 'initiation' ) {
96 $items_report->{initiable}++;
97 $items_report->{actionable}++;
98 push @{$items_report->{items}}, $report;
99 push @{$items_report->{initiable_items}}, $report;
100 } elsif ( $report->{reason} eq 'repatriation' ) {
101 $items_report->{repatriable}++;
102 $items_report->{actionable}++;
103 push @{$items_report->{items}}, $report;
104 push @{$items_report->{repatriable_items}}, $report;
105 } elsif ( $report->{reason} eq 'advancement' ) {
106 $items_report->{actionable}++;
107 push @{$items_report->{items}}, $report;
108 push @{$items_report->{advanceable_items}}, $report;
109 } elsif ( $report->{reason} eq 'in-demand' ) {
110 $items_report->{actionable}++;
111 push @{$items_report->{items}}, $report;
112 push @{$items_report->{indemand_items}}, $report;
113 } else {
114 $items_report->{stationary}++;
115 push @{$items_report->{log}}, $report;
119 return $items_report;
124 =head1 AUTHOR
126 Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
128 =cut