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 for None value #443

Merged
merged 1 commit into from
Dec 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion commcare_connect/form_receiver/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ def process_deliver_unit(user, xform: XForm, app: CommCareApp, opportunity: Oppo
)
completed_work_needs_save = False
today = datetime.date.today()
if opportunity.start_date > today or (payment_unit.start_date and payment_unit.start_date > today):
paymentunit_startdate = payment_unit.start_date if payment_unit else None
if opportunity.start_date > today or (paymentunit_startdate and paymentunit_startdate > today):
Copy link
Contributor

Choose a reason for hiding this comment

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

The issue arises when payment_unit is null. In cases where payment_unit is null and opportunity.start_date > today evaluates to false, the code proceeds to the else block. However, since payment_unit is required for completed_work, this results in an error.

Copy link
Member Author

Choose a reason for hiding this comment

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

You are right, this seems to be a seperate issue for a while https://dimagi.sentry.io/issues/6098769063/?environment=production&project=4505635339829248&query=is%3Aunresolved%20issue.priority%3A%5Bhigh%2C%20medium%5D&referrer=issue-stream&sort=date&statsPeriod=14d&stream_index=0

But let’s merge at least this fix, because that affects even where paymentunit is not NULL

Copy link
Member Author

Choose a reason for hiding this comment

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

completed_work = None
user_visit.status = VisitValidationStatus.trial
else:
Expand Down