Skip to content

[IP-135]: calculator unit tests#584

Draft
nielsdrost7 wants to merge 1 commit into
InvoicePlane:developfrom
underdogg-forks:feature/135-calculator-unit-tests
Draft

[IP-135]: calculator unit tests#584
nielsdrost7 wants to merge 1 commit into
InvoicePlane:developfrom
underdogg-forks:feature/135-calculator-unit-tests

Conversation

@nielsdrost7

@nielsdrost7 nielsdrost7 commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

No tests existed for InvoiceCalculator or QuoteCalculator — the core tax calculation logic had zero coverage.

Modules/Invoices/Tests/Unit/InvoiceCalculatorTest.php (8 tests, no DB required):

  • subtotal from quantity and price
  • item-level tax
  • two tax rates
  • item discount before tax (verifies discount reduces the taxable base, not the display subtotal)
  • grand total with taxes
  • document-level discount (fixed and percentage)
  • aggregates multiple items
  • zero totals for empty items

Modules/Quotes/Tests/Unit/QuoteCalculatorTest.php (7 tests, no DB required):

  • subtotal from quantity and price
  • tax rate from relationship object
  • two tax rates from relationship objects
  • percentage discount before tax
  • document-level percentage discount (quote_discount_percent field name)
  • aggregates totals across multiple items
  • zero totals for empty item list

Both test classes extend AbstractTestCase (no RefreshDatabase). They test the real, existing calculator logic (Modules/Core/Support/AbstractCalculator.php) — no mocking.

Closes

Closes #135 — invoice/quote tax calculation now has unit test coverage (15 tests total)

Follow-up issues

None.

Test plan

php artisan test --filter="InvoiceCalculatorTest|QuoteCalculatorTest"

@coderabbitai

coderabbitai Bot commented Jul 4, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: db8b703d-eee7-46b3-9bea-0df0b3de81a7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@nielsdrost7 nielsdrost7 changed the title Feature/135 calculator unit tests [IP-135]: calculator unit tests Jul 4, 2026
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@nielsdrost7 nielsdrost7 force-pushed the feature/135-calculator-unit-tests branch from b800348 to 59f9700 Compare July 4, 2026 12:23
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.

[Invoices]: Test correct tax calculation on invoices and quotes

1 participant