|
Lines 85-98
sub pay {
Link Here
|
| 85 |
my $patron = Koha::Patrons->find( $self->{patron_id} ); |
85 |
my $patron = Koha::Patrons->find( $self->{patron_id} ); |
| 86 |
|
86 |
|
| 87 |
# We should remove accountno, it is no longer needed |
87 |
# We should remove accountno, it is no longer needed |
| 88 |
my $last = Koha::Account::Lines->search( |
88 |
my $last = $self->lines->search( |
| 89 |
{ |
89 |
{}, |
| 90 |
borrowernumber => $self->{patron_id} |
90 |
{ order_by => 'accountno' } )->next(); |
| 91 |
}, |
|
|
| 92 |
{ |
| 93 |
order_by => 'accountno' |
| 94 |
} |
| 95 |
)->next(); |
| 96 |
my $accountno = $last ? $last->accountno + 1 : 1; |
91 |
my $accountno = $last ? $last->accountno + 1 : 1; |
| 97 |
|
92 |
|
| 98 |
my $manager_id = $userenv ? $userenv->{number} : 0; |
93 |
my $manager_id = $userenv ? $userenv->{number} : 0; |
|
Lines 156-164
sub pay {
Link Here
|
| 156 |
# than the what was owed on the given line. In that case pay down other |
151 |
# than the what was owed on the given line. In that case pay down other |
| 157 |
# lines with remaining balance. |
152 |
# lines with remaining balance. |
| 158 |
my @outstanding_fines; |
153 |
my @outstanding_fines; |
| 159 |
@outstanding_fines = Koha::Account::Lines->search( |
154 |
@outstanding_fines = $self->lines->search( |
| 160 |
{ |
155 |
{ |
| 161 |
borrowernumber => $self->{patron_id}, |
|
|
| 162 |
amountoutstanding => { '>' => 0 }, |
156 |
amountoutstanding => { '>' => 0 }, |
| 163 |
} |
157 |
} |
| 164 |
) if $balance_remaining > 0; |
158 |
) if $balance_remaining > 0; |
|
Lines 350-356
sub add_credit {
Link Here
|
| 350 |
$schema->txn_do( |
344 |
$schema->txn_do( |
| 351 |
sub { |
345 |
sub { |
| 352 |
# We should remove accountno, it is no longer needed |
346 |
# We should remove accountno, it is no longer needed |
| 353 |
my $last = Koha::Account::Lines->search( { borrowernumber => $self->{patron_id} }, |
347 |
my $last = $self->lines->search( |
|
|
348 |
{}, |
| 354 |
{ order_by => 'accountno' } )->next(); |
349 |
{ order_by => 'accountno' } )->next(); |
| 355 |
my $accountno = $last ? $last->accountno + 1 : 1; |
350 |
my $accountno = $last ? $last->accountno + 1 : 1; |
| 356 |
|
351 |
|
|
Lines 421-431
Return the balance (sum of amountoutstanding columns)
Link Here
|
| 421 |
|
416 |
|
| 422 |
sub balance { |
417 |
sub balance { |
| 423 |
my ($self) = @_; |
418 |
my ($self) = @_; |
| 424 |
return Koha::Account::Lines->search( |
419 |
return $self->lines->total_outstanding; |
| 425 |
{ |
|
|
| 426 |
borrowernumber => $self->{patron_id}, |
| 427 |
} |
| 428 |
)->total_outstanding; |
| 429 |
} |
420 |
} |
| 430 |
|
421 |
|
| 431 |
=head3 outstanding_debits |
422 |
=head3 outstanding_debits |
|
Lines 437-445
my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_debits;
Link Here
|
| 437 |
sub outstanding_debits { |
428 |
sub outstanding_debits { |
| 438 |
my ($self) = @_; |
429 |
my ($self) = @_; |
| 439 |
|
430 |
|
| 440 |
my $lines = Koha::Account::Lines->search( |
431 |
my $lines = $self->lines->search( |
| 441 |
{ |
432 |
{ |
| 442 |
borrowernumber => $self->{patron_id}, |
|
|
| 443 |
amountoutstanding => { '>' => 0 } |
433 |
amountoutstanding => { '>' => 0 } |
| 444 |
} |
434 |
} |
| 445 |
); |
435 |
); |
|
Lines 456-464
my $lines = Koha::Account->new({ patron_id => $patron_id })->outstanding_credits
Link Here
|
| 456 |
sub outstanding_credits { |
446 |
sub outstanding_credits { |
| 457 |
my ($self) = @_; |
447 |
my ($self) = @_; |
| 458 |
|
448 |
|
| 459 |
my $lines = Koha::Account::Lines->search( |
449 |
my $lines = $self->lines->search( |
| 460 |
{ |
450 |
{ |
| 461 |
borrowernumber => $self->{patron_id}, |
|
|
| 462 |
amountoutstanding => { '<' => 0 } |
451 |
amountoutstanding => { '<' => 0 } |
| 463 |
} |
452 |
} |
| 464 |
); |
453 |
); |
|
Lines 501-509
sub non_issues_charges {
Link Here
|
| 501 |
} |
490 |
} |
| 502 |
@not_fines = map { substr( $_, 0, $ACCOUNT_TYPE_LENGTH ) } uniq(@not_fines); |
491 |
@not_fines = map { substr( $_, 0, $ACCOUNT_TYPE_LENGTH ) } uniq(@not_fines); |
| 503 |
|
492 |
|
| 504 |
return Koha::Account::Lines->search( |
493 |
return $self->lines->search( |
| 505 |
{ |
494 |
{ |
| 506 |
borrowernumber => $self->{patron_id}, |
|
|
| 507 |
accounttype => { -not_in => \@not_fines } |
495 |
accounttype => { -not_in => \@not_fines } |
| 508 |
}, |
496 |
}, |
| 509 |
)->total_outstanding; |
497 |
)->total_outstanding; |
| 510 |
- |
|
|