/**
  * @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;
 }
 /**
  * @return array
  */
 public static function loadFixtures()
 {
     $ids = [];
     $dbConnection = Propel::getConnection();
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->setRate(10)->setName('Foo');
     $taxRateEntity->save();
     $ids['idTaxRate1'] = $taxRateEntity->getIdTaxRate();
     $taxRateEntity = new SpyTaxRate();
     $taxRateEntity->setRate(5)->setName('Bar');
     $taxRateEntity->save();
     $ids['idTaxRate2'] = $taxRateEntity->getIdTaxRate();
     $taxSetEntity = new SpyTaxSet();
     $taxSetEntity->setName('Baz');
     $taxSetEntity->save();
     $ids['idTaxSet'] = $taxSetEntity->getIdTaxSet();
     $taxSetTaxEntity = new SpyTaxSetTax();
     $taxSetTaxEntity->setFkTaxSet($ids['idTaxSet'])->setFkTaxRate($ids['idTaxRate1']);
     $taxSetTaxEntity->save();
     $taxSetTaxEntity = new SpyTaxSetTax();
     $taxSetTaxEntity->setFkTaxSet($ids['idTaxSet'])->setFkTaxRate($ids['idTaxRate2']);
     $taxSetTaxEntity->save();
     $productAbstractEntity = new SpyProductAbstract();
     $productAbstractEntity->setSku('ABC123')->setFkTaxSet($ids['idTaxSet'])->setAttributes('{}');
     $productAbstractEntity->save();
     $ids['idProductAbstract'] = $productAbstractEntity->getIdProductAbstract();
     $productEntity = new SpyProduct();
     $productEntity->setSku('DEF456')->setFkProductAbstract($ids['idProductAbstract'])->setAttributes('{}');
     $productEntity->save();
     $ids['idProductConcrete'] = $productEntity->getIdProduct();
     $productOptionTypeEntity = new SpyProductOptionType();
     $productOptionTypeEntity->save();
     $ids['idTypeColor'] = $productOptionTypeEntity->getIdProductOptionType();
     $productOptionTypeEntity = new SpyProductOptionType();
     $productOptionTypeEntity->setFkTaxSet($ids['idTaxSet']);
     $productOptionTypeEntity->save();
     $ids['idTypeSize'] = $productOptionTypeEntity->getIdProductOptionType();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeColor']);
     $productOptionValueEntity->save();
     $ids['idValueRed'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeColor']);
     $productOptionValueEntity->save();
     $ids['idValueBlue'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeColor']);
     $productOptionValueEntity->save();
     $ids['idValueGreen'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeColor']);
     $productOptionValueEntity->save();
     $ids['idValueYellow'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValuePriceEntity = new SpyProductOptionValuePrice();
     $productOptionValuePriceEntity->setPrice(199);
     $productOptionValuePriceEntity->save();
     $ids['idPriceLarge'] = $productOptionValuePriceEntity->getIdProductOptionValuePrice();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeSize'])->setFkProductOptionValuePrice($ids['idPriceLarge']);
     $productOptionValueEntity->save();
     $ids['idValueLarge'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeSize']);
     $productOptionValueEntity->save();
     $ids['idValueSmall'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeSize']);
     $productOptionValueEntity->save();
     $ids['idValueMedium'] = $productOptionValueEntity->getIdProductOptionValue();
     $productOptionValueEntity = new SpyProductOptionValue();
     $productOptionValueEntity->setFkProductOptionType($ids['idTypeSize']);
     $productOptionValueEntity->save();
     $ids['idValueXSmall'] = $productOptionValueEntity->getIdProductOptionValue();
     $localeEntity = new SpyLocale();
     $localeEntity->setLocaleName('xx_XX');
     $localeEntity->save();
     $ids['idLocale'] = $localeEntity->getIdLocale();
     $productOptionTypeTranslationEntity = new SpyProductOptionTypeTranslation();
     $productOptionTypeTranslationEntity->setName('Size')->setFkLocale($ids['idLocale'])->setFkProductOptionType($ids['idTypeSize']);
     $productOptionTypeTranslationEntity->save();
     $productOptionTypeTranslationEntity = new SpyProductOptionTypeTranslation();
     $productOptionTypeTranslationEntity->setName('Color')->setFkLocale($ids['idLocale'])->setFkProductOptionType($ids['idTypeColor']);
     $productOptionTypeTranslationEntity->save();
     $data = ['Blue' => $ids['idValueBlue'], 'Red' => $ids['idValueRed'], 'Yellow' => $ids['idValueYellow'], 'Green' => $ids['idValueGreen'], 'Large' => $ids['idValueLarge'], 'Medium' => $ids['idValueMedium'], 'Small' => $ids['idValueSmall'], 'Extra' => $ids['idValueXSmall']];
     foreach ($data as $name => $fkProductOptionValue) {
         $productOptionValueTranslationEntity = new SpyProductOptionValueTranslation();
         $productOptionValueTranslationEntity->setName($name)->setFkLocale($ids['idLocale'])->setFkProductOptionValue($fkProductOptionValue);
         $productOptionValueTranslationEntity->save();
     }
     $productOptionTypeUsageEntity = new SpyProductOptionTypeUsage();
     $productOptionTypeUsageEntity->setIsOptional(0)->setSequence(1)->setFkProduct($ids['idProductConcrete'])->setFkProductOptionType($ids['idTypeColor']);
     $productOptionTypeUsageEntity->save();
     $ids['idUsageColor'] = $productOptionTypeUsageEntity->getIdProductOptionTypeUsage();
     $productOptionTypeUsageEntity = new SpyProductOptionTypeUsage();
     $productOptionTypeUsageEntity->setIsOptional(0)->setSequence(1)->setFkProduct($ids['idProductConcrete'])->setFkProductOptionType($ids['idTypeSize']);
     $productOptionTypeUsageEntity->save();
     $ids['idUsageSize'] = $productOptionTypeUsageEntity->getIdProductOptionTypeUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(1)->setFkProductOptionValue($ids['idValueBlue'])->setFkProductOptionTypeUsage($ids['idUsageColor']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageBlue'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(2)->setFkProductOptionValue($ids['idValueRed'])->setFkProductOptionTypeUsage($ids['idUsageColor']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageRed'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(3)->setFkProductOptionValue($ids['idValueYellow'])->setFkProductOptionTypeUsage($ids['idUsageColor']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageYellow'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(4)->setFkProductOptionValue($ids['idValueGreen'])->setFkProductOptionTypeUsage($ids['idUsageColor']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageGreen'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(1)->setFkProductOptionValue($ids['idValueLarge'])->setFkProductOptionTypeUsage($ids['idUsageSize']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageLarge'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(2)->setFkProductOptionValue($ids['idValueMedium'])->setFkProductOptionTypeUsage($ids['idUsageSize']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageMedium'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(3)->setFkProductOptionValue($ids['idValueSmall'])->setFkProductOptionTypeUsage($ids['idUsageSize']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageSmall'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionValueUsageEntity = new SpyProductOptionValueUsage();
     $productOptionValueUsageEntity->setSequence(4)->setFkProductOptionValue($ids['idValueXSmall'])->setFkProductOptionTypeUsage($ids['idUsageSize']);
     $productOptionValueUsageEntity->save();
     $ids['idUsageXSmall'] = $productOptionValueUsageEntity->getIdProductOptionValueUsage();
     $productOptionTypeUsageExclusionEntity = new SpyProductOptionTypeUsageExclusion();
     $productOptionTypeUsageExclusionEntity->setFkProductOptionTypeUsageA($ids['idUsageColor'])->setFkProductOptionTypeUsageB($ids['idUsageSize']);
     $productOptionTypeUsageExclusionEntity->save();
     $productOptionValueUsageConstraintEntity = new SpyProductOptionValueUsageConstraint();
     $productOptionValueUsageConstraintEntity->setFkProductOptionValueUsageA($ids['idUsageBlue'])->setFkProductOptionValueUsageB($ids['idUsageSmall'])->setOperator('NOT');
     $productOptionValueUsageConstraintEntity->save();
     $productOptionValueUsageConstraintEntity = new SpyProductOptionValueUsageConstraint();
     $productOptionValueUsageConstraintEntity->setFkProductOptionValueUsageA($ids['idUsageRed'])->setFkProductOptionValueUsageB($ids['idUsageMedium'])->setOperator('ALWAYS');
     $productOptionValueUsageConstraintEntity->save();
     $productOptionValueUsageConstraintEntity = new SpyProductOptionValueUsageConstraint();
     $productOptionValueUsageConstraintEntity->setFkProductOptionValueUsageA($ids['idUsageGreen'])->setFkProductOptionValueUsageB($ids['idUsageSmall'])->setOperator('ALLOW');
     $productOptionValueUsageConstraintEntity->save();
     $productOptionValueUsageConstraintEntity = new SpyProductOptionValueUsageConstraint();
     $productOptionValueUsageConstraintEntity->setFkProductOptionValueUsageA($ids['idUsageGreen'])->setFkProductOptionValueUsageB($ids['idUsageLarge'])->setOperator('ALLOW');
     $productOptionValueUsageConstraintEntity->save();
     $productOptionConfigurationPresetEntity = new SpyProductOptionConfigurationPreset();
     $productOptionConfigurationPresetEntity->setIsDefault(true)->setSequence(1)->setFkProduct($ids['idProductConcrete']);
     $productOptionConfigurationPresetEntity->save();
     $ids['idConfigPresetA'] = $productOptionConfigurationPresetEntity->getIdProductOptionConfigurationPreset();
     $productOptionConfigurationPresetEntity = new SpyProductOptionConfigurationPreset();
     $productOptionConfigurationPresetEntity->setIsDefault(false)->setSequence(2)->setFkProduct($ids['idProductConcrete']);
     $productOptionConfigurationPresetEntity->save();
     $ids['idConfigPresetB'] = $productOptionConfigurationPresetEntity->getIdProductOptionConfigurationPreset();
     $data = [$ids['idUsageRed'] => $ids['idConfigPresetA'], $ids['idUsageMedium'] => $ids['idConfigPresetA'], $ids['idUsageGreen'] => $ids['idConfigPresetB'], $ids['idUsageLarge'] => $ids['idConfigPresetB']];
     foreach ($data as $fkProductOptionValueUsage => $fkProductOptionConfigurationPreset) {
         $productOptionConfigurationPresetValueEntity = new SpyProductOptionConfigurationPresetValue();
         $productOptionConfigurationPresetValueEntity->setFkProductOptionConfigurationPreset($fkProductOptionConfigurationPreset)->setFkProductOptionValueUsage($fkProductOptionValueUsage);
         $productOptionConfigurationPresetValueEntity->save();
     }
     return $ids;
 }
 /**
  * @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;
 }
 /**
  * @return void
  */
 private function loadFixtures()
 {
     $rate1 = new SpyTaxRate();
     $rate1->setName('Rate1')->setRate(10)->save();
     $this->taxRateIds[] = $rate1->getIdTaxRate();
     $rate2 = new SpyTaxRate();
     $rate2->setName('Rate2')->setRate(5)->save();
     $this->taxRateIds[] = $rate2->getIdTaxRate();
     $taxSet = new SpyTaxSet();
     $taxSet->setName('Set1')->addSpyTaxRate($rate1)->addSpyTaxRate($rate2)->save();
     $this->taxSetId = $taxSet->getIdTaxSet();
     $product1 = new SpyProductAbstract();
     $product1->setSku('Product1')->setSpyTaxSet($taxSet)->setAttributes('{}')->save();
     $this->productAbstractIds[] = $product1->getIdProductAbstract();
     $product2 = new SpyProductAbstract();
     $product2->setSku('Product2')->setSpyTaxSet($taxSet)->setAttributes('{}')->save();
     $this->productAbstractIds[] = $product2->getIdProductAbstract();
 }
Example #5
0
 /**
  * @param \Orm\Zed\Tax\Persistence\SpyTaxRate $taxRateEntity
  *
  * @return string
  */
 protected function createDeleteButton(SpyTaxRate $taxRateEntity)
 {
     $deleteTaxRateUrl = Url::generate('/tax/rate/delete', [self::URL_PARAM_ID_TAX_RATE => $taxRateEntity->getIdTaxRate()]);
     return $this->generateRemoveButton($deleteTaxRateUrl, 'Delete');
 }