Lines 236-242
sub store {
Link Here
|
236 |
|
236 |
|
237 |
$self = $self->SUPER::store; |
237 |
$self = $self->SUPER::store; |
238 |
|
238 |
|
239 |
$self->add_enrolment_fee_if_needed; |
239 |
$self->add_enrolment_fee_if_needed(0); |
240 |
|
240 |
|
241 |
logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" ) |
241 |
logaction( "MEMBERS", "CREATE", $self->borrowernumber, "" ) |
242 |
if C4::Context->preference("BorrowersLog"); |
242 |
if C4::Context->preference("BorrowersLog"); |
Lines 258-264
sub store {
Link Here
|
258 |
and $self->category->categorycode ne |
258 |
and $self->category->categorycode ne |
259 |
$self_from_storage->category->categorycode ) |
259 |
$self_from_storage->category->categorycode ) |
260 |
{ |
260 |
{ |
261 |
$self->add_enrolment_fee_if_needed; |
261 |
$self->add_enrolment_fee_if_needed(1); |
262 |
} |
262 |
} |
263 |
|
263 |
|
264 |
# Actionlogs |
264 |
# Actionlogs |
Lines 751-757
sub renew_account {
Link Here
|
751 |
$self->date_renewed( dt_from_string() ); |
751 |
$self->date_renewed( dt_from_string() ); |
752 |
$self->store(); |
752 |
$self->store(); |
753 |
|
753 |
|
754 |
$self->add_enrolment_fee_if_needed; |
754 |
$self->add_enrolment_fee_if_needed(1); |
755 |
|
755 |
|
756 |
logaction( "MEMBERS", "RENEW", $self->borrowernumber, "Membership renewed" ) if C4::Context->preference("BorrowersLog"); |
756 |
logaction( "MEMBERS", "RENEW", $self->borrowernumber, "Membership renewed" ) if C4::Context->preference("BorrowersLog"); |
757 |
return dt_from_string( $expiry_date )->truncate( to => 'day' ); |
757 |
return dt_from_string( $expiry_date )->truncate( to => 'day' ); |
Lines 875-897
sub article_requests_finished {
Link Here
|
875 |
|
875 |
|
876 |
=head3 add_enrolment_fee_if_needed |
876 |
=head3 add_enrolment_fee_if_needed |
877 |
|
877 |
|
878 |
my $enrolment_fee = $patron->add_enrolment_fee_if_needed; |
878 |
my $enrolment_fee = $patron->add_enrolment_fee_if_needed($renewal); |
879 |
|
879 |
|
880 |
Add enrolment fee for a patron if needed. |
880 |
Add enrolment fee for a patron if needed. |
881 |
|
881 |
|
|
|
882 |
$renewal - boolean denoting whether this is an account renewal or not |
883 |
|
882 |
=cut |
884 |
=cut |
883 |
|
885 |
|
884 |
sub add_enrolment_fee_if_needed { |
886 |
sub add_enrolment_fee_if_needed { |
885 |
my ($self) = @_; |
887 |
my ($self, $renewal) = @_; |
886 |
my $enrolment_fee = $self->category->enrolmentfee; |
888 |
my $enrolment_fee = $self->category->enrolmentfee; |
887 |
if ( $enrolment_fee && $enrolment_fee > 0 ) { |
889 |
if ( $enrolment_fee && $enrolment_fee > 0 ) { |
|
|
890 |
my $type = $renewal ? 'account_renew' : 'account'; |
888 |
$self->account->add_debit( |
891 |
$self->account->add_debit( |
889 |
{ |
892 |
{ |
890 |
amount => $enrolment_fee, |
893 |
amount => $enrolment_fee, |
891 |
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, |
894 |
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : undef, |
892 |
interface => C4::Context->interface, |
895 |
interface => C4::Context->interface, |
893 |
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, |
896 |
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, |
894 |
type => 'account' |
897 |
type => $type |
895 |
} |
898 |
} |
896 |
); |
899 |
); |
897 |
} |
900 |
} |