Bug 22421: (follow-up) Correct checkout relation
The Koha::Account::Line->checkout relationship accessor needed an update to respect the new fields and foreign keys introduced here. Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Victor Grousset/tuxayo <victor@tuxayo.net> 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
57593e81de
commit
1b2e24659f
|
|
@ -2650,9 +2650,8 @@ sub MarkIssueReturned {
|
|||
my $old_checkout = Koha::Old::Checkout->new($issue->unblessed)->store;
|
||||
|
||||
# Update accountlines
|
||||
my $accountlines =
|
||||
Koha::Account::Lines->search( { issue_id => $issue->issue_id } );
|
||||
$accountlines->update({ old_issue_id => $issue->issue_id, issue_id => undef });
|
||||
my $accountlines = Koha::Account::Lines->search( { issue_id => $issue->issue_id } );
|
||||
$accountlines->update( { old_issue_id => $issue->issue_id, issue_id => undef } );
|
||||
|
||||
# anonymise patron checkout immediately if $privacy set to 2 and AnonymousPatron is set to a valid borrowernumber
|
||||
if ( $privacy && $privacy == 2) {
|
||||
|
|
|
|||
|
|
@ -91,10 +91,17 @@ Return the checkout linked to this account line if exists
|
|||
|
||||
sub checkout {
|
||||
my ($self) = @_;
|
||||
return unless $self->issue_id;
|
||||
|
||||
return Koha::Checkouts->find( $self->issue_id )
|
||||
|| Koha::Old::Checkouts->find( $self->issue_id );
|
||||
my $result;
|
||||
if ( $self->issue_id ) {
|
||||
my $issue_rs = $self->_result->issue;
|
||||
$result = Koha::Checkout->_new_from_dbic($issue_rs) if $issue_rs;
|
||||
} elsif ( $self->old_issue_id ) {
|
||||
my $old_issue_rs = $self->_result->old_issue;
|
||||
$result = Koha::Old::Checkout->_new_from_dbic($old_issue_rs) if $old_issue_rs;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
=head3 library
|
||||
|
|
|
|||
|
|
@ -706,7 +706,7 @@ subtest 'adjust() tests' => sub {
|
|||
};
|
||||
|
||||
subtest 'checkout() tests' => sub {
|
||||
plan tests => 6;
|
||||
plan tests => 7;
|
||||
|
||||
$schema->storage->txn_begin;
|
||||
|
||||
|
|
@ -718,14 +718,17 @@ subtest 'checkout() tests' => sub {
|
|||
t::lib::Mocks::mock_userenv({ branchcode => $library->branchcode });
|
||||
my $checkout = AddIssue( $patron, $item->barcode );
|
||||
|
||||
my $line = $account->add_debit({
|
||||
amount => 10,
|
||||
interface => 'commandline',
|
||||
item_id => $item->itemnumber,
|
||||
issue_id => $checkout->issue_id,
|
||||
type => 'OVERDUE',
|
||||
status => 'UNRETURNED'
|
||||
});
|
||||
my $line = $account->add_debit(
|
||||
{
|
||||
amount => 10,
|
||||
interface => 'commandline',
|
||||
item_id => $item->itemnumber,
|
||||
issue_id => $checkout->issue_id,
|
||||
old_issue_id => undef,
|
||||
type => 'OVERDUE',
|
||||
status => 'UNRETURNED'
|
||||
}
|
||||
);
|
||||
|
||||
my $line_checkout = $line->checkout;
|
||||
is( ref($line_checkout), 'Koha::Checkout', 'Result type is correct' );
|
||||
|
|
@ -743,9 +746,15 @@ subtest 'checkout() tests' => sub {
|
|||
is( ref($old_line_checkout), 'Koha::Old::Checkout', 'Result type is correct' );
|
||||
is( $old_line_checkout->issue_id, $old_checkout->issue_id, 'Koha::Account::Line->checkout should return the correct old_checkout' );
|
||||
|
||||
$line->issue_id(undef)->store;
|
||||
$old_line_checkout->delete;
|
||||
$line->discard_changes; #NOTE: discard_changes refreshes the whole resultset, get_from_storage only refreshes the unjoined row
|
||||
is( $line->checkout, undef, 'Koha::Account::Line->checkout should return undef if no checkout linked' );
|
||||
|
||||
$line->old_issue_id(undef)->store;
|
||||
$line->discard_changes; #NOTE: discard_changes refreshes the whole resultset, get_from_storage only refreshes the unjoined row
|
||||
is( $line->checkout, undef, 'Koha::Account::Line->checkout should return undef if no checkout linked' );
|
||||
|
||||
|
||||
$schema->storage->txn_rollback;
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue