Post by dr.boczek » Mon Sep 28, 2009 1:12 am

Hi, i have problem.

in checkout/cart i have price 122.00 (100.00 and tax 22%)

but in checkout/confirm and in order i have 100.00 price

why???

Attachments

confirm.jpg

Confirm - confirm.jpg (5.74 KiB) Viewed 9425 times

cart.jpg

Cart - cart.jpg (5.34 KiB) Viewed 9425 times


User avatar
Newbie

Posts

Joined
Sat Sep 26, 2009 2:15 pm
Location - Poland

Post by dbstr » Mon Sep 28, 2009 2:20 am

Edit catalog/controller/checkout/confirm.php

Find (line 412-413):

Code: Select all

               'price'      => $this->currency->format($product['price']),
        		'total'      => $this->currency->format($product['total']),
Replace with:

Code: Select all

'price'      => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'))),
        		'total'      => $this->currency->format($this->tax->calculate($product['total'], $product['tax_class_id'], $this->config->get('config_tax'))),
And tell me if it works - I can't remember if I changed anything else for that part. I did the same for the admin (update & invoice) - but that requires you to load the tax helper in the admin index.php and stuff like that.

Update: I also changed "catalog/model/total/sub_total.php", where I replaced $this->cart->getSubTotal() with $this->cart->getTotal() in line 9 & 10.

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by dr.boczek » Mon Sep 28, 2009 3:39 am

Ok, all right, thanx!


I change too line 14 in sub_total model

Code: Select all

class ModelTotalSubTotal extends Model {
	public function getTotal(&$total_data, &$total, &$taxes) {
		if ($this->config->get('sub_total_status')) {
			$this->load->language('total/sub_total');
			
			$total_data[] = array( 
        		'title'      => $this->language->get('text_sub_total'),
        		'text'       => $this->currency->format($this->cart->getTotal()),
        		'value'      => $this->cart->getTotal(),
				'sort_order' => $this->config->get('sub_total_sort_order')
			);
			
			$total += $this->cart->getTotal();
		}
	}
}
I treat this as a bug?
Does this change will be included in the next version?

User avatar
Newbie

Posts

Joined
Sat Sep 26, 2009 2:15 pm
Location - Poland

Post by dr.boczek » Mon Sep 28, 2009 3:58 am

Now I have an error in the order, look at the screenshot :)

Attachments

order_details.jpg

order_details.jpg (33.47 KiB) Viewed 9418 times


User avatar
Newbie

Posts

Joined
Sat Sep 26, 2009 2:15 pm
Location - Poland

Post by dbstr » Mon Sep 28, 2009 4:16 am

I didn't change line 14 in sub_total.php. Could you explain what the error is, I dont understand that language :)

Ahh I see. The product prices. Did you change the first thing I wrote?

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by dr.boczek » Mon Sep 28, 2009 4:32 am

I asked whether this error is disappearing tax in checkout/confirm

yes, i change the first thing.
'price' => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'))),
'total' => $this->currency->format($this->tax->calculate($product['total'], $product['tax_class_id'], $this->config->get('config_tax'))),
I changed the line 14 because the total amount was net of tax

User avatar
Newbie

Posts

Joined
Sat Sep 26, 2009 2:15 pm
Location - Poland

Post by dr.boczek » Mon Sep 28, 2009 10:07 pm

dbstr wrote:Ahh I see. The product prices. Did you change the first thing I wrote?
any suggestions? :)

User avatar
Newbie

Posts

Joined
Sat Sep 26, 2009 2:15 pm
Location - Poland

Post by dbstr » Mon Sep 28, 2009 10:24 pm

Are you sure you did it right? I just tried on a new install of OpenCart v1.3.2, and it works.

Line 405 to 415 should look like this:

Code: Select all

$this->data['products'][] = array(
				'product_id' => $product['product_id'],
        		'name'       => $product['name'],
        		'model'      => $product['model'],
        		'option'     => $option_data,
        		'quantity'   => $product['quantity'],
				'tax'        => $this->tax->getRate($product['tax_class_id']),
        		'price'      => $this->currency->format($this->tax->calculate($product['price'], $product['tax_class_id'], $this->config->get('config_tax'))),
                'total'      => $this->currency->format($this->tax->calculate($product['total'], $product['tax_class_id'], $this->config->get('config_tax'))),
				'href'       => $this->url->http('product/product&product_id=' . $product['product_id'])
      		);
priceswithvat.jpg

priceswithvat.jpg (10.67 KiB) Viewed 9405 times

(I didnt change the subtotal here, but the prices for products are shown with VAT included)

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by dr.boczek » Tue Sep 29, 2009 2:00 am

i have 1.3.2, look at the attachment.

in my checkout/confirm page do not see tax.

screen order_details.jpg shows the account/invoice


I did like you said and my checkout/confirm screen looks like the attached image

Attachments

confirm.jpg

my checkout/confirm - confirm.jpg (5.74 KiB) Viewed 9403 times

controller, view, sub_total model


User avatar
Newbie

Posts

Joined
Sat Sep 26, 2009 2:15 pm
Location - Poland

Post by dbstr » Tue Sep 29, 2009 4:37 am

Sorry, but what page are we talking about now?
screen order_details.jpg shows the account/invoice
account/invoice or the confirm page?

The account/invoice.php file is abit harder to do it on, as it doesnt save the tax_class_id in your order_product table (database). I can help you with it, if you want...

Also, this might be a stupid question - are you sure you set a tax class for "Nokia 3110c"?
(Edit product -> Tab "Data" -> Tax Class)

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by dr.boczek » Tue Sep 29, 2009 5:24 am

I am talking about the fact that even if you tax me to the checkout/confirm it then appears on the account/invoice without the tax, it is not a problem for me but for others it may be a problem.


look http://sandroplus.pl/sklep/

i make for you new account test@user.pl
pass: test

is only in Polish :( if you want to change my tomorrow.
for nokia 3110 price changed to 100.00 and added 22% tax

for payment method (metoda płatności) select "Przelew bankowy"

User avatar
Newbie

Posts

Joined
Sat Sep 26, 2009 2:15 pm
Location - Poland

Post by dbstr » Tue Sep 29, 2009 5:49 am

Edit: catalog/model/account/order.php

At around line 20, insert:

Code: Select all

 // dbstr - Get Tax Class Id.
    public function getProductTaxClassId($product_id) {
        $query = $this->db->query("SELECT tax_class_id FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "'");  
        
        return $query->row;   
    }
Edit: catalog/controller/account/invoice.php

At around line 172, find:

Code: Select all

$this->data['products'][] = array(
          			'name'     => $product['name'],
          			'model'    => $product['model'],
          			'option'   => $option_data,
          			'quantity' => $product['quantity'],
          			'price'    => $this->currency->format($product['price'], $order_info['currency'], $order_info['value']),
					'total'    => $this->currency->format($product['total'], $order_info['currency'], $order_info['value'])
        		);
Replace with:

Code: Select all

// dbstr - Get Tax Class Id.
                $tax_class_id = $this->model_account_order->getProductTaxClassId($product['product_id']);
                
        		$this->data['products'][] = array(
          			'name'     => $product['name'],
          			'model'    => $product['model'],
          			'option'   => $option_data,
          			'quantity' => $product['quantity'],    
          			//'price'    => $this->currency->format($product['price'], $order_info['currency'], $order_info['value']),
                    'price'    => $this->currency->format($this->tax->calculate($product['price'], $tax_class_id['tax_class_id'], $this->config->get('config_tax')), $order_info['currency'], $order_info['value']),
					//'total'    => $this->currency->format($product['total'], $order_info['currency'], $order_info['value'])
                    'total'    => $this->currency->format($this->tax->calculate($product['total'], $tax_class_id['tax_class_id'], $this->config->get('config_tax')), $order_info['currency'], $order_info['value'])
        		);

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by dbstr » Tue Sep 29, 2009 5:58 am

This one was bugged. Well - most of it is. PM me if you want help.
Last edited by dbstr on Sat Jul 31, 2010 6:48 pm, edited 3 times in total.

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by dbstr » Tue Sep 29, 2009 6:10 am

For the admin side, (order details & invoice):

Edit: admin/index.php
Find (line 97)

Code: Select all

// Currency
Registry::set('currency', new HelperCurrency());
After, insert:

Code: Select all

// Tax - dbstr
Registry::set('tax', new HelperTax());
Edit: admin/model/customer/order.php
Find (line 120)

Code: Select all

public function getOrderProducts($order_id) {
		$query = $this->db->query("SELECT * FROM " . DB_PREFIX . "order_product WHERE order_id = '" . (int)$order_id . "'");
	
		return $query->rows;
	}
After, insert:

Code: Select all

// dbstr - Get Tax Class Id.
    public function getProductTaxClassId($product_id) {
        $query = $this->db->query("SELECT tax_class_id FROM " . DB_PREFIX . "product WHERE product_id = '" . (int)$product_id . "'");  
        
        return $query->row;   
    }
Edit: admin/controller/customer/order.php
Find (line 577)

Code: Select all

$this->data['products'][] = array(
          		'name'     => $product['name'],
          		'model'    => $product['model'],
          		'option'   => $option_data,
          		'quantity' => $product['quantity'],
          		'price'    => $this->currency->format($product['price'], $order_info['currency'], $order_info['value']),
				'total'    => $this->currency->format($product['total'], $order_info['currency'], $order_info['value'])
        	);
Replace with:

Code: Select all

            // dbstr - Tax...
        	$tax_class_id = $this->model_customer_order->getProductTaxClassId($product['product_id']);
             
            $this->data['products'][] = array(
                  'name'     => $product['name'],
                  'model'    => $product['model'],
                  'option'   => $option_data,
                  'quantity' => $product['quantity'],
                  //'price'    => $this->currency->format($product['price'], $order_info['currency'], $order_info['value']),
                  'price'    => $this->currency->format($this->tax->calculate($product['price'], $tax_class_id['tax_class_id'], $this->config->get('config_tax')), $order_info['currency'], $order_info['value']),
                  //'total'    => $this->currency->format($product['total'], $order_info['currency'], $order_info['value'])
                  'total'    => $this->currency->format($this->tax->calculate($product['total'], $tax_class_id['tax_class_id'], $this->config->get('config_tax')), $order_info['currency'], $order_info['value'])
            );
And for the invoice, do the same at line ~772.

(I don't know if I missed or forgot something, so just yell if it fails ;-))
Last edited by dbstr on Tue Sep 29, 2009 6:58 am, edited 1 time in total.

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by Daniel » Tue Sep 29, 2009 6:17 am

you only need to set your order totals tax module to enabled and set the right tax zone up.

why mess with the code when its working fine!

OpenCart®
Project Owner & Developer.


User avatar
Administrator

Posts

Joined
Fri Nov 03, 2006 6:57 pm

Post by dbstr » Tue Sep 29, 2009 6:28 am

The thing is, in Denmark atleast, we have to show all prices inclusive tax, and by default it doesn't do that in the confirm.php, invoice.php and other places.

I know the tax is being added in the "order total", but it still doesn't show the product prices with tax. Correct me if I'm wrong, please.. Would love to undo all the changes, if there is a better way to do it.

It's not your fault, it's just the way it is in some countries.

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by Qphoria » Tue Sep 29, 2009 7:18 am

Yea, I am not aware of any bugs with this. It just sounds like you had Display prices with tax set up and weren't logged in or something. Or were logged in from a zone outside of the tax zone.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by dbstr » Tue Sep 29, 2009 7:27 am

Qphoria wrote:Yea, I am not aware of any bugs with this. It just sounds like you had Display prices with tax set up and weren't logged in or something. Or were logged in from a zone outside of the tax zone.
Who are you talking to?

I tested this for a few hours with different setups. I only got one zone and one tax rate. No matter what I did, it didn't display the product prices with tax in the confirm & invoice pages (which you have to be logged in to see). In the controller files it isn't adding the tax, so how can it have anything to do with not being logged in, or in the wrong zone?

As I wrote in my previous post, this might not be a problem for everyone - but for some countries, you would want to display all prices with the tax included. I don't know the laws or preferences of UK and US shops, but this it how it is here, and how I want it to be. If there is an easier solution, feel free to tell me and delete my "messing with the code"-posts.

This is not a bug as such, but some people will need it - others won't.

Edit:
For the admin side changes, I forgot this;
Add this line at line 11, in admin/index.php:

Code: Select all

require_once(DIR_SYSTEM . 'helper/tax.php');

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am

Post by Qphoria » Tue Sep 29, 2009 8:58 am

The way it works is:
Case 1:
Display Prices with Tax = YES

Results 1:
a) Logged Out: Price + the tax rate set on the product.
b) Logged In (same zone as product tax zone):
- All pages: Price+tax
- Confirm page: Price + tax already in price. Tax listed only as text to break it down, but does not recalculate main total.
c) Logged In (different zone than product tax zone):
- All pages: Price+taxPrice only
- Confirm page: Price only. No tax.

Case 2:
Display Prices with Tax = NO

Results 2:
a) Logged Out: Price only
b) Logged In (same zone as product tax zone):
- All pages: Price only.
- Confirm page: Price only in totals. Tax listed and deducted as a total. recalculates main total.
c) Logged In (different zone than product tax zone):
- All pages: Price only
- Confirm page: Price only. No tax.
There should be no bearing on country or zone.. its all the same system.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by dbstr » Tue Sep 29, 2009 9:24 am

Example time:

I got 1 country, 1 zone, 1 tax rate. Display prices with vat set to yes.

A product with a price, let's say 80. Tax rate: 25%

What would it show in my confirm page, assuming I'm logged in, my address is set up with the only zone I got, and the product is set to my tax class? What unit price would it show?

I'm sorry if this sounds stupid, but I either misunderstood the basics of the tax calculation used, or we aren't understanding eachother and the purpose of my code-messing. I'm just looking for some clarification on this, not meaning to diss anyone or anything.

Request Reviews v1.0 released.


Active Member

Posts

Joined
Sun Aug 30, 2009 12:20 am
Who is online

Users browsing this forum: No registered users and 5 guests