public static function getCloudDefault()
 {
     $objStatus = TaxStatus::model()->findByAttributes(array('status' => 'Default', 'tax1_status' => '0', 'tax2_status' => '1', 'tax3_status' => '1', 'tax4_status' => '1', 'tax5_status' => '1'));
     if (is_null($objStatus)) {
         return false;
     } else {
         return $objStatus;
     }
 }
Exemple #2
0
 /**
  * Removes the tax from a tax inclusive price. Since our TaxIn prices are generated from our
  * default tax code, we can use this to undo the tax
  * @param $fltPrice
  * @return float
  */
 public static function StripTaxesFromPrice($fltSellTotal, $intTaxStatusId)
 {
     static $objTaxes;
     // Cached for better performance
     $fltSellTotalTaxed = $fltSellTotal;
     $arrTaxAmount = array(1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0);
     $intTaxCodeId = 0;
     $objTaxCodes = TaxCode::model()->findAll(array('order' => 'list_order'));
     //Default tax code is first in list
     $objTaxCode = $objTaxCodes[0];
     if (!$objTaxCode) {
         if (!is_null($intTaxCodeId)) {
             //Ignore null at this stage
             Yii::log("Unknown tax code passed: {$intTaxCodeId}", 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         }
         return array($fltSellTotalTaxed, $arrTaxAmount);
     }
     if ($intTaxStatusId instanceof TaxStatus) {
         $objTaxStatus = $intTaxStatusId;
     } elseif ($intTaxStatusId >= 0) {
         $objTaxStatus = TaxStatus::model()->findByAttributes(array('lsid' => $intTaxStatusId));
     } else {
         $objTaxStatus = false;
     }
     if (!$objTaxes) {
         $objTaxes = Tax::model()->findAll();
     }
     $taxtypes = 5;
     // Number of taxes in LS
     // for each exempt, reset the code to 0
     if ($objTaxStatus) {
         if ($objTaxStatus->tax1_status) {
             $objTaxCode->tax1_rate = 0;
         }
         if ($objTaxStatus->tax2_status) {
             $objTaxCode->tax2_rate = 0;
         }
         if ($objTaxStatus->tax3_status) {
             $objTaxCode->tax3_rate = 0;
         }
         if ($objTaxStatus->tax4_status) {
             $objTaxCode->tax4_rate = 0;
         }
         if ($objTaxStatus->tax5_status) {
             $objTaxCode->tax5_rate = 0;
         }
     }
     $i = 0;
     foreach ($objTaxes as $objTax) {
         $strRate = "tax" . ($i + 1) . "_rate";
         if ($objTaxCode->{$strRate} > 0) {
             if ($objTax->compounded) {
                 $fltTaxAmount = $fltSellTotalTaxed / ($objTaxCode->{$strRate} / 100);
             } else {
                 $fltOrig = $fltSellTotal / (1 + $objTaxCode->{$strRate} / 100);
                 $fltTaxAmount = round($fltSellTotal - $fltOrig, 2);
             }
         } else {
             $fltTaxAmount = 0;
         }
         if ($objTax->max_tax > 0 && $fltTaxAmount >= $objTax->max_tax) {
             $fltTaxAmount = $objTax->max_tax;
         }
         $arrTaxAmount[$i + 1] = $fltTaxAmount;
         $fltSellTotalTaxed = $fltSellTotalTaxed - $fltTaxAmount;
         $i++;
         if ($i >= $taxtypes) {
             $i = $taxtypes;
         }
     }
     return $fltSellTotalTaxed;
 }
 /**
  * Tax Status List
  *
  * @param string $passkey
  * @return string
  * @throws SoapFault
  * @soap
  */
 public function list_tax_statuses($passkey)
 {
     self::check_passkey($passkey);
     $obj = TaxStatus::model()->findAll();
     return CJSON::encode($obj);
 }