Site maintenance: Tuesday 17 Nov, from 10:00 UTC, about 4–6 hours. Details

This cutover relies on some testing that is still incomplete so may be cancelled at short notice

Forums / Bug Reports / [OPEN CHANGE-331 ]Wrong display of prices inc. tax on order and invoice

[OPEN CHANGE-331 ]Wrong display of prices inc. tax on order and invoice

Started by rued on 17 Sep 2012, 5:43 AM · Views: 1,829

Results 1 to 3 of 3
17 Sep 2012, 5:43 AM
#1
rued avatar

rued

Zen Follower

Join Date:
Oct 2005
Location:
Finland
Posts:
186
Plugin Contributions:
0

[OPEN CHANGE-331 ]Wrong display of prices inc. tax on order and invoice

Order and invoice view displayes prices ex. tax in the column inc. tax if 'Configuration -> My Store -> Display Prices with Tax in Admin' is set to 'false'

A price display telling it's inc. tax should be inc. tax whatever this setting is.
Now the price display inc. and ex. tax is the same, if set to false.

Guess same issue applyes to frontend.

9 Oct 2012, 8:49 PM
#2
wilt avatar

wilt

Oji-san

Join Date:
Jun 2003
Location:
Newcastle UK
Posts:
1,945
Plugin Contributions:
3

Re: [OPEN CHANGE-331 ]Wrong display of prices inc. tax on order and invoice

Hi,

We do agree that the display of totals in admin dependant on DISPLAY_PRICES_WITH_TAX can be a little confusing and needs to be better formatted.

As such have moved this to change management.

Thanks.

24 Oct 2012, 2:34 PM
#3
duncanad avatar

duncanad

Zen Follower

Join Date:
Nov 2004
Location:
Glasgow, Scotland
Posts:
247
Plugin Contributions:
0

Re: [OPEN CHANGE-331 ]Wrong display of prices inc. tax on order and invoice

I think I may have the solution to this bug. It requires two minor changes to the following files:
admin/includes/functions/general.php
admin/includes/classes/currencies.php

In admin/includes/functions/general.php we have the 'zen_add_tax' function at around line 1671. This looks like this:

/*  function zen_add_tax($price, $tax) {
    global $currencies;
    if (DISPLAY_PRICE_WITH_TAX_ADMIN == 'true') {
      return zen_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + zen_calculate_tax($price, $tax);
    } else {
      return zen_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']);
    }
  }

This returns the price with or without tax added dependent on the value of DISPLAY_PRICE_WITH_TAX_ADMIN which is set in Configuration>>My Store>>Display Prices with Tax in Admin.
By definition a function named 'zen_add-tax' when called should add the tax regardless so my solution is to change this function to the following:

    function zen_add_tax($price, $tax) {
      global $currencies;
      return zen_round($price, $currencies->currencies[DEFAULT_CURRENCY]['decimal_places']) + zen_calculate_tax($price, $tax);
  }

This change alone results in the tax inclusive price being displayed correctly in admin in orders and invoices, however it also results in the product prices in Catalog>>Categories/Products displaying as the tax inclusive price regardless of the value of DISPLAY_PRICE_WITH_TAX_ADMIN. This is not the desired result and requires a change to the 'display_price' function in admin/includes/classes/currencies.php
At around line 65 this looks like

    function display_price($products_price, $products_tax, $quantity = 1) {
		return $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
    }

This function sets how the price is displayed and therefore it is here that I believe the value of DISPLAY_PRICE_WITH_TAX_ADMIN should effect the return value. My solution is to change this function to the following:

    function display_price($products_price, $products_tax, $quantity = 1) {
	  if (DISPLAY_PRICE_WITH_TAX_ADMIN == 'true') {
		return $this->format(zen_add_tax($products_price, $products_tax) * $quantity);
	  }
	  else {
		return $this->format($products_price * $quantity);
	  }
      }

I have tested this on a v1.5 site and cannot find any adverse effects of these changes in either Admin or in the Store. Being 'Admin' files I would not expect any issues in the Store as a result of these changes.

If anyone finds any issues associated with these changes perhaps they could post these here.

I hope this helps.

Alan

workingIT.co.uk
working IT for business