@@ -, +, @@ --- .../search_for_data_inconsistencies.pl | 107 ++---------------- 1 file changed, 8 insertions(+), 99 deletions(-) --- a/misc/maintenance/search_for_data_inconsistencies.pl +++ a/misc/maintenance/search_for_data_inconsistencies.pl @@ -35,7 +35,7 @@ use C4::Biblio qw( GetMarcFromKohaField ); # Option 3: CheckItemsStatus - Check for bibliographic records and items without an item type or with an invalid item type # Option 4: CheckItemsFramework - Check for invalid values in fields where the framework limits to an authorized value category # Option 5: CheckItemsTitle - Check for bibliographic records without a title -# Option 6: CheckRelationshipsLoop - Check for relationships or dependencies between borrowers in a loop +# Option 6: CheckAgeForCategory - Check for patrons with invalid age for category my %methods = ( 1 => \&CheckItemsBranch, @@ -43,7 +43,7 @@ my %methods = ( 3 => \&CheckItemsStatus, 4 => \&CheckItemsFramework, 5 => \&CheckItemsTitle, -6 => \&CheckRelationshipsLoop, +6 => \&CheckAgeForCategory, ); my @methods_to_run; @@ -113,13 +113,13 @@ sub CheckItemsAuthHeader { while ( my $item = $items_without_itype->next ) { if (defined $item->biblioitem->itemtype && $item->biblioitem->itemtype ne '' ) { new_item( - sprintf "Item with itemnumber=%s does not have a itype value, biblio's item type will be used (%s)", - $item->itemnumber, $item->biblioitem->itemtype + sprintf "Item with itemnumber=%s and biblionumber = %s does not have a itype value, biblio's item type will be used (%s)", + $item->itemnumber, $item->biblioitem->biblionumber, $item->biblioitem->itemtype ); } else { new_item( - sprintf "Item with itemnumber=%s does not have a itype value, additionally no item type defined for biblionumber=%s", - $item->itemnumber, $item->biblioitem->biblionumber + sprintf "Item with itemnumber=%s and biblionumber = %s does not have a itype value, additionally no item type defined for biblionumber=%s", + $item->itemnumber, $item->biblioitem->biblionumber, $item->biblioitem->biblionumber ); } } @@ -307,12 +307,12 @@ if (%$invalid_av_per_framework) { : $table eq 'biblio' ? $i->biblio->$column : $i->biblioitem->$column; - $output .= " {" . $i->itemnumber . " => " . $value . "}\n"; + $output .= " {" . $i->itemnumber . " and " . $i->biblioitem->biblionumber. " => " . $value . "}\n"; } new_item( sprintf( "The Framework *%s* is using the authorised value's category *%s*, " - . "but the following %s do not have a value defined ({itemnumber => value }):\n%s", + . "but the following %s do not have a value defined ({itemnumber and biblionumber => value }):\n%s", $frameworkcode, $av_category, $kohafield, $output ) ); @@ -374,97 +374,6 @@ new_hint("You may change the patron's category automatically with misc/cronjobs/ } } -sub CheckRelationshipsLoop { -my @loop_borrowers_relationships; -my @relationships = Koha::Patron::Relationships->search(); -my @patrons_guarantors = Koha::Patron::Relationships::guarantors(@relationships)->as_list; -my @patrons_guarantees = Koha::Patron::Relationships::guarantees(@relationships)->as_list; - -foreach my $patron_guarantor (@patrons_guarantors) { -foreach my $patron_guarantee (@patrons_guarantees) { -if ($patron_guarantor->borrowernumber == $patron_guarantee->borrowernumber) { - -my $relationship_id; -my $guarantee_id; -my $size_list; -my $tmp_garantor_id = $patron_guarantor->borrowernumber; -my @relationship_ids; -my @guarantor_to_find; - -push @guarantor_to_find, $patron_guarantor->borrowernumber; - -do { -my @relationship_for_go = Koha::Patron::Relationships->search( -{ --or => [ -'guarantor_id' => { '=', $tmp_garantor_id }, -] -}, -)->as_list; -$size_list = scalar @relationship_for_go; - -foreach my $relation (@relationship_for_go) { - $relationship_id = $relation->id; - unless (grep { $_ == $relationship_id } @relationship_ids) { - push @relationship_ids, $relationship_id; - } - $guarantee_id = $relation->guarantee_id; - - if (grep { $_ eq $guarantee_id } @guarantor_to_find) { - last; - } - - my @relationship_for_go = Koha::Patron::Relationships->search( - { - -or => [ - 'guarantor_id' => { '=', $guarantee_id }, - ] - }, - )->as_list; - $size_list = scalar @relationship_for_go; - - push @guarantor_to_find, $guarantee_id; - - foreach my $relation (@relationship_for_go) { - $relationship_id = $relation->id; - unless (grep { $_ == $relationship_id } @relationship_ids) { - push @relationship_ids, $relationship_id; - } - $guarantee_id = $relation->guarantee_id; - - if (grep { $_ eq $guarantee_id } @guarantor_to_find) { - last; - } - } - if (grep { $_ eq $guarantee_id } @guarantor_to_find) { - last; - } -} - -$tmp_garantor_id = $guarantee_id; -} while ((!grep { $_ eq $guarantee_id } @guarantor_to_find) && $size_list > 0); - -if ($patron_guarantor->borrowernumber == $guarantee_id) { - unless (grep { join("", sort @$_) eq join("", sort @relationship_ids) } @loop_borrowers_relationships) { - push @loop_borrowers_relationships, \@relationship_ids; - } -} -} -} -} - -if (scalar @loop_borrowers_relationships > 0) { -new_section("The list of relationships id with guarantors who are also guarantee."); -foreach my $table (@loop_borrowers_relationships) { -new_item( -sprintf "Relationships connected : %s |", -join(" | ", @$table) -); -} -new_hint("Relationships that form guarantor loops must be deleted"); -} -} - sub new_section { my ( $name ) = @_; say "\n== $name =="; --