Lines 243-252
sub add_debit {
Link Here
|
243 |
Koha::Account::Debit->new_from_api( $c->validation->param('body') ) |
243 |
Koha::Account::Debit->new_from_api( $c->validation->param('body') ) |
244 |
->unblessed; |
244 |
->unblessed; |
245 |
|
245 |
|
246 |
$data->{library_id} = $data->{branchcode}; |
246 |
$data->{library_id} = delete $data->{branchcode}; |
247 |
$data->{cash_register} = $data->{cash_register_id}; |
247 |
$data->{type} = delete $data->{debit_type_code}; |
248 |
$data->{item_id} = $data->{itemnumber}; |
248 |
$data->{cash_register} = delete $data->{cash_register_id}; |
249 |
$data->{interface} = 'api' |
249 |
$data->{item_id} = delete $data->{itemnumber}; |
|
|
250 |
$data->{transaction_type} = delete $data->{payment_type}; |
251 |
$data->{interface} = 'api' |
250 |
; # Should this always be API, or should we allow the API consumer to choose? |
252 |
; # Should this always be API, or should we allow the API consumer to choose? |
251 |
$data->{user_id} = $patron->borrowernumber |
253 |
$data->{user_id} = $patron->borrowernumber |
252 |
; # Should this be API user OR staff the API may be acting on behalf of? |
254 |
; # Should this be API user OR staff the API may be acting on behalf of? |
Lines 263-268
sub add_debit {
Link Here
|
263 |
); |
265 |
); |
264 |
} |
266 |
} |
265 |
catch { |
267 |
catch { |
|
|
268 |
if ( blessed $_ ) { |
269 |
if ( $_->isa('Koha::Exceptions::Account::RegisterRequired') ) { |
270 |
return $c->render( |
271 |
status => 400, |
272 |
openapi => { error => "$_" } |
273 |
); |
274 |
} |
275 |
elsif ( $_->isa('Koha::Exceptions::Account::AmountNotPositive') ) { |
276 |
return $c->render( |
277 |
status => 400, |
278 |
openapi => { error => "$_" } |
279 |
); |
280 |
} |
281 |
elsif ( $_->isa('Koha::Exceptions::Account::UnrecognisedType') ) { |
282 |
return $c->render( |
283 |
status => 400, |
284 |
openapi => { error => "$_" } |
285 |
); |
286 |
} |
287 |
} |
288 |
|
266 |
$c->unhandled_exception($_); |
289 |
$c->unhandled_exception($_); |
267 |
}; |
290 |
}; |
268 |
} |
291 |
} |