Show remaining days alongside absences - #49
Merged
Conversation
The Absences view says how many days somebody took and nothing about how many they have left, and the sidebar it opens says no more — so the only way to answer the obvious follow-up was to abandon the view for the Balances report and come back. Request detail now carries the employee's balance for that leave type in the year the leave starts — that year, not the current one, because usage is attributed the same way, and reporting this year's allowance beside last year's leave would describe something else entirely. Null for a type that counts against nothing, where "how many are left" has no answer. Gated on canViewBalanceOf(), the same rule the balance endpoints use, so a colleague who may read a request still cannot read the allowance behind it. The sidebar shows it as a headline number with the workings under it — "22 days left, of 28 days · 6 days taken" — and names what is still awaiting a decision, since pending days are the difference between what is left and what is safe to book. The Absences rows carry the same figure inline, from one batched report per reload rather than a lookup per row; with the year filter on "All years" there is no single answer, so the rows simply omit it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The Absences view says how many days somebody took and nothing about how many they have left. The sidebar it opens says no more — so the only way to answer the obvious follow-up was to abandon the view for the Balances report and come back.
Two places, one figure
The right-hand sidebar now shows the balance among the other facts:
The headline is what's left; the workings sit under it. Pending days get their own line because they are precisely the difference between what is left and what is safe to book — the distinction that makes a balance actionable rather than just a number. The sidebar opens from Absences, Approvals, Team and My leave, so this covers all four.
The Absences rows carry the same figure inline:
2–4 Mar · 3 days · 22 days left.Details worth flagging
The year is the one the leave starts in, not the current one. Usage is attributed the same way in
BalanceService, and reporting this year's allowance beside last year's leave would describe something else entirely.Permission-gated.
canViewBalanceOf()— the same rule the balance endpoints use — so a colleague who may read a request still cannot read the allowance behind it. The lookup is skipped entirely when they may not.Null where the question has no answer. Unpaid and special leave count against nothing, so there is no "left" to report and the block is absent rather than showing zeroes.
One query batch, not one per row. The list uses a single balances report per reload, indexed by employee and type —
getBalancesForEmployees()computes the lot in a fixed number of queries, which a request per visible absence would not. With the year filter on "All years" there is no single answer, so the rows omit it.Testing
177 tests, 497 assertions, 0 failures (3 new): that the detail carries the right year's figures, that it is withheld from someone who may not see the allowance, and that a non-counting type yields null. eslint 0 errors, stylelint clean, 27/27 vitest, build succeeds.
RequestServiceTest's service construction moved into arebuildService()helper, so a test can reprogram a collaborator withexpects()before the constructor is handed it.Note
I could not see the screenshot referenced in the report, so I worked from the code. If by "the right hand side overview" you meant something other than the request sidebar — the stat tiles above the Balances table, say — tell me and I will follow up.
🤖 Generated with Claude Code