/**
  * Initialize the Table
  *
  * @param array $params Parameters from the {form_table} tag
  */
 public function init($params)
 {
     parent::init($params);
     // Load the TaxRule Table
     try {
         // Build the table
         $taxRules = load_array_TaxRuleDBO($where);
         foreach ($taxRules as $dbo) {
             // Put the row into the table
             $this->data[] = array("id" => $dbo->getID(), "country" => $dbo->getCountry(), "allstates" => $dbo->getAllStates(), "state" => $dbo->getState(), "description" => $dbo->getDescription(), "rate" => $dbo->getRate());
         }
     } catch (DBNoRowsFoundException $e) {
     }
 }
Exemplo n.º 2
0
 /**
  * Get Tax Rules
  *
  * @return array An array of tax rules that apply to this purchase
  */
 protected function getTaxRules()
 {
     $DB = DBConnection::getDBConnection();
     $filter = "country=" . $DB->quote_smart($this->accountdbo->getCountry()) . " AND (" . "allstates=" . $DB->quote_smart("YES") . " OR " . "state=" . $DB->quote_smart($this->accountdbo->getState()) . ")";
     try {
         return load_array_TaxRuleDBO($filter);
     } catch (DBNoRowsFoundException $e) {
         return array();
     }
 }
Exemplo n.º 3
0
 /**
  * Calculate Taxes for all OrderItems
  */
 public function calculateTaxes()
 {
     $DB = DBConnection::getDBConnection();
     if (!isset($this->orderitems)) {
         // No items to tax
         return;
     }
     // Load the tax rules that apply to the country and state provided
     $taxQuery = sprintf("country=%s AND (allstates=%s OR state=%s)", $DB->quote_smart($this->getCountry()), $DB->quote_smart("YES"), $DB->quote_smart($this->getState()));
     try {
         $taxRuleDBOArray = load_array_TaxRuleDBO($taxQuery);
         foreach ($this->orderitems as $orderItemDBO) {
             $orderItemDBO->setTaxRules($taxRuleDBOArray);
         }
     } catch (DBNoRowsFoundException $e) {
     }
 }