Bug 15548: Move new patron related code to Patron*
[koha.git] / tools / import_borrowers.pl
index 1876c88..e92137e 100755 (executable)
@@ -47,7 +47,7 @@ use C4::Members::AttributeTypes;
 use C4::Members::Messaging;
 use C4::Reports::Guided;
 use C4::Templates;
-use Koha::Borrower::Debarments;
+use Koha::Patron::Debarments;
 use Koha::DateUtils;
 
 use Text::CSV;
@@ -97,7 +97,7 @@ if ($input->param('sample')) {
     );
     $csv->combine(@columnkeys);
     print $csv->string, "\n";
-    exit 1;
+    exit 0;
 }
 my $uploadborrowers = $input->param('uploadborrowers');
 my $matchpoint      = $input->param('matchpoint');
@@ -280,7 +280,9 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
                 $template->param('lastinvalid'=>$borrower{'surname'}.' / '.$borrowernumber);
                 next LINE;
             }
-            if ( $borrower{debarred} ) {
+
+            # Don't add a new restriction if the existing 'combined' restriction matches this one
+            if ( $borrower{debarred} && ( ( $borrower{debarred} ne $member->{debarred} ) || ( $borrower{debarredcomment} ne $member->{debarredcomment} ) ) ) {
                 # Check to see if this debarment already exists
                 my $debarrments = GetDebarments(
                     {
@@ -300,6 +302,7 @@ if ( $uploadborrowers && length($uploadborrowers) > 0 ) {
                     );
                 }
             }
+
             if ($extended) {
                 if ($ext_preserve) {
                     my $old_attributes = GetBorrowerAttributes($borrowernumber);