user testing and fixing minor issues

This commit is contained in:
JCEEE
2026-08-31 19:26:55 +01:00
parent a521edaabf
commit fdacfc7e5c
4 changed files with 184 additions and 91 deletions
@@ -85,10 +85,19 @@ export async function familyStats(pb: any, famId: string): Promise<FamilyStats>
if (date) addWeek(c.memberId, weekStartFor(date, payday, tz), pts, cash, 1);
}
// Money-type todos auto-create a matching cash reward when the todo is
// completed (see completions.toggle). That cash is already counted in the
// completion loop above, so skip those completion-linked rewards here to
// avoid double-counting the same earning event.
const autoRewardIds = new Set(
completions.map((c: any) => c.rewardId).filter((id?: string) => !!id)
);
// Claimed rewards (bonuses/triggers/pocket money) count toward lifetime
// earnings once issued. Unclaimed/requested stay "to chase" client-side.
for (const r of rewards) {
if (r.status !== 'claimed') continue;
if (autoRewardIds.has(r.id)) continue;
const date = ((r.claimedAt as string) || (r.date as string) || '').slice(0, 10);
if (r.rewardType === 'points') {
const v = Number(r.value) || 0;