|
Lines 3019-3024
sub to_api {
Link Here
|
| 3019 |
? Mojo::JSON->true |
3019 |
? Mojo::JSON->true |
| 3020 |
: Mojo::JSON->false; |
3020 |
: Mojo::JSON->false; |
| 3021 |
|
3021 |
|
|
|
3022 |
$json_patron->{self_renewal_available} = $self->is_eligible_for_self_renewal(); |
| 3023 |
|
| 3022 |
return $json_patron; |
3024 |
return $json_patron; |
| 3023 |
} |
3025 |
} |
| 3024 |
|
3026 |
|
|
Lines 3592-3597
sub is_anonymous {
Link Here
|
| 3592 |
return ( $anonymous_patron && $self->borrowernumber eq $anonymous_patron ) ? 1 : 0; |
3594 |
return ( $anonymous_patron && $self->borrowernumber eq $anonymous_patron ) ? 1 : 0; |
| 3593 |
} |
3595 |
} |
| 3594 |
|
3596 |
|
|
|
3597 |
=head3 is_eligible_for_self_renewal |
| 3598 |
|
| 3599 |
my $eligible_for_self_renewal = $patron->is_eligible_for_self_renewal(); |
| 3600 |
|
| 3601 |
Returns a boolean value for whether self-renewal is available or not |
| 3602 |
|
| 3603 |
=cut |
| 3604 |
|
| 3605 |
sub is_eligible_for_self_renewal { |
| 3606 |
my ($self) = @_; |
| 3607 |
|
| 3608 |
my $category = $self->category; |
| 3609 |
return 0 if !$category->self_renewal_enabled; |
| 3610 |
|
| 3611 |
return 0 if $self->debarred; |
| 3612 |
|
| 3613 |
my $expiry_window = |
| 3614 |
$category->self_renewal_availability_start || C4::Context->preference('NotifyBorrowerDeparture'); |
| 3615 |
my $post_expiry_window = $category->self_renewal_if_expired || 0; |
| 3616 |
|
| 3617 |
my $expiry_date = dt_from_string( $self->dateexpiry, undef, 'floating' ); |
| 3618 |
my $window_start = dt_from_string( $self->dateexpiry, undef, 'floating' )->subtract( days => $expiry_window ); |
| 3619 |
my $window_end = dt_from_string( $self->dateexpiry, undef, 'floating' )->add( days => $post_expiry_window ); |
| 3620 |
my $today = dt_from_string( undef, undef, 'floating' ); |
| 3621 |
|
| 3622 |
my $within_expiry_window = |
| 3623 |
$window_start < $today->truncate( to => 'day' ) && $today < $window_end->truncate( to => 'day' ); |
| 3624 |
return 0 if !$within_expiry_window; |
| 3625 |
|
| 3626 |
my $charges_status = $self->is_patron_inside_charge_limits(); |
| 3627 |
my $self_renewal_charge_limit = $category->self_renewal_fines_block; |
| 3628 |
foreach my $key ( keys %$charges_status ) { |
| 3629 |
my $within_renewal_limit = |
| 3630 |
( $self_renewal_charge_limit && $self_renewal_charge_limit > $charges_status->{$key}->{charge} ) ? 1 : 0; |
| 3631 |
return 0 if $charges_status->{$key}->{overlimit} && !$within_renewal_limit; |
| 3632 |
} |
| 3633 |
|
| 3634 |
return 1; |
| 3635 |
} |
| 3636 |
|
| 3637 |
=head3 request_modification |
| 3638 |
|
| 3639 |
$patron->request_modification |
| 3640 |
|
| 3641 |
Used in the OPAC and in the patron self-renewal workflow to request a modification to a patron's account |
| 3642 |
Automatically approves the request based on the AutoApprovePatronProfileSettings syspref |
| 3643 |
|
| 3644 |
=cut |
| 3645 |
|
| 3646 |
sub request_modification { |
| 3647 |
my ( $self, $modification ) = @_; |
| 3648 |
|
| 3649 |
Koha::Patron::Modifications->search( { borrowernumber => $self->borrowernumber } )->delete; |
| 3650 |
|
| 3651 |
$modification->{verification_token} = q{} if !$modification->{verification_token}; |
| 3652 |
$modification->{borrowernumber} = $self->borrowernumber if !$modification->{borrowernumber}; |
| 3653 |
|
| 3654 |
my $patron_modification = Koha::Patron::Modification->new($modification)->store()->discard_changes; |
| 3655 |
|
| 3656 |
#Automatically approve patron profile changes if AutoApprovePatronProfileSettings is enabled |
| 3657 |
$patron_modification->approve() if C4::Context->preference('AutoApprovePatronProfileSettings'); |
| 3658 |
} |
| 3659 |
|
| 3660 |
=head3 create_expiry_notice_parameters |
| 3661 |
|
| 3662 |
my $letter_params = $expiring_patron->create_expiry_notice_parameters( |
| 3663 |
{ letter_code => $which_notice, forceprint => $forceprint, is_notice_mandatory => $is_notice_mandatory } ); |
| 3664 |
|
| 3665 |
Returns the parameters to send an expiry notice to a patron |
| 3666 |
Used by both the membership_expiry.pl cron and the self-renewal workflow |
| 3667 |
|
| 3668 |
=cut |
| 3669 |
|
| 3670 |
sub create_expiry_notice_parameters { |
| 3671 |
my ( $self, $args ) = @_; |
| 3672 |
|
| 3673 |
my $letter_code = $args->{letter_code}; |
| 3674 |
my $forceprint = $args->{forceprint} || 0; |
| 3675 |
my $is_notice_mandatory = $args->{is_notice_mandatory}; |
| 3676 |
|
| 3677 |
my $letter_params = { |
| 3678 |
module => 'members', |
| 3679 |
letter_code => $letter_code, |
| 3680 |
branchcode => $self->branchcode, |
| 3681 |
lang => $self->lang, |
| 3682 |
borrowernumber => $self->borrowernumber, |
| 3683 |
tables => { |
| 3684 |
borrowers => $self->borrowernumber, |
| 3685 |
branches => $self->branchcode, |
| 3686 |
}, |
| 3687 |
}; |
| 3688 |
|
| 3689 |
my $sending_params = { |
| 3690 |
letter_params => $letter_params, |
| 3691 |
message_name => 'Patron_Expiry', |
| 3692 |
forceprint => $forceprint |
| 3693 |
}; |
| 3694 |
|
| 3695 |
if ($is_notice_mandatory) { |
| 3696 |
$sending_params->{expiry_notice_mandatory} = 1; |
| 3697 |
$sending_params->{primary_contact_method} = $forceprint ? 'print' : $self->primary_contact_method; |
| 3698 |
} |
| 3699 |
|
| 3700 |
return $sending_params; |
| 3701 |
} |
| 3702 |
|
| 3595 |
=head2 Internal methods |
3703 |
=head2 Internal methods |
| 3596 |
|
3704 |
|
| 3597 |
=head3 _type |
3705 |
=head3 _type |