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