Skip to content

fix(chores): only block a bonus claim on bonus chores due today - #158

Merged
Szeraax merged 1 commit into
jherforth:mainfrom
mrramam:fix/bonus-claim-due-today
Sep 7, 2026
Merged

fix(chores): only block a bonus claim on bonus chores due today#158
Szeraax merged 1 commit into
jherforth:mainfrom
mrramam:fix/bonus-claim-due-today

Conversation

@mrramam

@mrramam mrramam commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Claiming a bonus chore is refused with "User already has an uncompleted bonus chore. Complete it first!" when the user has bonus chores assigned for other days of the week, even though every bonus chore actually due today is complete.

Cause

assignBonusChore() builds its blocking set with no due-today filter:

const userBonusSchedules = schedules.filter(s =>
  s.user_id === userId && s.visible === 1 && s.clam_value > 0);

schedules comes from /api/chore-schedules?usage=chart — every visible schedule regardless of crontab — so a Monday-only chore counts as outstanding on a Sunday.

The filter is right about which chores are bonus chores (clam_value > 0, matching the server's own test that a regular chore is clam_value === 0) and wrong about when they are outstanding.

This is not intermittent. A user whose bonus chores span the week always has some that are not due, so the gate fires every day and the claim path becomes unreachable. On the install where this was found, one child had bonus chores on Mon/Tue/Wed/Thu/Fri and could not claim on any day.

The inverse also holds: regular chores that are outstanding are invisible to the gate, since they are clam_value 0. It blocks on chores that are not due and ignores chores that are.

Fix

shouldShowChoreToday() already implements the due-today predicate — cron replay in the server timezone, plus snooze handling — and ChoreWidget already imports it and renders with it.

This extracts the rule into hasOutstandingBonusChore() in choreHelpers.js, filtering through that same predicate, so the gate and the visible list cannot disagree. The component's inline block collapses to one call.

The one-bonus-at-a-time rule itself is unchanged — only the set it is evaluated against.

Tests

Seven unit cases on the new helper: not-due chore does not block, due-and-uncompleted does, the reported case (due-today complete + other weekdays outstanding) does not, plus regular chores, other users, hidden schedules, and a one-off with no crontab.

Client suite: 167 passing (160 + 7). i18n parity unchanged; no new strings.

One test carries a comment worth noting for reviewers: cases are chosen to avoid the day immediately after "today", because shouldShowChoreToday compares a cron occurrence resolved in the server zone against local midnight. When the two differ, tomorrow-00:00 can land on today's local date. That is a pre-existing timezone issue, unrelated to this change, and not addressed here.

Claiming a bonus chore was refused with "User already has an
uncompleted bonus chore" whenever the user had bonus chores assigned
for other days of the week, even with every bonus chore actually due
today complete.

assignBonusChore built its blocking set from every visible schedule
with clam_value > 0, with no due-today filter, while `schedules` comes
from /api/chore-schedules?usage=chart — every visible schedule
regardless of crontab. A Monday-only chore therefore counted as
outstanding on a Sunday.

This is not intermittent: a user whose bonus chores span the week
always has some that are not due, so the gate fires every day and the
claim path is unreachable.

Extract the rule to hasOutstandingBonusChore() in choreHelpers, which
filters through shouldShowChoreToday — the same predicate the widget
renders with, so the gate and the visible list cannot disagree — and
cover it with unit tests.

The one-bonus-at-a-time rule itself is unchanged; only the set it is
evaluated against.
@Szeraax

Szeraax commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Preserves the intent of only doing 1 bonus chore at a time. Approved.

@Szeraax
Szeraax merged commit eee5fb6 into jherforth:main Sep 7, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from Backlog to Done in HomeGlow Kanban Sep 7, 2026
@Szeraax Szeraax added this to the 1.8 milestone Sep 7, 2026
@mrramam
mrramam deleted the fix/bonus-claim-due-today branch September 12, 2026 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants