Lines 231-237
sub store {
Link Here
|
231 |
|
231 |
|
232 |
$self = $self->SUPER::store; |
232 |
$self = $self->SUPER::store; |
233 |
|
233 |
|
234 |
$self->add_enrolment_fee_if_needed; |
234 |
$self->add_enrolment_fee_if_needed(0); |
235 |
|
235 |
|
236 |
logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" ) |
236 |
logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" ) |
237 |
if C4::Context->preference("BorrowersLog"); |
237 |
if C4::Context->preference("BorrowersLog"); |
Lines 253-259
sub store {
Link Here
|
253 |
and $self->category->categorycode ne |
253 |
and $self->category->categorycode ne |
254 |
$self_from_storage->category->categorycode ) |
254 |
$self_from_storage->category->categorycode ) |
255 |
{ |
255 |
{ |
256 |
$self->add_enrolment_fee_if_needed; |
256 |
$self->add_enrolment_fee_if_needed(1); |
257 |
} |
257 |
} |
258 |
|
258 |
|
259 |
# Actionlogs |
259 |
# Actionlogs |
Lines 716-722
sub renew_account {
Link Here
|
716 |
$self->date_renewed( dt_from_string() ); |
716 |
$self->date_renewed( dt_from_string() ); |
717 |
$self->store(); |
717 |
$self->store(); |
718 |
|
718 |
|
719 |
$self->add_enrolment_fee_if_needed; |
719 |
$self->add_enrolment_fee_if_needed(1); |
720 |
|
720 |
|
721 |
logaction( "MEMBERS", "RENEW", $self->borrowernumber, "Membership renewed" ) if C4::Context->preference("BorrowersLog"); |
721 |
logaction( "MEMBERS", "RENEW", $self->borrowernumber, "Membership renewed" ) if C4::Context->preference("BorrowersLog"); |
722 |
return dt_from_string( $expiry_date )->truncate( to => 'day' ); |
722 |
return dt_from_string( $expiry_date )->truncate( to => 'day' ); |
Lines 840-862
sub article_requests_finished {
Link Here
|
840 |
|
840 |
|
841 |
=head3 add_enrolment_fee_if_needed |
841 |
=head3 add_enrolment_fee_if_needed |
842 |
|
842 |
|
843 |
my $enrolment_fee = $patron->add_enrolment_fee_if_needed; |
843 |
my $enrolment_fee = $patron->add_enrolment_fee_if_needed($renewal); |
844 |
|
844 |
|
845 |
Add enrolment fee for a patron if needed. |
845 |
Add enrolment fee for a patron if needed. |
846 |
|
846 |
|
|
|
847 |
$renewal - boolean denoting whether this is an account renewal or not |
848 |
|
847 |
=cut |
849 |
=cut |
848 |
|
850 |
|
849 |
sub add_enrolment_fee_if_needed { |
851 |
sub add_enrolment_fee_if_needed { |
850 |
my ($self) = @_; |
852 |
my ($self, $renewal) = @_; |
851 |
my $enrolment_fee = $self->category->enrolmentfee; |
853 |
my $enrolment_fee = $self->category->enrolmentfee; |
852 |
if ( $enrolment_fee && $enrolment_fee > 0 ) { |
854 |
if ( $enrolment_fee && $enrolment_fee > 0 ) { |
|
|
855 |
my $type = $renewal ? 'account_renew' : 'account'; |
853 |
$self->account->add_debit( |
856 |
$self->account->add_debit( |
854 |
{ |
857 |
{ |
855 |
amount => $enrolment_fee, |
858 |
amount => $enrolment_fee, |
856 |
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, |
859 |
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, |
857 |
interface => C4::Context->interface, |
860 |
interface => C4::Context->interface, |
858 |
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, |
861 |
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, |
859 |
type => 'account' |
862 |
type => $type |
860 |
} |
863 |
} |
861 |
); |
864 |
); |
862 |
} |
865 |
} |