Example #1
0
 public static function VerifyAnyDestination()
 {
     $objAnyDest = Destination::model()->findByAttributes(array('country' => null, 'state' => null));
     if (!$objAnyDest instanceof Destination) {
         $objTax = TaxCode::GetNoTaxCode();
         if ($objTax) {
             $objNewAny = new Destination();
             $objNewAny->country = null;
             $objNewAny->state = null;
             $objNewAny->zipcode1 = '';
             $objNewAny->zipcode2 = '';
             $objNewAny->taxcode = $objTax->lsid;
             $objNewAny->save();
         }
     }
 }
Example #2
0
 /**
  * Update Cart by setting taxes when in Tax Inclusive
  */
 public function UpdateTaxInclusive()
 {
     if (_xls_get_conf('TAX_INCLUSIVE_PRICING', '0') != '1') {
         return;
     }
     $TAX_DECIMAL = _xls_get_conf('TAX_DECIMAL', 2);
     // Reset taxes
     $this->tax1 = 0;
     $this->tax2 = 0;
     $this->tax3 = 0;
     $this->tax4 = 0;
     $this->tax5 = 0;
     // Get the rowid for "No Tax"
     $objNoTax = TaxCode::GetNoTaxCode();
     $intNoTax = 999;
     if ($objNoTax) {
         $intNoTax = $objNoTax->lsid;
     }
     // Tax Inclusive && Want taxes, so return and set prices back to inclusive if needed
     if ($this->fk_tax_code_id != $intNoTax) {
         if (!$this->tax_inclusive) {
             //if the last destination was exclusive, and we have inclusive now, we need to reset the line items
             $this->tax_inclusive = 1;
             foreach ($this->documentItems as $objItem) {
                 // Set back tax inclusive prices
                 $objItem->sell = $objItem->product->GetPrice($objItem->qty);
                 $objItem->sell_base = $objItem->sell;
                 $objItem->tax_in = true;
                 $objItem->save();
             }
         }
         return;
     }
     $this->tax_inclusive = 0;
     // Tax Inclusive && Don't want taxes
     foreach ($this->documentItems as $objItem) {
         // For quote to cart, we have to remove prices manually
         if ($objItem->cart_type == CartType::quote && $objItem->tax_in) {
             $taxes = $objItem->product->CalculateTax(TaxCode::GetDefault(), $objItem->Sell);
             // Taxes are deducted from cart for Lightspeed
             $this->tax1 -= $taxes[1];
             $this->tax2 -= $taxes[2];
             $this->tax3 -= $taxes[3];
             $this->tax4 -= $taxes[4];
             $this->tax5 -= $taxes[5];
             $objItem->sell -= round(array_sum($taxes), $TAX_DECIMAL);
             $objItem->sell_base = $objItem->Sell;
             $objItem->sell_total = $objItem->sell * $objItem->qty;
             $objItem->tax_in = false;
             $objItem->save();
         } elseif ($objItem->cart_type = CartType::order && $objItem->tax_in) {
             // Set Tax Exclusive price
             $objItem->sell = $objItem->product->GetPrice($objItem->qty, true);
             $objItem->sell_base = $objItem->sell;
             $objItem->tax_in = false;
             $objItem->save();
         }
     }
 }
Example #3
0
 /**
  * Update shipping price and shipping tax price on the cart.
  */
 protected function updateTaxShipping()
 {
     if (isset($this->shipping->shipping_sell) === false) {
         return;
     }
     if (Yii::app()->params['SHIPPING_TAXABLE'] != '1') {
         $this->shipping->shipping_sell_taxed = $this->shipping->shipping_sell;
         $this->shipping->shipping_taxable = 0;
         $this->shipping->save();
         return;
     }
     $this->shipping->shipping_taxable = 1;
     $this->shipping->save();
     $objNoTax = TaxCode::GetNoTaxCode();
     $intNoTax = 999;
     if ($objNoTax instanceof TaxCode) {
         $intNoTax = $objNoTax->lsid;
     }
     if (Yii::app()->params['TAX_INCLUSIVE_PRICING'] == '0' && $this->tax_code_id == $intNoTax) {
         $this->shipping->shipping_sell_taxed = $this->shipping->shipping_sell;
         $this->shipping->save();
         return;
     }
     $objShipProduct = Product::LoadByCode($this->shipping->shipping_method);
     $intTaxStatus = 0;
     if ($objShipProduct) {
         $intTaxStatus = $objShipProduct->taxStatus->lsid;
     }
     // Check if the tax status is set to no tax for it, if so, make it
     // default, otherwise leave it alone.
     if (Yii::app()->getComponent('storepickup')->IsStorePickup && $intTaxStatus) {
         $objTaxStatus = $objShipProduct->taxStatus;
         if ($objTaxStatus && $objTaxStatus->IsNoTax()) {
             $intTaxStatus = 0;
         }
     }
     $nprice_taxes = Tax::calculatePricesWithTax($this->shipping->shipping_sell, $this->tax_code_id, $intTaxStatus);
     $taxes = $nprice_taxes['arrTaxValues'];
     if ($this->tax_code_id == $intNoTax) {
         $this->shipping->shipping_sell_taxed = $this->shipping->shipping_sell;
     } else {
         $this->shipping->shipping_sell_taxed = $nprice_taxes['fltSellTotalWithTax'];
         if (Yii::app()->params['TAX_INCLUSIVE_PRICING'] != '1') {
             $this->tax1 += $taxes[1];
             $this->tax2 += $taxes[2];
             $this->tax3 += $taxes[3];
             $this->tax4 += $taxes[4];
             $this->tax5 += $taxes[5];
         }
     }
     $this->shipping->shipping_taxable = 1;
     $this->shipping->save();
 }