Browse Source

Bug 6759: Split account creation and renewal charges

Test plan:
1. Enable charging for patron enrolement
2. Add a new patron where the category is charged for
3. Note the charge of type 'Account management fee'
4. Renew the patron
5. Note the next charge of type 'Account management fee'
6. Apply patch
7. Repeat steps 1-6 and note the first charge will be of type 'Account
creation fee' and the second of type 'Account renewal fee'
8. Bonus points, enable 'FeeOnChangePatronCategory' and check that when
changing a patron from a free category to a charged one that a new
'Account renewal fee' is charged.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Maryse Simard <maryse.simard@inlibro.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
remotes/origin/19.11.x
Martin Renvoize 3 years ago
parent
commit
839c095b54
Signed by: martin.renvoize GPG Key ID: 422B469130441A0F
  1. 5
      Koha/Account.pm
  2. 15
      Koha/Patron.pm
  3. 3
      koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc
  4. 2
      koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt
  5. 3
      koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc

5
Koha/Account.pm

@ -433,6 +433,7 @@ $debit_type can be any of:
- lost_item
- new_card
- account
- account_renew
- sundry
- processing
- rent
@ -700,6 +701,7 @@ our $offset_type = {
'payment' => 'Payment',
'writeoff' => 'Writeoff',
'account' => 'Account Fee',
'account_renew' => 'Account Fee',
'reserve' => 'Reserve Fee',
'processing' => 'Processing Fee',
'lost_item' => 'Lost Item',
@ -729,7 +731,8 @@ our $account_type_credit = {
=cut
our $account_type_debit = {
'account' => 'A',
'account' => 'ACCOUNT',
'account_renew' => 'ACCOUNT_RENEW',
'overdue' => 'OVERDUE',
'lost_item' => 'LOST',
'new_card' => 'N',

15
Koha/Patron.pm

@ -236,7 +236,7 @@ sub store {
$self = $self->SUPER::store;
$self->add_enrolment_fee_if_needed;
$self->add_enrolment_fee_if_needed(0);
logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" )
if C4::Context->preference("BorrowersLog");
@ -258,7 +258,7 @@ sub store {
and $self->category->categorycode ne
$self_from_storage->category->categorycode )
{
$self->add_enrolment_fee_if_needed;
$self->add_enrolment_fee_if_needed(1);
}
# Actionlogs
@ -751,7 +751,7 @@ sub renew_account {
$self->date_renewed( dt_from_string() );
$self->store();
$self->add_enrolment_fee_if_needed;
$self->add_enrolment_fee_if_needed(1);
logaction( "MEMBERS", "RENEW", $self->borrowernumber, "Membership renewed" ) if C4::Context->preference("BorrowersLog");
return dt_from_string( $expiry_date )->truncate( to => 'day' );
@ -875,23 +875,26 @@ sub article_requests_finished {
=head3 add_enrolment_fee_if_needed
my $enrolment_fee = $patron->add_enrolment_fee_if_needed;
my $enrolment_fee = $patron->add_enrolment_fee_if_needed($renewal);
Add enrolment fee for a patron if needed.
$renewal - boolean denoting whether this is an account renewal or not
=cut
sub add_enrolment_fee_if_needed {
my ($self) = @_;
my ($self, $renewal) = @_;
my $enrolment_fee = $self->category->enrolmentfee;
if ( $enrolment_fee && $enrolment_fee > 0 ) {
my $type = $renewal ? 'account_renew' : 'account';
$self->account->add_debit(
{
amount => $enrolment_fee,
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef,
interface => C4::Context->interface,
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef,
type => 'account'
type => $type
}
);
}

3
koha-tmpl/intranet-tmpl/prog/en/includes/accounts.inc

@ -3,7 +3,8 @@
[%- CASE 'Pay' -%]<span>Payment
[%- CASE 'N' -%]<span>New card
[%- CASE 'OVERDUE' -%]<span>Fine
[%- CASE 'A' -%]<span>Account management fee
[%- CASE 'ACCOUNT' -%]<span>Account creation fee
[%- CASE 'ACCOUNT_RENEW' -%]<span>Account renewal fee
[%- CASE 'M' -%]<span>Sundry
[%- CASE 'LOST' -%]<span>Lost item
[%- CASE 'W' -%]<span>Writeoff

2
koha-tmpl/intranet-tmpl/prog/en/modules/members/maninvoice.tt

@ -79,7 +79,7 @@
[% INCLUDE 'str/members-menu.inc' %]
[% Asset.js("js/members-menu.js") | $raw %]
<script>
var type_fees = {'LOST':'','OVERDUE':'','A':'','N':'','M':''};
var type_fees = {'LOST':'','OVERDUE':'','ACCOUNT':'','ACCOUNT_RENEW':'','N':'','M':''};
[% FOREACH invoice_types_loo IN invoice_types_loop %]
type_fees['[% invoice_types_loo.authorised_value | html %]'] = "[% invoice_types_loo.lib | html %]";
[% END %]

3
koha-tmpl/opac-tmpl/bootstrap/en/includes/account-table.inc

@ -162,7 +162,8 @@
[%- CASE 'VOID' -%]<span>Voided
[%- CASE 'N' -%]<span>New card
[%- CASE 'OVERDUE' -%]<span>Fine
[%- CASE 'A' -%]<span>Account management fee
[%- CASE 'ACCOUNT' -%]<span>Account creation fee
[%- CASE 'ACCOUNT_RENEW' -%]<span>Account renewal fee
[%- CASE 'M' -%]<span>Sundry
[%- CASE 'LOST' -%]<span>Lost item
[%- CASE 'W' -%]<span>Writeoff

Loading…
Cancel
Save