Skip to content

Award no loyalty points on refunds - #33

Open
sergical wants to merge 1 commit into
releasefrom
fix/loyalty-no-points-on-refunds
Open

sergical wants to merge 1 commit into
releasefrom
fix/loyalty-no-points-on-refunds

Conversation

@sergical

Copy link
Copy Markdown
Member

pointsFor now returns 0 for a negative total, so a refund no longer takes points away from the customer. There is one new test for a refund.

Created with Claude Code

Co-authored-by: Claude <claude@anthropic.com>
@github-actions

Copy link
Copy Markdown

Verdict: Approve — small, correct, well-tested change that makes refunds (negative totals) award zero loyalty points.

Correctness

  • Logic is sound: the early-return guard (totalCents < 0 → 0) correctly short-circuits before the rounding math, and doesn't affect existing behavior for totalCents >= 0.
  • New test (pointsFor(-10_000) === 0) is meaningful and passes.
  • All tests pass: 17 passed, 0 failed (2 suites run).
  • No edge cases missed for the stated scope (e.g., -0 and non-integer cents still behave as before; boundary at 0 is unaffected).

Style (minor, non-blocking)

  • The updated doc comment packs two unrelated facts (rounding rule + refund rule) into one run-on sentence. Consider splitting into two sentences/lines for scannability, e.g.:
    /**
     * One and a half points per whole dollar spent, rounded once after the multiplier.
     * Negative totals (refunds) always earn zero points.
     */
    
  • The guard clause's intent (negative = refund) isn't obvious from the code itself — an inline comment near the if would help readers who skip the docblock.
  • The new test only checks one refund value (-10_000); consider also covering a boundary case like -1 for consistency with the suite's existing boundary-focused style.
  • The new test is appended at the end of the file; grouping it next to the other "awards nothing for …" tests would improve readability/organization.

None of the style points are blocking — the change is small, correct, and adequately tested.

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.

1 participant