@@ -, +, @@
column and accessor names
---
C4/Circulation.pm | 3 ++-
Koha/Checkout.pm | 12 ++++++------
Koha/Old/Checkout.pm | 15 +++++++++++++++
.../prog/en/modules/catalogue/issuehistory.tt | 6 +++---
.../prog/en/modules/members/readingrec.tt | 2 +-
t/db_dependent/Circulation.t | 14 ++++++--------
t/db_dependent/Koha/Checkouts.t | 12 ++++++------
7 files changed, 39 insertions(+), 25 deletions(-)
--- a/C4/Circulation.pm
+++ a/C4/Circulation.pm
@@ -1527,7 +1527,7 @@ sub AddIssue {
my $userenv = C4::Context->userenv();
my $usernumber = (ref($userenv) eq 'HASH') ? $userenv->{'number'} : undef;
if ($usernumber) {
- $issue_attributes->{issuer} = $usernumber;
+ $issue_attributes->{issuer_id} = $usernumber;
}
}
@@ -1545,6 +1545,7 @@ sub AddIssue {
}
)->store;
}
+ $issue->discard_changes;
if ( $item_object->location && $item_object->location eq 'CART'
&& ( !$item_object->permanent_location || $item_object->permanent_location ne 'CART' ) ) {
## Item was moved to cart via UpdateItemLocationOnCheckin, anything issued should be taken off the cart.
--- a/Koha/Checkout.pm
+++ a/Koha/Checkout.pm
@@ -106,18 +106,19 @@ sub patron {
return Koha::Patron->_new_from_dbic( $patron_rs );
}
-=head3 issued_by
+=head3 issuer
-my $issued_by = $checkout->issued_by
+my $issuer = $checkout->issuer
Return the patron by whom the checkout was done
=cut
-sub issued_by {
+sub issuer {
my ( $self ) = @_;
- my $issued_by_rs = $self->_result->issuer;
- return Koha::Patron->_new_from_dbic( $issued_by_rs );
+ my $issuer_rs = $self->_result->issuer;
+ return unless $issuer_rs;
+ return Koha::Patron->_new_from_dbic( $issuer_rs );
}
=head3 to_api_mapping
@@ -131,7 +132,6 @@ sub to_api_mapping {
return {
issue_id => 'checkout_id',
borrowernumber => 'patron_id',
- issuer => 'issuer_id',
itemnumber => 'item_id',
date_due => 'due_date',
branchcode => 'library_id',
--- a/Koha/Old/Checkout.pm
+++ a/Koha/Old/Checkout.pm
@@ -74,6 +74,21 @@ sub patron {
return Koha::Patron->_new_from_dbic( $patron_rs );
}
+=head3 issuer
+
+my $issuer = $checkout->issuer
+
+Return the patron by whom the checkout was done
+
+=cut
+
+sub issuer {
+ my ( $self ) = @_;
+ my $issuer_rs = $self->_result->issuer;
+ return unless $issuer_rs;
+ return Koha::Patron->_new_from_dbic( $issuer_rs );
+}
+
=head3 to_api_mapping
This method returns the mapping for representing a Koha::Old::Checkout object
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/issuehistory.tt
@@ -67,9 +67,9 @@
[% END %]
[% IF Koha.Preference('RecordStaffUserOnCheckout') %]
-
[% IF checkout.issuer %]
-
- [% INCLUDE 'patron-title.inc' patron=checkout.issued_by %]
+ | [% IF checkout.issuer_id %]
+
+ [% INCLUDE 'patron-title.inc' patron=checkout.issuer_id %]
[% END %] |
[% END %]
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt
+++ a/koha-tmpl/intranet-tmpl/prog/en/modules/members/readingrec.tt
@@ -98,7 +98,7 @@
[% Branches.GetName( issue.branchcode ) | html %] |
[% IF Koha.Preference('RecordStaffUserOnCheckout') %]
- [% issue.firstname | html %] [% issue.surname | html %] |
+ [% issue.firstname | html %] [% issue.surname | html %] |
[% END %]
[% IF issue.date_due %]
--- a/t/db_dependent/Circulation.t
+++ a/t/db_dependent/Circulation.t
@@ -4610,20 +4610,19 @@ subtest 'AddIssue records staff who checked out item if appropriate' => sub {
$module->mock( 'userenv', sub { { branch => $library->{id} } } );
- my $library =
- $builder->build_object( { class => 'Koha::Libraries' } )->store;
+ my $library = $builder->build_object( { class => 'Koha::Libraries' } );
my $patron = $builder->build_object(
{
class => 'Koha::Patrons',
value => { categorycode => $patron_category->{categorycode} }
}
- )->store;
+ );
my $issuer = $builder->build_object(
{
class => 'Koha::Patrons',
value => { categorycode => $patron_category->{categorycode} }
}
- )->store;
+ );
my $item = $builder->build_sample_item(
{
library => $library->{branchcode}
@@ -4632,11 +4631,10 @@ subtest 'AddIssue records staff who checked out item if appropriate' => sub {
$module->mock( 'userenv', sub { { branch => $library->id, number => $issuer->{borrowernumber} } } );
- my $dt_from = dt_from_string();
- my $dt_to = dt_from_string()->add( days => 7 );
+ my $dt_from = dt_from_string();
+ my $dt_to = dt_from_string()->add( days => 7 );
- my $issue =
- AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
+ my $issue = AddIssue( $patron->unblessed, $item->barcode, $dt_to, undef, $dt_from );
is( $issue->issuer, undef, "Staff who checked out the item not recorded when RecordStaffUserOnCheckout turned off" );
--- a/t/db_dependent/Koha/Checkouts.t
+++ a/t/db_dependent/Koha/Checkouts.t
@@ -133,24 +133,24 @@ subtest 'issuer' => sub {
my $item = $builder->build_sample_item;
my $checkout = Koha::Checkout->new({
borrowernumber => $patron->borrowernumber,
- issuer => $issuer->borrowernumber,
+ issuer_id => $issuer->borrowernumber,
itemnumber => $item->itemnumber,
branchcode => $library->{branchcode},
})->store;
- my $i = $checkout->issued_by;
+ my $i = $checkout->issuer;
is( ref($i), 'Koha::Patron',
- 'Koha::Checkout->issued_by should return a Koha::Patron' );
+ 'Koha::Checkout->issuer should return a Koha::Patron' );
is( $i->borrowernumber, $issuer->borrowernumber,
- 'Koha::Checkout->issued_by should return the correct patron' );
+ 'Koha::Checkout->issuer should return the correct patron' );
# Testing Koha::Old::Checkout->patron now
my $issue_id = $checkout->issue_id;
C4::Circulation::MarkIssueReturned( $patron->borrowernumber, $checkout->itemnumber );
$i->delete;
my $old_issue = Koha::Old::Checkouts->find($issue_id);
- is( $old_issue->issuer, undef,
- 'Koha::Checkout->issuer should return undef if the patron record has been deleted'
+ is( $old_issue->issuer_id, undef,
+ 'Koha::Checkout->issuer_id should return undef if the patron record has been deleted'
);
};
--
|