Skip to content

New balances table w/ test examples#14

Merged
srkirkland merged 1 commit into
mainfrom
srk/balances-table
Jul 16, 2026
Merged

New balances table w/ test examples#14
srkirkland merged 1 commit into
mainfrom
srk/balances-table

Conversation

@srkirkland

@srkirkland srkirkland commented Jul 16, 2026

Copy link
Copy Markdown
Member

Will eventually be populated by fabric but this is the right shape and gives us something to work with

Summary by CodeRabbit

  • New Features

    • Added employee accrual balance data support, including balances, employee details, leave information, limits, and accrual metrics.
    • Added development data seeding for employee accrual balances.
    • Added read-only querying for employee accrual balances.
  • Bug Fixes

    • Development seeding now avoids creating duplicate balance records.
  • Tests

    • Added coverage for balance data mapping, seeded values, duplicate prevention, and read-only queries.

@coderabbitai

coderabbitai Bot commented Jul 16, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds the EmployeeAccrualBalance EF Core entity, database migration, no-tracking query, development seed data, derived-value mapping, and integration tests covering schema metadata, idempotent seeding, and query tracking behavior.

Changes

Employee accrual balances

Layer / File(s) Summary
Balance entity and query contract
server.core/Domain/EmployeeAccrualBalance.cs, server.core/Data/AppDbContext.cs
Defines the employee accrual balance properties, composite key, column mappings, indexes, and an AsNoTracking() queryable.
Database schema migration
server.core/Migrations/20260716171119_AddEmployeeAccrualBalances.cs, server.core/Migrations/20260716171119_AddEmployeeAccrualBalances.Designer.cs, server.core/Migrations/AppDbContextModelSnapshot.cs
Creates and snapshots the dbo.EmployeeAccrualBalances table with its typed columns, composite primary key, indexes, and rollback operation.
Development seeding and validation
server.core/Data/DbInitializer.cs, tests/server.tests/Data/EmployeeAccrualBalanceTests.cs
Adds development balance records, composite-key deduplication, derived-value mapping, and tests for metadata, idempotency, seeded values, and no-tracking queries.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant DbInitializer
  participant AppDbContext
  participant Database
  DbInitializer->>AppDbContext: Query existing EmployeeAccrualBalance keys
  AppDbContext->>Database: Read EmployeeAccrualBalances
  Database-->>AppDbContext: Return existing keys
  AppDbContext-->>DbInitializer: Identify missing seed records
  DbInitializer->>AppDbContext: Add mapped balances
  DbInitializer->>Database: SaveChangesAsync
Loading

Possibly related PRs

  • ucdavis/leaves#5: Updates the same EF Core context and development seeding integration points for another domain entity.

Suggested reviewers: aristachauhan

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is clearly related to the new balances table and accompanying tests, though it is a bit broad.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch srk/balances-table

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
server.core/Domain/EmployeeAccrualBalance.cs (1)

76-89: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Confirm nvarchar(max) is intentional for short status/flag codes.

HrStatus, EmployeeStatus, EmployeeType, and ApproachingMax are mapped as nvarchar(max), yet DbInitializer.CreateEmployeeAccrualBalance only ever populates them with single-character values ("A", "E", "Y"/"N"). Sibling short codes on this same entity (UnionCode, EmployeeClassCode) are correctly bounded (nvarchar(3)). Since this table's purpose is to "establish the intended shape" for Fabric-sourced data, worth confirming these widths actually mirror the source columns — unbounded nvarchar(max) wastes storage and blocks efficient indexing/filtering if these fields are ever queried.

♻️ Example bound if source values are short codes
-        entity.Property(e => e.HrStatus).HasColumnType("nvarchar(max)");
-        entity.Property(e => e.EmployeeStatus).HasColumnType("nvarchar(max)");
+        entity.Property(e => e.HrStatus).HasColumnType("nvarchar(1)").HasMaxLength(1);
+        entity.Property(e => e.EmployeeStatus).HasColumnType("nvarchar(1)").HasMaxLength(1);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server.core/Domain/EmployeeAccrualBalance.cs` around lines 76 - 89, Update
the EmployeeAccrualBalance mappings for HrStatus, EmployeeStatus, EmployeeType,
and ApproachingMax to use bounded nvarchar lengths matching their Fabric source
columns and short-code values, consistent with UnionCode and EmployeeClassCode;
do not leave them as nvarchar(max) unless the source schema confirms they are
intentionally unbounded.
server.core/Data/DbInitializer.cs (1)

528-588: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Verify the sign convention of HoursOverUnderPolicyMax.

HoursOverUnderPolicyMax = AccrualLimit - CalculatedBal (line 571) produces a positive value when the employee is well under the cap — e.g. the test expects +152.62 for a balance of 87.38 against a 240.00 limit. That's the inverse of what the property name typically implies (positive = over the max, negative = under). If a real employee ever exceeds the cap, this formula goes negative, which downstream consumers reading the field literally ("hours over policy max") would likely misinterpret.

Since this table is meant to mirror the Fabric source shape, please confirm the source system's actual sign convention for this column before this dev-seed placeholder becomes the reference implementation for real ingestion logic.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@server.core/Data/DbInitializer.cs` around lines 528 - 588, Verify the Fabric
source sign convention for HoursOverUnderPolicyMax, then update the assignment
in CreateEmployeeAccrualBalance to match it rather than assuming AccrualLimit
minus CalculatedBal. Preserve the zero-limit handling and ensure under-cap and
over-cap values have the source-defined signs.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@server.core/Data/DbInitializer.cs`:
- Around line 528-588: Verify the Fabric source sign convention for
HoursOverUnderPolicyMax, then update the assignment in
CreateEmployeeAccrualBalance to match it rather than assuming AccrualLimit minus
CalculatedBal. Preserve the zero-limit handling and ensure under-cap and
over-cap values have the source-defined signs.

In `@server.core/Domain/EmployeeAccrualBalance.cs`:
- Around line 76-89: Update the EmployeeAccrualBalance mappings for HrStatus,
EmployeeStatus, EmployeeType, and ApproachingMax to use bounded nvarchar lengths
matching their Fabric source columns and short-code values, consistent with
UnionCode and EmployeeClassCode; do not leave them as nvarchar(max) unless the
source schema confirms they are intentionally unbounded.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 608826c4-a10d-422f-82f8-fdf8b84c10dd

📥 Commits

Reviewing files that changed from the base of the PR and between fde870a and d39d6c9.

📒 Files selected for processing (7)
  • server.core/Data/AppDbContext.cs
  • server.core/Data/DbInitializer.cs
  • server.core/Domain/EmployeeAccrualBalance.cs
  • server.core/Migrations/20260716171119_AddEmployeeAccrualBalances.Designer.cs
  • server.core/Migrations/20260716171119_AddEmployeeAccrualBalances.cs
  • server.core/Migrations/AppDbContextModelSnapshot.cs
  • tests/server.tests/Data/EmployeeAccrualBalanceTests.cs

@srkirkland
srkirkland merged commit 6ff3739 into main Jul 16, 2026
4 checks passed
@srkirkland
srkirkland deleted the srk/balances-table branch July 16, 2026 17:26
@coderabbitai coderabbitai Bot mentioned this pull request Jul 17, 2026
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.

3 participants