Bug 25184: (RM follow-up) Make DB update idempotent
[koha.git] / Koha / StockRotationRotas.pm
blob0f346917efc847f28b55701d1730fe717c668834
1 package Koha::StockRotationRotas;
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::StockRotationRota;
25 use base qw(Koha::Objects);
27 =head1 NAME
29 StockRotationRotas - Koha StockRotationRotas Object class
31 =head1 SYNOPSIS
33 StockRotationRotas 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 investigate
48 my $report = $rotas->investigate;
50 Return a report detailing the current status and required actions for all
51 relevant items spread over rotas.
53 See Koha::StockRotationRota->investigate for details.
55 =cut
57 sub investigate {
58 my ( $self ) = @_;
60 my $report = {
61 actionable => 0,
62 advanceable => 0,
63 initiable => 0,
64 indemand => 0,
65 items_inactive => 0,
66 repatriable => 0,
67 rotas_active => 0,
68 rotas_inactive => 0,
69 stationary => 0,
70 sum_items => 0,
71 sum_rotas => $self->count,
72 branched => {},
73 rotas => [],
74 items => [],
77 while ( my $rota = $self->next ) {
78 $report = $rota->investigate($report)
81 return $report;
84 =head3 _type
86 =cut
88 sub _type {
89 return 'Stockrotationrota';
92 =head3 object_class
94 =cut
96 sub object_class {
97 return 'Koha::StockRotationRota';
102 =head1 AUTHOR
104 Alex Sassmannshausen <alex.sassmannshausen@ptfs-europe.com>
106 =cut