Gross prices and calculated net prices, where are the decimals?

I am trying to solve the problem with grossprices giving differences on the invoice because of rounding the net-price to 2 decimals.

When customerprice incl. VAT is 39 Euro (7%) the calculated netprice is 36,4485981308 with 11 units I get 2 Cent too much on the invoice.
With 11 products at gross 29 Euro (net 27,1028037383) 3 cents too little is on the invoice.

The solution is to quit rounding in the background in the DB save the netprice like 36,4485981308 and present with 2 decimals in the program.
Field product_price - decimal(20,10) was given in the DB.

the following 4 Fields were adjusted to decimal 20,10
ip_invoice_items - item-price
ip_invoice_item_amounts - item_subtotal
ip_invoice_item_amounts - item_total
ip_invoice_amounts - invoice_item_subtotal
After that I still had 2 cent too much

I adjusted all fields that could cause it to decimal 20,10 without result

as far as I see it the summs are calcutated here

application/models/invoices/models

So I am searching where the values from the DB get read,
can someone tell where that is, I just started a few days ago with code igniter.

I have been working with openbravopos, unicentapos, chromispos etc. where the netproce is calculated with
7 decimals, we do not have differences there. So I thought that adjusting the decimals might solve the problem.

Regards,
Jan

Hi Janvl

For now you can change this very easy.
In the file: application/helpers/number_helper.php

Line: 27
if ($currency_symbol_placement == 'before') { return $currency_symbol . number_format($amount, ($decimal_point) ? 2 : 0, $decimal_point, $thousands_separator); } elseif ($currency_symbol_placement == 'afterspace') { return number_format($amount, ($decimal_point) ? 2 : 0, $decimal_point, $thousands_separator) . ' ' . $currency_symbol; } else { return number_format($amount, ($decimal_point) ? 2 : 0, $decimal_point, $thousands_separator) . $currency_symbol; } }

Change the 2’s to 10

Remember, the first line of the instruction $decimal_point is only used to show the decimals on first plane, for calculations you need to change all other lines of $decimal_point set to 10.

before: ($decimal_point) ? 2 :
after: ($decimal_point) ? 10 :

Regards.

Hi mdroger,

thank you very much. I will do this tomorrow and see if it “cures” the problem with prices as described.

I certainly hope that for version 2 this problem is tackled, for a lot of people use gross prices and InvoicePlane is such a nice program.
Code Igniter is something one has to get into, I used to work with Frontaccounting which is PHP-only.
It is however too large for most of my clients.

I will report back.
After this I am going to work on some better reports for IP.

Regards,
Jan

Sorry mdroger

it does not solve the problem but it shows the problem very clear. in the DB I have 10 decimals,
on screen in IP it shows 10 decimals but a rounded value with the first 2 rounded decimals an 8 zeros.

So I will have to search further where the value gets read from the database.

[edit]
I found application/modules/invoices/models where some PHP files do the accounting.

regards,
Jan

Any solution for this?