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

The "buy" function only accepts integer data #831

Closed
JoelVeloz opened this issue Jan 2, 2024 · 2 comments · Fixed by #826
Closed

The "buy" function only accepts integer data #831

JoelVeloz opened this issue Jan 2, 2024 · 2 comments · Fixed by #826
Assignees
Labels
in-developing question Further information is requested

Comments

@JoelVeloz
Copy link

Describe the bug
The "buy" function only accepts integer data, how do I buy something with decimal data? , I am applying "WalletFloat" throughout my project, but when I try to create an item, and I want to pay, it does not withdraw the mentioned amount, which is $100, but 0.1, it is clear that it is because I use decimals, but there is no function to decimals? so that you explicitly put the value in decimal "0.1" and not 100, since you would have to apply another function for the conversion.

To Reproduce
Steps to reproduce the behavior:
use the same configuration from the documentation but with interfaces referring to float
image

@JoelVeloz JoelVeloz added bug Something isn't working question Further information is requested labels Jan 2, 2024
@rez1dent3 rez1dent3 removed the bug Something isn't working label Jan 2, 2024
@rez1dent3
Copy link
Member

Hello. This is not a bug, it's a feature. I'll think in this direction. I'll answer you later.

@rez1dent3
Copy link
Member

Hello.

Starting from version 11.x, FormatterServiceInterface will be added, which will help you multiply a number by another number)

    public function getAmountProduct(Customer $customer): int
    {
        /** @var Wallet $wallet */
        $wallet = app(CastServiceInterface::class)->getWallet($customer);

        return (int) app(FormatterServiceInterface::class)->intValue(
            $this->price,
            $wallet->decimal_places,
        );
    }

BUT you need to remember about decimal_places, if it is different for different wallets, then you need to take this into account in the logic of the model.

@rez1dent3 rez1dent3 linked a pull request Jan 5, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in-developing question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants