|
Lines 220-226
This method allows updating a debit or credit on a patron's account
Link Here
|
| 220 |
); |
220 |
); |
| 221 |
|
221 |
|
| 222 |
$update_type can be any of: |
222 |
$update_type can be any of: |
| 223 |
- fine_increment |
223 |
- fine_update |
| 224 |
|
224 |
|
| 225 |
Authors Note: The intention here is that this method is only used |
225 |
Authors Note: The intention here is that this method is only used |
| 226 |
to adjust accountlines where the final amount is not yet known/fixed. |
226 |
to adjust accountlines where the final amount is not yet known/fixed. |
|
Lines 236-242
sub adjust {
Link Here
|
| 236 |
my $amount = $params->{amount}; |
236 |
my $amount = $params->{amount}; |
| 237 |
my $update_type = $params->{type}; |
237 |
my $update_type = $params->{type}; |
| 238 |
|
238 |
|
| 239 |
unless ( exists($Koha::Account::Line::offset_type->{$update_type}) ) { |
239 |
unless ( exists($Koha::Account::Line::allowed_update->{$update_type}) ) { |
| 240 |
Koha::Exceptions::Account::UnrecognisedType->throw( |
240 |
Koha::Exceptions::Account::UnrecognisedType->throw( |
| 241 |
error => 'Update type not recognised' |
241 |
error => 'Update type not recognised' |
| 242 |
); |
242 |
); |
|
Lines 258-263
sub adjust {
Link Here
|
| 258 |
my $amount_outstanding_before = $self->amountoutstanding; |
258 |
my $amount_outstanding_before = $self->amountoutstanding; |
| 259 |
my $difference = $amount - $amount_before; |
259 |
my $difference = $amount - $amount_before; |
| 260 |
my $new_outstanding = $amount_outstanding_before + $difference; |
260 |
my $new_outstanding = $amount_outstanding_before + $difference; |
|
|
261 |
my $offset_type = |
| 262 |
substr( $update_type, 0, index( $update_type, '_' ) ) |
| 263 |
. ( $difference > 0 ) ? "_increment" : "_decrement"; |
| 261 |
|
264 |
|
| 262 |
# Catch cases that require patron refunds |
265 |
# Catch cases that require patron refunds |
| 263 |
if ( $new_outstanding < 0 ) { |
266 |
if ( $new_outstanding < 0 ) { |
|
Lines 268-274
sub adjust {
Link Here
|
| 268 |
amount => $new_outstanding * -1, |
271 |
amount => $new_outstanding * -1, |
| 269 |
description => 'Overpayment refund', |
272 |
description => 'Overpayment refund', |
| 270 |
type => 'credit', |
273 |
type => 'credit', |
| 271 |
( $update_type eq 'fine_increment' ? ( item_id => $self->itemnumber ) : ()), |
274 |
( $update_type eq 'fine_update' ? ( item_id => $self->itemnumber ) : ()), |
| 272 |
} |
275 |
} |
| 273 |
); |
276 |
); |
| 274 |
$new_outstanding = 0; |
277 |
$new_outstanding = 0; |
|
Lines 280-286
sub adjust {
Link Here
|
| 280 |
date => \'NOW()', |
283 |
date => \'NOW()', |
| 281 |
amount => $amount, |
284 |
amount => $amount, |
| 282 |
amountoutstanding => $new_outstanding, |
285 |
amountoutstanding => $new_outstanding, |
| 283 |
( $update_type eq 'fine_increment' ? ( lastincrement => $difference ) : ()), |
286 |
( $update_type eq 'fine_update' ? ( lastincrement => $difference ) : ()), |
| 284 |
} |
287 |
} |
| 285 |
)->store(); |
288 |
)->store(); |
| 286 |
|
289 |
|
|
Lines 288-294
sub adjust {
Link Here
|
| 288 |
my $account_offset = Koha::Account::Offset->new( |
291 |
my $account_offset = Koha::Account::Offset->new( |
| 289 |
{ |
292 |
{ |
| 290 |
debit_id => $self->id, |
293 |
debit_id => $self->id, |
| 291 |
type => $Koha::Account::Line::offset_type->{$update_type}, |
294 |
type => $offset_type, |
| 292 |
amount => $difference |
295 |
amount => $difference |
| 293 |
} |
296 |
} |
| 294 |
)->store(); |
297 |
)->store(); |
|
Lines 310-316
sub adjust {
Link Here
|
| 310 |
manager_id => undef, |
313 |
manager_id => undef, |
| 311 |
} |
314 |
} |
| 312 |
) |
315 |
) |
| 313 |
) if ( $update_type eq 'fine_increment' ); |
316 |
) if ( $update_type eq 'fine_update' ); |
| 314 |
} |
317 |
} |
| 315 |
} |
318 |
} |
| 316 |
); |
319 |
); |
|
Lines 358-374
sub _type {
Link Here
|
| 358 |
|
361 |
|
| 359 |
=head2 Name mappings |
362 |
=head2 Name mappings |
| 360 |
|
363 |
|
| 361 |
=head3 $offset_type |
|
|
| 362 |
|
| 363 |
=cut |
| 364 |
|
| 365 |
our $offset_type = { 'fine_increment' => 'Fine Update', }; |
| 366 |
|
| 367 |
=head3 $allowed_update |
364 |
=head3 $allowed_update |
| 368 |
|
365 |
|
| 369 |
=cut |
366 |
=cut |
| 370 |
|
367 |
|
| 371 |
our $allowed_update = { 'fine_increment' => 'FU', }; |
368 |
our $allowed_update = { 'fine_update' => 'FU', }; |
| 372 |
|
369 |
|
| 373 |
=head1 AUTHORS |
370 |
=head1 AUTHORS |
| 374 |
|
371 |
|