Lines 1265-1322
sub _set_found_trigger {
Link Here
|
1265 |
} |
1265 |
} |
1266 |
} |
1266 |
} |
1267 |
|
1267 |
|
1268 |
# restore fine for lost book |
1268 |
# possibly restore fine for lost book |
1269 |
if ( $lostreturn_policy eq 'restore' ) { |
1269 |
my $lost_overdue = Koha::Account::Lines->search( |
1270 |
my $lost_overdue = Koha::Account::Lines->search( |
1270 |
{ |
1271 |
{ |
1271 |
itemnumber => $self->itemnumber, |
1272 |
itemnumber => $self->itemnumber, |
1272 |
debit_type_code => 'OVERDUE', |
1273 |
debit_type_code => 'OVERDUE', |
1273 |
status => 'LOST' |
1274 |
status => 'LOST' |
1274 |
}, |
1275 |
}, |
1275 |
{ |
1276 |
{ |
1276 |
order_by => { '-desc' => 'date' }, |
1277 |
order_by => { '-desc' => 'date' }, |
1277 |
rows => 1 |
1278 |
rows => 1 |
1278 |
} |
1279 |
} |
1279 |
)->single; |
1280 |
)->single; |
1280 |
if ( $lostreturn_policy eq 'restore' && $lost_overdue ) { |
1281 |
|
|
|
1282 |
if ( $lost_overdue ) { |
1283 |
|
1284 |
my $patron = $lost_overdue->patron; |
1285 |
if ($patron) { |
1286 |
my $account = $patron->account; |
1287 |
|
1281 |
|
1288 |
# Update status of fine |
1282 |
my $patron = $lost_overdue->patron; |
1289 |
$lost_overdue->status('FOUND')->store(); |
1283 |
if ($patron) { |
|
|
1284 |
my $account = $patron->account; |
1290 |
|
1285 |
|
1291 |
# Find related forgive credit |
1286 |
# Update status of fine |
1292 |
my $refund = $lost_overdue->credits( |
1287 |
$lost_overdue->status('FOUND')->store(); |
|
|
1288 |
|
1289 |
# Find related forgive credit |
1290 |
my $refund = $lost_overdue->credits( |
1291 |
{ |
1292 |
credit_type_code => 'FORGIVEN', |
1293 |
itemnumber => $self->itemnumber, |
1294 |
status => [ { '!=' => 'VOID' }, undef ] |
1295 |
}, |
1296 |
{ order_by => { '-desc' => 'date' }, rows => 1 } |
1297 |
)->single; |
1298 |
|
1299 |
if ( $refund ) { |
1300 |
# Revert the forgive credit |
1301 |
$refund->void({ interface => 'trigger' }); |
1302 |
$self->add_message( |
1293 |
{ |
1303 |
{ |
1294 |
credit_type_code => 'FORGIVEN', |
1304 |
type => 'info', |
1295 |
itemnumber => $self->itemnumber, |
1305 |
message => 'lost_restored', |
1296 |
status => [ { '!=' => 'VOID' }, undef ] |
1306 |
payload => { refund_id => $refund->id } |
1297 |
}, |
1307 |
} |
1298 |
{ order_by => { '-desc' => 'date' }, rows => 1 } |
1308 |
); |
1299 |
)->single; |
1309 |
} |
1300 |
|
1310 |
|
1301 |
if ( $refund ) { |
1311 |
# Reconcile balances if required |
1302 |
# Revert the forgive credit |
1312 |
if ( C4::Context->preference('AccountAutoReconcile') ) { |
1303 |
$refund->void({ interface => 'trigger' }); |
1313 |
$account->reconcile_balance; |
1304 |
$self->add_message( |
|
|
1305 |
{ |
1306 |
type => 'info', |
1307 |
message => 'lost_restored', |
1308 |
payload => { refund_id => $refund->id } |
1309 |
} |
1310 |
); |
1311 |
} |
1312 |
|
1313 |
# Reconcile balances if required |
1314 |
if ( C4::Context->preference('AccountAutoReconcile') ) { |
1315 |
$account->reconcile_balance; |
1316 |
} |
1317 |
} |
1314 |
} |
1318 |
} |
1315 |
} |
1319 |
} elsif ( $lostreturn_policy eq 'charge' ) { |
1316 |
|
|
|
1317 |
} elsif ( $lostreturn_policy eq 'charge' && ( $lost_overdue || $lost_charge ) ) { |
1320 |
$self->add_message( |
1318 |
$self->add_message( |
1321 |
{ |
1319 |
{ |
1322 |
type => 'info', |
1320 |
type => 'info', |
1323 |
- |
|
|