Lines 65-70
Koha::Account->new( { patron_id => $borrowernumber } )->pay(
Link Here
|
65 |
lines => $lines, # Arrayref of Koha::Account::Line objects to pay |
65 |
lines => $lines, # Arrayref of Koha::Account::Line objects to pay |
66 |
credit_type => $type, # credit_type_code code |
66 |
credit_type => $type, # credit_type_code code |
67 |
offset_type => $offset_type, # offset type code |
67 |
offset_type => $offset_type, # offset type code |
|
|
68 |
item_id => $itemnumber, # pass the itemnumber if this is a credit pertianing to a specific item (i.e LOST_FOUND) |
68 |
} |
69 |
} |
69 |
); |
70 |
); |
70 |
|
71 |
|
Lines 83-91
sub pay {
Link Here
|
83 |
my $credit_type = $params->{credit_type}; |
84 |
my $credit_type = $params->{credit_type}; |
84 |
my $offset_type = $params->{offset_type} || $type eq 'WRITEOFF' ? 'Writeoff' : 'Payment'; |
85 |
my $offset_type = $params->{offset_type} || $type eq 'WRITEOFF' ? 'Writeoff' : 'Payment'; |
85 |
my $cash_register = $params->{cash_register}; |
86 |
my $cash_register = $params->{cash_register}; |
|
|
87 |
my $item_id = $params->{item_id}; |
86 |
|
88 |
|
87 |
my $userenv = C4::Context->userenv; |
89 |
my $userenv = C4::Context->userenv; |
88 |
|
90 |
|
|
|
91 |
$credit_type ||= |
92 |
$type eq 'WRITEOFF' |
93 |
? 'WRITEOFF' |
94 |
: 'PAYMENT'; |
95 |
|
89 |
my $patron = Koha::Patrons->find( $self->{patron_id} ); |
96 |
my $patron = Koha::Patrons->find( $self->{patron_id} ); |
90 |
|
97 |
|
91 |
my $manager_id = $userenv ? $userenv->{number} : 0; |
98 |
my $manager_id = $userenv ? $userenv->{number} : 0; |
Lines 130-141
sub pay {
Link Here
|
130 |
} |
137 |
} |
131 |
|
138 |
|
132 |
# Same logic exists in Koha::Account::Line::apply |
139 |
# Same logic exists in Koha::Account::Line::apply |
133 |
if ( $new_amountoutstanding == 0 |
140 |
if ( C4::Context->preference('MarkLostItemsAsReturned') =~ m|onpayment| |
134 |
&& $fine->itemnumber |
|
|
135 |
&& $fine->debit_type_code |
141 |
&& $fine->debit_type_code |
136 |
&& ( $fine->debit_type_code eq 'LOST' ) ) |
142 |
&& $fine->debit_type_code eq 'LOST' |
|
|
143 |
&& $new_amountoutstanding == 0 |
144 |
&& $fine->itemnumber |
145 |
&& !( $credit_type eq 'LOST_FOUND' |
146 |
&& $item_id == $fine->itemnumber ) ) |
137 |
{ |
147 |
{ |
138 |
C4::Circulation::ReturnLostItem( $self->{patron_id}, $fine->itemnumber ); |
148 |
C4::Circulation::ReturnLostItem( $self->{patron_id}, |
|
|
149 |
$fine->itemnumber ); |
139 |
} |
150 |
} |
140 |
|
151 |
|
141 |
my $account_offset = Koha::Account::Offset->new( |
152 |
my $account_offset = Koha::Account::Offset->new( |
Lines 197-208
sub pay {
Link Here
|
197 |
push @{$renew_outcomes}, $outcome; |
208 |
push @{$renew_outcomes}, $outcome; |
198 |
} |
209 |
} |
199 |
|
210 |
|
200 |
if ( $fine->amountoutstanding == 0 |
211 |
if ( C4::Context->preference('MarkLostItemsAsReturned') =~ m|onpayment| |
201 |
&& $fine->itemnumber |
|
|
202 |
&& $fine->debit_type_code |
212 |
&& $fine->debit_type_code |
203 |
&& ( $fine->debit_type_code eq 'LOST' ) ) |
213 |
&& $fine->debit_type_code eq 'LOST' |
|
|
214 |
&& $fine->amountoutstanding == 0 |
215 |
&& $fine->itemnumber |
216 |
&& !( $credit_type eq 'LOST_FOUND' |
217 |
&& $item_id == $fine->itemnumber ) ) |
204 |
{ |
218 |
{ |
205 |
C4::Circulation::ReturnLostItem( $self->{patron_id}, $fine->itemnumber ); |
219 |
C4::Circulation::ReturnLostItem( $self->{patron_id}, |
|
|
220 |
$fine->itemnumber ); |
206 |
} |
221 |
} |
207 |
|
222 |
|
208 |
my $account_offset = Koha::Account::Offset->new( |
223 |
my $account_offset = Koha::Account::Offset->new( |
Lines 239-249
sub pay {
Link Here
|
239 |
last unless $balance_remaining > 0; |
254 |
last unless $balance_remaining > 0; |
240 |
} |
255 |
} |
241 |
|
256 |
|
242 |
$credit_type ||= |
|
|
243 |
$type eq 'WRITEOFF' |
244 |
? 'WRITEOFF' |
245 |
: 'PAYMENT'; |
246 |
|
247 |
$description ||= $type eq 'WRITEOFF' ? 'Writeoff' : q{}; |
257 |
$description ||= $type eq 'WRITEOFF' ? 'Writeoff' : q{}; |
248 |
|
258 |
|
249 |
my $payment = Koha::Account::Line->new( |
259 |
my $payment = Koha::Account::Line->new( |
Lines 260-265
sub pay {
Link Here
|
260 |
branchcode => $library_id, |
270 |
branchcode => $library_id, |
261 |
register_id => $cash_register, |
271 |
register_id => $cash_register, |
262 |
note => $note, |
272 |
note => $note, |
|
|
273 |
itemnumber => $item_id, |
263 |
} |
274 |
} |
264 |
)->store(); |
275 |
)->store(); |
265 |
|
276 |
|
266 |
- |
|
|