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