Skip to content

Conversation

Sajjon
Copy link
Owner

@Sajjon Sajjon commented Jul 2, 2025

Remove custom F64 type, replaced with Decimal which is a wrapper around rust_decimal::Decimal - changing the serde to serialise into a f64, not a string, for simplest possible bridging into Typst dictionary. In the future if anyone needs more precision than f64 we can remove the wrapper and just use Decimal as is, and let it serialize into a string, and write a more advanced bridge to Typst than going via JSON.

Copy link

codecov bot commented Jul 2, 2025

Codecov Report

Attention: Patch coverage is 96.87500% with 1 line in your changes missing coverage. Please review.

Project coverage is 97.40%. Comparing base (71fe8a4) to head (851f923).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/core/src/models/decimal.rs 92.85% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #11      +/-   ##
==========================================
+ Coverage   97.25%   97.40%   +0.14%     
==========================================
  Files          59       59              
  Lines        1312     1308       -4     
==========================================
- Hits         1276     1274       -2     
+ Misses         36       34       -2     

☔ 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 requested a review from Copilot July 2, 2025 16:59
Copy link

@Copilot 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 replaces the custom F64 wrapper with a new Decimal type backed by rust_decimal::Decimal, migrating all monetary and quantity models to use high-precision decimals via the dec! macro.

  • Introduces models/decimal.rs and adds dec to the prelude for easy decimal literals
  • Updates UnitPrice, Quantity, Cost, exchange-rate logic, item builders, serialization, and tests to use Decimal and dec!
  • Renames the old F64 wrapper in f64_eq.rs to Decimal, which now conflicts with the new Decimal type

Reviewed Changes

Copilot reviewed 22 out of 23 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
crates/core/src/models/unit_price.rs Switched UnitPrice from F64 to new Decimal, updated tests
crates/core/src/models/quantity.rs Switched Quantity to Decimal, added ONE constant
crates/core/src/models/cost.rs Switched Cost to Decimal
crates/core/src/models/decimal.rs New wrapper for rust_decimal::Decimal with serde + RON support
crates/core/src/models/f64_eq.rs Renamed F64 to Decimal but now collides with new Decimal
crates/core/src/models/error.rs Added InvalidDecimalConversion, updated parse error comments
crates/core/src/logic/serde_to_typst.rs Enhanced RON→Typst conversion for decimal strings
Comments suppressed due to low confidence (1)

crates/core/src/models/f64_eq.rs:26

  • The old F64 wrapper was renamed to Decimal, but there is already a new Decimal type in models/decimal.rs. Consider giving this wrapper a distinct name (e.g., F64 or F64Bits) or renaming the file to match.
pub struct Decimal(f64);

…l::Decimal which serializes into a number not a string
@Sajjon Sajjon merged commit ce74b73 into main Jul 2, 2025
6 of 7 checks passed
@Sajjon Sajjon deleted the decimal branch July 2, 2025 18:34
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