Lines 108-119
sub chargelostitem{
Link Here
|
108 |
if ($usedefaultreplacementcost && $amount == 0 && $defaultreplacecost){ |
108 |
if ($usedefaultreplacementcost && $amount == 0 && $defaultreplacecost){ |
109 |
$replacementprice = $defaultreplacecost; |
109 |
$replacementprice = $defaultreplacecost; |
110 |
} |
110 |
} |
|
|
111 |
|
112 |
my $account = Koha::Account->new({ patron_d => $borrowernumber } ); |
111 |
# first make sure the borrower hasn't already been charged for this item |
113 |
# first make sure the borrower hasn't already been charged for this item |
112 |
# FIXME this should be more exact |
114 |
# FIXME this should be more exact |
113 |
# there is no reason a user can't lose an item, find and return it, and lost it again |
115 |
# there is no reason a user can't lose an item, find and return it, and lost it again |
114 |
my $existing_charges = Koha::Account::Lines->search( |
116 |
my $existing_charges = $account->lines->search( |
115 |
{ |
117 |
{ |
116 |
borrowernumber => $borrowernumber, |
|
|
117 |
itemnumber => $itemnumber, |
118 |
itemnumber => $itemnumber, |
118 |
accounttype => 'L', |
119 |
accounttype => 'L', |
119 |
} |
120 |
} |
Lines 123-204
sub chargelostitem{
Link Here
|
123 |
unless ($existing_charges) { |
124 |
unless ($existing_charges) { |
124 |
#add processing fee |
125 |
#add processing fee |
125 |
if ($processfee && $processfee > 0){ |
126 |
if ($processfee && $processfee > 0){ |
126 |
my $accountline = Koha::Account::Line->new( |
127 |
my $accountline = $account->add_debit( |
127 |
{ |
|
|
128 |
borrowernumber => $borrowernumber, |
129 |
accountno => getnextacctno($borrowernumber), |
130 |
date => \'NOW()', |
131 |
amount => $processfee, |
132 |
description => $description, |
133 |
accounttype => 'PF', |
134 |
amountoutstanding => $processfee, |
135 |
itemnumber => $itemnumber, |
136 |
note => $processingfeenote, |
137 |
manager_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : 0, |
138 |
} |
139 |
)->store(); |
140 |
|
141 |
my $account_offset = Koha::Account::Offset->new( |
142 |
{ |
128 |
{ |
143 |
debit_id => $accountline->id, |
129 |
amount => $processfee, |
144 |
type => 'Processing Fee', |
130 |
description => $description, |
145 |
amount => $accountline->amount, |
131 |
note => $processingfeenote, |
|
|
132 |
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : 0, |
133 |
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, |
134 |
type => 'processing', |
135 |
item_id => $itemnumber, |
146 |
} |
136 |
} |
147 |
)->store(); |
137 |
); |
148 |
|
|
|
149 |
if ( C4::Context->preference("FinesLog") ) { |
150 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
151 |
action => 'create_fee', |
152 |
borrowernumber => $accountline->borrowernumber,, |
153 |
accountno => $accountline->accountno, |
154 |
amount => $accountline->amount, |
155 |
description => $accountline->description, |
156 |
accounttype => $accountline->accounttype, |
157 |
amountoutstanding => $accountline->amountoutstanding, |
158 |
note => $accountline->note, |
159 |
itemnumber => $accountline->itemnumber, |
160 |
manager_id => $accountline->manager_id, |
161 |
})); |
162 |
} |
163 |
} |
138 |
} |
164 |
#add replace cost |
139 |
#add replace cost |
165 |
if ($replacementprice > 0){ |
140 |
if ($replacementprice > 0){ |
166 |
my $accountline = Koha::Account::Line->new( |
141 |
my $accountline = $account->add_debit( |
167 |
{ |
|
|
168 |
borrowernumber => $borrowernumber, |
169 |
accountno => getnextacctno($borrowernumber), |
170 |
date => \'NOW()', |
171 |
amount => $replacementprice, |
172 |
description => $description, |
173 |
accounttype => 'L', |
174 |
amountoutstanding => $replacementprice, |
175 |
itemnumber => $itemnumber, |
176 |
manager_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : 0, |
177 |
} |
178 |
)->store(); |
179 |
|
180 |
my $account_offset = Koha::Account::Offset->new( |
181 |
{ |
142 |
{ |
182 |
debit_id => $accountline->id, |
143 |
amount => $replacementprice, |
183 |
type => 'Lost Item', |
144 |
description => $description, |
184 |
amount => $accountline->amount, |
145 |
note => undef, |
|
|
146 |
user_id => C4::Context->userenv ? C4::Context->userenv->{'number'} : 0, |
147 |
library_id => C4::Context->userenv ? C4::Context->userenv->{'branch'} : undef, |
148 |
type => 'lost_item', |
149 |
item_id => $itemnumber, |
185 |
} |
150 |
} |
186 |
)->store(); |
151 |
); |
187 |
|
|
|
188 |
if ( C4::Context->preference("FinesLog") ) { |
189 |
logaction("FINES", 'CREATE',$borrowernumber,Dumper({ |
190 |
action => 'create_fee', |
191 |
borrowernumber => $accountline->borrowernumber,, |
192 |
accountno => $accountline->accountno, |
193 |
amount => $accountline->amount, |
194 |
description => $accountline->description, |
195 |
accounttype => $accountline->accounttype, |
196 |
amountoutstanding => $accountline->amountoutstanding, |
197 |
note => $accountline->note, |
198 |
itemnumber => $accountline->itemnumber, |
199 |
manager_id => $accountline->manager_id, |
200 |
})); |
201 |
} |
202 |
} |
152 |
} |
203 |
} |
153 |
} |
204 |
} |
154 |
} |
205 |
- |
|
|