Skip to content

Commit

Permalink
Merge pull request #4620 from bcgov/dev-MD-4369
Browse files Browse the repository at this point in the history
4369 patch - Change notification msg to use axisrequestid
  • Loading branch information
milosdes authored Oct 24, 2023
2 parents b1e1cc0 + 7332ec0 commit f61f626
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 5 additions & 2 deletions request-management-api/request_api/models/FOIRawRequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,12 @@ def getassignmenttransition(cls,requestid):
def getonholdapplicationfeerequests(cls): # with the reminder date
onholdapplicationfeerequests = []
try:
sql = '''SELECT * FROM (SELECT DISTINCT ON (requestid) requestid, (updated_at + INTERVAL '20 days') as reminder_date, status FROM public."FOIRawRequests"
ORDER BY requestid ASC, version DESC) r
sql = '''
SELECT * FROM (SELECT DISTINCT ON (requestid) requestid, (updated_at + INTERVAL '20 days') as reminder_date, status FROM public."FOIRawRequests"
ORDER BY requestid ASC, version DESC) r
WHERE r.status = 'On-Hold - Application Fee'
and r.reminder_date::date = now()::date
order by r.reminder_date asc
'''
rs = db.session.execute(text(sql))
for row in rs:
Expand Down
9 changes: 4 additions & 5 deletions request-management-api/request_api/services/events/payment.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from dateutil.parser import parse
from pytz import timezone
from request_api.utils.enums import PaymentEventType
from request_api.services.commons.duecalculator import duecalculator
from request_api.utils.commons.datetimehandler import datetimehandler
from request_api.exceptions import BusinessException
from flask import current_app
Expand Down Expand Up @@ -43,15 +42,15 @@ def createpaymentreminderevent(self):
try:
_today = datetimehandler().gettoday()

# notificationservice().dismissremindernotification("ministryrequest", self.__notificationtype())
notificationservice().dismissremindernotification("rawrequest", self.__notificationtype())
# ca_holidays = duecalculator.getholidays()
eventtype = PaymentEventType.reminder.value
_onholdrequests = FOIRawRequest.getonholdapplicationfeerequests()
for entry in _onholdrequests:
_reminderdate = datetimehandler().formatdate(entry['reminder_date'])
if _reminderdate == _today:
self.__createnotificationforrawrequest(entry['requestid'], eventtype)
self.__createcommentforrawrequest(entry['requestid'], eventtype)
self.__createcommentforrawrequest(entry['axisrequestid'], eventtype)
pass
return DefaultMethodResult(True,'Payment reminder notifications created',_today)
except BusinessException as exception:
Expand All @@ -60,11 +59,11 @@ def createpaymentreminderevent(self):

def __createcommentforrawrequest(self, requestid, eventtype):
comment = self.__preparecomment(requestid, eventtype)
return commentservice().createrawrequestcomment(comment, "System", 2)
return commentservice().createrawrequestcomment(comment, "system", 2)

def __createnotificationforrawrequest(self, requestid, eventtype):
notification = self.__preparenotification(requestid, eventtype)
return notificationservice().createnotification({"message" : notification}, requestid, "rawrequest", "Payment", "System")
return notificationservice().createnotification({"message" : notification}, requestid, "rawrequest", "Payment", "system")

def __createcomment(self, requestid, eventtype):
comment = self.__preparecomment(requestid, eventtype)
Expand Down

0 comments on commit f61f626

Please sign in to comment.