Exemplo n.º 1
0
 /**
  * @param int $taxRate
  * @param string $iso2Code
  *
  * @return \Orm\Zed\Product\Persistence\SpyProductAbstract
  */
 protected function createAbstractProductWithTaxSet($taxRate, $iso2Code)
 {
     $countryEntity = SpyCountryQuery::create()->findOneByIso2Code($iso2Code);
     $taxRateEntity1 = new SpyTaxRate();
     $taxRateEntity1->setRate($taxRate);
     $taxRateEntity1->setName('test rate');
     $taxRateEntity1->setFkCountry($countryEntity->getIdCountry());
     $taxRateEntity1->save();
     $taxRateEntity2 = new SpyTaxRate();
     $taxRateEntity2->setRate(13);
     $taxRateEntity2->setName('test rate');
     $taxRateEntity2->setFkCountry($countryEntity->getIdCountry());
     $taxRateEntity2->save();
     $taxRateExemptEntity = new SpyTaxRate();
     $taxRateExemptEntity->setRate(0);
     $taxRateExemptEntity->setName(TaxConstants::TAX_EXEMPT_PLACEHOLDER);
     $taxRateExemptEntity->save();
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->setName('name of tax set');
     $taxSetEntity->save();
     $taxSetTaxRateEntity = new SpyTaxSetTax();
     $taxSetTaxRateEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $taxSetTaxRateEntity->setFkTaxRate($taxRateEntity1->getIdTaxRate());
     $taxSetTaxRateEntity->save();
     $taxSetTaxRateEntity = new SpyTaxSetTax();
     $taxSetTaxRateEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $taxSetTaxRateEntity->setFkTaxRate($taxRateEntity2->getIdTaxRate());
     $taxSetTaxRateEntity->save();
     $taxSetTaxRateEntity = new SpyTaxSetTax();
     $taxSetTaxRateEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $taxSetTaxRateEntity->setFkTaxRate($taxRateExemptEntity->getIdTaxRate());
     $taxSetTaxRateEntity->save();
     $abstractProductEntity = new SpyProductAbstract();
     $abstractProductEntity->setSku('test-abstract-sku');
     $abstractProductEntity->setAttributes('');
     $abstractProductEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $abstractProductEntity->save();
     return $abstractProductEntity;
 }
 /**
  * @param int $taxRate
  * @param string $iso2Code
  *
  * @return \Orm\Zed\Shipment\Persistence\SpyShipmentMethod
  */
 protected function createShipmentMethodWithTaxSet($taxRate, $iso2Code)
 {
     $countryEntity = SpyCountryQuery::create()->findOneByIso2Code($iso2Code);
     $taxRateEntity1 = new SpyTaxRate();
     $taxRateEntity1->setRate($taxRate);
     $taxRateEntity1->setName('test rate 1');
     $taxRateEntity1->setFkCountry($countryEntity->getIdCountry());
     $taxRateEntity1->save();
     $taxRateEntity2 = new SpyTaxRate();
     $taxRateEntity2->setRate(13);
     $taxRateEntity2->setName('tax rate 2');
     $taxRateEntity2->setFkCountry($countryEntity->getIdCountry());
     $taxRateEntity2->save();
     $taxRateExemptEntity = new SpyTaxRate();
     $taxRateExemptEntity->setRate(0);
     $taxRateExemptEntity->setName(TaxConstants::TAX_EXEMPT_PLACEHOLDER);
     $taxRateExemptEntity->save();
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->setName('name of tax set');
     $taxSetEntity->save();
     $taxSetTaxRateEntity = new SpyTaxSetTax();
     $taxSetTaxRateEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $taxSetTaxRateEntity->setFkTaxRate($taxRateEntity1->getIdTaxRate());
     $taxSetTaxRateEntity->save();
     $taxSetTaxRateEntity = new SpyTaxSetTax();
     $taxSetTaxRateEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $taxSetTaxRateEntity->setFkTaxRate($taxRateEntity2->getIdTaxRate());
     $taxSetTaxRateEntity->save();
     $taxSetTaxRateEntity = new SpyTaxSetTax();
     $taxSetTaxRateEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $taxSetTaxRateEntity->setFkTaxRate($taxRateExemptEntity->getIdTaxRate());
     $taxSetTaxRateEntity->save();
     $shipmentCarrierEntity = new SpyShipmentCarrier();
     $shipmentCarrierEntity->setName('name carrier');
     $shipmentCarrierEntity->save();
     $shipmentMethodEntity = new SpyShipmentMethod();
     $shipmentMethodEntity->setFkShipmentCarrier($shipmentCarrierEntity->getIdShipmentCarrier());
     $shipmentMethodEntity->setFkTaxSet($taxSetEntity->getIdTaxSet());
     $shipmentMethodEntity->setName('test shipment method');
     $shipmentMethodEntity->save();
     return $shipmentMethodEntity;
 }
Exemplo n.º 3
0
 /**
  * @param \Generated\Shared\Transfer\TaxRateTransfer $taxRateTransfer
  *
  * @return \Orm\Zed\Tax\Persistence\SpyTaxRate
  */
 private function createTaxRateEntity(TaxRateTransfer $taxRateTransfer)
 {
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->fromArray($taxRateTransfer->toArray());
     if ($taxRateTransfer->getFkCountry() === 0) {
         $taxRateEntity->setFkCountry(null);
     }
     $taxRateEntity->save();
     return $taxRateEntity;
 }