Bug 26593: Remove _get_discount_from_rule
authorNick Clemens <nick@bywatersolutions.com>
Thu, 19 Nov 2020 15:46:52 +0000 (15:46 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 12 Jan 2021 10:17:37 +0000 (11:17 +0100)
commitc055685ac4f59b2a83730c67792c6fb3c81d2123
tree70ac0d86f8164b7059ce273d5b31c9e130d2eff6
parent3af9563a4f52e050461942e4f25c7e9e4918f3d0
Bug 26593: Remove _get_discount_from_rule

This patch remove the private sub used in GetIssuingCharges in favor
of get_effective_rule

It corrects the wrong precedence for rules and adds tests to cover this
subroutine

NOTE: the 'branch' for the discount will be determined by the signed in branch,
    this is a bug to be fixed in the future

To test:
1 - Define a rentalcharge for an itemtype
2 - Define a 10% discount for library A, category A, all itemtypes
3 - Define a 50% discount for all libraries, category A, same itemtype
4 - Attempt to checkout an item from library A of the matching itemtype
5 - The 50% discount is applied
6 - Apply patches
7 - Attempt to checkout an item from library A of the matching itemtype
8 - The 10% discount is applied

prove -v t/db_dependent/Circulation.t

Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/Circulation.pm
t/db_dependent/Circulation.t