Skip to content

Write two decimal places into the BR Code CRC helper - #34

Open
SashaMIT wants to merge 1 commit into
naomijub:masterfrom
SashaMIT:codered-amount-cents
Open

SashaMIT wants to merge 1 commit into
naomijub:masterfrom
SashaMIT:codered-amount-cents

Conversation

@SashaMIT

Copy link
Copy Markdown

Summary

encode writes an amount with two decimal places. to_crc16_json checksummed Display of the float instead, so 10.5 was checksummed as 10.5 while the QR code contains 10.50. The CRC in the JSON did not match the code. The helper now uses the same two decimal places. 123.45 is unchanged.

Test plan

  • cargo test --lib amount_with_one_decimal fails on master (the JSON CRC is 5A08, not the CRC of the QR code) and passes with this change.
  • enconde_brcode and json_crc16 still pass.

Made with Cursor

An amount of 10.5 was checksummed as 10.5, while the QR code writes 10.50. The helper now uses the same two decimal places, so its CRC matches the code.

@naomijub naomijub left a comment •

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Interesting catch, was cursor that identified it or was it you? Plain curiosity

Just need to run the ci which requires some updates

@SashaMIT

Copy link
Copy Markdown
Author

Cursor helped me spot it, and I checked the two-decimal CRC path before opening the PR. Happy to stand behind the change. No rush on the CI updates, and thanks for taking a look.

@naomijub

Copy link
Copy Markdown
Owner

Today I should update the CI, then you can update your branch with main and CI should work

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