Skip to content

Commit

Permalink
Merge pull request #161 inveniosoftware#3592 from mvesper/invenio_ill…
Browse files Browse the repository at this point in the history
…_recall_mail

  BibCirculation: reset ILL overdue_letter_number

  Notes:
    Update accordingly to Tibor's comments in inveniosoftware#3592
  • Loading branch information
egabancho committed May 9, 2016
2 parents 002d648 + bd7c03a commit 010c294
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions modules/bibcirculation/lib/bibcirculation_dblayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2721,6 +2721,11 @@ def get_purchase_request_borrower_details(ill_request_id):
else:
return None

def update_ill_request_letter_number(ill_request_id, overdue_letter_number):
query = ('UPDATE crcILLREQUEST set overdue_letter_number=%s '
'where id=%s')
run_sql(query, (overdue_letter_number, ill_request_id))

def update_ill_request(ill_request_id, library_id, request_date,
expected_date, arrival_date, due_date, return_date,
status, cost, barcode, library_notes):
Expand Down
19 changes: 19 additions & 0 deletions modules/bibcirculation/lib/bibcirculationadminlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -4968,6 +4968,25 @@ def ill_request_details_step2(req, delete_key, ill_request_id, new_status,
barcode = db.get_ill_barcode(ill_request_id)
db.update_ill_loan_status(borrower_id, barcode, return_date, 'ill')

# ill recall letter issue
try:
from invenio.dbquery import run_sql
_query = ('SELECT due_date from crcILLREQUEST where id = %s')
_due = run_sql(_query, (ill_request_id))[0][0]

# Since we don't know if the due_date is a string or datetime
try:
_due_date = datetime.datetime.strptime(due_date, '%Y-%m-%d')
except TypeError:
_due_date = due_date

# This means that the ILL got extended, we therefore reset the
# overdue_letter_numer
if _due < _due_date:
db.update_ill_request_letter_number(ill_request_id, 0)
except Exception:
pass

db.update_ill_request(ill_request_id, library_id, request_date,
expected_date, arrival_date, due_date, return_date,
new_status, cost, barcode,
Expand Down

0 comments on commit 010c294

Please sign in to comment.