[Koha-bugs] [Bug 27946] Add a charge per article request to patron categories configuration

bugzilla-daemon at bugs.koha-community.org bugzilla-daemon at bugs.koha-community.org
Fri Jul 2 16:21:56 CEST 2021


https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=27946

--- Comment #24 from Martin Renvoize <martin.renvoize at ptfs-europe.com> ---
Comment on attachment 122531
  --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=122531
Bug 27946: Add article request fee feature

Review of attachment 122531:
 --> (https://bugs.koha-community.org/bugzilla3/page.cgi?id=splinter.html&bug=27946&attachment=122531)
-----------------------------------------------------------------

::: Koha/ArticleRequest.pm
@@ +103,5 @@
>  
>      $self->status(Koha::ArticleRequest::Status::Canceled);
>      $self->notes($notes) if $notes;
> +    if ( $self->debit_line_id ) {
> +        my $line = Koha::Account::Lines->find( $self->debit_line_id );

Hmm, having looked at this a little more closely now I've read the
concerns/discussion above..

I think we may need to add some additional considerations here.

a) What should happen if a fee was 'Written off' or 'Reduced' (You've taken
care of 'Cancelled' by the looks).
b) We could use the 'reduce' method to cover both cases and allow the passing
of 'CANCELLED' credit type perhaps?

I'm thinking something along the lines of

```
my $refundable = 0;
if ( $line->amount != $line->amountoutstanding ) {
    my $refundable_offsets = Koha::Account::Offsets->search(
        {
            debit_id  => $line->id,
            credit_id => { '!=' => undef }, # Not the debt itself
            type      => { '!=' => [ 'Writeoff', 'Refund', 'Cancellation',
'Discount' ] },
            amount    => { '<' => 0 }    # credits are negative on the DB
    );

    $refundable = ( $refundable_offsets->count > 0 )
        ? $credits_offsets->total * -1    # credits are negative on the DB
        : 0;
    }

    $refundable += $line->amountoutstanding;

    $line->reduce(
        reduction_type => REQUEST_CANCELLATION,
        amount         => $refundable,
        staff_id       => C4::Context->userenv ?
C4::Context->userenv->{'number'} : undef,
        interface      => C4::Context->interface,
        branchcode     => C4::Context->userenv ?
C4::Context->userenv->{'branch'} : undef
    );
}
```

-- 
You are receiving this mail because:
You are watching all bug changes.


More information about the Koha-bugs mailing list