bernhard Posted October 20 Share Posted October 20 Usage: echo rockmoney() ->parse("1,4") ->minus(0.4) ->format(); // 1,00€ Why? The short answer is, because 0.1 + 0.2 is not 0.3 in computer world: Download & Docs: baumrock.com/RockMoney 1 1 Link to comment Share on other sites More sharing options...
wbmnfktr Posted October 20 Share Posted October 20 You don't save money values in cents (or whatever the smallest unit is)? Link to comment Share on other sites More sharing options...
bernhard Posted October 20 Author Share Posted October 20 What is your question? Are you asking about the inner workings of the module? The db storage? How the money library works? 1 Link to comment Share on other sites More sharing options...
wbmnfktr Posted October 22 Share Posted October 22 On 10/20/2024 at 9:49 PM, bernhard said: What is your question? Are you asking about the inner workings of the module? The db storage? How the money library works? No, nothing of that. I was just a bit surprised you don't save currency values in cents (for Euro and Dollar and similar for other currencies) and had the need for this. As a drop-in solution, for already existing projects with tons of products/items, this seems perfect. 1 Link to comment Share on other sites More sharing options...
bernhard Posted October 23 Author Share Posted October 23 Well, you get all kind of weird rounding issues if you do that. Of course you could round() all results, but that is tedious and I'm not sure if that's 100% bulletproof: 2 Link to comment Share on other sites More sharing options...
Andy Posted November 9 Share Posted November 9 On 10/22/2024 at 11:57 PM, wbmnfktr said: No, nothing of that. I was just a bit surprised you don't save currency values in cents (for Euro and Dollar and similar for other currencies) and had the need for this. As a drop-in solution, for already existing projects with tons of products/items, this seems perfect. As far as I understood from the documentation, the module is based on the well-known library https://github.com/moneyphp/money. This library is used by a lot of people who have to calculate finances. Yes, this library stores finance values in integer variables. That is, in cents. You are right. Why, are there other solutions? Today @bernhard made it easy for us to integrate this library into ProcessWire. Many thanks to him. What are modules written for? To speed up development. This module will speed up development? Yes, it will. That's what we need. I once spent a lot of time and effort to integrate PDF formatting into a project. And then I took the RockPDF module and did in a couple of hours what had taken me a month before. Thanks to @bernhard for his modules, which are beautiful. 1 Link to comment Share on other sites More sharing options...
Klenkes Posted December 3 Share Posted December 3 @bernhard In order to get RockCommerce running I need RockMoney to run. Right? But unfortunately it throws a fatal error: Fatal Error: Uncaught Error: Class "NumberFormatter" not found in D:\xxxx\processwire-rockcommerce\www1\site\modules\RockMoney\RockMoney.module.php:58 I suspect more dependencies? Like Composer needed? Link to comment Share on other sites More sharing options...
bernhard Posted December 3 Author Share Posted December 3 Please check RockMoney v2.0.4 - does that fix your issue? Link to comment Share on other sites More sharing options...
Klenkes Posted December 3 Share Posted December 3 Nope... unfortunately not. Same Error. Link to comment Share on other sites More sharing options...
bernhard Posted December 3 Author Share Posted December 3 Ok then it's likely because your PHP does not have the Intl extension installed. Please do that, then it should work! 1 Link to comment Share on other sites More sharing options...
Klenkes Posted December 3 Share Posted December 3 Yepp! That's it. Now it works. Thank you Bernhard! 1 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now