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

API does not handle negative values #29

Open
sigrist opened this issue Jan 17, 2020 · 7 comments · May be fixed by #33
Open

API does not handle negative values #29

sigrist opened this issue Jan 17, 2020 · 7 comments · May be fixed by #33
Labels
bug Something isn't working

Comments

@sigrist
Copy link

sigrist commented Jan 17, 2020

The API does not handle negative values:

from price_parser import Price
def test_price_parser():
    value = Price.fromstring("R$ 1,00")
    assert value.amount_float == 1.0

    value = Price.fromstring("R$ -2,00")
    assert value.amount_float == -2.0 # Fails
@kmike
Copy link
Member

kmike commented Jan 24, 2020

Just to confirm: do you have a real use case for this?

@sigrist
Copy link
Author

sigrist commented Jan 27, 2020

Yes.

Imagine an account balance where we have entries with positive values (deposits) and negative values (withdrawals)

@kmike kmike added the bug Something isn't working label Jan 27, 2020
@rennerocha rennerocha linked a pull request Feb 13, 2020 that will close this issue
@mself
Copy link

mself commented Jul 31, 2020

I have the same issue. The module ignores the minus sign in "-$100,000.00", which is a typical format you see in CSV files exported from Excel.

@labellson
Copy link

Is there a plan to add this feature to master? I see a PR #33 linked to the issue but there is no activity since 2 years ago.

@ruimelodev
Copy link

I just came across the same issue.

Price.fromstring("-2,525,077.54") # returns 2525077.54

My use case is when dealing with credit notes inside an invoicing system.

@Kagee
Copy link

Kagee commented Sep 17, 2023

This is an example from scraping order details from a webshop, where negative values indicated payback to the customer:

>>> Price.fromstring('-kr 6.645')
Price(amount=Decimal('6645'), currency='kr')

It would also be ecpected that this order should work

>>> Price.fromstring('kr -6.645')
Price(amount=Decimal('6645'), currency='kr')

2023-09-17-191829_913x143_scrot

@lopuhin
Copy link
Member

lopuhin commented Sep 22, 2023

Btw there are also websites where '-' means '0' instead of a negative amount, e.g. –,59 *

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants