Comments (3)
That was our original plan, but I have to say it's not perfect for tax calculations.
I give you an example:
- You're selling to multiple EU countries
- You have to calculate prices based on varying EU VAT rates
- Your base country has 19% VAT rate
- You want to sell your product for 17 EUR
The net value of the product (without the 19% VAT) is 14.285714286.
If you save it as a money, it'll be: 14.29
If you apply the 19% VAT, the result is: 17.0051 -> 17.01 rounded to money
It means you'll always have 1 cent difference, and using the money pattern you're not able to store the proper net price.
It's also true that many shops don't deal with multiple VAT/sales tax rates and simply store the gross price, thus don't have this problem.
But the scenario I've depicted is not rare at all; this example was a real case.
Therefore, we'll probably go with some kind of a decimal implementation like this: https://github.com/direvus/php-decimal
No final decision was done yet, so I'm looking for arguments.
from framework.
Extra: as an alternative solution there's the precise money branch. We've used that solution, but it doesn't seem to ever be the part of the library: moneyphp/money#7
from framework.
We're not going to implement this in the core so far.
With Vanilo 2.0 we wanted to replace all the price related numbers to some Decimal implementation. As we headed forward, we were facing multiple difficulties and we had the impression we're causing more problems than we're solving.
Afterward, we have analyzed a couple of similar e-commerce packages (incl. SpreeCommerce, Magento, Sylius, OroCommerce) and have come to the conclusion we'll keep using floats.
Especially, this comment has convinced me to rather deal with those rare rounding issues within their own scope, instead of adding complexity to the primitives. Additionally, the real issues we have faced with the Money pattern and tax calculation (see my comment above) made me revert all the Decimal sprouts in Vanilo 2 and keep using floats.
Whether or not it'll bite us - time will tell.
from framework.
Related Issues (20)
- Route [appshell.xoxoxo.xoxo] not found HOT 2
- Extending values in app setting HOT 5
- Master Products cannot allocate attributes HOT 3
- Issue with User permissions on new install HOT 2
- zones table is missing but referenced...? HOT 2
- How to get access to the sponsor slack channel? HOT 2
- No vanilo.php configuration file exists HOT 1
- option merge_duplicates delete the user cart HOT 2
- cart item adjustable HOT 3
- withTrashed()-method for route model binding isn't working with Vanilo HOT 6
- Do you plan to release the Vanilo Ecommerce Rest API for self-hosted installs? HOT 1
- Create GitHub release for each new version HOT 3
- Change visibility of `ProductSearch` properties from `private` to `proteced` HOT 2
- ArrayAccess implementation depreciation notice HOT 1
- OrderItem returns product of wrong type HOT 6
- OrderProcessingStarted is never triggered HOT 3
- Cant see all of FormRequest files HOT 1
- When can we expect version 4? HOT 4
- Question: link a user to a customer?
- Links module problem
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from framework.