Topic: Journal Entries Round to 2 decimal places on add, not update

We need 8 decimal places for GL entries and despite setting the precision adding a new journal entry always rounded to 2 places.

If we go back and update the entry, then the full number would stay.

In includes/ui/items_cart.inc, the definition for class gl_item ignores the user precision at line 535 (line 534 in the GitMaster):

$this->amount = round($amount, 2);

Whereas the function update_gl_item does not round (line 161):

$this->gl_items[$index]->amount = $amount;

I've hacked the file, but would probably be better to update -- not sure where to submit a pull request on sourceforge.

Thanks!

Re: Journal Entries Round to 2 decimal places on add, not update

Items in the Cart are used for both display and for populating the tables. To conserve screen real-estate, the display is generally rounded off to 2 decimal places. Hopefully all the 8 digit amounts can fit into the Chart of Account table fields.

It is the function add_gl_item that needs to be fixed - inspect the value of $amount at the point when $this->gl_items[] = new gl_item(..... is executed whether it has the 8 digits in the decimals at line 130.

@joe: Worth fixing.

3 (edited by ed45626 05/02/2018 02:35:24 pm)

Re: Journal Entries Round to 2 decimal places on add, not update

I did check it -- dropped log statements in methodically (just downloaded yesterday, code is new to me, and php is not my strong suite).

The gl_items class (which is the culprit) is defined in items_cart.inc, not intuitive, but can't hide from grep smile

EDIT:  To also be clear, it's not just the display.  When an item is added to the gl_items list it uses the constructor in the gl_items class which does the rounding, so the rounded number is what gets pushed to the sql table.