Bug 24081: Add DISCOUNT to the allowed 'reduce' types
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Thu, 9 Jan 2020 14:14:34 +0000 (14:14 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 4 Mar 2020 14:46:19 +0000 (14:46 +0000)
This patch adds the DISCOUNT type to the handled types list in the
reduce method introduced in bug 23442

Signed-off-by: Michal Denar <black23@gmail.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Koha/Account/Line.pm

index d77e350..546fc84 100644 (file)
@@ -291,6 +291,7 @@ debts.
 Reduction type may be one of:
 
 * REFUND
+* DISCOUNT
 
 Returns the reduction accountline (which will be a credit)
 
@@ -339,14 +340,14 @@ sub reduce {
 "Amount to reduce ($params->{amount}) is higher than original amount ($original)"
     ) unless ( $original >= $params->{amount} );
     my $reduced =
-      $self->credits( { credit_type_code => [ 'REFUND' ] } )->total;
+      $self->credits( { credit_type_code => [ 'DISCOUNT', 'REFUND' ] } )->total;
     Koha::Exceptions::ParameterTooHigh->throw( error =>
 "Combined reduction ($params->{amount} + $reduced) is higher than original amount ("
           . abs($original)
           . ")" )
       unless ( $original >= ( $params->{amount} + abs($reduced) ) );
 
-    my $status = { 'REFUND' => 'REFUNDED' };
+    my $status = { 'REFUND' => 'REFUNDED', 'DISCOUNT' => 'DISCOUNTED' };
 
     my $reduction;
     $self->_result->result_source->schema->txn_do(