Skip to content

Display allocation warning during pending LSF approval (#622)#638

Open
DanielRukwasha wants to merge 21 commits into
allocation-card-real-data-rukfrom
622-allocation-warning-lsf-approval
Open

Display allocation warning during pending LSF approval (#622)#638
DanielRukwasha wants to merge 21 commits into
allocation-card-real-data-rukfrom
622-allocation-warning-lsf-approval

Conversation

@DanielRukwasha

Copy link
Copy Markdown

Closes #622

Adds a non-blocking over-allocation warning to the pending-LSF approval confirmation modal, so Labor Office admins can see the allocation impact before approving.

  • Extracted the allocation-counting logic from Create Current Allocation Card for the Department Portal #602's Department Portal card into a shared \�pp/logic/allocation.py\ (\getAllocationSummary, \getAllocationWarning), so this reuses the exact same 'used' counting (non-denied LaborStatusForms) instead of duplicating queries.
  • \modal_approval_and_denial_data()\ now returns one allocation warning per unique department among the selected forms, alongside the existing per-form table data.
  • The approval modal (\pendingApprovalModal.html\ / \�llPendingForms.js) renders a warning box per department: blue if within allocation, amber if any category is over. Positions and Break Hours are highlighted independently per the issue's requirement ('highlight any allocation categories that exceed'), since a department can be over on one and fine on the other.
  • Fixed a pre-existing demo-data gap found while testing: no student/supervisor was ever marked \isActive, so the approval checkbox (which requires both to be active) never rendered at all in this environment.

Branched off \�llocation-card-real-data-ruk\ (not \�llocation_card\ directly) since this depends on the allocation logic from #636, which hasn't merged yet.

Tested via direct API calls and in-browser: confirmed the warning shows correct numbers, confirmed the red/amber highlighting triggers independently for positions-only and break-hours-only over-allocation scenarios, and confirmed the full approve flow completes correctly end-to-end.

BrianRamsay and others added 3 commits July 2, 2026 16:01
Extract allocation logic into app/logic/allocation.py (getAllocationSummary, getAllocationWarning), wire it into modal_approval_and_denial_data() to show a per-department warning box in the approval confirmation modal, and fix demo data so students/supervisors are marked active (needed for the approval checkbox to render at all).
isOverAllocated was a single combined flag, so a department over on one category but fine on the other would show the whole box the same way. Split into isPositionsOverAllocated / isBreakHoursOverAllocated so each metric line is highlighted (with an explicit warning marker, not just color) based on its own status.
@MImran2002

Copy link
Copy Markdown
Contributor

The warning is not popping up when i follow the steps to create that warning.

@MImran2002 MImran2002 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Warning not showing

DanielRukwasha and others added 7 commits July 9, 2026 14:20
…llocated

Complements the pre-approval modal warning: after a Pending LSF is approved, check the affected department's allocation and flash a warning (non-blocking) if it's now over its allocated positions or break hours. Reuses getAllocationWarning() from #602/#622's shared allocation logic.
Imran found that approving forms into a specific band (e.g. 10 Hour Primary, allocated 1) past its limit showed no warning, because isPositionsOverAllocated only compared the aggregate total across all 6 bands. A department can be under its total while one band is individually over. getAllocationWarning() now also flags any band where used > allocated, and both the pre-approval modal and the post-approval flash name the specific band(s) that are over instead of just the misleading aggregate number.

Also removed docstrings that were flagged as too explicit in review.
…-allocation-warning-lsf-approval

# Conflicts:
#	app/models/allocation.py
#	app/models/positionHistory.py
#	database/demo_data.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants