akaunting / laravel-money

Currency formatting and conversion package for Laravel
https://akaunting.com
MIT License
732 stars 101 forks source link

how to get amount in subunit as int #84

Closed lotarbo closed 1 year ago

lotarbo commented 1 year ago

Hello, I store all prices in subunit as int. I use this package for price manipulation and store new value to database Ex: in db 34237 → in frontend $342.37 right now i do like this (int)Money::USD($price)->multiply(2)->getAmount() In my opinion, it's easy to forget about int conversion. I think, additional method can solve this problem, ex getAmountAsInt() or similar As reference https://github.com/brick/money#persisting-the-amount

Thank you

miomech commented 1 year ago

@lotarbo Check this out. https://github.com/akaunting/laravel-money/issues/85#issuecomment-1631064642

It looks like this should help you out.