- my $type = $accountline->amount < 0 ? 'credit' : 'debit';
- my $column = $type eq 'credit' ? 'credit_id' : 'debit_id';
-
- my @account_offsets = Koha::Account::Offsets->search( { $column => $accountlines_id } );
+ my $account_offsets = Koha::Account::Offsets->search(
+ [
+ {
+ credit_id => $accountline->accountlines_id
+ },
+ {
+ debit_id => $accountline->accountlines_id
+ }
+ ],
+ { order_by => 'created_on' }
+ );