Post by thegeekz » Fri Oct 12, 2012 5:14 pm

Dear all,

You may know that I've been seeking help recently with regards to displaying Subtotals with Tax inclusive --- in the backend and Invoice Print out from Admin.

I just need to know 2 things :

1) What file controls the backend -- Sales / Order / Totals Tab

2) What code to alter or add for Subtotals with Tax to be shown properly in the Order backend and the Invoice Printout.

Please help me!

Regards

The Geekz


Notes :


It should be :


Item : 107.00

Subtotal : 107.00

GST Inclusive : 7.00

Totals : 107.00


Currently :

1.5.2.1

Have checked the Display Prices with Tax in Settings.

Invoice --

Initially it works, unless I click the Update Totals in the Order Backend -- Total tab -- the Subtotal will become without TAX!

Order Backend --

Totally cannot..... its displaying Subtotal without Tax



** given, I already edited in 1.5.2.1's Controller : admin/controller/sale/order.php (1.5.4.1 already has these codes in the controllers)

Code: Select all

        $this->data['products'][] = array(
                       'order_product_id' => $product['order_product_id'],
                       'product_id'       => $product['product_id'],
                       'name'              => $product['name'],
                       'model'             => $product['model'],
                       'option'            => $option_data,
                       'quantity'         => $product['quantity'],
                       // Edited 'price' & 'total' (Start).
                       'price'             => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
                       'total'             => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value']),
                       // Edited 'price' & 'total' (End).
                       'href'              => $this->url->link('catalog/product/update', 'token=' . $this->session->data['token'] . '&product_id=' . $product['product_id'], 'SSL')
                    );

Code: Select all

        $product_data[] = array(
                          'name'     => $product['name'],
                          'model'    => $product['model'],
                          'option'   => $option_data,
                          'quantity' => $product['quantity'],
                          // Edited 'price' & 'total' (Start).
                          'price'    => $this->currency->format($product['price'] + ($this->config->get('config_tax') ? $product['tax'] : 0), $order_info['currency_code'], $order_info['currency_value']),
                          'total'    => $this->currency->format($product['total'] + ($this->config->get('config_tax') ? ($product['tax'] * $product['quantity']) : 0), $order_info['currency_code'], $order_info['currency_value'])
                          // Edited 'price' & 'total' (End).
                       );



1.5.4.1

Totally cannot work in both Invoice and Order Backend.
Last edited by thegeekz on Thu Nov 08, 2012 2:30 pm, edited 1 time in total.

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Fri Oct 12, 2012 8:50 pm

Hi,

Just a wild guess that its a bug.... to my logic, with Display with tax checked... Subtotal should be Inc tax as well...

The thing is this...

I would require :

Item : 107.00

Subtotal : 107.00

GST INC : 7.00

SHIPPING : 10.00

TOTAL : 117.00


With your brief guidance... I'm still unable to make it like above for the backend and invoice (in a stable mode so that Pressing Update Totals button does not change the figure).

Could you give a detailed description, especially the codes and steps.

Is there any codes I need to change further in the controller and the model file indicated?

My front end is taken care of by an extension.

Thanks!

Note :

Subtotal will not include the shipping and I do require shipping figure to be after the subtotal as there is no tax on the shipping.

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Sun Oct 14, 2012 9:28 pm

Thank you so much for the detailed explanation!!!

If the front end - checkout function with subtotal inc. tax is already solved by the Order total with tax extension.. (not sure if that affects the order history that the customer/user sees after they place order)
-- if that ext. doesn't affect their order history.... then I supposed its fine to do this? let me check and get back about that?

The coupon you actually meant the default OC one? I have an Advanced Coupon module.. hope that will not affect the subtotal.

Also.. for Order history in Admin end, you meant the one in the Total tab in the order admin? overall I hope to make it the same with the Invoice to make things simple for my friend/client that I'm helping out part time with my limited knowledge...

I will start the step by step before trying to solve the voucher affecting the subtotal issue. (if that's what you meant in this particular para. below the "--"). Worst case scenario.. complete solving this by November.

As a noob, I'm not sure what you mean by the following, but let's take things step by step.. especially the adjust what the module puts back part.

(iterate? means repeat? sorry my English may not be that perfect to understand some words.

You mean to repeat the above changes to the order.php and put them through to the sub_total.php?)
--

You could take the products from the cart and adjust what the module returns back. That part I haven't touched but it can be done in a similar manner as the admin/controller/sale/order.php where you iterate through the products, add the tax and return back the sub-total. This is because I haven't tested all combinations and how it will affect the regular checkout.

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Mon Oct 15, 2012 2:16 pm

Update : -- Not yet done anything to the coding yet..

Tried making a test order, and this is what I've found..... The Order Totals with Tax extension did affect the Order history as well.
Image 7.jpg

Image 7.jpg (29.41 KiB) Viewed 7764 times

In the Order Admin -- Totals Tab:
Image 8.jpg

Image 8.jpg (51.08 KiB) Viewed 7773 times


In the Invoice Printout :
Image 9.jpg

Image 9.jpg (52.33 KiB) Viewed 7773 times

** This is all before I press the Update Totals...
Last edited by thegeekz on Mon Oct 15, 2012 4:31 pm, edited 4 times in total.

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Mon Oct 15, 2012 2:23 pm

Pressed Update Totals button in the Totals Tab

Totals Tab --
Image 10.jpg

Image 10.jpg (39.25 KiB) Viewed 7773 times

Saved then :

Invoice --
Image 11.jpg

Image 11.jpg (49.23 KiB) Viewed 7773 times


Order History -- Frontend --
Image 12.jpg

Image 12.jpg (31.58 KiB) Viewed 7773 times

So apparently once Update Totals button is pressed, the Order History is affected as well !!! !!!!
Last edited by thegeekz on Mon Oct 15, 2012 4:31 pm, edited 1 time in total.

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Mon Oct 15, 2012 3:59 pm

Latest update : -- After changing most of the codes till :

"Ok now this file you see it will invoke the totals modules one of which is the sub-total. catalog/model/total/sub_total.php.
....
.....
there is no reason to go through all this trouble to modify the cart. "


I checked the Order Backend -- Totals Tab :

Subtotals are looks ok initially -- Unit Price I realised it did not show with Tax as well! Which is wierd cos isn't it supposed to show with Tax since "Display Prices with Tax" is activated?

Now the thing is --> Upon pressing Save button, the Subtotals instead of $107, became $114 :

Totals Tab -- Order Admin :
Image 15.jpg

Image 15.jpg (36.04 KiB) Viewed 7765 times

Unit price still not showing the 7% GST added........

Invoice :
Image 16.jpg

Image 16.jpg (43.6 KiB) Viewed 7765 times

Here & the front end order history shows the Item total as $114 which is wrong, should be $107.. may need some adjustments in the code?

Front end order history:
Image 17.jpg

Image 17.jpg (29.86 KiB) Viewed 7764 times

Last edited by thegeekz on Mon Oct 15, 2012 4:31 pm, edited 3 times in total.

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Mon Oct 15, 2012 4:02 pm

Instead of changing the coding directly in the respective files, I did the change via vqmod : (may need some adjustments here due to the problems above? I don't know what's wrong there... :( )

Code: Select all

<modification>
        <id>Admin Totals with tax incl.</id>
        <version>1.0.1</version>
        <vqmver>2.1</vqmver>
        <author>KGShop-SG.com</author>
        <file name="admin/controller/sale/order.php">
                <operation>
                        <search position="before">
						<![CDATA[
						foreach ($order_products as $order_product) {
						]]></search>
                        <add><![CDATA[
                        $sub_total_with_tax = 0;
                        ]]></add>
                </operation>
				<operation>
						<search position="before">
						<![CDATA[
						$this->data['order_products'][] = array(
						]]></search>
						<add><![CDATA[
                        $total_item_taxed = number_format($order_product['total'] + ($this->config->get('config_tax') ? ($order_product['tax'] * $order_product['quantity']) : 0), 4);
						$sub_total_with_tax += $total_item_taxed;
                        ]]></add>
				</operation>		
				<operation>
						<search position="replace">
						<![CDATA[		
						'total'            => $order_product['total'], 
						]]></search>
						<add><![CDATA[
						'total'             => $total_item_taxed,
						]]></add>
				</operation>		
				<operation>
						<search position="before">
						<![CDATA[
						$this->template = 'sale/order_form.tpl'; 
						]]></search>
						<add><![CDATA[
						for( $i=0, $j=count($this->data['order_totals']); $i<$j; $i++) {
							if( $this->data['order_totals'][$i]['code'] == 'sub_total' ) {
							$this->data['order_totals'][$i]['value'] = number_format($sub_total_with_tax,4);
							$this->data['order_totals'][$i]['text'] = $this->currency->format($sub_total_with_tax, $order_info['currency_code'], $order_info['currency_value']);
							break;
							}
						}
						]]></add>
				</operation>	
		</file>
        <file name="catalog/controller/checkout/manual.php">
                <operation>
                        <search position="before"><![CDATA[
						$json['order_product'][] = array( 
						]]></search>
                        <add><![CDATA[
                        if (isset($this->request->post['order_product'])) {                        
						$product_total_price = number_format( $product['total'] + ($this->config->get('config_tax') ? ($this->tax->getTax($product['price'], $product['tax_class_id']) * $product['quantity']) : 0), 4);
						} else {
						$product_total_price = $product['total'];
						}
                        ]]></add>
                </operation>
        		<operation>
						<search position="replace">
						<![CDATA[
						'total'      => $product['total'], 
						]]></search>
						<add><![CDATA[
						'total'      => $product_total_price,
						]]></add>
				</operation>
				<operation>
						<search position="replace">
						<![CDATA[
						'tax'        => $this->tax->getTax($product['total'], $product['tax_class_id']), 
						]]></search>
						<add><![CDATA[
						'tax'        => $this->tax->getTax($product['price'], $product['tax_class_id']),
						]]></add>
				</operation>
        </file>		
</modification>

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Mon Oct 15, 2012 6:38 pm

Enigma1 :

So what other codes do I need to change to solve the double tax issue?

Is it only the above subtotal coding you mentioned?

I see once we solve the double tax as well as the Order Backend -- unit price not showing with Tax, it should work fine...
Last edited by thegeekz on Wed Oct 17, 2012 10:54 am, edited 2 times in total.

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Wed Oct 17, 2012 10:48 am

thegeekz wrote:Latest update : -- After changing most of the codes till :


....

I checked the Order Backend -- Totals Tab :

Subtotals are looks ok initially -- Unit Price I realised it did not show with Tax as well! Which is wierd cos isn't it supposed to show with Tax since "Display Prices with Tax" is activated?

Now the thing is --> Upon pressing Save button, the Subtotals instead of $107, became $114 :

Totals Tab -- Order Admin :
Image 15.jpg

Image 15.jpg (36.04 KiB) Viewed 7737 times

Unit price still not showing the 7% GST added........
Enigma1 or any expert, could you help me solve this issue as well? Unit price is totally without tax in the Order Backend
(Totals tab)

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Wed Oct 17, 2012 6:19 pm

enigma1 wrote:If you wanted to display under the order total tab the unit price including tax then having the code above I posted in the admin/controller/sale/order.php you also change:

Code: Select all

'price'            => $order_product['price'],
to:

Code: Select all

'price'            => $total_item_taxed,
unfortunately there are many other places the individual prices+tax need to be changed to have consistency.

Hmm thanks! I'll try this 1st.

Meanwhile.... what other places you mean?

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Wed Oct 17, 2012 6:46 pm

I'm sorry... I still could not catch what you meant here...


I don't think I need to process products one at a time? Lost here...

So I just need to change this coding in the sub_total.php file? Or is this the original code?

How can I solve the double tax amount that appeared now then?
enigma1 wrote:
(iterate? means repeat? sorry my English may not be that perfect to understand some words.
You mean to repeat the above changes to the order.php and put them through to the sub_total.php?)
I mean process the products from the cart or from the order_product table one at a time to create the sub-total including tax. If you see the sub_total.php file in the catalog/model/total folder, it gets the sub-total straight from the cart.

$sub_total = $this->cart->getSubTotal();

The cart function getSubTotal gets the product total price for each:

Code: Select all

  	public function getSubTotal() {
		$total = 0;
		
		foreach ($this->getProducts() as $product) {
			$total += $product['total'];
		}
		return $total;
  	}
If you change the code to include the taxes for the sub-total it will affect the grand total of the order adding the tax twice. So you want to display only the product+tax not to update the database. So this involves quite a lot of changes in many files. It's the reason I asked if it's only for an invoice to print and email a customer setup a new script to do just that and leave the cart as is.

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Wed Oct 17, 2012 8:19 pm

enigma1 wrote:Other places like print invoice, shopping cart page, view order vs edit order, on catalog customer account view orders etc etc.
OK. Most of those in the front end... the subtotal with gst issue is solved with the extension I bought... only the invoice.

So I assume it's the invoice.tpl file?

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Wed Oct 17, 2012 8:23 pm

enigma1 wrote:Yes you need to process products one at a time because you want to apply the tax to each product on the one hand and on the other you want to show the subtotal for the products with the product tax only. No shipping, credits etc to be included.

The getSubTotal is the original function code.
So how to do this processing? Super lost..

And how to solve the double tax problem with the subtotal or item total?

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Wed Oct 17, 2012 9:38 pm

enigma1 wrote:It's just too many places to change the code and add conditionals for the sub-total, to list them here and of course do the coding. If you really want to do this you will have to start changing one file at a time where you see the product's price and follow the initial steps how the product price and sub-total can include tax.
Ok.

I'll need you to list down the files I need to change.. and I'll do it.. no matter what.

To solve the Double Tax problem... I'm just this one step away from changing it! That also includes the step to solve the Unit price with tax in Order - Totals Tab.

Conclusion:

I just need to follow your 1st post step by step coding changes for the files affected, which I will await here for your kind guidance onto which files to edit. Also confirm the codings needed to change.



Thanks!

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Mon Oct 22, 2012 5:52 pm

Kindly state the step by step details to solve the issue with the double tax..... In the Subtotal as well as the Item Total.

I'll need the coding and the files that it needs to be edited. I must make this work!

Just 2 steps aways only!

Thanks!

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Mon Oct 22, 2012 7:52 pm

Hmm ok. Learnt something today.

How about the coding to solve the double tax problem I'm facing now after editing using the 1st set earlier?.

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Tue Oct 23, 2012 4:43 pm

enigma1 wrote:If you wanted to display under the order total tab the unit price including tax then having the code above I posted in the admin/controller/sale/order.php you also change:

Code: Select all

'price'            => $order_product['price'],
to:

Code: Select all

'price'            => $total_item_taxed,
unfortunately there are many other places the individual prices+tax need to be changed to have consistency.
Ok, finally made changes to the xml code to include this change to solve the Unit Price with Tax, but now it became triple tax as well. -- after pressing save button in the Totals tab
Image - 4.jpg

Image - 4.jpg (45.09 KiB) Viewed 7619 times



Now a check in the front end -- Customer History, instead of $107, it appeared $121 as well! This similarly appeared in the Invoice printout in the backend as well.

Frontend - Customer Order History --
Image - 2.jpg

Image - 2.jpg (30.24 KiB) Viewed 7619 times

Backend - Invoice --
Image - 3.jpg

Image - 3.jpg (52.75 KiB) Viewed 7619 times

Seriously I need to know how to adjust these!


Need to know the code to adjust the double / triple tax issue!

Thank you.
Last edited by thegeekz on Tue Oct 23, 2012 5:11 pm, edited 1 time in total.

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Tue Oct 23, 2012 4:45 pm

Here's the VQMOD.. Need help to adjust for the double / triple tax issue happening now...

Note:

If I remove the Front end - Order Totals with Tax vqmod - -that I purchased from Beop, the Customer Order History -- Item Price and Item Totals will become $114, and not the before one @ $121.

Backend Invoice Item Price and Item Total remain the same @ $121,.

But all this are not correct.. should be $107... :(

Due to obvious reasons, its inconvenient for me to post Beop's VQMOD here.... since its a commercial one....

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Tue Oct 23, 2012 5:12 pm

I just realised something, every time I went into the Totals tab in Order Admin, press save, the Item Price, Item Total figure will plus $7!! So now instead of $121, it became $128 for all related !!! argh.

I set up a new order again, everything looks fine... till I hit Save button on the Totals tab....

Item Unit Price / Item Total from
$107 --> $114

Every save will add $7 onto this.

Subtotals remain fine -- correct at $107.

So now Only thing is to see what code can be adjusted to prevent the addition of $7 after each save.

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am

Post by thegeekz » Wed Oct 24, 2012 10:09 am

Hmm.... sorry for being slow... I'm still not able to catch it....

From your post :
$sub_total = $this->cart->getSubTotal(); -- I saw this in catalog/model/total/sub_total.php

The cart function getSubTotal gets the product total price for each: - Saw the following code in system/library/cart.php

Code: Select all

         public function getSubTotal() {
          $total = 0;
          
          foreach ($this->getProducts() as $product) {
             $total += $product['total'];
          }
          return $total;
         }
But not sure how this can relate to the double/triple/quadraple etc .. tax in the Item price / Item Total?

No more using Apsona, as they are not updated.

  • Every upgrade -- rem. 2 reinstall vqmod & mindful of modules w/ VQmod -- E.g Import / Export Tool by MHC


Active Member

Posts

Joined
Tue Nov 02, 2010 10:24 am
Who is online

Users browsing this forum: Baidu [Spider] and 69 guests