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

Check whether paymentunits have deliverunits set before processing #458

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

sravfeyn
Copy link
Member

@sravfeyn sravfeyn commented Jan 6, 2025

Product Description

Detect when paymentunits don't have deliverunit set.

Technical Summary

We have been having cases where projects are trying to submit forms and they are failing due to their payment-units being configured partially. This will do two things when paymentunits don't have deliverunit set.

  1. When setting up opportunity, users will get a warning that opportunity setup is not complete.
  2. Server will respond with a more clear message when submissions do occur.

Safety Assurance

Safety story

Automated test coverage

Existing processor tests

QA Plan

NA

Labels & Review

  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@sravfeyn sravfeyn requested a review from calellowitz January 6, 2025 10:23
Copy link
Contributor

@pxwxnvermx pxwxnvermx left a comment

Choose a reason for hiding this comment

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

Thanks 🙌🏽

Copy link
Collaborator

@calellowitz calellowitz left a comment

Choose a reason for hiding this comment

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

Left a few questions

@@ -100,6 +100,9 @@ def is_setup_complete(self):
for pu in self.paymentunit_set.all():
if not (pu.max_total and pu.max_daily):
return False
if not pu.deliver_units.exists():
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is it possible to add this as validation on the form that sets these up? It probably shouldn't be possible to submit that form (or section of the form) if there are none selected. That way users will also know before forms start to come in.

Copy link
Member Author

@sravfeyn sravfeyn Jan 15, 2025

Choose a reason for hiding this comment

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

Interesting, the form already has this as required, so this shouldn't really happen, I am not sure how it ended up happening. Do you have any idea how this could have occurred?

@@ -232,6 +232,8 @@ def clean_form_submission(access: OpportunityAccess, user_visit: UserVisit, xfor


def process_deliver_unit(user, xform: XForm, app: CommCareApp, opportunity: Opportunity, deliver_unit_block: dict):
if not opportunity.is_setup_complete:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we want this to be more targeted? Occasionally projects add new payment units part way through, and I would be concerned that if they improperly add new ones, this check would prevent the old ones from being processed as well. If we instead just did an error message when we hit this error, that might be safer.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, I am happy to just make a sentry error here instead of hard-fail. Though, per above comment this shouldn't be possible.

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.

3 participants