|
Lines 819-827
sub CanBookBeIssued {
Link Here
|
| 819 |
# |
819 |
# |
| 820 |
# BORROWER STATUS |
820 |
# BORROWER STATUS |
| 821 |
# |
821 |
# |
| 822 |
if ( $patron->category->category_type eq 'X' && ( $item_object->barcode ) ) { |
822 |
my $patron_borrowing_status = $patron->can_borrow({ patron => $patron }); |
| 823 |
|
823 |
if ( $patron->category->category_type eq 'X' && ( $item_object->barcode )) { |
| 824 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
824 |
# stats only borrower -- add entry to statistics table, and return issuingimpossible{STATS} = 1 . |
| 825 |
C4::Stats::UpdateStats( |
825 |
C4::Stats::UpdateStats( |
| 826 |
{ |
826 |
{ |
| 827 |
branch => C4::Context->userenv->{'branch'}, |
827 |
branch => C4::Context->userenv->{'branch'}, |
|
Lines 865-927
sub CanBookBeIssued {
Link Here
|
| 865 |
my $non_issues_charges = $account->non_issues_charges; |
865 |
my $non_issues_charges = $account->non_issues_charges; |
| 866 |
my $other_charges = $balance - $non_issues_charges; |
866 |
my $other_charges = $balance - $non_issues_charges; |
| 867 |
|
867 |
|
| 868 |
my $amountlimit = C4::Context->preference("noissuescharge"); |
|
|
| 869 |
my $allowfineoverride = C4::Context->preference("AllowFineOverride"); |
868 |
my $allowfineoverride = C4::Context->preference("AllowFineOverride"); |
| 870 |
my $allfinesneedoverride = C4::Context->preference("AllFinesNeedOverride"); |
869 |
my $allfinesneedoverride = C4::Context->preference("AllFinesNeedOverride"); |
| 871 |
|
870 |
|
| 872 |
# Check the debt of this patrons guarantees |
871 |
# Check the debt of this patrons guarantees |
| 873 |
my $no_issues_charge_guarantees = C4::Context->preference("NoIssuesChargeGuarantees"); |
872 |
my $no_issues_charge_guarantees = $patron_borrowing_status->{NoIssuesChargeGuarantees}->{limit}; |
| 874 |
$no_issues_charge_guarantees = undef unless looks_like_number( $no_issues_charge_guarantees ); |
873 |
$no_issues_charge_guarantees = undef unless looks_like_number($no_issues_charge_guarantees); |
| 875 |
if ( defined $no_issues_charge_guarantees ) { |
874 |
if ( defined $no_issues_charge_guarantees ) { |
| 876 |
my @guarantees = map { $_->guarantee } $patron->guarantee_relationships->as_list; |
875 |
if ( $patron_borrowing_status->{NoIssuesChargeGuarantees}->{overlimit} && !$inprocess && !$allowfineoverride ) { |
| 877 |
my $guarantees_non_issues_charges = 0; |
876 |
$issuingimpossible{DEBT_GUARANTEES} = $patron_borrowing_status->{NoIssuesChargeGuarantees}->{charge}; |
| 878 |
foreach my $g ( @guarantees ) { |
877 |
} elsif ( $patron_borrowing_status->{NoIssuesChargeGuarantees}->{overlimit} |
| 879 |
$guarantees_non_issues_charges += $g->account->non_issues_charges; |
878 |
&& !$inprocess |
| 880 |
} |
879 |
&& $allowfineoverride ) |
| 881 |
|
880 |
{ |
| 882 |
if ( $guarantees_non_issues_charges > $no_issues_charge_guarantees && !$inprocess && !$allowfineoverride) { |
881 |
$needsconfirmation{DEBT_GUARANTEES} = $patron_borrowing_status->{NoIssuesChargeGuarantees}->{charge}; |
| 883 |
$issuingimpossible{DEBT_GUARANTEES} = $guarantees_non_issues_charges; |
882 |
} elsif ( $allfinesneedoverride |
| 884 |
} elsif ( $guarantees_non_issues_charges > $no_issues_charge_guarantees && !$inprocess && $allowfineoverride) { |
883 |
&& $patron_borrowing_status->{NoIssuesChargeGuarantees}->{charge} > 0 |
| 885 |
$needsconfirmation{DEBT_GUARANTEES} = $guarantees_non_issues_charges; |
884 |
&& !$inprocess ) |
| 886 |
} elsif ( $allfinesneedoverride && $guarantees_non_issues_charges > 0 && $guarantees_non_issues_charges <= $no_issues_charge_guarantees && !$inprocess ) { |
885 |
{ |
| 887 |
$needsconfirmation{DEBT_GUARANTEES} = $guarantees_non_issues_charges; |
886 |
$needsconfirmation{DEBT_GUARANTEES} = $patron_borrowing_status->{NoIssuesChargeGuarantees}->{charge}; |
| 888 |
} |
887 |
} |
| 889 |
} |
888 |
} |
| 890 |
|
889 |
|
| 891 |
# Check the debt of this patrons guarantors *and* the guarantees of those guarantors |
890 |
# Check the debt of this patrons guarantors *and* the guarantees of those guarantors |
| 892 |
my $no_issues_charge_guarantors = C4::Context->preference("NoIssuesChargeGuarantorsWithGuarantees"); |
891 |
my $no_issues_charge_guarantors = $patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{limit}; |
| 893 |
$no_issues_charge_guarantors = undef unless looks_like_number( $no_issues_charge_guarantors ); |
892 |
$no_issues_charge_guarantors = undef unless looks_like_number($no_issues_charge_guarantors); |
| 894 |
if ( defined $no_issues_charge_guarantors ) { |
893 |
if ( defined $no_issues_charge_guarantors ) { |
| 895 |
my $guarantors_non_issues_charges = $patron->relationships_debt({ include_guarantors => 1, only_this_guarantor => 0, include_this_patron => 1 }); |
894 |
if ( $patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit} |
| 896 |
|
895 |
&& !$inprocess |
| 897 |
if ( $guarantors_non_issues_charges > $no_issues_charge_guarantors && !$inprocess && !$allowfineoverride) { |
896 |
&& !$allowfineoverride ) |
| 898 |
$issuingimpossible{DEBT_GUARANTORS} = $guarantors_non_issues_charges; |
897 |
{ |
| 899 |
} elsif ( $guarantors_non_issues_charges > $no_issues_charge_guarantors && !$inprocess && $allowfineoverride) { |
898 |
$issuingimpossible{DEBT_GUARANTORS} = |
| 900 |
$needsconfirmation{DEBT_GUARANTORS} = $guarantors_non_issues_charges; |
899 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{charge}; |
| 901 |
} elsif ( $allfinesneedoverride && $guarantors_non_issues_charges > 0 && $guarantors_non_issues_charges <= $no_issues_charge_guarantors && !$inprocess ) { |
900 |
} elsif ( $patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{overlimit} |
| 902 |
$needsconfirmation{DEBT_GUARANTORS} = $guarantors_non_issues_charges; |
901 |
&& !$inprocess |
|
|
902 |
&& $allowfineoverride ) |
| 903 |
{ |
| 904 |
$needsconfirmation{DEBT_GUARANTORS} = |
| 905 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{charge}; |
| 906 |
} elsif ( $allfinesneedoverride |
| 907 |
&& $patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{charge} > 0 |
| 908 |
&& !$inprocess ) |
| 909 |
{ |
| 910 |
$needsconfirmation{DEBT_GUARANTORS} = |
| 911 |
$patron_borrowing_status->{NoIssuesChargeGuarantorsWithGuarantees}->{charge}; |
| 903 |
} |
912 |
} |
| 904 |
} |
913 |
} |
| 905 |
|
914 |
|
| 906 |
if ( C4::Context->preference("IssuingInProcess") ) { |
915 |
if ( C4::Context->preference("IssuingInProcess") ) { |
| 907 |
if ( $non_issues_charges > $amountlimit && !$inprocess && !$allowfineoverride) { |
916 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$inprocess && !$allowfineoverride ) { |
| 908 |
$issuingimpossible{DEBT} = $non_issues_charges; |
917 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
| 909 |
} elsif ( $non_issues_charges > $amountlimit && !$inprocess && $allowfineoverride) { |
918 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$inprocess && $allowfineoverride ) { |
| 910 |
$needsconfirmation{DEBT} = $non_issues_charges; |
919 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
| 911 |
} elsif ( $allfinesneedoverride && $non_issues_charges > 0 && $non_issues_charges <= $amountlimit && !$inprocess ) { |
920 |
} elsif ( $allfinesneedoverride && $patron_borrowing_status->{noissuescharge}->{charge} > 0 && !$inprocess ) { |
| 912 |
$needsconfirmation{DEBT} = $non_issues_charges; |
921 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
| 913 |
} |
922 |
} |
| 914 |
} |
923 |
} else { |
| 915 |
else { |
924 |
if ( $patron_borrowing_status->{noissuescharge}->{overlimit} && $allowfineoverride ) { |
| 916 |
if ( $non_issues_charges > $amountlimit && $allowfineoverride ) { |
925 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
| 917 |
$needsconfirmation{DEBT} = $non_issues_charges; |
926 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{overlimit} && !$allowfineoverride ) { |
| 918 |
} elsif ( $non_issues_charges > $amountlimit && !$allowfineoverride) { |
927 |
$issuingimpossible{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
| 919 |
$issuingimpossible{DEBT} = $non_issues_charges; |
928 |
} elsif ( $patron_borrowing_status->{noissuescharge}->{charge} > 0 && $allfinesneedoverride ) { |
| 920 |
} elsif ( $non_issues_charges > 0 && $allfinesneedoverride ) { |
929 |
$needsconfirmation{DEBT} = $patron_borrowing_status->{noissuescharge}->{charge}; |
| 921 |
$needsconfirmation{DEBT} = $non_issues_charges; |
|
|
| 922 |
} |
930 |
} |
| 923 |
} |
931 |
} |
| 924 |
|
932 |
|
|
|
933 |
|
| 925 |
if ($balance > 0 && $other_charges > 0) { |
934 |
if ($balance > 0 && $other_charges > 0) { |
| 926 |
$alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges ); |
935 |
$alerts{OTHER_CHARGES} = sprintf( "%.2f", $other_charges ); |
| 927 |
} |
936 |
} |