Skip to content

feat: implement margin and total calculations with tests#63

Merged
LudoLoops merged 1 commit intomainfrom
feat/11-margin-calculations
Nov 29, 2025
Merged

feat: implement margin and total calculations with tests#63
LudoLoops merged 1 commit intomainfrom
feat/11-margin-calculations

Conversation

@LudoLoops
Copy link
Contributor

Summary

Implement business logic for calculations using TDD:

  • Add calculateItemCost, calculateItemRevenue, calculateMargin functions
  • Add calculateProfitPercentage for profit margin percentage calculation
  • Add calculateOrderTotals to aggregate order financial metrics
  • Define OrderTotals interface for aggregated order totals
  • Implement 33 tests covering all calculation functions with edge cases

Test Coverage

✅ 33 new tests (all passing)
✅ 103 total tests (all passing)
✅ TDD approach: red → green → refactor

Changes

  • src/lib/utils/calculations.ts - Implementation of 5 calculation functions
  • src/lib/utils/calculations.spec.ts - Comprehensive test suite
  • src/lib/types/interfaces.ts - Added OrderTotals interface

Closes #11

- Add calculateItemCost, calculateItemRevenue, calculateMargin functions
- Add calculateProfitPercentage for profit margin percentage calculation
- Add calculateOrderTotals to aggregate order financial metrics
- Define OrderTotals interface for aggregated order totals
- Implement 33 tests covering all calculation functions with edge cases
- TDD approach: red (failing tests) → green (passing code) → refactor

Closes #11
@LudoLoops LudoLoops merged commit 9f97d2a into main Nov 29, 2025
0 of 2 checks passed
@LudoLoops LudoLoops deleted the feat/11-margin-calculations branch November 29, 2025 14:42
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.

Implement margin and total calculations with tests

1 participant