Lines 430-450
sub patronflags {
Link Here
|
430 |
my %flags; |
430 |
my %flags; |
431 |
my ( $patroninformation) = @_; |
431 |
my ( $patroninformation) = @_; |
432 |
my $dbh=C4::Context->dbh; |
432 |
my $dbh=C4::Context->dbh; |
433 |
my ($amount) = GetMemberAccountRecords( $patroninformation->{'borrowernumber'}); |
433 |
my ($ballance, $owing) = GetMemberAccountBallance( $patroninformation->{'borrowernumber'}); |
434 |
if ( $amount > 0 ) { |
434 |
if ( $owing > 0 ) { |
435 |
my %flaginfo; |
435 |
my %flaginfo; |
436 |
my $noissuescharge = C4::Context->preference("noissuescharge") || 5; |
436 |
my $noissuescharge = C4::Context->preference("noissuescharge") || 5; |
437 |
$flaginfo{'message'} = sprintf "Patron owes \$%.02f", $amount; |
437 |
$flaginfo{'message'} = sprintf "Patron owes \$%.02f", $owing; |
438 |
$flaginfo{'amount'} = sprintf "%.02f", $amount; |
438 |
$flaginfo{'amount'} = sprintf "%.02f", $owing; |
439 |
if ( $amount > $noissuescharge && !C4::Context->preference("AllowFineOverride") ) { |
439 |
if ( $owing > $noissuescharge && !C4::Context->preference("AllowFineOverride") ) { |
440 |
$flaginfo{'noissues'} = 1; |
440 |
$flaginfo{'noissues'} = 1; |
441 |
} |
441 |
} |
442 |
$flags{'CHARGES'} = \%flaginfo; |
442 |
$flags{'CHARGES'} = \%flaginfo; |
443 |
} |
443 |
} |
444 |
elsif ( $amount < 0 ) { |
444 |
elsif ( $ballance < 0 ) { |
445 |
my %flaginfo; |
445 |
my %flaginfo; |
446 |
$flaginfo{'message'} = sprintf "Patron has credit of \$%.02f", -$amount; |
446 |
$flaginfo{'message'} = sprintf "Patron has credit of \$%.02f", -$ballance; |
447 |
$flaginfo{'amount'} = sprintf "%.02f", $amount; |
447 |
$flaginfo{'amount'} = sprintf "%.02f", $ballance; |
448 |
$flags{'CREDITS'} = \%flaginfo; |
448 |
$flags{'CREDITS'} = \%flaginfo; |
449 |
} |
449 |
} |
450 |
if ( $patroninformation->{'gonenoaddress'} |
450 |
if ( $patroninformation->{'gonenoaddress'} |
Lines 1112-1120
total amount outstanding for all of the account lines.
Link Here
|
1112 |
|
1112 |
|
1113 |
=cut |
1113 |
=cut |
1114 |
|
1114 |
|
1115 |
#' |
|
|
1116 |
sub GetMemberAccountRecords { |
1115 |
sub GetMemberAccountRecords { |
1117 |
my ($borrowernumber,$date) = @_; |
1116 |
my ($borrowernumber) = @_; |
1118 |
my $dbh = C4::Context->dbh; |
1117 |
my $dbh = C4::Context->dbh; |
1119 |
my @acctlines; |
1118 |
my @acctlines; |
1120 |
my $numlines = 0; |
1119 |
my $numlines = 0; |
Lines 1122-1135
sub GetMemberAccountRecords {
Link Here
|
1122 |
SELECT * |
1121 |
SELECT * |
1123 |
FROM accountlines |
1122 |
FROM accountlines |
1124 |
WHERE borrowernumber=?); |
1123 |
WHERE borrowernumber=?); |
1125 |
my @bind = ($borrowernumber); |
|
|
1126 |
if ($date && $date ne ''){ |
1127 |
$strsth.=" AND date < ? "; |
1128 |
push(@bind,$date); |
1129 |
} |
1130 |
$strsth.=" ORDER BY date desc,timestamp DESC"; |
1124 |
$strsth.=" ORDER BY date desc,timestamp DESC"; |
1131 |
my $sth= $dbh->prepare( $strsth ); |
1125 |
my $sth= $dbh->prepare( $strsth ); |
1132 |
$sth->execute( @bind ); |
1126 |
$sth->execute( $borrowernumber ); |
|
|
1127 |
|
1133 |
my $total = 0; |
1128 |
my $total = 0; |
1134 |
while ( my $data = $sth->fetchrow_hashref ) { |
1129 |
while ( my $data = $sth->fetchrow_hashref ) { |
1135 |
if ( $data->{itemnumber} ) { |
1130 |
if ( $data->{itemnumber} ) { |
Lines 1145-1150
sub GetMemberAccountRecords {
Link Here
|
1145 |
return ( $total, \@acctlines,$numlines); |
1140 |
return ( $total, \@acctlines,$numlines); |
1146 |
} |
1141 |
} |
1147 |
|
1142 |
|
|
|
1143 |
=head2 GetMemberAccountBallance |
1144 |
|
1145 |
($total_ballance, $non_issue_ballance, $other_charges) = &GetMemberAccountBallance($borrowernumber); |
1146 |
|
1147 |
Calculates amount immediately owing by the patron - non-issue charges. |
1148 |
Based on GetMemberAccountRecords. |
1149 |
Charges exempt from non-issue are: |
1150 |
* Res (reserves) |
1151 |
* Rent (rental) if RentalsInNoissueCharges syspref is set to false |
1152 |
* Manual invoices if ManInvInNoissueCharges syspref is set to false |
1153 |
|
1154 |
=cut |
1155 |
|
1156 |
my $ACCOUNT_TYPE_LENGTH = 5; # this is plain ridiculous... |
1157 |
|
1158 |
my @not_fines = ('Res'); |
1159 |
push @not_fines, 'Rent' unless C4::Context->preference('RentalsInNoissueCharges'); |
1160 |
unless ( C4::Context->preference('ManInvInNoissueCharges') ) { |
1161 |
my $dbh = C4::Context->dbh; |
1162 |
my $man_inv_types = $dbh->selectcol_arrayref(qq{SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'}); |
1163 |
push @not_fines, map substr($_, 0, $ACCOUNT_TYPE_LENGTH), @$man_inv_types; |
1164 |
} |
1165 |
my %not_fine = map {$_ => 1} @not_fines; |
1166 |
|
1167 |
sub GetMemberAccountBallance { |
1168 |
my ($borrowernumber) = @_; |
1169 |
|
1170 |
my ($total, $acctlines) = GetMemberAccountRecords($borrowernumber); |
1171 |
my $other_charges = 0; |
1172 |
foreach (@$acctlines) { |
1173 |
$other_charges += $_->{amountoutstanding} if $not_fine{ substr($_->{accounttype}, 0, $ACCOUNT_TYPE_LENGTH) }; |
1174 |
} |
1175 |
|
1176 |
return ( $total, $total - $other_charges, $other_charges); |
1177 |
} |
1178 |
|
1148 |
=head2 GetBorNotifyAcctRecord |
1179 |
=head2 GetBorNotifyAcctRecord |
1149 |
|
1180 |
|
1150 |
($total, $acctlines, $count) = &GetBorNotifyAcctRecord($params,$notifyid); |
1181 |
($total, $acctlines, $count) = &GetBorNotifyAcctRecord($params,$notifyid); |