indiehd / web-api

GNU Affero General Public License v3.0
6 stars 4 forks source link

Consider using moneyphp #163

Closed mblarsen closed 4 years ago

mblarsen commented 4 years ago

https://github.com/moneyphp/money

Reimplementing code that deals with money, fractions, discounts, currencies is tiresome and error prone.

You could cast directly to a money instance using custom casts much the same way dates works with Carbon

One such place would be:

            $table->unsignedDecimal('full_album_price', 8, 4)->nullable();
cbj4074 commented 4 years ago

I couldn't agree more! Thanks for bringing this library to our attention; it sounds perfect.

mblarsen commented 4 years ago

I found it while looking at Laravel Cachier which uses it too.

Should I try to use that in the casts PR #164? If tests are written it shouldn't break anything/too much.

So the money values are cast directly to Money.

cbj4074 commented 4 years ago

Yes, absolutely. This seems like a good opportunity to integrate it.

mblarsen commented 4 years ago

Is the API in USD only? Maybe we should stick it in a config?

cbj4074 commented 4 years ago

I like the idea of making the currency unit configurable.

mblarsen commented 4 years ago

It is now a part of #164

cbj4074 commented 4 years ago

Fixed in #164