feat(Payroll): add regular-rate-of-pay workweek distribution helpers#2473
Draft
krisxcrash wants to merge 1 commit into
Draft
feat(Payroll): add regular-rate-of-pay workweek distribution helpers#2473krisxcrash wants to merge 1 commit into
krisxcrash wants to merge 1 commit into
Conversation
Ports gusto-web's evenlyDistributeValue (pro-rata distribution across workweeks, weighted by calendar days, with rounding-remainder reconciliation) and its existence-based needsWorkweekBreakdown / needsWorkweekBreakdownForEarning detection predicates into a pure, framework-agnostic TypeScript module (SDK-1135). Workweek boundaries are accepted as an external input and rounding precision is caller-supplied — the Embedded API does not yet expose per-workweek fields (backend work is landing under EMBPAY-705/709 but is alpha-only and not in this SDK's vendored API version), so this PR covers only the pure math, with no UI or API wiring. Co-Authored-By: Claude Sonnet 5 <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.
Summary
src/components/Payroll/Rrop/rropHelpers.ts: a pure, framework-agnostic TypeScript port of gusto-web'sevenlyDistributeValue(workweek-weighted pro-ration with rounding-remainder reconciliation onto the first workweek) plusneedsWorkweekBreakdown/needsWorkweekBreakdownForEarningexistence-based detection predicates, ported from gusto-web'suseEmployeesNeedWorkweekBreakdowns.{ startDate, endDate }[]input, never derived client-side. Once the API ships, boundaries are expected to arrive asstart_date/end_dateon each compensation'sbreakdowns[]rows (frompayrolls#prepare/#update/#create), not as a standalone workweeks list — a future integration ticket will extract aWorkweek[]from that shape.workweeksarray returns{}here instead of throwing (gusto-web's real code throws onworkweeks[0]before its own length check).Known gaps / open questions (tracked, not resolved, in this PR)
includedInRegularRateOfPay(gusto-web) vs.included_in_overtime_pay(proposed API) — naming/semantic equivalence is unconfirmed; the new predicate's parameter is named generically to avoid committing to either.Test plan
npm run test -- --run src/components/Payroll/Rrop— 32/32 passing, covering the worked examples (equal/uneven/three-way splits, non-contiguous "gappy" workweeks, empty array, single workweek, remainder-to-first-week assignment, a precision 0–6 sweep, and a US DST-transition case)npm run test -- --run(full suite, on top of the rebased base branch) — passingnpx tsc --noEmitandnpx eslintclean on changed files🤖 Generated with Claude Code