Never fulfill requests that are on hold.
Requests on hold can never be fulfilled. If you want to fulfill a request that is currently on hold, the right semantic is that you should remove the hold, then fulfill the request. Note that this test now passes and it didn't before: fulfillRequest: .... but undef is returned when attempting to fulfill a held request.
This commit is contained in:
parent
836a70c0ab
commit
258d9fad0f
1 changed files with 10 additions and 0 deletions
|
@ -1289,6 +1289,16 @@ sub fulfillRequest($$) {
|
||||||
|
|
||||||
my $fulfillRecord = $self->dbh()->selectall_hashref($fulfillLookupSql, "request_id");
|
my $fulfillRecord = $self->dbh()->selectall_hashref($fulfillLookupSql, "request_id");
|
||||||
if (not defined $fulfillRecord or not defined $fulfillRecord->{$requestId}) {
|
if (not defined $fulfillRecord or not defined $fulfillRecord->{$requestId}) {
|
||||||
|
# First check if request is held. If it's held, it cannot be fulfilled.
|
||||||
|
my $holdReq = $self->dbh()->selectall_hashref("SELECT id, request_id, release_date " .
|
||||||
|
"FROM request_hold WHERE request_id = " .
|
||||||
|
$self->dbh->quote($requestId, 'SQL_INTEGER'),
|
||||||
|
'request_id');
|
||||||
|
return undef
|
||||||
|
if (defined $holdReq and defined $holdReq->{$requestId} and defined $holdReq->{$requestId}{id}
|
||||||
|
and $TODAY lt $holdReq->{$requestId}{release_date});
|
||||||
|
|
||||||
|
# Ok, it's not on hold, so go ahead and fulfill it.
|
||||||
$self->_beginWork;
|
$self->_beginWork;
|
||||||
my $sth = $self->dbh->prepare("INSERT INTO fulfillment(request_id, who, how, date) " .
|
my $sth = $self->dbh->prepare("INSERT INTO fulfillment(request_id, who, how, date) " .
|
||||||
"VALUES(? , ? , ? , date('now'))");
|
"VALUES(? , ? , ? , date('now'))");
|
||||||
|
|
Loading…
Reference in a new issue