Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OBPIH-5801 Add approval/rejection fields to the Requisition domain #4280

Merged
merged 15 commits into from
Sep 18, 2023

Conversation

kchelstowski
Copy link
Collaborator

No description provided.

CONFIRMING(0, null, StatusType.PRIMARY),
WAITING_FOR_APPROVAL(0, null, StatusType.WARNING),
APPROVED(0, null, StatusType.SUCCESS),
REJECTED(0, null, StatusType.DANGER)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let me know what sortOrder those should have in your opinion - I've just added it at the end for now, to have a discussion about that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new fields should be mixed in the first "section" of statuses. As you can see you added these in // Removed section.

@kchelstowski kchelstowski marked this pull request as ready for review September 14, 2023 10:44
Copy link
Collaborator

@awalkowiak awalkowiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not yet reviewed the DB change log, but I already found a few issues (see comments) and you forgot about adding a list of designated approvers to that request.

@@ -91,6 +93,8 @@ class Requisition implements Comparable<Requisition>, Serializable {
// Intended recipient
Person recipient

Person approvedBy
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you move it down to other related fields and add a comment that these are approval related fields

CONFIRMING(0, null, StatusType.PRIMARY),
WAITING_FOR_APPROVAL(0, null, StatusType.WARNING),
APPROVED(0, null, StatusType.SUCCESS),
REJECTED(0, null, StatusType.DANGER)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new fields should be mixed in the first "section" of statuses. As you can see you added these in // Removed section.

Copy link
Collaborator

@awalkowiak awalkowiak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my previous comment

Copy link
Collaborator

@drodzewicz drodzewicz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to me, good job

@@ -117,16 +119,42 @@ class Requisition implements Comparable<Requisition>, Serializable {

Integer statusSortOrder

// Request approval fields
Person approvedBy

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: Let's remove the white space since all of the properties are related to the approvals feature

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

static mapping = {
id generator: 'uuid'
requisitionItems cascade: "all-delete-orphan", sort: "orderIndex", order: 'asc', batchSize: 100

statusSortOrder formula: RequisitionStatus.getStatusSortOrderFormula()
monthRequested formula: "date_format(date_requested, '%M %Y')"
comments joinTable: [name: "requisition_comment", key: "requisition_id"]
events joinTable: [name: "requisition_event", key: "requisition_id"]
designatedApprovers joinTable: [name: "requisition_designated_approvers", key: "requisition_id"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're going to need to refactor this a bit.

My first thought was that designated is an unnecessary qualifier so we should just name this property approvers and the table should be called requisition_approvers.

That would suffice.

But my spidey senses quickly indicated that maybe we need a more generic relationship here. One where we might have different users (and even people or organizations) that are associated with the requisition in different ways. Therefore we could have a generic table requisition_role that would map users (eventually parties) to requisitions through roles (creator, modifier, approver, etc).

We've never really needed a table like this in the past because the creator/modifier roles were always 1:1 and just needed a simple association (createdBy, updatedBy). But with approvers, it becomes a little different since we need to support multiple approvers.

By using a request_role table we would easily handle the approver use case, but could also future-proof the system to support more complex use cases like approval voting (require at least two approvals), notification schemes (users/roles watching certain requisitions), task assignments (picker, packer).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After consulting it with @awalkowiak , we will leave it as it is for now, not to block the whole feature, as we need to discuss it and we'll eventually include this refactor in this ticket but as "post-factum".


Date dateRejected

Boolean requiresApproval
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was what I came up with, but at the time I was thinking "that doesn't sound exactly right". Is there a naming convention that makes this sound more like a property that overrides some behavior or that the requisition is marked to be approved?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

honestly I don't have a better idea. The only one that comes to my mind would be approvalRequired, but this is the same, but in reversed order, so I don't know.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

went for approvalRequired (approved by @awalkowiak )

</preConditions>
<addForeignKeyConstraint baseColumnNames="comment_id"
baseTableName="requisition_comment"
constraintName="fk_requisition_comment_comment"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer the way that Hibernate handles the foreign key naming so we don't have these long meandering names. I'll review old tickets to try to remember how that gets done.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since you probably forgot to reply on that one, I left the "manual" foreign keys names for now not to waste time.

</preConditions>
<addForeignKeyConstraint baseColumnNames="approved_by_id"
baseTableName="requisition"
constraintName="fk_approved_by_requisition"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You followed the correct naming convention for the previous foreign keys (which should be fk__) but not for this one.

fk_requisition_approved_by

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed


Date dateApproved

Date dateRejected
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondering if we should add one more timestamp to represent the date the approval was requested in case we need to send notifications after some period of time. This would probably be unnecessary if we set a timestamp when the requisition is submitted (i.e. dateSubmitted).

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind doing that, so I leave the decision for you.
On the other hand, I think this could be misleading, unless we'd override the dateSubmitted over and over again.
I imagine a situation, when the request is REJECTED, then I believe someone will have a chance to correct it (?), and then again will send it for an approval (submit).

So the question would be - if we reject the request - should the dateSubmitted be cleared out or should it stay, and then, after another submission we'd just override it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussed with the guys - we have dateRequested already, hence we didn't find an advantage of adding it for now.

ERROR(11, null, StatusType.DANGER),
WAITING_FOR_APPROVAL(3, null, StatusType.WARNING),
VERIFYING(4, PENDING, StatusType.WARNING),
APPROVED(5, null, StatusType.SUCCESS),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verifying should come after Approved/Rejected.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've consulted the order with Katarzyna and yeah, we've struggled with positioning those two - we agreed they are "equal", so I couldn't decide whether I should place them above or below the VERIFYING.
I'll change that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed the order

@@ -24,11 +24,28 @@ enum EventCode {
DELIVERED,
RECEIVED,
PARTIALLY_RECEIVED,
CANCELLED
CANCELLED,
WAITING_FOR_APPROVAL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm wondering if we could come up with a more generic term for this like SUBMITTED. Or maybe we need both SUBMITTED and something like PENDING_APPROVAL.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it were up to me, I'd distinguish them. Having said PENDING_APPROVAL, do you mean that I should change the naming from WAITING_FOR_APPROVAL to PENDING_APPROVAL, or it was just an open suggestion?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed to PENDING_APPROVAL, but left the translation as "Waiting for approval". Additionally - added translations for all of the EventCodes, since there were not any.

@awalkowiak awalkowiak merged commit 5783b9b into develop Sep 18, 2023
3 checks passed
@awalkowiak awalkowiak deleted the OBPIH-5801 branch September 18, 2023 08:48
awalkowiak pushed a commit that referenced this pull request Oct 26, 2023
…4280)

* OBPIH-5801 Add fields for request approval workflow for Requisition table/domain

* OBPIH-5801 Include new fields in data binding of requisition and add those fields also to StockMovement Dto

* OBPIH-5801 Add new requisition statuses for the request approval workflow

* OBPIH-5801 Add events, requiresApproval fields to Requisition domain

* OBPIH-5801 Add event codes for request approval workflow

* OBPIH-5801 Revert changes in data binding of requisition, added for testing purposes

* OBPIH-5801 Add a few unit tests to test fields added for Requisition domain for request approval workflow

* OBPIH-5801 Revert unnecessary changes provided in the StockMovement dto

* OBPIH-5801 Add designatedApprovers field to Requisition domain

* OBPIH-5801 Change order of request approval statuses in RequisitionStatus enum

* OBPIH-5801 Fixes after review to Requisition domain

* OBPIH-5801 Add approvers list to StockMovement dto

* OBPIH-5801 Rename event codes related to request approval and add translations for them

* OBPIH-5801 Fix unit test related to renaming the boolean to approvalRequired

* OBPIH-5801 Remove unused Event import in stock movement service
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants