Page 1 of 1

Entering Price with tax included

Posted: Wed Feb 24, 2010 6:49 am
by cdstg
A lot of prices we only have the sale price including tax ( GST in our case)
So wanted a way to enter it like that
This appears to work but use at your own risk I did it for 1.4 so am unsure if it works for other versions
also does not work for sales price yet if I have time will do that as well

Unzip it in your cart directory and it all overwrite
admin\language\english\catalog\product.php
admin\view\template\catalog\product_form.tpl
admin\index.php
admin\controller\catalog\product.php

In your admin set display prices with TAX
It will also use your store settings country and location for the TAX rate when entering
so make sure you have a Geo class that matches that with a tax rate in the tax class

When entering your products you can enter as Gross ( eg with tax ) and it will back calculate the net ( before tax price ) or if you enter that price then it to forward calculate the gross price

It still only saves the price to the database
and if the shopper has other taxes because of his area he will still get these

anyway it works for my case and certainly helps the person entering the prices

Re: Entering Price with tax included

Posted: Fri Apr 09, 2010 2:47 pm
by isparduotuvele
Is this solution upgrade proof or I should reinstall files after every upgrade of OC? Houw about compatibility issues after OC update? Any chances this could be implemented in core? In my opinion it very usefull feature, because when you sold as enterprice and need to add VAT using backward math it's practically impossible to get "marketig price" as XX.99 or so.
Also I get an error, that required file /system/library/measurement.php can not be found.

Re: Entering Price with tax included

Posted: Sun May 23, 2010 9:06 pm
by katalin
Very interesting, that would help me a lot, the archive seems to be damaged, could you please post a guide on how we can do this?
PS: I am using v1.4.6.

Re: Entering Price with tax included

Posted: Sun May 23, 2010 10:34 pm
by Xsecrets
isparduotuvele wrote:Is this solution upgrade proof or I should reinstall files after every upgrade of OC? Houw about compatibility issues after OC update? Any chances this could be implemented in core? In my opinion it very usefull feature, because when you sold as enterprice and need to add VAT using backward math it's practically impossible to get "marketig price" as XX.99 or so.
Also I get an error, that required file /system/library/measurement.php can not be found.
considering the files it overwrites no it absolutely would not be upgrade proof. And you wouldn't want to blindly go overwriting the files for the next version either. If there are any changes in the product entry at all it would completely remove them.

Re: Entering Price with tax included

Posted: Sun May 23, 2010 11:09 pm
by katalin
@Xsecrets How about the files? Where can I download them?

Re: Entering Price with tax included

Posted: Tue Jun 01, 2010 12:54 pm
by mcs107
cdstg, any chance of re-uploading the taxchange.zip attachment for us. When I download it, the archive is corrupt. Your contribution looks good; it'd be a shame to not get it because of a transfer error. Thanks in advance.

Re: Entering Price with tax included

Posted: Tue Jun 01, 2010 9:10 pm
by Xsecrets
yeah when the forum had to be reinstalled a while back some of the files got corrupted the op or someone who has the files would have to reupload them.

Re: Entering Price with tax included

Posted: Sun Jun 13, 2010 7:24 pm
by katalin
Here's the original attachment.

Re: Entering Price with tax included

Posted: Wed Jun 16, 2010 3:19 am
by tronics
Or simply use this hack by only exchanging this templatefile in admin/views/template/catalog/product_form.php
and change TAXVALUE - ENTER DIRECTLY according to your value. Ok this is a bit simpler but much easier to handle.

There are only 2 blocks needed, easy to update them in the next release, marked with
<!-- TAXMOD1 BEGIN --> <!-- TAXMOD1 END -->

Cheers,
tronics

Re: Entering Price with tax included

Posted: Wed Jun 16, 2010 3:33 am
by tronics
Unfortunately the upload does not work however just replace the price against:

Code: Select all

          <!-- TAXMOD1 BEGIN -->
          <tr>
            <td><b>Bruttopreis</b> Komma mit . angeben nicht mit Komma</td>
            <td><input type="text" id="grossprice" name="grossprice" onkeyup="updateNet()" value="<?php print ($price*1.2); ?>" /></td>
          </tr>
          <tr>
            <td><?php echo $entry_price; ?></td>
            <td><input type="text" id="price" name="price" onkeyup="updateGross()" value="<?php echo $price; ?>" /></td>
          </tr>
          <!-- TAXMOD1 END -->

--------------

and below use this javascript but change the TAX value first:

Code: Select all

<script type="text/javascript"><!--
var image_row = <?php echo $image_row; ?>;

function addImage() {
    html  = '<tbody id="image_row' + image_row + '">';
	html += '<tr>';
	html += '<td class="left"><input type="hidden" name="product_image[' + image_row + ']" value="" id="image' + image_row + '" /><img src="<?php echo $no_image; ?>" alt="" id="preview' + image_row + '" class="image" onclick="image_upload(\'image' + image_row + '\', \'preview' + image_row + '\');" /></td>';
	html += '<td class="left"><a onclick="$(\'#image_row' + image_row  + '\').remove();" class="button"><span><?php echo $button_remove; ?></span></a></td>';
	html += '</tr>';
	html += '</tbody>';
	
	$('#images tfoot').before(html);
	
	image_row++;
}
//--></script>
<script type="text/javascript" src="view/javascript/jquery/ui/ui.datepicker.js"></script>
<script type="text/javascript"><!--
$(document).ready(function() {
	$('.date').datepicker({dateFormat: 'yy-mm-dd'});
});
//--></script>
<script type="text/javascript"><!--
$.tabs('#tabs a'); 
$.tabs('#languages a'); 
//--></script>

<!-- TAXMOD1 BEGIN -->
  <script type="text/javascript"><!--

 
    function doRound(x, places) {
      return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
    }


    function updateGross() {
      var taxRate = 20; //TAXVALUE - ENTER DIRECTLY
      var grossValue = document.forms["form"].price.value;
    
      if (taxRate > 0) {
        grossValue = grossValue * ((taxRate / 100) + 1);
      }
    
      document.forms["form"].grossprice.value = doRound(grossValue, 4);
    }

    function updateNet() {
      var taxRate = 20; //TAXVALUE - ENTER DIRECTLY
      var netValue = document.forms["form"].grossprice.value;
    
      if (taxRate > 0) {
        netValue = netValue / ((taxRate / 100) + 1);
      }
    
      document.forms["form"].price.value = doRound(netValue, 4);
    }
  //--></script>
<!-- TAXMOD1 END -->

Re: Entering Price with tax included

Posted: Fri Jun 25, 2010 1:14 pm
by visnetmedia
Sorry but can you please tell me if I can change this for the latest opencart. I am not totally sure exactly where to change this - is on the product.php and product_form.tpl

Thanks - don't want to upset the beautiful code.

I changed the code in the product_form.tpl after reading it again but can't get it to have the gross working correctly. Every time I add say 500.0000 and save it when I go back it has 545.4546

Any reason why the gross amount won't stay?

Thanks - not sure if it is because I have to change files anywhere else.

Re: Entering Price with tax included

Posted: Mon Jun 28, 2010 12:57 pm
by visnetmedia
Thanks I got this sorted it was on the gross field having $price*1.2 whereas I needed to change this to 1.1
Cheers

Re: Entering Price with tax included

Posted: Thu Jun 09, 2011 1:07 am
by BMWMaX
This works fine in 1.4.9.5. Thanks!

Re: Entering Price with tax included

Posted: Sun Feb 19, 2012 11:41 pm
by Photospirit
Hi,

I'm using the code / script posted by tronics, which works fine for a "single" price.

I tried to use and change the code, so that also the prices in the options table are being shown with/without tax. I was able to add the fields, but the automatic calculation does not work here. I'm not very familiar with JavaScript so any help is appriciated.

Here's the code I'm trying to find the solution

Code: Select all

            <!-- TAXMOD1 BEGIN -->

					<input type="text" id="grossprice1" name="grossprice1" onkeyup="updateNet1()" value="<?php print ($product_option_value['price']*1.025); ?>" size="5" />

                    <input type="text" name="product_option[<?php echo $option_row; ?>][product_option_value][<?php echo $option_value_row; ?>][price]" id="price" onkeyup="updateGross1()" value="<?php echo $product_option_value['price']; ?>" size="5" /></td>



            <!-- TAXMOD1 BEGIN -->
              <script type="text/javascript"><!--
        
        
                function doRound(x, places) {
                  return Math.round(x * Math.pow(10, places)) / Math.pow(10, places);
                }
        
        
                function updateGross1() {
                  var taxRate = 2.5; //TAXVALUE - ENTER DIRECTLY
                  var grossValue = document.forms["form"].price.value;
                  if (taxRate > 0) {
                    grossValue = grossValue * ((taxRate / 100) + 1);
                  }
               
                  document.forms["form"].grossprice1.value = doRound(grossValue, 4);
                }
        
                function updateNet1() {
                  var taxRate = 2.5; //TAXVALUE - ENTER DIRECTLY
                  var netValue = document.forms["form"].grossprice1.value;
               
                  if (taxRate > 0) {
                    netValue = netValue / ((taxRate / 100) + 1);
                  }
               
                  document.forms["form"].price.value = doRound(netValue, 4);
                }
              //--></script>
            <!-- TAXMOD1 END -->
Many thanks for your help.
Cheers, Chris

Re: Entering Price with tax included

Posted: Wed Mar 28, 2012 9:22 pm
by robster
Interesting thread - is there a version available for 1.5.1.3.1?

Re: Entering Price with tax included

Posted: Fri Sep 21, 2012 5:09 pm
by hdwallpaper
I need it thanks very much

Re: Entering Price with tax included

Posted: Fri Sep 21, 2012 9:04 pm
by i2Paq

Re: Entering Price with tax included

Posted: Mon Nov 25, 2013 5:53 am
by guntis.e
Here is commercial solution:

ImageFor Opencart 1.5.x: Price Input Helper - Entering Price With Tax Included
ImageFor Opencart 2.x: Price Input Helper 2 - Enter price with tax

This OpenCart extension allows e-commerce store owner to input prices with tax on product edit form. The price without tax will be automatically calculated and saved with the form.

Features

Imagepossibility to edit and save the price modifyer (or myltiplyer)
Imagepossibility to auto-detect the tax rate based on product tax class
Imagehelper field available in all places where the price input is done:
Imageproduct price
Imageoptions prices
Imagediscounts prices
Imagespecial prices
ImageProduct list page has additional column with price incl. tax

Image