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 1119-1127
total amount outstanding for all of the account lines.
Link Here
|
1119 |
|
1119 |
|
1120 |
=cut |
1120 |
=cut |
1121 |
|
1121 |
|
1122 |
#' |
|
|
1123 |
sub GetMemberAccountRecords { |
1122 |
sub GetMemberAccountRecords { |
1124 |
my ($borrowernumber,$date) = @_; |
1123 |
my ($borrowernumber) = @_; |
1125 |
my $dbh = C4::Context->dbh; |
1124 |
my $dbh = C4::Context->dbh; |
1126 |
my @acctlines; |
1125 |
my @acctlines; |
1127 |
my $numlines = 0; |
1126 |
my $numlines = 0; |
Lines 1129-1142
sub GetMemberAccountRecords {
Link Here
|
1129 |
SELECT * |
1128 |
SELECT * |
1130 |
FROM accountlines |
1129 |
FROM accountlines |
1131 |
WHERE borrowernumber=?); |
1130 |
WHERE borrowernumber=?); |
1132 |
my @bind = ($borrowernumber); |
|
|
1133 |
if ($date && $date ne ''){ |
1134 |
$strsth.=" AND date < ? "; |
1135 |
push(@bind,$date); |
1136 |
} |
1137 |
$strsth.=" ORDER BY date desc,timestamp DESC"; |
1131 |
$strsth.=" ORDER BY date desc,timestamp DESC"; |
1138 |
my $sth= $dbh->prepare( $strsth ); |
1132 |
my $sth= $dbh->prepare( $strsth ); |
1139 |
$sth->execute( @bind ); |
1133 |
$sth->execute( $borrowernumber ); |
|
|
1134 |
|
1140 |
my $total = 0; |
1135 |
my $total = 0; |
1141 |
while ( my $data = $sth->fetchrow_hashref ) { |
1136 |
while ( my $data = $sth->fetchrow_hashref ) { |
1142 |
if ( $data->{itemnumber} ) { |
1137 |
if ( $data->{itemnumber} ) { |
Lines 1152-1157
sub GetMemberAccountRecords {
Link Here
|
1152 |
return ( $total, \@acctlines,$numlines); |
1147 |
return ( $total, \@acctlines,$numlines); |
1153 |
} |
1148 |
} |
1154 |
|
1149 |
|
|
|
1150 |
=head2 GetMemberAccountBallance |
1151 |
|
1152 |
($total_ballance, $non_issue_ballance, $other_charges) = &GetMemberAccountBallance($borrowernumber); |
1153 |
|
1154 |
Calculates amount immediately owing by the patron - non-issue charges. |
1155 |
Based on GetMemberAccountRecords. |
1156 |
Charges exempt from non-issue are: |
1157 |
* Res (reserves) |
1158 |
* Rent (rental) if RentalsInNoissueCharges syspref is set to false |
1159 |
* Manual invoices if ManInvInNoissueCharges syspref is set to false |
1160 |
|
1161 |
=cut |
1162 |
|
1163 |
my $ACCOUNT_TYPE_LENGTH = 5; # this is plain ridiculous... |
1164 |
|
1165 |
my @not_fines = ('Res'); |
1166 |
push @not_fines, 'Rent' unless C4::Context->preference('RentalsInNoissueCharges'); |
1167 |
unless ( C4::Context->preference('ManInvInNoissueCharges') ) { |
1168 |
my $dbh = C4::Context->dbh; |
1169 |
my $man_inv_types = $dbh->selectcol_arrayref(qq{SELECT authorised_value FROM authorised_values WHERE category = 'MANUAL_INV'}); |
1170 |
push @not_fines, map substr($_, 0, $ACCOUNT_TYPE_LENGTH), @$man_inv_types; |
1171 |
} |
1172 |
my %not_fine = map {$_ => 1} @not_fines; |
1173 |
|
1174 |
sub GetMemberAccountBallance { |
1175 |
my ($borrowernumber) = @_; |
1176 |
|
1177 |
my ($total, $acctlines) = GetMemberAccountRecords($borrowernumber); |
1178 |
my $other_charges = 0; |
1179 |
foreach (@$acctlines) { |
1180 |
$other_charges += $_->{amountoutstanding} if $not_fine{ substr($_->{accounttype}, 0, $ACCOUNT_TYPE_LENGTH) }; |
1181 |
} |
1182 |
|
1183 |
return ( $total, $total - $other_charges, $other_charges); |
1184 |
} |
1185 |
|
1155 |
=head2 GetBorNotifyAcctRecord |
1186 |
=head2 GetBorNotifyAcctRecord |
1156 |
|
1187 |
|
1157 |
($total, $acctlines, $count) = &GetBorNotifyAcctRecord($params,$notifyid); |
1188 |
($total, $acctlines, $count) = &GetBorNotifyAcctRecord($params,$notifyid); |