Lines 1187-1244
sub _set_found_trigger {
Link Here
|
1187 |
} |
1187 |
} |
1188 |
} |
1188 |
} |
1189 |
|
1189 |
|
1190 |
# restore fine for lost book |
1190 |
# possibly restore fine for lost book |
1191 |
if ( $lostreturn_policy eq 'restore' ) { |
1191 |
my $lost_overdue = Koha::Account::Lines->search( |
1192 |
my $lost_overdue = Koha::Account::Lines->search( |
1192 |
{ |
1193 |
{ |
1193 |
itemnumber => $self->itemnumber, |
1194 |
itemnumber => $self->itemnumber, |
1194 |
debit_type_code => 'OVERDUE', |
1195 |
debit_type_code => 'OVERDUE', |
1195 |
status => 'LOST' |
1196 |
status => 'LOST' |
1196 |
}, |
1197 |
}, |
1197 |
{ |
1198 |
{ |
1198 |
order_by => { '-desc' => 'date' }, |
1199 |
order_by => { '-desc' => 'date' }, |
1199 |
rows => 1 |
1200 |
rows => 1 |
1200 |
} |
1201 |
} |
1201 |
)->single; |
1202 |
)->single; |
1202 |
if ( $lostreturn_policy eq 'restore' && $lost_overdue ) { |
1203 |
|
|
|
1204 |
if ( $lost_overdue ) { |
1205 |
|
1206 |
my $patron = $lost_overdue->patron; |
1207 |
if ($patron) { |
1208 |
my $account = $patron->account; |
1209 |
|
1203 |
|
1210 |
# Update status of fine |
1204 |
my $patron = $lost_overdue->patron; |
1211 |
$lost_overdue->status('FOUND')->store(); |
1205 |
if ($patron) { |
|
|
1206 |
my $account = $patron->account; |
1212 |
|
1207 |
|
1213 |
# Find related forgive credit |
1208 |
# Update status of fine |
1214 |
my $refund = $lost_overdue->credits( |
1209 |
$lost_overdue->status('FOUND')->store(); |
|
|
1210 |
|
1211 |
# Find related forgive credit |
1212 |
my $refund = $lost_overdue->credits( |
1213 |
{ |
1214 |
credit_type_code => 'FORGIVEN', |
1215 |
itemnumber => $self->itemnumber, |
1216 |
status => [ { '!=' => 'VOID' }, undef ] |
1217 |
}, |
1218 |
{ order_by => { '-desc' => 'date' }, rows => 1 } |
1219 |
)->single; |
1220 |
|
1221 |
if ( $refund ) { |
1222 |
# Revert the forgive credit |
1223 |
$refund->void({ interface => 'trigger' }); |
1224 |
$self->add_message( |
1215 |
{ |
1225 |
{ |
1216 |
credit_type_code => 'FORGIVEN', |
1226 |
type => 'info', |
1217 |
itemnumber => $self->itemnumber, |
1227 |
message => 'lost_restored', |
1218 |
status => [ { '!=' => 'VOID' }, undef ] |
1228 |
payload => { refund_id => $refund->id } |
1219 |
}, |
1229 |
} |
1220 |
{ order_by => { '-desc' => 'date' }, rows => 1 } |
1230 |
); |
1221 |
)->single; |
1231 |
} |
1222 |
|
1232 |
|
1223 |
if ( $refund ) { |
1233 |
# Reconcile balances if required |
1224 |
# Revert the forgive credit |
1234 |
if ( C4::Context->preference('AccountAutoReconcile') ) { |
1225 |
$refund->void({ interface => 'trigger' }); |
1235 |
$account->reconcile_balance; |
1226 |
$self->add_message( |
|
|
1227 |
{ |
1228 |
type => 'info', |
1229 |
message => 'lost_restored', |
1230 |
payload => { refund_id => $refund->id } |
1231 |
} |
1232 |
); |
1233 |
} |
1234 |
|
1235 |
# Reconcile balances if required |
1236 |
if ( C4::Context->preference('AccountAutoReconcile') ) { |
1237 |
$account->reconcile_balance; |
1238 |
} |
1239 |
} |
1236 |
} |
1240 |
} |
1237 |
} |
1241 |
} elsif ( $lostreturn_policy eq 'charge' ) { |
1238 |
|
|
|
1239 |
} elsif ( $lostreturn_policy eq 'charge' && ( $lost_overdue || $lost_charge ) ) { |
1242 |
$self->add_message( |
1240 |
$self->add_message( |
1243 |
{ |
1241 |
{ |
1244 |
type => 'info', |
1242 |
type => 'info', |