|
Lines 66-72
sub should_refund {
Link Here
|
| 66 |
my $self = shift; |
66 |
my $self = shift; |
| 67 |
my $params = shift; |
67 |
my $params = shift; |
| 68 |
|
68 |
|
| 69 |
return $self->_effective_branch_rule( $self->_choose_branch( $params ) ); |
69 |
# Options are: |
|
|
70 |
# 'none' - Do not refund |
| 71 |
# 'refund' - Refund only |
| 72 |
# 'restore' - Refund and Restore original fine value |
| 73 |
# 'charge' - Refund and Charge new fine value |
| 74 |
my $rule = $self->_effective_branch_rule( $self->_choose_branch( $params ) ); |
| 75 |
return $rule eq 'none' ? 0 : 1; |
| 76 |
} |
| 77 |
|
| 78 |
=head3 should_restore_fine |
| 79 |
|
| 80 |
Koha::RefundLostItemFeeRules->should_restore() |
| 81 |
|
| 82 |
Returns a boolean telling if the original overdue fee needs to be restored |
| 83 |
given the passed params, and the current rules/sysprefs configuration. |
| 84 |
|
| 85 |
=cut |
| 86 |
|
| 87 |
sub should_restore_fine { |
| 88 |
|
| 89 |
my $self = shift; |
| 90 |
my $params = shift; |
| 91 |
|
| 92 |
my $rule = $self->_effective_branch_rule( $self->_choose_branch( $params ) ); |
| 93 |
return $rule eq 'restore' ? 1 : 0; |
| 94 |
} |
| 95 |
|
| 96 |
=head3 should_charge_fine |
| 97 |
|
| 98 |
Koha::RefundLostItemFeeRules->should_charge_fine() |
| 99 |
|
| 100 |
Returns a boolean telling if a new overdue fee should be chargeed given the |
| 101 |
passed params, and the current rules/sysprefs configuration. |
| 102 |
|
| 103 |
=cut |
| 104 |
|
| 105 |
sub should_charge_fine { |
| 106 |
|
| 107 |
my $self = shift; |
| 108 |
my $params = shift; |
| 109 |
|
| 110 |
my $rule = $self->_effective_branch_rule( $self->_choose_branch( $params ) ); |
| 111 |
return $rule eq 'charge' ? 1 : 0; |
| 70 |
} |
112 |
} |
| 71 |
|
113 |
|
| 72 |
|
114 |
|
|
Lines 89-95
sub _effective_branch_rule {
Link Here
|
| 89 |
branchcode => $branch, |
131 |
branchcode => $branch, |
| 90 |
categorycode => undef, |
132 |
categorycode => undef, |
| 91 |
itemtype => undef, |
133 |
itemtype => undef, |
| 92 |
rule_name => 'refund', |
134 |
rule_name => 'lost_return', |
| 93 |
} |
135 |
} |
| 94 |
)->next(); |
136 |
)->next(); |
| 95 |
|
137 |
|
|
Lines 138-144
sub _choose_branch {
Link Here
|
| 138 |
|
180 |
|
| 139 |
=head3 Koha::RefundLostItemFeeRules->find(); |
181 |
=head3 Koha::RefundLostItemFeeRules->find(); |
| 140 |
|
182 |
|
| 141 |
Inherit from Koha::Objects->find(), but forces rule_name => 'refund' |
183 |
Inherit from Koha::Objects->find(), but forces rule_name => 'lost_return' |
| 142 |
|
184 |
|
| 143 |
=cut |
185 |
=cut |
| 144 |
|
186 |
|
|
Lines 146-152
sub find {
Link Here
|
| 146 |
my ( $self, @pars ) = @_; |
188 |
my ( $self, @pars ) = @_; |
| 147 |
|
189 |
|
| 148 |
if ( ref($pars[0]) eq 'HASH' ) { |
190 |
if ( ref($pars[0]) eq 'HASH' ) { |
| 149 |
$pars[0]->{rule_name} = 'refund'; |
191 |
$pars[0]->{rule_name} = 'lost_return'; |
| 150 |
} |
192 |
} |
| 151 |
|
193 |
|
| 152 |
return $self->SUPER::find(@pars); |
194 |
return $self->SUPER::find(@pars); |
|
Lines 167-179
sub _default_rule {
Link Here
|
| 167 |
branchcode => undef, |
209 |
branchcode => undef, |
| 168 |
categorycode => undef, |
210 |
categorycode => undef, |
| 169 |
itemtype => undef, |
211 |
itemtype => undef, |
| 170 |
rule_name => 'refund', |
212 |
rule_name => 'lost_return', |
| 171 |
} |
213 |
} |
| 172 |
)->next(); |
214 |
)->next(); |
| 173 |
|
215 |
|
| 174 |
return (defined $default_rule) |
216 |
return (defined $default_rule) |
| 175 |
? $default_rule->rule_value |
217 |
? $default_rule->rule_value |
| 176 |
: 1; |
218 |
: 'refund'; |
| 177 |
} |
219 |
} |
| 178 |
|
220 |
|
| 179 |
1; |
221 |
1; |
| 180 |
- |
|
|