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