Bug 24545: Fix license statements
[koha.git] / Koha / StockRotationItems.pm
1 package Koha::StockRotationItems;
2
3 # Copyright PTFS Europe 2016
4 #
5 # This file is part of Koha.
6 #
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.
11 #
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.
16 #
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>.
19
20 use Modern::Perl;
21
22 use Koha::Database;
23 use Koha::StockRotationItem;
24
25 use base qw(Koha::Objects);
26
27 =head1 NAME
28
29 StockRotationItems - Koha StockRotationItems Object class
30
31 =head1 SYNOPSIS
32
33 StockRotationItems class used primarily by stockrotation .pls and the stock
34 rotation cron script.
35
36 =head1 DESCRIPTION
37
38 Standard Koha::Objects definitions, and additional methods.
39
40 =head1 API
41
42 =head2 Class Methods
43
44 =cut
45
46 =head3 _type
47
48 =cut
49
50 sub _type {
51     return 'Stockrotationitem';
52 }
53
54 =head3 object_class
55
56 =cut
57
58 sub object_class {
59     return 'Koha::StockRotationItem';
60 }
61
62 =head3 investigate
63
64   my $report = $items->investigate;
65
66 Return a stockrotation report about this set of stockrotationitems.
67
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.
71
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.
74
75 For details of intent and context of this procedure, please see
76 Koha::StockRotationRota->investigate.
77
78 =cut
79
80 sub investigate {
81     my ( $self ) = @_;
82
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,
92     };
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;
116         }
117     }
118
119     return $items_report;
120 }
121
122 1;
123
124 =head1 AUTHOR
125
126 Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
127
128 =cut