Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve number handling for amount with leading decimal point. #3096

Closed
wants to merge 6 commits into from

Conversation

wdpk
Copy link
Contributor

@wdpk wdpk commented Jul 18, 2024

Fixes #1051


category: Bugfix
authors: [wdpk]

Improve number handling to handle leading decimal places.

Existing behavior: amount = '.47', then m.index ===0 so then the return call calls extractNumbers on amount.
extractNumbers('.47') returns 47.

This PR changes the if statement so if m.index ===0 it adds a leading 0, and then the number is correctly handled from there.

wdpk added 3 commits July 17, 2024 20:49
e.g. .47 previously resolves to 47 on csv import with .47 values. Or any other time this function is called. if the number is ,34 or .43 I would think it's clear that it is meant to be 0,34 and 0.43 respectively. however, because m.index === 0, logic called extractNumbers on '.47', outputs '47' which becomes '47.00'
@actual-github-bot actual-github-bot bot changed the title Leadingdecimalpoint [WIP] Leadingdecimalpoint Jul 18, 2024
Copy link

netlify bot commented Jul 18, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit 55ff163
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/6698be626c1b000008eacb61
😎 Deploy Preview https://deploy-preview-3096.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jul 18, 2024

Deploy Preview for actualbudget ready!

Name Link
🔨 Latest commit cc4e76c
🔍 Latest deploy log https://app.netlify.com/sites/actualbudget/deploys/6698bf83e5b0960008362c42
😎 Deploy Preview https://deploy-preview-3096.demo.actualbudget.org
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@wdpk wdpk changed the title [WIP] Leadingdecimalpoint Improve number handling for amount with leading decimal point. Jul 18, 2024
@wdpk wdpk changed the title Improve number handling for amount with leading decimal point. Improve number handling for amount with leading decimal point. Jul 18, 2024
Copy link
Contributor

github-actions bot commented Jul 18, 2024

Bundle Stats — desktop-client

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
9 4.74 MB → 4.74 MB (-117 B) -0.00%
Changeset
File Δ Size
home/runner/work/actual/actual/packages/loot-core/src/shared/util.ts 📈 +37 B (+0.57%) 6.37 kB → 6.41 kB
src/components/budget/rollover/RolloverComponents.tsx 📉 -154 B (-1.19%) 12.59 kB → 12.44 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
static/js/index.js 2.99 MB → 2.99 MB (+37 B) +0.00%

Smaller

Asset File Size % Changed
static/js/wide.js 274.25 kB → 274.1 kB (-154 B) -0.05%

Unchanged

Asset File Size % Changed
static/js/indexeddb-main-thread-worker-e59fee74.js 13.5 kB 0%
static/js/resize-observer.js 18.37 kB 0%
static/js/BackgroundImage.js 122.29 kB 0%
static/js/narrow.js 76.19 kB 0%
static/js/usePreviewTransactions.js 790 B 0%
static/js/AppliedFilters.js 27.61 kB 0%
static/js/ReportRouter.js 1.23 MB 0%

Copy link
Contributor

github-actions bot commented Jul 18, 2024

Bundle Stats — loot-core

Hey there, this message comes from a GitHub action that helps you and reviewers to understand how these changes affect the size of this project's bundle.

As this PR is updated, I'll keep you updated on how the bundle size is impacted.

Total

Files count Total bundle size % Changed
1 1.13 MB → 1.13 MB (+15 B) +0.00%
Changeset
File Δ Size
packages/loot-core/src/shared/util.ts 📈 +95 B (+0.90%) 10.3 kB → 10.39 kB
View detailed bundle breakdown

Added

No assets were added

Removed

No assets were removed

Bigger

Asset File Size % Changed
kcab.worker.js 1.13 MB → 1.13 MB (+15 B) +0.00%

Smaller

No assets were smaller

Unchanged

No assets were unchanged

@youngcw
Copy link
Member

youngcw commented Jul 18, 2024

Hi! This looks nearly the same as what I did in #3044. I don't have that extra step you added though. Is that fixing an issue you were seeing?

@wdpk
Copy link
Contributor Author

wdpk commented Jul 18, 2024

Hi! This looks nearly the same as what I did in #3044. I don't have that extra step you added though. Is that fixing an issue you were seeing?

Oh whoops. Glad I was at least heading in the right direction.

This fixes the bug seen in 1051, but yes, duplicates your fix from #3044. I was testing on "app.actualbudget.org" and not edge, so I wasted some time here.

Your fix in 3044 fixes 1051 as well.

@wdpk wdpk closed this Jul 18, 2024
@wdpk wdpk deleted the leadingdecimalpoint branch July 19, 2024 06:50
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.

[Bug]: Importing cents imports as whole numbers if no leading zero
2 participants