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

Import template: negate uses float math #284

Open
anze555 opened this issue Sep 8, 2024 · 0 comments
Open

Import template: negate uses float math #284

anze555 opened this issue Sep 8, 2024 · 0 comments

Comments

@anze555
Copy link

anze555 commented Sep 8, 2024

Describe your Environment
OS: Linux (via Docker)
Paisa Version: 0.7.0
App Variant: Desktop (browser)

Describe the bug
When importing, number negate "0.00000001" gets converted into -1e-8, which is then rejected by parser.

To Reproduce
Steps to reproduce the behavior:

  1. Create a custom import template, upload any CSV file
  2. Demonstrate use of "negate" function on a small amount, for example by using this template:
    2024/09/08 Test
        Assets:Test:Main Account  {{negate "0.00000001"}} ETH
        Equity:Opening Balances
    
  3. Observe the output: -1e-8
  4. If used as amount, ledger parser complains:
    -1e-8
    ^^^^^^^^^^^^^^^^^^^^^^
    Error: Unexpected char '-' (Note: inline math requires parentheses)
    

(of course, this is just a small example to reproduce buggy behavior - I encountered this problem when importing real data)

Expected behavior

  • output should be -0.00000001

Workaround
If you know the number to be positive, you can just put - in front of the expression: -{{ROW.X}}. If it is always negative, {{replace ROW.X "-" ""}} helps. If uncertain, {{#if regexpTest ROW.X "-.*"}}{{replace ROW.X "-" ""}}{{else}}-{{ROW.X}}{{/if}} can be used. It is cumbersome though.

Screenshots

image

Awesome app by the way, the import works very nicely!

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

No branches or pull requests

1 participant