bigcapital icon indicating copy to clipboard operation
bigcapital copied to clipboard

Decimal precision issue

Open chamoda opened this issue 1 year ago • 5 comments

Thanks for this app.

I've noticed that decimal fractional values get rounded into integers and this makes some reports inaccurate.

Here's the steps to recreate.

  1. Create an item with price 100.50
  2. Create an invoice with the item
  3. Go to Journal sheet. Debit is 100.50 but Credit is 101.00 with .50 cents difference

Screenshot from 2023-08-02 15-11-01

chamoda avatar Aug 02 '23 09:08 chamoda

@abouolia

This is odd. Did you fix this issue ? I am unable to replicate it.

image

asenawritescode avatar Jan 17 '24 17:01 asenawritescode

I'm having the same issue. I created an invoice which has an item with a rate of 13 EUR and a quantity of 159,58 which should total 2.074,54 but instead it rounds it up to 2.080,00

image

xprnio avatar Jan 19 '24 16:01 xprnio

My issue was caused by the quantity field in entries being an int instead of a decimal. I'll send a PR up tomorrow for changing it to a decimal

xprnio avatar Jan 19 '24 19:01 xprnio

@xprnio You're absolutely right, when I wrote the database migration never thought it could be 1.123457 I thought would be integer all the time, I'd be grateful if you created a PR to fix it, btw here's some things in my mind to do to fix it.

  • Create a new database migration on tenants DBs and there're some especial commands for Bigcapital, you can create a new one by node packages/server/build/commands.js tenants:migrate:make convert_items_entries_quantity_to_decimal if the commands.js file wasn't exist run pnpm run build:server to build it.
  • Change the controllers validation schema of of the quantity of all services that have quantity, I remember the services have quantity invoices, receipts, estimates, credit notes, bills and vendor credits.
  • preferable to make the decimal columns accepts 7 digits maximum e.g. 1.1234567

If you have any more questions please let me know.

abouolia avatar Jan 19 '24 20:01 abouolia

@abouolia I just created the PR, however I didn't run the e2e tests locally (running Arch with Brave and I couldn't figure out how to configure Playwright to use that), but I saw the GH Actions also run those. So now I'm just waiting for authorization for it to run I guess.

You can find the PR here: https://github.com/bigcapitalhq/bigcapital/pull/316

xprnio avatar Jan 20 '24 14:01 xprnio