Topic: Needed idea to work-arround diff. decimal places for unit price/amount

I guess this question is directed to more experienced users.

I need to have prices per unit with 4 digits after decimal and all amounts rounded to cent (second digit after dec.).
This is especially valid for taxes and totals.

I think I have tried all combinations of Display Setup and Company Setup/Round Calculated Prices.
(The last seems to be for Price lists calculations etc., not for direct sales input)

The only idea I have is changing the unit of measure, but it leads to consequential issues.
Any other idea will be appreciated smile

Re: Needed idea to work-arround diff. decimal places for unit price/amount

If you can edit code just replace lines 222 of sales/includes/ui/sales_order_ui.inc with $display_sub_total = round(price_format($total + input_num('freight_cost'))*100)/100; and line 227 with $display_total = round(price_format(($total + input_num('freight_cost') + $tax_total))*100)/100;

Phuong

Re: Needed idea to work-arround diff. decimal places for unit price/amount

Thanks a lot!!!
This much I can edit smile

Re: Needed idea to work-arround diff. decimal places for unit price/amount

Oh sorry! That was not good solution, instead of that you just add $line_total = round($line_total*100)/100; into line 170.

Phuong

5 (edited by stefan 02/17/2017 02:21:32 pm)

Re: Needed idea to work-arround diff. decimal places for unit price/amount

Sorry, both ways it doesn't not work.

168-169 changed to
$line_total = round($stock_item->qty_dispatched * $stock_item->price * (1 - $stock_item->discount_percent), 2);
solves the Sub-total, but not the Total and Taxes.

222 this solves Sub-total
$display_sub_total = round($total + input_num('freight_cost'), 2);

227 this solves the Total
$display_total = round(($total + input_num('freight_cost') + $tax_total), 2);

only simple tests are done, but looks to work correct on the Sales Order.

My central issue are the taxes, and they are still not ready

I am just a beginner, so it might take time.
It seems "user_price_dec" has to be replaced with "2" at many places, mainly in .inc files

6 (edited by stefan 02/20/2017 11:52:38 am)

Re: Needed idea to work-arround diff. decimal places for unit price/amount

Update:

In /includes/current_user.inc I added this:

function amount_format($number) {  return number_format2($number, 2); }

At the sub-totals and totals of this file I have replaced price_format with amount_format

Than in /includes/ui/ui_view.inc in the functions:
display_customer_trans_tax_details
display_supp_trans_tax_details
display_edit_tax_items
I replaced all occurrences of "user_price_dec()" with "2" and the relevant "price_format" with "amount_format"

For the moment looks fine. I can use prices with .00001 and the line_totals are the same. The sub-total, the taxes and the total are .01 (rounded to cent).

update: IT'S NOT GOOD !!!