Skip to content

Split out invoice specific logic and models from core and render.#24

Merged
Sajjon merged 6 commits intomainfrom
split_out_invoice_from_render
Feb 15, 2026
Merged

Split out invoice specific logic and models from core and render.#24
Sajjon merged 6 commits intomainfrom
split_out_invoice_from_render

Conversation

@Sajjon
Copy link
Copy Markdown
Owner

@Sajjon Sajjon commented Oct 24, 2025

Note

ChatGPT authored the commits of this PR.

Preparing for reuse for other documents than invoices.

…rom core/render - preparing for reuse for other documents than invoices.
@Sajjon Sajjon requested a review from Copilot October 24, 2025 18:16
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 refactors the codebase to separate invoice-specific logic from generic PDF rendering capabilities, enabling future reuse for other document types beyond invoices.

  • Split klirr-core into klirr-core-invoice (invoice domain logic) and klirr-core-pdf (generic PDF primitives)
  • Split klirr-render into klirr-render-invoice (invoice rendering) and klirr-render-pdf (generic Typst-based PDF rendering)
  • Introduced DocumentPlan and InlineModule abstractions to replace invoice-specific rendering context

Reviewed Changes

Copilot reviewed 87 out of 171 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/render-pdf/Cargo.toml New crate for generic PDF rendering with Typst dependencies
crates/render-pdf/src/lib.rs Exports generic document rendering API
crates/render-pdf/src/module.rs Defines DocumentPlan and InlineModule for flexible document composition
crates/render-pdf/src/render.rs Generic render_document function replacing invoice-specific implementation
crates/render-pdf/src/typst_context/* Refactored Typst context to work with generic modules instead of fixed invoice sources
crates/core-pdf/Cargo.toml New crate for PDF-focused primitives
crates/core-pdf/src/* Extracted font handling, Typst conversion traits, and PDF type from core
crates/render-invoice/* Updated to use new generic rendering layer via DocumentPlan
crates/core-invoice/* Renamed from klirr-core with updated import paths
crates/cli/* Updated imports to reference renamed crates

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

if let Some(font) = self.environment().fonts().get(index).cloned() {
Some(font)
} else {
self.environment().fonts().get(index).cloned().or_else(|| {
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

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

The or_else closure will always panic, making the cloned() operation pointless. The panic should occur when get(index) returns None, not inside or_else. Consider using unwrap_or_else or restructuring to: self.environment().fonts().get(index).cloned().unwrap_or_else(|| panic!(\"Font not found at index: {}\", index))

Suggested change
self.environment().fonts().get(index).cloned().or_else(|| {
self.environment().fonts().get(index).cloned().unwrap_or_else(|| {

Copilot uses AI. Check for mistakes.
@codecov
Copy link
Copy Markdown

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 90.90909% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 94.41%. Comparing base (74a56db) to head (bbfb8b4).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
crates/render-invoice/src/render.rs 66.66% 3 Missing ⚠️
crates/render-pdf/src/render.rs 81.81% 2 Missing ⚠️
crates/render-pdf/src/typst_context/context.rs 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
- Coverage   95.74%   94.41%   -1.33%     
==========================================
  Files          92      100       +8     
  Lines        2113     2186      +73     
==========================================
+ Hits         2023     2064      +41     
- Misses         90      122      +32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Sajjon Sajjon force-pushed the split_out_invoice_from_render branch from fa49646 to d93e8b1 Compare October 25, 2025 06:43
@Sajjon Sajjon force-pushed the split_out_invoice_from_render branch from fd16b99 to e9e1395 Compare October 26, 2025 14:50
@Sajjon Sajjon force-pushed the split_out_invoice_from_render branch from e9e1395 to a4daab7 Compare October 26, 2025 14:52
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

Copilot reviewed 91 out of 176 changed files in this pull request and generated no new comments.


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

@Sajjon Sajjon merged commit e781288 into main Feb 15, 2026
11 of 13 checks passed
@Sajjon Sajjon deleted the split_out_invoice_from_render branch February 15, 2026 08:12
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.

2 participants