/**
  * Add a tax code into the WS
  *
  * @param string $passkey
  * @param int $intRowid
  * @param string $strCode
  * @param int $intListOrder
  * @param double $fltTax1Rate
  * @param double $fltTax2Rate
  * @param double $fltTax3Rate
  * @param double $fltTax4Rate
  * @param double $fltTax5Rate
  * @return string
  */
 public function add_tax_code($passkey, $intRowid, $strCode, $intListOrder, $fltTax1Rate, $fltTax2Rate, $fltTax3Rate, $fltTax4Rate, $fltTax5Rate)
 {
     if (!$this->check_passkey($passkey)) {
         return self::FAIL_AUTH;
     }
     if ($strCode == "") {
         //ignore blank tax codes
         return self::OK;
     }
     // Loads tax
     $tax = TaxCode::LoadByLS($intRowid);
     if (!$tax) {
         $tax = new TaxCode();
     }
     $tax->lsid = $intRowid;
     $tax->code = $strCode;
     $tax->list_order = $intListOrder;
     $tax->tax1_rate = $fltTax1Rate;
     $tax->tax2_rate = $fltTax2Rate;
     $tax->tax3_rate = $fltTax3Rate;
     $tax->tax4_rate = $fltTax4Rate;
     $tax->tax5_rate = $fltTax5Rate;
     if (!$tax->save()) {
         Yii::log("SOAP ERROR : Error saving tax {$strCode} " . print_r($tax->getErrors()), 'error', 'application.' . __CLASS__ . "." . __FUNCTION__);
         return self::UNKNOWN_ERROR . " Error saving category {$strCode} " . print_r($tax->getErrors(), true);
     }
     return self::OK;
 }
示例#2
0
 /**
  * For a product, returns tax rate for all defined destinations
  * Useful for RSS exports
  * @return TaxGrid[]
  */
 public function GetTaxRateGrid()
 {
     $arrGrid = array();
     $intTaxStatus = $this->tax_status_id;
     $objStatus = TaxStatus::LoadByLS($intTaxStatus);
     $objDestinations = Destination::model()->findAll();
     foreach ($objDestinations as $objDestination) {
         //Because of differences in how Google defines zip code ranges, we can't convert our ranges
         //to theirs. At this time we won't be able to support zip code ranges
         if (!is_null($objDestination->country) && $objDestination->Zipcode1 == '') {
             $objTaxCode = TaxCode::LoadByLS($objDestination->taxcode);
             //print_r($objTaxCode);
             $fltRate = 0.0;
             for ($x = 1; $x <= 5; $x++) {
                 $statusstring = "tax" . $x . "_status";
                 $codestring = "tax" . $x . "_rate";
                 if ($objStatus->{$statusstring} == 0) {
                     $fltRate += $objTaxCode->{$codestring};
                 }
             }
             //Our four elements
             $strCountry = Country::CodeById($objDestination->country);
             if (!is_null($objDestination->state)) {
                 $strState = State::CodeById($objDestination->state);
             } else {
                 $strState = '';
             }
             //$fltRate -- built above
             $strTaxShip = Yii::app()->params['SHIPPING_TAXABLE'] == '1' ? "y" : "n";
             $arrGrid[] = array($strCountry, $strState, $fltRate, $strTaxShip);
         }
     }
     return $arrGrid;
 }
 /**
  * Add a tax code into the WS
  *
  * @param string $passkey
  * @param int $intRowid
  * @param string $strCode
  * @param int $intListOrder
  * @param double $fltTax1Rate
  * @param double $fltTax2Rate
  * @param double $fltTax3Rate
  * @param double $fltTax4Rate
  * @param double $fltTax5Rate
  * @return string
  * @throws SoapFault
  * @soap
  */
 public function add_tax_code($passkey, $intRowid, $strCode, $intListOrder, $fltTax1Rate, $fltTax2Rate, $fltTax3Rate, $fltTax4Rate, $fltTax5Rate)
 {
     self::check_passkey($passkey);
     if ($strCode == "") {
         //ignore blank tax codes
         return self::OK;
     }
     // Loads tax
     $tax = TaxCode::LoadByLS($intRowid);
     if (!$tax) {
         $tax = new TaxCode();
     }
     $tax->lsid = $intRowid;
     $tax->code = $strCode;
     $tax->list_order = $intListOrder;
     $tax->tax1_rate = $fltTax1Rate;
     $tax->tax2_rate = $fltTax2Rate;
     $tax->tax3_rate = $fltTax3Rate;
     $tax->tax4_rate = $fltTax4Rate;
     $tax->tax5_rate = $fltTax5Rate;
     if (!$tax->save()) {
         $strMsg = "Error saving tax {$strCode}";
         Yii::log("SOAP ERROR : {$strMsg} " . print_r($tax->getErrors(), true), CLogger::LEVEL_ERROR, 'application.' . __CLASS__ . "." . __FUNCTION__);
         throw new SoapFault($strMsg, WsSoapException::ERROR_UNKNOWN);
     }
     TaxCode::VerifyAnyDestination();
     return self::OK;
 }