Skip to content

Fix tip rounding at every step and bar staff FOH pool participation#1

Merged
bradydibble merged 3 commits intomainfrom
claude/fix-tip-rounding-bar-split-CeYEI
Apr 7, 2026
Merged

Fix tip rounding at every step and bar staff FOH pool participation#1
bradydibble merged 3 commits intomainfrom
claude/fix-tip-rounding-bar-split-CeYEI

Conversation

@bradydibble
Copy link
Copy Markdown
Owner

@bradydibble bradydibble commented Apr 7, 2026

  • Investigate current state of code and test files
  • Add fohPoolParticipantCount to CalculationResult interface
  • Update Distribution.fohShareCents comment to reflect Bar participation
  • Fix fohStaffCount test assertion (now correctly 5) and add fohPoolParticipantCount test (correctly 6)
  • Fix roundToDollar: false test to use exact values (all 5 FOH = 13671¢, bartender = 13670¢)
  • Run tests to verify all changes pass (18/18 passing)

- Round ccFees, kitchenPool, and barPool to the nearest dollar when
  roundToDollar:true so all displayed pool totals are whole dollars
  (no more $131.63 / $307.12 / $282.12 in the breakdown)
- Bar staff now participate in the FOH pool split alongside FOH staff
  and receive fohShare + barPoolShare (previously received bar pool only)
- Update FOH section header divisor to include bar staff count
- Update tests to reflect new rounding values and bar behavior

https://claude.ai/code/session_01XVxvLCrTE8DWaJHMGEcyrA
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the tip-splitting calculation to (1) round key intermediate amounts to whole dollars when roundToDollar: true and (2) include bar staff as participants in the FOH pool split (while still receiving their bar pool share).

Changes:

  • Round CC fees, kitchen pool, and bar pool to the nearest dollar when roundToDollar is enabled, producing whole-dollar pool totals and payouts.
  • Include Bar staff in the FOH pool participant set and adjust distribution logic so Bar receives fohShare + barPoolShare.
  • Update UI + tests to reflect new FOH divisor and new distribution/rounding behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
src/routes/calculate/[id]/+page.svelte Updates FOH per-person header divisor to include bar staff count.
src/lib/calculator.ts Implements whole-dollar rounding for intermediate amounts and includes bar staff in FOH pool participation; updates distribution logic accordingly.
src/lib/calculator.test.ts Updates expectations to match new rounding behavior and bar participation in FOH pool.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/lib/calculator.ts Outdated
Comment thread src/lib/calculator.ts
Comment on lines 135 to 140
for (let i = 0; i < barStaff.length; i++) {
const cents = barDollars[i] * 100;
const fohCents = fohDollars[fohStaff.length + i] * 100;
const barCents = barDollars[i] * 100;
distributions.push({ staffId: barStaff[i].id, name: barStaff[i].name, role: 'Bar',
fohShareCents: 0, barPoolShareCents: cents, kitchenShareCents: 0, totalCents: cents });
fohShareCents: fohCents, barPoolShareCents: barCents, kitchenShareCents: 0, totalCents: fohCents + barCents });
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

Bar distributions now set a non-zero fohShareCents, but the Distribution interface comment still says fohShareCents is 0 for Bar/Kitchen. Please update the type/interface docs to reflect the new model (Bar participates in FOH pool).

Copilot uses AI. Check for mistakes.
Comment thread src/lib/calculator.test.ts Outdated
Comment on lines +74 to +88
it('5 FOH servers split $820.25 among 6 (FOH+Bar) → $136.70 each (floor $136, 5¢ remainder to first 5)', () => {
// fohPool = 82025 cents, 6 participants: floor(82025/6) = 13670, remainder = 82025 - 13670*6 = 5
// first 5 get 13671, last gets 13670
expect(foh).toHaveLength(5);
foh.forEach(d => expect(d.totalCents).toBe(16405)); // $164.05
foh.forEach(d => {
expect(d.totalCents === 13671 || d.totalCents === 13670).toBe(true);
});
});

it('bartender gets bar pool share only: $96.50', () => {
it('bartender gets FOH share + bar pool share: FOH $136.70ish + bar $96.50', () => {
expect(bar).toHaveLength(1);
expect(bar[0].totalCents).toBe(9650); // $96.50
expect(bar[0].fohShareCents).toBe(0);
// bartender gets the 6th FOH share (13670 or 13671) + bar pool 9650
expect(bar[0].fohShareCents === 13671 || bar[0].fohShareCents === 13670).toBe(true);
expect(bar[0].barPoolShareCents).toBe(9650);
expect(bar[0].totalCents).toBe(bar[0].fohShareCents + 9650);
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

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

In the roundToDollar: false fixture, distributePoolCents assigns the 5¢ remainder to the first 5 participants in order. Since fohPoolParticipants is [...fohStaff, ...barStaff], all 5 FOH should always receive 13671¢ and the bartender should always receive 13670¢. The current assertions (13670 || 13671) contradict the comment above and make the test less effective; consider asserting the exact expected cents for FOH and Bar here.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@bradydibble
Copy link
Copy Markdown
Owner Author

@copilot apply changes based on the comments in this thread

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 7, 2026

@copilot apply changes based on the comments in this thread

Applied all three review changes in commit c354b3d:

  1. Distribution.fohShareCents comment updated from "0 for Bar and Kitchen" to "0 for Kitchen; Bar staff also receive a FOH share (they participate in the FOH pool)"
  2. CalculationResult interface now includes fohPoolParticipantCount: number alongside fohStaffCount: number (the implementation already had both, but the interface type was missing the new field)
  3. roundToDollar: false tests now use exact expected values: all 5 FOH servers each get exactly 13671¢ (they are indices 0–4 in fohPoolParticipants = [...fohStaff, ...barStaff], so they receive the 5 remainder cents), and the bartender gets exactly 13670¢. The fohStaffCount assertion is also corrected to 5 with a new fohPoolParticipantCount === 6 assertion.

@bradydibble bradydibble merged commit 74a7dae into main Apr 7, 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.

4 participants