Bug 29757: Add filters for reversable offsets

This patch adds filtering methods for (non)reversable offsets.

To test:
1. Apply this patches
2. Run:
   $ kshell
  k$ prove t/db_dependent/Koha/Account/Offsets.t
=> SUCCESS: Tests pass!
3. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
This commit is contained in:
Martin Renvoize 2021-12-22 16:36:07 -03:00 committed by Fridolin Somers
parent 3eca78a316
commit 31f7efb851

View file

@ -60,6 +60,50 @@ sub total {
: 0; : 0;
} }
=head3 filter_by_non_reversable
=cut
sub filter_by_non_reversable {
my ($self) = @_;
my $me = $self->_resultset()->current_source_alias;
my $where = {
debit_id => { '!=' => undef },
credit_id => { '!=' => undef },
type => 'APPLY',
'credit.credit_type_code' => [ 'WRITEOFF', 'DISCOUNT', 'CANCELLATION' ],
'credit.status' => [ { '!=' => 'VOID' }, undef ],
$me . '.amount' => { '<' => 0 }
};
my $attr = { join => 'credit' };
return $self->search( $where, $attr );
}
=head3 filter_by_reversable
=cut
sub filter_by_reversable {
my ($self) = @_;
my $me = $self->_resultset()->current_source_alias;
my $where = {
debit_id => { '!=' => undef },
credit_id => { '!=' => undef },
type => 'APPLY',
'credit.credit_type_code' => { -not_in => [ 'WRITEOFF', 'DISCOUNT', 'CANCELLATION' ] },
'credit.status' => [ { '!=' => 'VOID' }, undef ],
$me . '.amount' => { '<' => 0 }
};
my $attr = { join => 'credit' };
return $self->search( $where, $attr );
}
=head2 Internal methods =head2 Internal methods
=head3 _type =head3 _type