Post by Fredo » Wed Mar 19, 2008 2:15 am

Hello

In checkout_confirm, i have an order like this :

Name        Ref         Qty        Unit Price      Total Price with VAT
Object      PM03 1   29.00€     29.00€
                          Subtotal without VAT :      24.25€
                                        Tax amount :     4.75€
                              Subtotal with VAT :      29.00€
                    Delivery amount with VAT :     9.00€
                            Delivery tax amount :     1.47€
                                        Total to pay :   38.00€

The problem is that tax amount is calcultated twice. Calculate::getTotals() seems to be called twice whereas the only call point is in ControllerCheckoutConfirm::index() !

Same problem with coupon !

Some idea about this ?

Thanks

Newbie

Posts

Joined
Wed Mar 19, 2008 1:58 am

Post by bruce » Wed Mar 19, 2008 7:43 pm

I think those numbers are correct.

Active Member

Posts

Joined
Wed Dec 12, 2007 2:26 pm

Post by Fredo » Thu Mar 27, 2008 4:42 pm

No problem with tax in fact.

But the promotion code was calculated twice :

once by my payment system to submit total amount (payment system class)
and
once by CheckoutConfirmClassController class

As object calculate is initialised by reference, i added as static variable in CalculateCoupon::calculate()

function calculate() {
static $i = 1; // ADD
$total_data = array();

if (($this->config->get('coupon_status')) && ($this->coupon->getId())) {
if ($this->coupon->getDiscount($this->cart->getTotal()) > 0) {
      $total_data[] = array(
        'title' => $this->language->get('text_coupon_title', $this->coupon->getName()),
    'text'  => '-' . $this->currency->format($this->coupon->getDiscount($this->cart->getTotal())),
        'value' => $this->coupon->getDiscount($this->cart->getTotal())
      );

if($i == 1) { // ADD
$this->cart->decreaseTotal($this->coupon->getDiscount($this->cart->getTotal()));
}
}

if (($this->coupon->getShipping()) && ($this->cart->hasShipping())) {
      $total_data[] = array(
        'title' => $this->language->get('text_coupon_shipping'),
    'text'  => '-' . $this->currency->format($this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method')))),
        'value' => $this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method')))
      );

if($i == 1) { // ADD
$this->cart->decreaseTotal($this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method'))));
}
}
    }

$i++; // ADD
    return $total_data;
}

Newbie

Posts

Joined
Wed Mar 19, 2008 1:58 am
Who is online

Users browsing this forum: No registered users and 2 guests