bavix / laravel-wallet

It's easy to work with a virtual wallet
https://bavix.github.io/laravel-wallet/
MIT License
1.14k stars 230 forks source link

Retrieve all deposits for a particular wallet. #466

Closed otilor closed 2 years ago

otilor commented 2 years ago

I want to show the funding history of a customer. I want to be able to retrieve all the deposits to their wallet. Is there a way to achieve this with the package?

otilor commented 2 years ago

When I try to run this script, it works except that the amount doesn't get converted to the float amount

use Bavix\Wallet\Models\Transaction;

Transaction::query()->where('type', 'deposit')->where('payable_id', 1)->get();

I get 400000 instead of 4000.00

rez1dent3 commented 2 years ago

Hello.

I want to show the funding history of a customer. I want to be able to retrieve all the deposits to their wallet. Is there a way to achieve this with the package?

See https://github.com/bavix/laravel-wallet/issues/314 https://github.com/bavix/laravel-wallet/issues/240 https://github.com/bavix/laravel-wallet/issues/203 https://github.com/bavix/laravel-wallet/issues/198 https://github.com/bavix/laravel-wallet/issues/277

When I try to run this script, it works except that the amount doesn't get converted to the float amount

The package only works with integer values. The reason is in the mantissa (Numerical Methods). https://github.com/bavix/laravel-wallet/issues/149#issuecomment-600041147

See https://github.com/bavix/laravel-wallet/issues/169

rez1dent3 commented 2 years ago

https://github.com/bavix/laravel-wallet/issues/416

otilor commented 2 years ago

When I try to run this script, it works except that the amount doesn't get converted to the float amount

use Bavix\Wallet\Models\Transaction;

Transaction::query()->where('type', 'deposit')->where('payable_id', 1)->get();

I get 400000 instead of 4000.00

What I did to fix this was to use the amountFloat attribute.

rez1dent3 commented 2 years ago

This attribute exists in transactions. You can use it. https://github.com/bavix/laravel-wallet/blob/7a30789a2f102f5dd1e4a094a177e726cdb64f0b/tests/Units/Domain/WalletFloatTest.php#L201-L204