if ($duedate && ref $duedate ne 'DateTime') {
$duedate = dt_from_string($duedate);
}
- my $now = DateTime->now( time_zone => C4::Context->tz() );
+ my $now = dt_from_string();
unless ( $duedate ) {
my $issuedate = $now->clone();
}
}
- my $issuedate = DateTime->now( time_zone => C4::Context->tz() );
+ my $issuedate = dt_from_string();
my $calendar = Koha::Calendar->new( branchcode => $branchcode );
# $issuedate defaults to today.
if ( !defined $issuedate ) {
- $issuedate = DateTime->now( time_zone => C4::Context->tz() );
+ $issuedate = dt_from_string();
}
else {
if ( ref $issuedate ne 'DateTime' ) {
$item_object->holdingbranch(C4::Context->userenv->{'branch'});
$item_object->itemlost(0);
$item_object->onloan($datedue->ymd());
- $item_object->datelastborrowed(DateTime->now( time_zone => C4::Context->tz() )->ymd()); # FIXME we should use dt_from_string here
+ $item_object->datelastborrowed( dt_from_string()->ymd() );
$item_object->store({log_action => 0});
ModDateLastSeen( $item_object->itemnumber );
# this is always done regardless of whether the item was on loan or not
my $item_holding_branch = $item->holdingbranch;
if ($item->holdingbranch ne $branch) {
- UpdateHoldingbranch($branch, $item->itemnumber);
- $item->holdingbranch($branch); # update item data holdingbranch too # FIXME I guess this is for the _debar_user_on_return call later
+ $item->holdingbranch($branch)->store;
}
my $leave_item_lost = C4::Context->preference("BlockReturnOfLostItems") ? 1 : 0;
return ( 0, 'overdue');
}
- if ( $issue->auto_renew ) {
+ if ( $issue->auto_renew && $patron->autorenew_checkouts ) {
if ( $patron->category->effective_BlockExpiredPatronOpacActions and $patron->is_expired ) {
return ( 0, 'auto_account_expired' );
$soonestrenewal->truncate( to => 'day' );
}
- if ( $soonestrenewal > DateTime->now( time_zone => C4::Context->tz() ) )
+ if ( $soonestrenewal > dt_from_string() )
{
- return ( 0, "auto_too_soon" ) if $issue->auto_renew;
+ return ( 0, "auto_too_soon" ) if $issue->auto_renew && $patron->autorenew_checkouts;
return ( 0, "too_soon" );
}
- elsif ( $issue->auto_renew ) {
+ elsif ( $issue->auto_renew && $patron->autorenew_checkouts ) {
$auto_renew = 1;
}
}
# Fallback for automatic renewals:
# If norenewalbefore is undef, don't renew before due date.
- if ( $issue->auto_renew && !$auto_renew ) {
+ if ( $issue->auto_renew && !$auto_renew && $patron->autorenew_checkouts ) {
my $now = dt_from_string;
if ( $now >= dt_from_string( $issue->date_due, 'sql' ) ){
$auto_renew = 1;
my $itemnumber = shift or return;
my $branch = shift;
my $datedue = shift;
- my $lastreneweddate = shift || DateTime->now(time_zone => C4::Context->tz);
+ my $lastreneweddate = shift || dt_from_string();
my $skipfinecalc = shift;
my $item_object = Koha::Items->find($itemnumber) or return;
$datedue = (C4::Context->preference('RenewalPeriodBase') eq 'date_due') ?
dt_from_string( $issue->date_due, 'sql' ) :
- DateTime->now( time_zone => C4::Context->tz());
+ dt_from_string();
$datedue = CalcDateDue($datedue, $itemtype, $circ_library->branchcode, $patron_unblessed, 'is a renewal');
}
DelUniqueDebarment({ borrowernumber => $borrowernumber, type => 'OVERDUES' });
}
- unless ( C4::Context->interface eq 'opac' ) { #if from opac we are obeying OpacRenewalBranch as calculated in opac-renew.pl
- $branch = ( C4::Context->userenv && defined C4::Context->userenv->{branch} ) ? C4::Context->userenv->{branch} : $branch;
- }
-
# Add the renewal to stats
UpdateStats(
{
- branch => $branch,
+ branch => $item_object->renewal_branchcode({branch => $branch}),
type => 'renew',
amount => $charge,
itemnumber => $itemnumber,
# LOCK TABLES is not transaction-safe and implicitly commits any active transaction before attempting to lock the tables.
# If the LOCK/UNLOCK statements are executed from tests, the current transaction will be committed.
# To avoid that we need to guess if this code is execute from tests or not (yes it is a bit hacky)
- my $do_not_lock = ( exists $ENV{_} && $ENV{_} =~ m|prove| ) || $ENV{KOHA_NO_TABLE_LOCKS};
+ my $do_not_lock = ( exists $ENV{_} && $ENV{_} =~ m|prove| ) || $ENV{KOHA_TESTING};
for my $mtt (@transports) {
my $letter = C4::Letters::GetPreparedLetter (
ModItemTransfer($itemNumber, $FromLibrary, $waitingAtLibrary);
#third step changing holdingbranch of item
- UpdateHoldingbranch($FromLibrary,$itemNumber);
-}
-
-=head2 UpdateHoldingbranch
-
- $items = UpdateHoldingbranch($branch,$itmenumber);
-
-Simple methode for updating hodlingbranch in items BDD line
-
-=cut
-
-sub UpdateHoldingbranch {
- my ( $branch,$itemnumber ) = @_;
- ModItem({ holdingbranch => $branch }, undef, $itemnumber);
+ my $item = Koha::Items->find($itemNumber)->holdingbranch($FromLibrary)->store;
}
=head2 CalcDateDue
$datedue = $startdate->clone;
}
} else {
- $datedue =
- DateTime->now( time_zone => C4::Context->tz() )
- ->truncate( to => 'minute' );
+ $datedue = dt_from_string()->truncate( to => 'minute' );
}
}
#Get how many days the borrower has to reach the age restriction
- my @Today = split /-/, DateTime->today->ymd();
+ my @Today = split /-/, dt_from_string()->ymd();
my $daysToAgeRestriction = Date_to_Days(@alloweddate) - Date_to_Days(@Today);
#Negative days means the borrower went past the age restriction age
return ($restriction_year, $daysToAgeRestriction);