View | Details | Raw Unified | Return to bug 36027
Collapse All | Expand All

(-)a/misc/maintenance/search_for_data_inconsistencies.pl (-102 / +5 lines)
Lines 127-142 sub set_skip_options { Link Here
127
# Set all check options to 1 if none are provided, considering skip options
127
# Set all check options to 1 if none are provided, considering skip options
128
sub set_all_check_options_if_none_provided {
128
sub set_all_check_options_if_none_provided {
129
    my $any_check_option_provided = grep { $options{$_} } grep { /^check-/ } keys %options;
129
    my $any_check_option_provided = grep { $options{$_} } grep { /^check-/ } keys %options;
130
    if ( !$any_check_option_provided ) {
131
        foreach my $key ( keys %options ) {
132
            if ( $key =~ /^check-/ ) {
133
                my $skip_key = $key;
134
                $skip_key =~ s/^check-/skip-/;
135
130
136
                # Set check option to 1 unless the corresponding skip option indicated
131
    if ( !$any_check_option_provided ) {
137
                $options{$key} = 1 unless $options{$skip_key};
132
        handle_invalid_options("No options selected");
138
            }
133
        die;
139
        }
140
    }
134
    }
141
}
135
}
142
136
Lines 271-284 sub CheckItemsStatus { Link Here
271
        } else {
265
        } else {
272
            $biblioitemnumber = $record->subfield( $biblioitem_tag, $biblioitem_subfield );
266
            $biblioitemnumber = $record->subfield( $biblioitem_tag, $biblioitem_subfield );
273
        }
267
        }
274
        if ( $biblionumber != $biblio->biblionumber ) {
268
        if ( not( defined $biblionumber ) and $biblionumber != $biblio->biblionumber ) {
275
            push @ids_not_in_marc,
269
            push @ids_not_in_marc,
276
                {
270
                {
277
                biblionumber         => $biblio->biblionumber,
271
                biblionumber         => $biblio->biblionumber,
278
                biblionumber_in_marc => $biblionumber,
272
                biblionumber_in_marc => $biblionumber,
279
                };
273
                };
280
        }
274
        }
281
        if ( $biblioitemnumber != $biblio->biblioitem->biblioitemnumber ) {
275
        if ( not( defined $biblioitemnumber ) and $biblioitemnumber != $biblio->biblioitem->biblioitemnumber ) {
282
            push @ids_not_in_marc,
276
            push @ids_not_in_marc,
283
                {
277
                {
284
                biblionumber             => $biblio->biblionumber,
278
                biblionumber             => $biblio->biblionumber,
Lines 705-800 sub CheckRelationshipsLoop { Link Here
705
    }
699
    }
706
}
700
}
707
701
708
sub CheckRelationshipsLoop {
709
    my @loop_borrowers_relationships;
710
    my @guarantor_ids = Koha::Patron::Relationships->_resultset->get_column('guarantor_id')->all();
711
    my @guarantee_ids = Koha::Patron::Relationships->_resultset->get_column('guarantee_id')->all();
712
713
    foreach my $guarantor_id (@guarantor_ids) {
714
        foreach my $guarantee_id (@guarantee_ids) {
715
            if ( $guarantor_id == $guarantee_id ) {
716
717
                my $relation_guarantor_id;
718
                my $relation_guarantee_id;
719
                my $size_list;
720
                my $tmp_garantor_id = $guarantor_id;
721
                my @guarantor_ids;
722
723
                do {
724
                    my @relationship_for_go = Koha::Patron::Relationships->search(
725
                        {
726
                            -or => [
727
                                'guarantor_id' => { '=', $tmp_garantor_id },
728
                            ]
729
                        },
730
                    )->as_list;
731
                    $size_list = scalar @relationship_for_go;
732
733
                    foreach my $relation (@relationship_for_go) {
734
                        $relation_guarantor_id = $relation->guarantor_id;
735
                        unless ( grep { $_ == $relation_guarantor_id } @guarantor_ids ) {
736
                            push @guarantor_ids, $relation_guarantor_id;
737
                        }
738
                        $relation_guarantee_id = $relation->guarantee_id;
739
740
                        my @relationship_for_go = Koha::Patron::Relationships->search(
741
                            {
742
                                -or => [
743
                                    'guarantor_id' => { '=', $relation_guarantee_id },
744
                                ]
745
                            },
746
                        )->as_list;
747
                        $size_list = scalar @relationship_for_go;
748
749
                        if ( $guarantor_id == $relation_guarantee_id ) {
750
                            last;
751
                        }
752
753
                        foreach my $relation (@relationship_for_go) {
754
                            $relation_guarantor_id = $relation->guarantor_id;
755
                            unless ( grep { $_ == $relation_guarantor_id } @guarantor_ids ) {
756
                                push @guarantor_ids, $relation_guarantor_id;
757
                            }
758
                            $relation_guarantee_id = $relation->guarantee_id;
759
760
                            if ( $guarantor_id == $relation_guarantee_id ) {
761
                                last;
762
                            }
763
                        }
764
                        if ( $guarantor_id == $relation_guarantee_id ) {
765
                            last;
766
                        }
767
                    }
768
769
                    $tmp_garantor_id = $relation_guarantee_id;
770
                } while ( $guarantor_id != $relation_guarantee_id && $size_list > 0 );
771
772
                if ( $guarantor_id == $relation_guarantee_id ) {
773
                    unless ( grep { join( "", sort @$_ ) eq join( "", sort @guarantor_ids ) }
774
                        @loop_borrowers_relationships )
775
                    {
776
                        push @loop_borrowers_relationships, \@guarantor_ids;
777
                    }
778
                }
779
            }
780
        }
781
    }
782
783
    if ( scalar @loop_borrowers_relationships > 0 ) {
784
        new_section("The list of guarantors who are also guarantee.");
785
        my $count = 0;
786
        foreach my $table (@loop_borrowers_relationships) {
787
            $count++;
788
            print "Loop $count, borrowers id  : ";
789
            foreach my $borrower_id (@$table) {
790
                print "$borrower_id , ";
791
            }
792
            print "\n";
793
        }
794
        new_hint("Relationships that form guarantor loops must be deleted");
795
    }
796
}
797
798
sub new_section {
702
sub new_section {
799
    my ($name) = @_;
703
    my ($name) = @_;
800
    say "\n== $name ==";
704
    say "\n== $name ==";
801
- 

Return to bug 36027