Bug 29139: $line->debit_offsets doesn't honor list context
authorTomas Cohen Arazi <tomascohen@theke.io>
Wed, 29 Sep 2021 19:27:04 +0000 (16:27 -0300)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 1 Oct 2021 14:28:55 +0000 (16:28 +0200)
commitfc5c91f53f59af9e4f2ff203ebfd6e10196a1b9d
tree3de691fdfef4b8dec7c7b2033a247f7929f2a9cd
parentedfa6b9ffe808075c00761a204c4dbd9d6ca77b8
Bug 29139: $line->debit_offsets doesn't honor list context

Being based on _new_from_dbic (discussion on bug 28883), makes the
assignment incorrect:

my @account_offsets = $payment->debit_offsets;

This patch explicitly makes the resultset be assigned as a list by
calling *as_list*.

To test:
1. Have UseEmailReceipts disabled
2. Have a patron with a debt of 6
3. Make a payment of 2
=> SUCCESS: All good
4. Enable UseEmailReceipts
5. Repeat 3
=> FAIL: You get something like:

ERROR PROCESSING TEMPLATE: undef error - The method Koha::Account::Offsets->debit is not covered by tests!

Trace begun at /kohadevbox/koha/Koha/Objects.pm line 595
Koha::Objects::AUTOLOAD('Koha::Account::Offsets=HASH(0x561cbe2ac930)') called at input text line 6
eval {...} at input text line 6
eval {...} at input text line 23

6. Apply this patch
7. Repeat 3
=> SUCCESS: It doesn't explode anymore!
8. Sign off :-D

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Koha/Account.pm