Koha/C4/SIP/ILS/Transaction.pm
Jonathan Druart 546379cc92 Bug 17680: C4::Circulation - Remove GetItemIssue, simple calls
C4::Circulation::GetItemIssue returned all the issue and item
informations for a given issue. Moveover it also did some date
manipulations. Most of the time this subroutine was called, there
additional information were useless as the caller usually just needed
the basic issue's infos 'from the issue table).

This first patch updates the simple calls, ie. the ones that just need
the issue's infomations.

Test plan:
The following operations should success:
- transfer a book
- create a rule for on-site checkouts and confirm that a patron cannot
check more items out that it's defined in the rule.
- Renew an issue using ILSDI
- Using SIP confirm that you are able to see your issues

Followed test plan, works as expected
Signed-off-by: Marc Véron <veron@veron.ch>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
2017-07-10 12:06:37 -03:00

82 lines
1.5 KiB
Perl

#
# Transaction: Superclass of all the transactional status objects
#
package C4::SIP::ILS::Transaction;
use Carp;
use strict;
use warnings;
use C4::Context;
use Koha::DateUtils;
use Koha::Checkouts;
my %fields = (
ok => 0,
patron => undef,
item => undef,
desensitize => 0,
alert => '',
transaction_id=> undef,
sip_fee_type => '01', # Other/Unknown
fee_amount => undef,
sip_currency => 'USD', # FIXME: why hardcoded?
screen_msg => '',
print_line => '',
fee_ack => 'N',
);
our $AUTOLOAD;
sub new {
my $class = shift;
my $self = {
_permitted => \%fields,
%fields,
};
return bless $self, $class;
}
sub duedatefromissue {
my ($self, $iss, $itemnum) = @_;
my $due_dt;
if (defined $iss ) {
$due_dt = dt_from_string( $iss->date_due() );
} # renew from AddIssue ??
else {
# need to reread the issue to get due date
$iss = Koha::Checkouts->find( { itemnumber => $itemnum } );
if ($iss && $iss->date_due ) {
$due_dt = dt_from_string( $iss->date_due, 'sql' );
}
}
return $due_dt;
}
sub DESTROY {
# be cool
}
sub AUTOLOAD {
my $self = shift;
my $class = ref($self) or croak "$self is not an object";
my $name = $AUTOLOAD;
$name =~ s/.*://;
unless (exists $self->{_permitted}->{$name}) {
croak "Can't access '$name' field of class '$class'";
}
if (@_) {
return $self->{$name} = shift;
} else {
return $self->{$name};
}
}
1;
__END__