Skip to content

Commit

Permalink
Merge pull request #161 from mvesper/cds_ill_recall_mail
Browse files Browse the repository at this point in the history
  BibCirculation: reset ILL overdue_letter_number
  • Loading branch information
egabancho committed Mar 10, 2016
2 parents d424e56 + 748643e commit 584fe49
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={0} '
'where id="{1}"')
run_sql(query.format(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 = "{0}"')
_due = run_sql(_query.format(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 584fe49

Please sign in to comment.