Bug 22421: (follow-up): Check issue during add_credit
Additional handling for the case where a credit is added with an issue_id after the issue is returned. add_credit will keep the same method signature, where the issue_id parameter may now refer to a current issue or an old issue. It will then internally determine whether it is a current or old checkout and handle it appropriately. If the caller is updating an account line, or adding a credit to refund an existing debit, they may not need to know whether it is for a current checkout or an old checkout. In this case, they can use the account line's ->checkout accessor to pass in the appropriate issue_id regardless of whether it is a current or old checkout. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
33b6aa466a
commit
e35ab15741
|
|
@ -224,6 +224,16 @@ sub add_credit {
|
|||
my $item_id = $params->{item_id};
|
||||
my $issue_id = $params->{issue_id};
|
||||
|
||||
my $old_issue_id;
|
||||
if ( $issue_id ) {
|
||||
my $issue = Koha::Checkouts->find($issue_id);
|
||||
unless ( $issue ) {
|
||||
my $old_issue = Koha::Old::Checkouts->find($issue_id);
|
||||
$issue_id = undef;
|
||||
$old_issue_id = $old_issue->id;
|
||||
}
|
||||
}
|
||||
|
||||
Koha::Exceptions::Account::RegisterRequired->throw()
|
||||
if ( C4::Context->preference("UseCashRegisters")
|
||||
&& defined($payment_type)
|
||||
|
|
@ -252,7 +262,16 @@ sub add_credit {
|
|||
branchcode => $library_id,
|
||||
register_id => $cash_register,
|
||||
itemnumber => $item_id,
|
||||
issue_id => $issue_id,
|
||||
(
|
||||
$issue_id
|
||||
? ( issue_id => $issue_id )
|
||||
: ()
|
||||
),
|
||||
(
|
||||
$old_issue_id
|
||||
? ( old_issue_id => $old_issue_id )
|
||||
: ()
|
||||
),
|
||||
}
|
||||
)->store();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue