From 497c6d351e3ed9b75ef5faf495372176bc035ea6 Mon Sep 17 00:00:00 2001 From: Aparna Date: Mon, 10 Jun 2024 09:08:20 -0700 Subject: [PATCH 1/6] Comment added for override reason --- .../io/message/processor/notificationprocessor.py | 12 ++++++++++++ .../io/message/schemas/notification.py | 1 + 2 files changed, 13 insertions(+) diff --git a/notification-manager/notification_api/io/message/processor/notificationprocessor.py b/notification-manager/notification_api/io/message/processor/notificationprocessor.py index 9cce87ac3..1170244c5 100644 --- a/notification-manager/notification_api/io/message/processor/notificationprocessor.py +++ b/notification-manager/notification_api/io/message/processor/notificationprocessor.py @@ -137,6 +137,15 @@ def __createnotificationforresponse(self, notification): ) def __createcommentforresponse(self, notification): + if notification.feeoverridereason is not None: + comment = {"comment": notification.feeoverridereason} + return commentservice().createcomment( + "ministryrequest", + notification.ministryrequestid, + comment, + notification.createdby, + 2, + ) comment = {"comment": self.__createresponsemessage(notification.errorflag)} return commentservice().createcomment( "ministryrequest", @@ -164,6 +173,9 @@ def __createcommentforredline(self, notification): notification.createdby, 2, ) + + def __createfeeoverridemessage(self, feeoverridereason): + return "Username overrode balance outstanding warning for the following reason: "+feeoverridereason def __createresponsemessage(self, errorflag): if errorflag == "YES": diff --git a/notification-manager/notification_api/io/message/schemas/notification.py b/notification-manager/notification_api/io/message/schemas/notification.py index ced8fa5da..87b82a0b7 100644 --- a/notification-manager/notification_api/io/message/schemas/notification.py +++ b/notification-manager/notification_api/io/message/schemas/notification.py @@ -34,3 +34,4 @@ class NotificationRedlineResponsePDFStitchPublishSchema(object): serviceid = fields.Str(data_key="serviceid", allow_none=False) errorflag = fields.Str(data_key="errorflag", allow_none=False) createdby = fields.Str(data_key="message", allow_none=False) + feeoverridereason= fields.Str(data_key="feeoverridereason", allow_none=True) From f619f9fbbb4f9edbd68c8145134c8cc8474e7464 Mon Sep 17 00:00:00 2001 From: Aparna Date: Mon, 10 Jun 2024 15:33:57 -0700 Subject: [PATCH 2/6] Empty check added --- .../io/message/processor/notificationprocessor.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/notification-manager/notification_api/io/message/processor/notificationprocessor.py b/notification-manager/notification_api/io/message/processor/notificationprocessor.py index 1170244c5..7a38c9e7e 100644 --- a/notification-manager/notification_api/io/message/processor/notificationprocessor.py +++ b/notification-manager/notification_api/io/message/processor/notificationprocessor.py @@ -137,7 +137,7 @@ def __createnotificationforresponse(self, notification): ) def __createcommentforresponse(self, notification): - if notification.feeoverridereason is not None: + if notification.feeoverridereason is not None and notification.feeoverridereason != '': comment = {"comment": notification.feeoverridereason} return commentservice().createcomment( "ministryrequest", @@ -174,9 +174,6 @@ def __createcommentforredline(self, notification): 2, ) - def __createfeeoverridemessage(self, feeoverridereason): - return "Username overrode balance outstanding warning for the following reason: "+feeoverridereason - def __createresponsemessage(self, errorflag): if errorflag == "YES": return "Creating the Release Package failed. Please try again" From 89884a8a33bf4286aa9cc31f3cbabe5ad6386fa9 Mon Sep 17 00:00:00 2001 From: Aparna Date: Tue, 11 Jun 2024 21:48:37 -0700 Subject: [PATCH 3/6] Updated api from docreviewer to include fee details --- request-management-api/request_api/resources/foirequest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/request-management-api/request_api/resources/foirequest.py b/request-management-api/request_api/resources/foirequest.py index bf063df38..27e4b126f 100644 --- a/request-management-api/request_api/resources/foirequest.py +++ b/request-management-api/request_api/resources/foirequest.py @@ -56,7 +56,7 @@ def get(foirequestid,foiministryrequestid,usertype = None): jsondata = {} statuscode = 200 if (AuthHelper.getusertype() == "iao") and (usertype is None or (usertype == "iao")): - jsondata = requestservice().getrequest(foirequestid,foiministryrequestid) + jsondata = requestservice().getrequestdetails(foirequestid,foiministryrequestid) assignee = jsondata['assignedTo'] isrestricted = jsondata['iaorestricteddetails']['isrestricted'] if ('isrestricted' in jsondata['iaorestricteddetails']) else False if(canrestictdata(foiministryrequestid,assignee,isrestricted,False)): From d367d6f70c42f33de3fcfdb512bd2066db74c278 Mon Sep 17 00:00:00 2001 From: Aparna Date: Wed, 12 Jun 2024 09:54:37 -0700 Subject: [PATCH 4/6] Updated docreviewer to foiflow request fetch api --- .../request_api/resources/foirequest.py | 45 +++++++++++++++++-- .../foirequest/requestservicegetter.py | 4 +- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/request-management-api/request_api/resources/foirequest.py b/request-management-api/request_api/resources/foirequest.py index 27e4b126f..6e9b9c719 100644 --- a/request-management-api/request_api/resources/foirequest.py +++ b/request-management-api/request_api/resources/foirequest.py @@ -56,7 +56,7 @@ def get(foirequestid,foiministryrequestid,usertype = None): jsondata = {} statuscode = 200 if (AuthHelper.getusertype() == "iao") and (usertype is None or (usertype == "iao")): - jsondata = requestservice().getrequestdetails(foirequestid,foiministryrequestid) + jsondata = requestservice().getrequest(foirequestid,foiministryrequestid) assignee = jsondata['assignedTo'] isrestricted = jsondata['iaorestricteddetails']['isrestricted'] if ('isrestricted' in jsondata['iaorestricteddetails']) else False if(canrestictdata(foiministryrequestid,assignee,isrestricted,False)): @@ -287,7 +287,7 @@ class FOIRequestByMinistryId(Resource): @auth.require def get(ministryrequestid,usertype=None): try : - return FOIRequest.get(requestservice().getrequestid(ministryrequestid), ministryrequestid, usertype) + return FOIRequestForDocReviewer.get(requestservice().getrequestid(ministryrequestid), ministryrequestid, usertype) except ValueError: return {'status': 500, 'message':"Invalid Request"}, 500 except BusinessException as exception: @@ -325,4 +325,43 @@ def post(foirequestid,foiministryrequestid,section): except KeyError as error: return {'status': False, 'message': CUSTOM_KEYERROR_MESSAGE + str(error)}, 400 except BusinessException as exception: - return {'status': exception.status_code, 'message':exception.message}, 500 \ No newline at end of file + return {'status': exception.status_code, 'message':exception.message}, 500 + + +@cors_preflight('GET,OPTIONS') +class FOIRequestForDocReviewer(Resource): + """Retrieve foi request for opened request - Used + in docreviewer""" + + @staticmethod + @TRACER.trace() + @cross_origin(origins=allowedorigins()) + @auth.require + @auth.ismemberofgroups(getrequiredmemberships()) + def get(foirequestid,foiministryrequestid,usertype = None): + try : + jsondata = {} + statuscode = 200 + if (AuthHelper.getusertype() == "iao") and (usertype is None or (usertype == "iao")): + jsondata = requestservice().getrequestdetails(foirequestid,foiministryrequestid) + assignee = jsondata['assignedTo'] + isrestricted = jsondata['iaorestricteddetails']['isrestricted'] if ('isrestricted' in jsondata['iaorestricteddetails']) else False + if(canrestictdata(foiministryrequestid,assignee,isrestricted,False)): + jsondata = {} + statuscode = 401 + elif usertype is not None and usertype == "ministry" and AuthHelper.getusertype() == "ministry": + jsondata = requestservice().getrequestdetailsforministry(foirequestid,foiministryrequestid,AuthHelper.getministrygroups()) + assignee = jsondata['assignedministryperson'] + isrestricted = jsondata['ministryrestricteddetails']['isrestricted'] if ('isrestricted' in jsondata['ministryrestricteddetails']) else False + if(canrestictdata_ministry(foiministryrequestid,assignee,isrestricted)): + jsondata = {} + statuscode = 401 + else: + statuscode = 401 + return jsondata , statuscode + except ValueError: + return {'status': 500, 'message':"Invalid Request Id"}, 500 + except KeyError as error: + return {'status': False, 'message': CUSTOM_KEYERROR_MESSAGE + str(error)}, 400 + except BusinessException as exception: + return {'status': exception.status_code, 'message':exception.message}, 500 \ No newline at end of file diff --git a/request-management-api/request_api/services/foirequest/requestservicegetter.py b/request-management-api/request_api/services/foirequest/requestservicegetter.py index ab4b3dfd7..b2dec36cc 100644 --- a/request-management-api/request_api/services/foirequest/requestservicegetter.py +++ b/request-management-api/request_api/services/foirequest/requestservicegetter.py @@ -119,11 +119,11 @@ def getrequestdetails(self,foirequestid, foiministryrequestid): payment = paymentservice().getpayment(foirequestid, foiministryrequestid) if approvedcfrfee is not None and approvedcfrfee != {}: requestdetails['cfrfee'] = approvedcfrfee - _totaldue = float(approvedcfrfee['feedata']['actualtotaldue']) if float(approvedcfrfee['feedata']['actualtotaldue']) > 0 else float(approvedcfrfee['feedata']['estimatedtotaldue']) + _totaldue = float(approvedcfrfee['feedata']['actualtotaldue']) if 'actualtotaldue' in approvedcfrfee['feedata'] and float(approvedcfrfee['feedata']['actualtotaldue']) > 0 else float(approvedcfrfee['feedata']['estimatedtotaldue']) _balancedue = _totaldue - (float(cfrfee['feedata']['amountpaid']) + float(approvedcfrfee['feedata']['feewaiveramount'])) requestdetails['cfrfee']['feedata']['amountpaid'] = cfrfee['feedata']['amountpaid'] requestdetails['cfrfee']['feedata']["balanceDue"] = '{:.2f}'.format(_balancedue) - if approvedcfrfee['feedata']['actualtotaldue']: + if 'actualtotaldue' in approvedcfrfee['feedata'] and approvedcfrfee['feedata']['actualtotaldue']: requestdetails['cfrfee']['feedata']["totalamountdue"] = '{:.2f}'.format(requestdetails['cfrfee']['feedata']["actualtotaldue"]) else: requestdetails['cfrfee']['feedata']["totalamountdue"] = '{:.2f}'.format(requestdetails['cfrfee']['feedata']["estimatedtotaldue"]) From 04b2fc7dd5506940b831ccccd6a28608664aa1af Mon Sep 17 00:00:00 2001 From: Aparna Date: Wed, 12 Jun 2024 10:46:46 -0700 Subject: [PATCH 5/6] Updated docreviewer api endpoint --- .../request_api/resources/foirequest.py | 29 +++++-------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/request-management-api/request_api/resources/foirequest.py b/request-management-api/request_api/resources/foirequest.py index 6e9b9c719..2cb7feadf 100644 --- a/request-management-api/request_api/resources/foirequest.py +++ b/request-management-api/request_api/resources/foirequest.py @@ -277,21 +277,6 @@ def post(ministryrequestid=None,type=None): except BusinessException as exception: return {'status': exception.status_code, 'message':exception.message}, 500 -@cors_preflight('GET,POST,OPTIONS') -@API.route('/foirequests/ministryrequestid/', defaults={'usertype':None}) -@API.route('/foirequests/ministryrequestid//') -class FOIRequestByMinistryId(Resource): - """Return request based on ministryrequestid""" - @staticmethod - @cross_origin(origins=allowedorigins()) - @auth.require - def get(ministryrequestid,usertype=None): - try : - return FOIRequestForDocReviewer.get(requestservice().getrequestid(ministryrequestid), ministryrequestid, usertype) - except ValueError: - return {'status': 500, 'message':"Invalid Request"}, 500 - except BusinessException as exception: - return {'status': exception.status_code, 'message':exception.message}, 500 @cors_preflight('POST, DELETE, UPDATE, OPTIONS') @API.route('/foirequests//ministryrequest//section/') @@ -329,6 +314,8 @@ def post(foirequestid,foiministryrequestid,section): @cors_preflight('GET,OPTIONS') +@API.route('/foirequests/ministryrequestid/', defaults={'usertype':None}) +@API.route('/foirequests/ministryrequestid//') class FOIRequestForDocReviewer(Resource): """Retrieve foi request for opened request - Used in docreviewer""" @@ -337,23 +324,23 @@ class FOIRequestForDocReviewer(Resource): @TRACER.trace() @cross_origin(origins=allowedorigins()) @auth.require - @auth.ismemberofgroups(getrequiredmemberships()) - def get(foirequestid,foiministryrequestid,usertype = None): + def get(ministryrequestid,usertype=None): try : jsondata = {} statuscode = 200 + foirequestid=requestservice().getrequestid(ministryrequestid) if (AuthHelper.getusertype() == "iao") and (usertype is None or (usertype == "iao")): - jsondata = requestservice().getrequestdetails(foirequestid,foiministryrequestid) + jsondata = requestservice().getrequestdetails(foirequestid,ministryrequestid) assignee = jsondata['assignedTo'] isrestricted = jsondata['iaorestricteddetails']['isrestricted'] if ('isrestricted' in jsondata['iaorestricteddetails']) else False - if(canrestictdata(foiministryrequestid,assignee,isrestricted,False)): + if(canrestictdata(ministryrequestid,assignee,isrestricted,False)): jsondata = {} statuscode = 401 elif usertype is not None and usertype == "ministry" and AuthHelper.getusertype() == "ministry": - jsondata = requestservice().getrequestdetailsforministry(foirequestid,foiministryrequestid,AuthHelper.getministrygroups()) + jsondata = requestservice().getrequestdetailsforministry(foirequestid,ministryrequestid,AuthHelper.getministrygroups()) assignee = jsondata['assignedministryperson'] isrestricted = jsondata['ministryrestricteddetails']['isrestricted'] if ('isrestricted' in jsondata['ministryrestricteddetails']) else False - if(canrestictdata_ministry(foiministryrequestid,assignee,isrestricted)): + if(canrestictdata_ministry(ministryrequestid,assignee,isrestricted)): jsondata = {} statuscode = 401 else: From 6fbad43d310791230429e88ad66e79b6cf971f85 Mon Sep 17 00:00:00 2001 From: Aparna Date: Wed, 12 Jun 2024 16:13:12 -0700 Subject: [PATCH 6/6] Notificationprocessor return update --- .../io/message/processor/notificationprocessor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/notification-manager/notification_api/io/message/processor/notificationprocessor.py b/notification-manager/notification_api/io/message/processor/notificationprocessor.py index 7a38c9e7e..01bfb9017 100644 --- a/notification-manager/notification_api/io/message/processor/notificationprocessor.py +++ b/notification-manager/notification_api/io/message/processor/notificationprocessor.py @@ -139,7 +139,7 @@ def __createnotificationforresponse(self, notification): def __createcommentforresponse(self, notification): if notification.feeoverridereason is not None and notification.feeoverridereason != '': comment = {"comment": notification.feeoverridereason} - return commentservice().createcomment( + commentservice().createcomment( "ministryrequest", notification.ministryrequestid, comment,