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

(-)a/Koha/Exceptions/Patron.pm (+5 lines)
Lines 41-46 use Exception::Class ( Link Here
41
        isa         => 'Koha::Exceptions::Patron',
41
        isa         => 'Koha::Exceptions::Patron',
42
        description => "Patron not found"
42
        description => "Patron not found"
43
    },
43
    },
44
    'Koha::Exceptions::Patron::CannotRestore' => {
45
        isa         => 'Koha::Exceptions::Patron',
46
        description => 'The patron cannot be restored due to conflicts',
47
        fields      => ['type'],
48
    },
44
);
49
);
45
50
46
sub full_message {
51
sub full_message {
(-)a/Koha/Old/Patron.pm (-1 / +29 lines)
Lines 50-55 sub restore_deleted_borrower { Link Here
50
    my $schema = Koha::Database->new->schema;
50
    my $schema = Koha::Database->new->schema;
51
    my $restored_patron;
51
    my $restored_patron;
52
52
53
    # Check if borrowernumber exists in borrowers. If it does thrown an exception, cannot restore.
54
    my $existing_borrower = Koha::Patrons->find( $self->borrowernumber );
55
    if ($existing_borrower) {
56
        Koha::Exceptions::Patron::CannotRestore->throw(
57
            error => 'Borrower number already exists',
58
            type  => 'borrowernumber',
59
        );
60
    }
61
62
    # Check if cardnumber exists in borrowers. If it does thrown an exception, cannot restore.
63
    my $existing_cardnumber = Koha::Patrons->find( { cardnumber => $self->cardnumber } );
64
    if ($existing_cardnumber) {
65
        Koha::Exceptions::Patron::CannotRestore->throw(
66
            error => 'Card number already in use',
67
            type  => 'cardnumber',
68
        );
69
    }
70
71
    # Check if userid exists. If it does thrown an exception, cannot restore.
72
    if ( $self->userid ) {
73
        my $existing_userid = Koha::Patrons->find( { userid => $self->userid } );
74
        if ($existing_userid) {
75
            Koha::Exceptions::Patron::CannotRestore->throw(
76
                error => 'Username already in use',
77
                type  => 'userid',
78
            );
79
        }
80
    }
81
53
    $schema->txn_do(
82
    $schema->txn_do(
54
        sub {
83
        sub {
55
            # Retrive all the data about this patron from deleteborrowers table
84
            # Retrive all the data about this patron from deleteborrowers table
56
- 

Return to bug 34069