/** * Add a new tax rule * @param $result * @return mixed */ public function addTaxRule($result) { $jsonval = new JsonValidate($this->data, '{"name":"", "inclusive":true, "base":"", "locations":""}'); if (($errors = $jsonval->validate()) !== true) { $result['error'] = $errors; return $result; } $taxRuleMdl = new TaxRulesModel(); $qresult = $taxRuleMdl->create($this->data); if ($qresult === false) { $result['error'] = "Could not add the tax rule: " . $taxRuleMdl->errorInfo; } else { $this->data->id = $qresult; $result['data'] = $this->data; $this->broadcastTaxUpdate(); // log data Logger::write("Tax rule added with id:" . $this->data->id, "TAX", json_encode($this->data)); } return $result; }