my $patron = Koha::Patrons->find( $self->{patron_id} );
# We should remove accountno, it is no longer needed
- my $last = Koha::Account::Lines->search(
- {
- borrowernumber => $self->{patron_id}
- },
- {
- order_by => 'accountno'
- }
- )->next();
+ my $last = $self->lines->search(
+ {},
+ { order_by => 'accountno' } )->next();
my $accountno = $last ? $last->accountno + 1 : 1;
my $manager_id = $userenv ? $userenv->{number} : 0;
# than the what was owed on the given line. In that case pay down other
# lines with remaining balance.
my @outstanding_fines;
- @outstanding_fines = Koha::Account::Lines->search(
+ @outstanding_fines = $self->lines->search(
{
- borrowernumber => $self->{patron_id},
amountoutstanding => { '>' => 0 },
}
) if $balance_remaining > 0;
$schema->txn_do(
sub {
# We should remove accountno, it is no longer needed
- my $last = Koha::Account::Lines->search( { borrowernumber => $self->{patron_id} },
+ my $last = $self->lines->search(
+ {},
{ order_by => 'accountno' } )->next();
my $accountno = $last ? $last->accountno + 1 : 1;
sub balance {
my ($self) = @_;
- return Koha::Account::Lines->search(
- {
- borrowernumber => $self->{patron_id},
- }
- )->total_outstanding;
+ return $self->lines->total_outstanding;
}
=head3 outstanding_debits
sub outstanding_debits {
my ($self) = @_;
- my $lines = Koha::Account::Lines->search(
+ my $lines = $self->lines->search(
{
- borrowernumber => $self->{patron_id},
amountoutstanding => { '>' => 0 }
}
);
sub outstanding_credits {
my ($self) = @_;
- my $lines = Koha::Account::Lines->search(
+ my $lines = $self->lines->search(
{
- borrowernumber => $self->{patron_id},
amountoutstanding => { '<' => 0 }
}
);
}
@not_fines = map { substr( $_, 0, $ACCOUNT_TYPE_LENGTH ) } uniq(@not_fines);
- return Koha::Account::Lines->search(
+ return $self->lines->search(
{
- borrowernumber => $self->{patron_id},
accounttype => { -not_in => \@not_fines }
},
)->total_outstanding;