Commit 960f24d
fix(hr): correct document-expiry date formulas — CEL has no Timestamp+int (#93)
`hr_document.is_expiring_soon` and `expiry_status` used `today() + 30` /
`today() + 60` to build the reminder windows. The formula engine is CEL,
where dates are Timestamps and there is no `Timestamp + int` operator — so
`today() + 30` evaluated to null and every comparison against it silently
failed. Net effect: `is_expiring_soon` was always false and `expiry_status`
never returned the `expiring_30d` / `expiring_60d` bands (only expired / valid
/ none), so the expiry-reminder flow had nothing to fire on.
Fix — use the `daysFromNow(n)` builtin (which returns the Timestamp n days
out) instead of `today() + n`:
expires_at <= daysFromNow(30) // was (today() + 30)
expires_at <= daysFromNow(60) // was (today() + 60)
Boot-verified against a fresh dev server (@objectstack 15.1.1, 0 errors) —
the seeded documents now band correctly:
- expires in ~15d → is_expiring_soon = true, expiry_status = expiring_30d
- expires next year → is_expiring_soon = false, expiry_status = valid
- expired 10d ago → is_expired = true, expiry_status = expired
- no expiry date → expiry_status = none
Note: `hr_employee.tenure_years` has a related but distinct defect
(`floor((today() - hire_date) / 365)` — CEL has neither `Timestamp - Timestamp`
→ number nor a `floor` builtin, and the intended `daysBetween()` primitive is
declared in @objectstack/formula's type list but not wired into the runtime,
so it returns null). That one can't be fixed at the template level without a
working date-diff builtin, so it is intentionally left for a framework
follow-up rather than worked around with an unreadable bucketed ternary.
Claude-Session: https://claude.ai/code/session_01BZguyAaQbyUpwMZ2gMLaAP
Co-authored-by: Claude <noreply@anthropic.com>1 parent 93a5477 commit 960f24d
1 file changed
Lines changed: 7 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
51 | | - | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
| |||
57 | 60 | | |
58 | 61 | | |
59 | 62 | | |
60 | | - | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
61 | 66 | | |
62 | 67 | | |
63 | 68 | | |
| |||
0 commit comments