Skip to content

Commit

Permalink
Merge pull request #4844 from bcgov/dev-rook
Browse files Browse the repository at this point in the history
Dev to Test Rook Merge (Ticket 4671 Bug Fixes/Adjustments + Ticket 4679 + Ticket 4694)
  • Loading branch information
sumathi-thirumani authored Dec 6, 2023
2 parents f1e6aba + 0c5e061 commit b70bed6
Show file tree
Hide file tree
Showing 15 changed files with 372 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import {
getReceivedDate,
// onBehalfFullName,
getRecordsDue,
LightTooltip,
LightTooltip,
displayQueueFlagIcons,
} from "../../utils";
import { ActionContext } from "./ActionContext";
import {
Expand Down Expand Up @@ -97,6 +98,12 @@ const DataGridAdvancedSearch = ({ userDetail }) => {


const ProcessingTeamColumns = [
{
field: "flags",
headerName: "FLAGS",
headerAlign: "left",
renderCell: displayQueueFlagIcons,
},
{
field: "axisRequestId",
headerName: "ID NUMBER",
Expand Down Expand Up @@ -189,6 +196,12 @@ const DataGridAdvancedSearch = ({ userDetail }) => {
];

const IntakeTeamColumns = [
{
field: "flags",
headerName: "FLAGS",
headerAlign: "left",
renderCell: displayQueueFlagIcons,
},
{
field: "applicantName",
headerName: "APPLICANT NAME",
Expand Down Expand Up @@ -250,6 +263,12 @@ const DataGridAdvancedSearch = ({ userDetail }) => {
];

const FlexTeamColumns = [
{
field: "flags",
headerName: "FLAGS",
headerAlign: "left",
renderCell: displayQueueFlagIcons,
},
{
field: "axisRequestId",
headerName: "ID NUMBER",
Expand Down
5 changes: 3 additions & 2 deletions forms-flow-web/src/components/FOI/FOIRequest/FOIRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ const FOIRequest = React.memo(({ userDetail }) => {
_status,
requestExtensions,
});

setRequestStatus(mappedBottomText);
};

Expand Down Expand Up @@ -1045,7 +1045,8 @@ const FOIRequest = React.memo(({ userDetail }) => {
</div>

<div className="foileftpanelstatus">
{bottomTextArray.length > 0 &&
{isOIPCReview && requestDetails.isreopened ? ""
: bottomTextArray.length > 0 &&
_requestStatus &&
_requestStatus.toLowerCase().includes("days") &&
bottomTextArray.map((text) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ const OIPCItem = (props) => {
InputLabelProps={{ shrink: true }}
InputProps={{inputProps: { max: formatDate(new Date())} }}
type="date"
error={(!oipc.outcomeid || oipc.outcomeid === 5) && oipc.receiveddate === null}
error={(!oipc.outcomeid || oipc.outcomeid === 5) && oipc.receiveddate === null || oipc.receiveddate === ""}
required
disabled={oipc.outcomeid && oipc.outcomeid !== 5}
/>
Expand Down Expand Up @@ -360,15 +360,15 @@ const OIPCItem = (props) => {
<Grid item md={4}>
<TextField
fullWidth
label="Comply By Date"
label="Order Comply Date"
variant="outlined"
value={oipc.inquiryattributes.inquirydate ? formatDate(new Date(oipc.inquiryattributes.inquirydate)) : null}
onChange = {(event) => handleInquiryFields(event.target.value, "COMPLYDATE")}
InputLabelProps={{ shrink: true }}
InputProps={{inputProps: { min: oipc.receiveddate ? formatDate(new Date(oipc.receiveddate)) : null } }}
type="date"
error={(!oipc.outcomeid || oipc.outcomeid === 5) && oipc.inquiryattributes.inquirydate === null}
required
error={oipc.inquiryattributes.orderno ? (!oipc.outcomeid || oipc.outcomeid === 5) && oipc.inquiryattributes.inquirydate === null || oipc.inquiryattributes.inquirydate === "" : false}
required={oipc.inquiryattributes.orderno}
disabled={oipc.outcomeid && oipc.outcomeid !== 5}
/>
</Grid>
Expand All @@ -380,8 +380,8 @@ const OIPCItem = (props) => {
value={oipc.inquiryattributes.orderno}
onChange = {(event) => handleInquiryFields(event.target.value, "ORDERNO")}
InputLabelProps={{ shrink: true }}
error={(!oipc.outcomeid || oipc.outcomeid === 5) && oipc.inquiryattributes.orderno === ""}
required
error={oipc.inquiryattributes.inquirydate ? (!oipc.outcomeid || oipc.outcomeid === 5) && oipc.inquiryattributes.orderno === "" : false}
required={oipc.inquiryattributes.inquirydate}
disabled={oipc.outcomeid && oipc.outcomeid !== 5}
placeholder="Order Number"
/>
Expand All @@ -394,9 +394,7 @@ const OIPCItem = (props) => {
onChange = {(event) => handleInquiryFields(event.target.value, "INQUIRYOUTCOME")}
fullWidth
value={oipc.inquiryattributes.inquiryoutcome ? oipc.inquiryattributes.inquiryoutcome : -1}
label="Outcome"
error={(!oipc.outcomeid || oipc.outcomeid === 5) && oipc.inquiryattributes.inquiryoutcome === null}
required
label="Inquiry Outcome"
disabled={oipc.outcomeid && oipc.outcomeid !== 5}
>
<MenuItem disabled value={-1}>
Expand Down
9 changes: 7 additions & 2 deletions forms-flow-web/src/components/FOI/FOIRequest/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,13 @@ export const checkValidationError = (
!requiredRequestDetailsValues.requestStartDate ||
!requiredAxisDetails.axisRequestId ||
(oipcData?.length > 0 && isOipcReview && oipcData?.some((oipc) => {
return oipc.oipcno === "" || oipc.receiveddate === null || oipc.receiveddate === "" || oipc.reviewtypeid === null || oipc.reasonid === null || oipc.statusid === null ||
oipc.inquiryattributes?.orderno === "" || oipc.inquiryattributes?.inquiryoutcome === null || oipc.inquiryattributes?.inquirydate === null || oipc.inquiryattributes?.inquirydate === "";
if (oipc.inquiryattributes?.inquirydate) {
return oipc.inquiryattributes.orderno === "";
}
if (oipc.inquiryattributes?.orderno) {
return oipc.inquiryattributes?.inquirydate === null || oipc.inquiryattributes?.inquirydate === "";
}
return oipc.oipcno === "" || oipc.receiveddate === null || oipc.receiveddate === "" || oipc.reviewtypeid === null || oipc.reasonid === null || oipc.statusid === null;
}))
);
};
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
"""empty message
Revision ID: 3e91d4f34699
Revises: 455a24da8c58
Create Date: 2023-11-30 00:11:56.160830
"""
from alembic import op
import sqlalchemy as sa
from sqlalchemy.dialects import postgresql

# revision identifiers, used by Alembic.
revision = '3e91d4f34699'
down_revision = '455a24da8c58'
branch_labels = None
depends_on = None


def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute('Insert into public."NotificationTypes" (name, description, isactive) values (\'OIPC\', \'OIPC\', true);commit;')
op.execute('Insert into public."NotificationTypes" (name, description, isactive) values (\'OIPC Due Reminder\', \'OIPC Due Reminder\', true);commit;')
op.execute('Insert into public."CommentTypes" (name, description, isactive) values (\'OIPC Tracking\', \'OIPC Tracking\', true);commit;')
# ### end Alembic commands ###


def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
op.execute('delete from public."NotificationTypes" where name in (\'OIPC\');commit;')
op.execute('delete from public."NotificationTypes" where name in (\'OIPC Due Reminder\');commit;')
op.execute('delete from public."CommentTypes" where name in (\'OIPC Tracking\');commit;')
# ### end Alembic commands ###
29 changes: 28 additions & 1 deletion request-management-api/request_api/models/FOIMinistryRequests.py
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ def getrequestssubquery(cls, groups, filterfields, keyword, additionalfilter, us
SubjectCode,
SubjectCode.subjectcodeid == FOIMinistryRequestSubjectCode.subjectcodeid,
isouter=True
).filter(FOIMinistryRequest.requeststatusid != 3)
).filter(or_(FOIMinistryRequest.requeststatusid != 3, and_(FOIMinistryRequest.isoipcreview == True, FOIMinistryRequest.requeststatusid == 3)))

if(additionalfilter == 'watchingRequests'):
#watchby
Expand Down Expand Up @@ -788,6 +788,33 @@ def getupcomingdivisionduerecords(cls):
finally:
db.session.close()
return upcomingduerecords

@classmethod
def getupcomingoipcduerecords(cls):
upcomingduerecords = []
try:
sql = """select axisrequestid, filenumber, fma.foiministryrequestid , fma.foiministryrequestversion, fma.foirequest_id,
frd.oipcid , frd.inquiryattributes ->> 'orderno'as orderno,
frd.inquiryattributes ->> 'inquirydate' as duedate, frd.created_at, frd.createdby
from "FOIRequestOIPC" frd
inner join (select distinct on (fpa.foiministryrequestid) foiministryrequestid, version as foiministryrequestversion, axisrequestid, filenumber, foirequest_id, requeststatusid
from "FOIMinistryRequests" fpa
order by fpa.foiministryrequestid , fpa.version desc) fma on frd.foiministryrequest_id = fma.foiministryrequestid
and frd.foiministryrequestversion_id = fma.foiministryrequestversion and fma.requeststatusid not in (5,6,4,11,3,15)
and (frd.inquiryattributes ->> 'inquirydate')::date between NOW() - INTERVAL '7 DAY' AND NOW() + INTERVAL '7 DAY'
order by frd.foiministryrequest_id , frd.foiministryrequestversion_id desc;"""
rs = db.session.execute(text(sql))
for row in rs:
upcomingduerecords.append({"axisrequestid": row["axisrequestid"], "filenumber": row["filenumber"],
"foiministryrequestid": row["foiministryrequestid"], "version": row["foiministryrequestversion"],
"foirequest_id": row["foirequest_id"], "created_at": row["created_at"], "createdby": row["createdby"],
"orderno": row["orderno"],"duedate": row["duedate"]})
except Exception as ex:
logging.error(ex)
raise ex
finally:
db.session.close()
return upcomingduerecords

@classmethod
def updateduedate(cls, ministryrequestid, duedate, userid)->DefaultMethodResult:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ class OIPCReviewTypesReasons(db.Model):
__tablename__ = 'OIPCReviewTypesReasons'
# Defining the columns
reviewtypereasonid = db.Column(db.Integer, primary_key=True,autoincrement=True)
reviewtypeid = db.Column(db.Integer, ForeignKey('FOIReviewTypes'))
relationship("FOIReviewTypes", backref=backref("FOIReviewTypes"), uselist=False)
reasonid = db.Column(db.Integer, ForeignKey('FOIReasons'))
relationship("FOIReasons", backref=backref("FOIReasons"), uselist=False)
reviewtypeid = db.Column(db.Integer, ForeignKey('OIPCReviewTypes'))
relationship("OIPCReviewTypes", backref=backref("OIPCReviewTypes"), uselist=False)
reasonid = db.Column(db.Integer, ForeignKey('OIPCReasons'))
relationship("OIPCReasons", backref=backref("OIPCReasons"), uselist=False)
isactive = db.Column(db.Boolean, unique=False, nullable=False)

@classmethod
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ def getpreviousbusinessday(self, cfrduedate,ca_holidays):
return _prevbusinessday
else:
return self.getpreviousbusinessday(_prevbusinessday,ca_holidays)


def getpreviousbusinessday_by_n(self, duedate, ca_holidays, n):
_prevbusinessday = duedate
for i in range(n):
_prevbusinessday = self.getpreviousbusinessday(_prevbusinessday, ca_holidays)
return _prevbusinessday

def formatduedate(self,input):
return datetimehandler().formatdate(input)

Expand Down
156 changes: 156 additions & 0 deletions request-management-api/request_api/services/events/oipc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@

from os import stat
from re import VERBOSE
from request_api.models.FOIRequestOIPC import FOIRequestOIPC
from request_api.services.commentservice import commentservice
from request_api.services.oipcservice import oipcservice
from request_api.services.notificationservice import notificationservice
from request_api.models.FOIMinistryRequests import FOIMinistryRequest
import json
from request_api.models.default_method_result import DefaultMethodResult
from enum import Enum
from request_api.exceptions import BusinessException
from dateutil.parser import parse
from request_api.utils.enums import CommentType

class oipcevent:
""" FOI OIPC Event management service
"""

def createoipcevent(self, requestid, userid):
inquiryoutcomes = oipcservice().getinquiryoutcomes()
version = FOIMinistryRequest.getversionforrequest(requestid)
curoipcs = FOIRequestOIPC.getoipc(requestid, version)
prevoipcs = FOIRequestOIPC.getoipc(requestid, version[0]-1)
oipcsummary = self.__maintained(curoipcs, prevoipcs, inquiryoutcomes)
if oipcsummary is None or (oipcsummary and len(oipcsummary) <1):
return DefaultMethodResult(True,'No change',requestid)
try:
for oipc in oipcsummary:
self.__createcomment(requestid, oipc, userid)
self.__createnotification(requestid, oipc, userid)
return DefaultMethodResult(True,'Comment posted',requestid)
except BusinessException as exception:
return DefaultMethodResult(False,'unable to post comment - '+exception.message,requestid)


def __createcomment(self, requestid, oipc, userid):
comment = {"ministryrequestid": requestid, "comment": self.__preparemessage(oipc)}
commentservice().createministryrequestcomment(comment, userid, CommentType.OIPC.value)

def __createnotification(self, requestid, oipc, userid):
return notificationservice().createnotification({"message" : self.__preparemessage(oipc)}, requestid, "ministryrequest", "OIPC", userid, False)


def __maintained(self,coipcs, poipcs, inquiryoutcomes):
oipcs = []
for coipc in coipcs:
if self.__isoipcpresent(self.__getoipcnumber(coipc), poipcs) == False:
oipcs.append(self.__createoipcsummary(coipc, EventType.add.value, inquiryoutcomes))
else:
if self.__isoutcomeclosed(coipc, poipcs) == True:
oipcs.append(self.__createoipcsummary(coipc, EventType.close.value, inquiryoutcomes))
if self.__isinquirychanged(coipc, poipcs) == True:
oipcs.append(self.__createoipcsummary(coipc, EventType.inquirychange.value, inquiryoutcomes))
elif self.__isinquiryoutcomechanged(coipc, poipcs, inquiryoutcomes) == True:
oipcs.append(self.__createoipcsummary(coipc, EventType.inquiryoutcome.value, inquiryoutcomes))
return oipcs

# def __deleted(self, coipcs, poipcs):
# oipcs = []
# for poipc in poipcs:
# if self.__isoipcpresent(self.__getoipcnumber(poipc), coipcs) == False:
# oipcs.append(self.__createoipcsummary(poipc, EventType.delete.value))
# return oipcs

def __isoipcpresent(self, oipcno, poipcs):
for oipc in poipcs:
if self.__getoipcnumber(oipc) == oipcno:
return True
return False

def __isoutcomeclosed(self, coipc, poipcs):
for oipc in poipcs:
if self.__getoipcnumber(oipc) == self.__getoipcnumber(coipc) and self.__getoutcome(oipc) != self.__getoutcome(coipc) and self.__getoutcome(coipc) == "Closed":
return True
return False

def __isinquirychanged(self, coipc, poipcs):
for oipc in poipcs:
if self.__getoipcnumber(oipc) == self.__getoipcnumber(coipc) and self.__getinquiry(oipc) != self.__getinquiry(coipc):
if self.__getinquirycomplydate(coipc) not in (None, "") and self.__getinquiryorderno(coipc) not in (None, "") and (self.__getinquiryorderno(oipc) != self.__getinquiryorderno(coipc) or self.__getinquirycomplydate(oipc) != self.__getinquirycomplydate(coipc)):
return True
return False

def __isinquiryoutcomechanged(self, coipc, poipcs, inquiryoutcomes):
for oipc in poipcs:
if self.__getoipcnumber(oipc) == self.__getoipcnumber(coipc) and self.__getinquiry(oipc) != self.__getinquiry(coipc):
if self.__getinquiryoutcome(coipc, inquiryoutcomes) not in (None, "") and self.__getinquiryoutcome(oipc, inquiryoutcomes) != self.__getinquiryoutcome(coipc, inquiryoutcomes):
return True
return False

def __createoipcsummary(self, oipc, event, inquiryoutcomes):
return {'oipcno': self.__getoipcnumber(oipc),
'reviewtype': self.__getoipcreviewtype(oipc),
'reason':self.__getreason(oipc),
'outcome': self.__getoutcome(oipc),
'inquirycomplydate': self.__getinquirycomplydate(oipc),
'inquiryorderno': self.__getinquirycomplydate(oipc),
'inquiryoutcome': self.__getinquiryoutcome(oipc, inquiryoutcomes),
'event': event}

def __getoipcnumber(self, dataschema):
return dataschema['oipcno']

def __getoipcreviewtype(self, dataschema):
return dataschema['reviewtype.name']

def __getreason(self, dataschema):
return dataschema['reason.name']

def __getoutcome(self, dataschema):
return dataschema['outcome.name'] if dataschema['outcomeid'] not in (None,"") else None

def __getinquirycomplydate(self, dataschema):
return self.__getinquiry(dataschema)['inquirydate'] if dataschema['inquiryattributes'] not in (None,"") else None

def __getinquiryoutcome(self, dataschema, inquiryoutcomes):
if dataschema['inquiryattributes'] not in (None,""):
inquiryoutcomeid = self.__getinquiry(dataschema)['inquiryoutcome']
if inquiryoutcomeid not in (None,""):
return self.__getinquiryoutcomename(inquiryoutcomeid, inquiryoutcomes)
return None

def __getinquiryorderno(self, dataschema):
return self.__getinquiry(dataschema)['orderno'] if dataschema['inquiryattributes'] not in (None,"") else None

def __getinquiry(self, dataschema):
return dataschema['inquiryattributes']

def __getinquiryoutcomename(self, inquiryoutcomeid, inquiryoutcomes):
for outcome in inquiryoutcomes:
if inquiryoutcomeid == outcome["inquiryoutcomeid"]:
return outcome["name"]
return None

def __preparemessage(self, oipc):
if oipc['event'] == EventType.add.value:
return 'OIPC '+ oipc['reviewtype'] +' opened for '+ oipc['reason']
elif oipc['event'] == EventType.close.value:
return 'OIPC '+ oipc['reviewtype'] +' closed for '+ oipc['reason']
elif oipc['event'] == EventType.inquirychange.value:
_inquirychange_msg = 'OIPC Inquiry Order '+ oipc['inquiryorderno'] +' compliance date due '+oipc['inquirycomplydate']
if oipc['inquiryoutcome'] not in (None, ""):
return _inquirychange_msg+' .Inquiry Decision:' + oipc['inquiryoutcome']
else:
return _inquirychange_msg
elif oipc['event'] == EventType.inquiryoutcome.value:
return 'OIPC '+ oipc['reviewtype'] +' Inquiry Decision: '+ oipc['inquiryoutcome']


class EventType(Enum):
add = "add"
delete = "delete"
close = "close"
inquirychange = "inquirychange"
inquiryoutcome = "inquiryoutcome"
Loading

0 comments on commit b70bed6

Please sign in to comment.