|
Lines 62-67
use Koha::Patron::Images;
Link Here
|
| 62 |
use Koha::Patron::Messages; |
62 |
use Koha::Patron::Messages; |
| 63 |
use Koha::Patron::Modifications; |
63 |
use Koha::Patron::Modifications; |
| 64 |
use Koha::Patron::MessagePreferences; |
64 |
use Koha::Patron::MessagePreferences; |
|
|
65 |
use Koha::Patron::AccountLinks; |
| 65 |
use Koha::Patron::Relationships; |
66 |
use Koha::Patron::Relationships; |
| 66 |
use Koha::Patron::Restrictions; |
67 |
use Koha::Patron::Restrictions; |
| 67 |
use Koha::Patrons; |
68 |
use Koha::Patrons; |
|
Lines 639-644
sub relationships_debt {
Link Here
|
| 639 |
return $non_issues_charges; |
640 |
return $non_issues_charges; |
| 640 |
} |
641 |
} |
| 641 |
|
642 |
|
|
|
643 |
=head3 account_link |
| 644 |
|
| 645 |
Returns the Koha::Patron::AccountLink for this patron, or undef if not linked |
| 646 |
|
| 647 |
=cut |
| 648 |
|
| 649 |
sub account_link { |
| 650 |
my ($self) = @_; |
| 651 |
return Koha::Patron::AccountLinks->find( { borrowernumber => $self->borrowernumber } ); |
| 652 |
} |
| 653 |
|
| 654 |
=head3 linked_accounts |
| 655 |
|
| 656 |
Returns Koha::Patrons of all linked accounts (excluding self) |
| 657 |
|
| 658 |
=cut |
| 659 |
|
| 660 |
sub linked_accounts { |
| 661 |
my ($self) = @_; |
| 662 |
|
| 663 |
my $link = $self->account_link; |
| 664 |
return Koha::Patrons->new->empty unless $link; |
| 665 |
|
| 666 |
return $link->linked_patrons; |
| 667 |
} |
| 668 |
|
| 669 |
=head3 all_linked_borrowernumbers |
| 670 |
|
| 671 |
Returns arrayref of all borrowernumbers in the link group (including self) |
| 672 |
|
| 673 |
=cut |
| 674 |
|
| 675 |
sub all_linked_borrowernumbers { |
| 676 |
my ($self) = @_; |
| 677 |
|
| 678 |
my $link = $self->account_link; |
| 679 |
return [ $self->borrowernumber ] unless $link; |
| 680 |
|
| 681 |
return $link->all_linked_borrowernumbers; |
| 682 |
} |
| 683 |
|
| 684 |
=head3 linked_accounts_debt |
| 685 |
|
| 686 |
Returns total non_issues_charges across all linked accounts |
| 687 |
|
| 688 |
=cut |
| 689 |
|
| 690 |
sub linked_accounts_debt { |
| 691 |
my ($self) = @_; |
| 692 |
|
| 693 |
my $total = 0; |
| 694 |
my $link = $self->account_link; |
| 695 |
return $total unless $link; |
| 696 |
|
| 697 |
my $linked = Koha::Patron::AccountLinks->search( { link_group_id => $link->link_group_id } ); |
| 698 |
|
| 699 |
while ( my $l = $linked->next ) { |
| 700 |
my $patron = Koha::Patrons->find( $l->borrowernumber ); |
| 701 |
$total += $patron->account->non_issues_charges if $patron; |
| 702 |
} |
| 703 |
|
| 704 |
return $total; |
| 705 |
} |
| 706 |
|
| 642 |
=head3 housebound_profile |
707 |
=head3 housebound_profile |
| 643 |
|
708 |
|
| 644 |
Returns the HouseboundProfile associated with this patron. |
709 |
Returns the HouseboundProfile associated with this patron. |
|
Lines 3509-3515
sub can_checkout {
Link Here
|
| 3509 |
$status->{can_checkout} = 0 |
3574 |
$status->{can_checkout} = 0 |
| 3510 |
if $patron_charge_limits->{noissuescharge}->{overlimit} |
3575 |
if $patron_charge_limits->{noissuescharge}->{overlimit} |
| 3511 |
|| $patron_charge_limits->{NoIssuesChargeGuarantees}->{overlimit} |
3576 |
|| $patron_charge_limits->{NoIssuesChargeGuarantees}->{overlimit} |
| 3512 |
|| $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit}; |
3577 |
|| $patron_charge_limits->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit} |
|
|
3578 |
|| $patron_charge_limits->{NoIssuesChargeLinkedAccounts}->{overlimit}; |
| 3513 |
|
3579 |
|
| 3514 |
return $status; |
3580 |
return $status; |
| 3515 |
} |
3581 |
} |
|
Lines 3576-3581
sub is_patron_inside_charge_limits {
Link Here
|
| 3576 |
if $no_issues_charge_guarantors_with_guarantees |
3642 |
if $no_issues_charge_guarantors_with_guarantees |
| 3577 |
&& $guarantors_non_issues_charges > $no_issues_charge_guarantors_with_guarantees; |
3643 |
&& $guarantors_non_issues_charges > $no_issues_charge_guarantors_with_guarantees; |
| 3578 |
|
3644 |
|
|
|
3645 |
my $no_issues_charge_linked = C4::Context->preference('NoIssuesChargeLinkedAccounts'); |
| 3646 |
my $linked_non_issues_charges = 0; |
| 3647 |
|
| 3648 |
if ( C4::Context->preference('EnablePatronAccountLinking') |
| 3649 |
&& defined $no_issues_charge_linked |
| 3650 |
&& looks_like_number($no_issues_charge_linked) ) |
| 3651 |
{ |
| 3652 |
$linked_non_issues_charges = $patron->linked_accounts_debt(); |
| 3653 |
} |
| 3654 |
|
| 3655 |
$patron_charge_limits->{NoIssuesChargeLinkedAccounts} = { |
| 3656 |
limit => $no_issues_charge_linked, |
| 3657 |
charge => $linked_non_issues_charges, |
| 3658 |
overlimit => 0 |
| 3659 |
}; |
| 3660 |
$patron_charge_limits->{NoIssuesChargeLinkedAccounts}->{overlimit} = 1 |
| 3661 |
if $no_issues_charge_linked |
| 3662 |
&& $linked_non_issues_charges > $no_issues_charge_linked; |
| 3663 |
|
| 3579 |
return $patron_charge_limits; |
3664 |
return $patron_charge_limits; |
| 3580 |
} |
3665 |
} |
| 3581 |
|
3666 |
|
| 3582 |
- |
|
|