Skip to content

Commit

Permalink
Merge pull request #5408 from bcgov/dev
Browse files Browse the repository at this point in the history
FOIMOD-3073-Fees - Remaining Balance Check
  • Loading branch information
aparna-aot authored Oct 9, 2024
2 parents b75f934 + 1469a7e commit f82f616
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,15 @@ def __createnotificationforresponse(self, notification):
)

def __createcommentforresponse(self, notification):
if notification.feeoverridereason is not None and notification.feeoverridereason != '':
comment = {"comment": notification.feeoverridereason}
commentservice().createcomment(
"ministryrequest",
notification.ministryrequestid,
comment,
notification.createdby,
2,
)
comment = {"comment": self.__createresponsemessage(notification.errorflag)}
return commentservice().createcomment(
"ministryrequest",
Expand Down Expand Up @@ -164,7 +173,7 @@ def __createcommentforredline(self, notification):
notification.createdby,
2,
)

def __createresponsemessage(self, errorflag):
if errorflag == "YES":
return "Creating the Release Package failed. Please try again"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
58 changes: 42 additions & 16 deletions request-management-api/request_api/resources/foirequest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/<int:ministryrequestid>', defaults={'usertype':None})
@API.route('/foirequests/ministryrequestid/<ministryrequestid>/<usertype>')
class FOIRequestByMinistryId(Resource):
"""Return request based on ministryrequestid"""
@staticmethod
@cross_origin(origins=allowedorigins())
@auth.require
def get(ministryrequestid,usertype=None):
try :
return FOIRequest.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/<int:foirequestid>/ministryrequest/<int:foiministryrequestid>/section/<string:section>')
Expand Down Expand Up @@ -325,4 +310,45 @@ 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
return {'status': exception.status_code, 'message':exception.message}, 500


@cors_preflight('GET,OPTIONS')
@API.route('/foirequests/ministryrequestid/<int:ministryrequestid>', defaults={'usertype':None})
@API.route('/foirequests/ministryrequestid/<ministryrequestid>/<usertype>')
class FOIRequestForDocReviewer(Resource):
"""Retrieve foi request for opened request - Used
in docreviewer"""

@staticmethod
@TRACER.trace()
@cross_origin(origins=allowedorigins())
@auth.require
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,ministryrequestid)
assignee = jsondata['assignedTo']
isrestricted = jsondata['iaorestricteddetails']['isrestricted'] if ('isrestricted' in jsondata['iaorestricteddetails']) else 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,ministryrequestid,AuthHelper.getministrygroups())
assignee = jsondata['assignedministryperson']
isrestricted = jsondata['ministryrestricteddetails']['isrestricted'] if ('isrestricted' in jsondata['ministryrestricteddetails']) else False
if(canrestictdata_ministry(ministryrequestid,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
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down

0 comments on commit f82f616

Please sign in to comment.