Lines 235-241
sub store {
Link Here
|
235 |
|
235 |
|
236 |
$self = $self->SUPER::store; |
236 |
$self = $self->SUPER::store; |
237 |
|
237 |
|
238 |
$self->add_enrolment_fee_if_needed; |
238 |
$self->add_enrolment_fee_if_needed(0); |
239 |
|
239 |
|
240 |
logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" ) |
240 |
logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" ) |
241 |
if C4::Context->preference("BorrowersLog"); |
241 |
if C4::Context->preference("BorrowersLog"); |
Lines 257-263
sub store {
Link Here
|
257 |
and $self->category->categorycode ne |
257 |
and $self->category->categorycode ne |
258 |
$self_from_storage->category->categorycode ) |
258 |
$self_from_storage->category->categorycode ) |
259 |
{ |
259 |
{ |
260 |
$self->add_enrolment_fee_if_needed; |
260 |
$self->add_enrolment_fee_if_needed(1); |
261 |
} |
261 |
} |
262 |
|
262 |
|
263 |
# Actionlogs |
263 |
# Actionlogs |
Lines 723-729
sub renew_account {
Link Here
|
723 |
$self->date_renewed( dt_from_string() ); |
723 |
$self->date_renewed( dt_from_string() ); |
724 |
$self->store(); |
724 |
$self->store(); |
725 |
|
725 |
|
726 |
$self->add_enrolment_fee_if_needed; |
726 |
$self->add_enrolment_fee_if_needed(1); |
727 |
|
727 |
|
728 |
logaction( "MEMBERS", "RENEW", $self->borrowernumber, "Membership renewed" ) if C4::Context->preference("BorrowersLog"); |
728 |
logaction( "MEMBERS", "RENEW", $self->borrowernumber, "Membership renewed" ) if C4::Context->preference("BorrowersLog"); |
729 |
return dt_from_string( $expiry_date )->truncate( to => 'day' ); |
729 |
return dt_from_string( $expiry_date )->truncate( to => 'day' ); |
Lines 847-869
sub article_requests_finished {
Link Here
|
847 |
|
847 |
|
848 |
=head3 add_enrolment_fee_if_needed |
848 |
=head3 add_enrolment_fee_if_needed |
849 |
|
849 |
|
850 |
my $enrolment_fee = $patron->add_enrolment_fee_if_needed; |
850 |
my $enrolment_fee = $patron->add_enrolment_fee_if_needed($renewal); |
851 |
|
851 |
|
852 |
Add enrolment fee for a patron if needed. |
852 |
Add enrolment fee for a patron if needed. |
853 |
|
853 |
|
|
|
854 |
$renewal - boolean denoting whether this is an account renewal or not |
855 |
|
854 |
=cut |
856 |
=cut |
855 |
|
857 |
|
856 |
sub add_enrolment_fee_if_needed { |
858 |
sub add_enrolment_fee_if_needed { |
857 |
my ($self) = @_; |
859 |
my ($self, $renewal) = @_; |
858 |
my $enrolment_fee = $self->category->enrolmentfee; |
860 |
my $enrolment_fee = $self->category->enrolmentfee; |
859 |
if ( $enrolment_fee && $enrolment_fee > 0 ) { |
861 |
if ( $enrolment_fee && $enrolment_fee > 0 ) { |
|
|
862 |
my $type = $renewal ? 'account_renew' : 'account'; |
860 |
$self->account->add_debit( |
863 |
$self->account->add_debit( |
861 |
{ |
864 |
{ |
862 |
amount => $enrolment_fee, |
865 |
amount => $enrolment_fee, |
863 |
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, |
866 |
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, |
864 |
interface => C4::Context->interface, |
867 |
interface => C4::Context->interface, |
865 |
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, |
868 |
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, |
866 |
type => 'account' |
869 |
type => $type |
867 |
} |
870 |
} |
868 |
); |
871 |
); |
869 |
} |
872 |
} |