getIsDefault(); } public function setEditIsDefault($v) { $this->setIsDefault($v); } public function isSystemDefault() { return parent::getIsSystemDefault(); } public function __sleep() { return array_keys($this->toArray(BasePeer::TYPE_FIELDNAME)); } public function __wakeup() { $this->setNew(false); $this->resetModified(); } public function __serialize() { return $this->toArray(BasePeer::TYPE_FIELDNAME); } public function __unserialize(array $data) { $this->fromArray($data, BasePeer::TYPE_FIELDNAME); $this->setNew(false); $this->resetModified(); } /** * Obsługa domyślności funkcji VAT * * @author Marcin Butlak * * @param unknown_type $con */ public function save($con = null) { if (($this->isColumnModified(TaxPeer::IS_DEFAULT)) && ($this->getIsDefault())) { $c = new Criteria(); $c->add(TaxPeer::IS_DEFAULT, 1); $tax = TaxPeer::doSelectOne($c); if ($tax) { $tax->setIsDefault(false); $tax->save(); } } $ret = parent::save($con); TaxPeer::clearCache(); return $ret; } public function delete($con = null) { $ret = parent::delete($con); TaxPeer::clearCache(); return $ret; } /** * Zwraca stawkę VAT dla kraju dostawy * * @return string|null Stawka VAT [%] */ public function getTaxRateByCountry() { $country = $this->getDeliveryCountry(); $config = stConfig::getInstance('stShopInfoBackend'); if (stTax::getIsCustomerEuTaxEnabled() && null !== $country && $country->getIsoA2() != $config->get('country') && isset($this->rates_by_country[$country->getIsoA2()])) { return $this->rates_by_country[$country->getIsoA2()]; } return null; } /** * * Przeciążenie metody - zapamiętywanie poprzedniej stawki VAT * * @param float $v Stawka VAT * * @author Marcin Butlak */ public function setVat($v) { if (!$this->isColumnModified(TaxPeer::VAT) && !$this->isNew()) { $this->prevVat = $this->getVat(); } parent::setVat($v); } public function getDefaultTaxRate() { return parent::getVat(); } public function getVat() { $vat = parent::getVat(); $countryTaxRate = $this->getTaxRateByCountry(); return $countryTaxRate ? $countryTaxRate : $vat; } /** * Wyświetlenie nazwy zamiast id * * @return unknown */ public function __toString() { return $this->getVat() . '%'; } /** * Zwraca kraj dostawy * * @return Countries */ public function getDeliveryCountry() { if (null === $this->deliveryCountry && stConfig::getInstance('stTaxBackend')->get('is_customer_eu_tax_enabled')) { $id = sfContext::getInstance()->getUser()->getAttribute('delivery_country', null, stDeliveryFrontend::SESSION_NAMESPACE); $this->deliveryCountry = CountriesPeer::retrieveById($id); } return $this->deliveryCountry; } /** * Ustawia kraj dostawy * * @param Countries $deliveryCountry Kraj dostawy * * @return self */ public function setDeliveryCountry(Countries $deliveryCountry = null) { $this->deliveryCountry = $deliveryCountry; return $this; } }