/**
  * @return void
  */
 protected function setUpSalesOrderTestData()
 {
     $country = SpyCountryQuery::create()->findOneByIso2Code('DE');
     $billingAddress = (new SpySalesOrderAddress())->setFkCountry($country->getIdCountry())->setFirstName('John')->setLastName('Doe')->setAddress1('Straße des 17. Juni 135')->setCity('Berlin')->setZipCode('10623');
     $billingAddress->save();
     $customer = (new SpyCustomerQuery())->filterByFirstName('John')->filterByLastName('Doe')->filterByEmail('*****@*****.**')->filterByDateOfBirth('1970-01-01')->filterByGender(SpyCustomerTableMap::COL_GENDER_MALE)->filterByCustomerReference('payolution-pre-authorization-test')->findOneOrCreate();
     $customer->save();
     $this->orderEntity = (new SpySalesOrder())->setEmail('*****@*****.**')->setIsTest(true)->setFkSalesOrderAddressBilling($billingAddress->getIdSalesOrderAddress())->setFkSalesOrderAddressShipping($billingAddress->getIdSalesOrderAddress())->setCustomer($customer)->setOrderReference('foo-bar-baz-2');
     $this->orderEntity->save();
 }
Beispiel #2
0
 /**
  * @param string $processName
  *
  * @return array
  */
 public function prepareItems($processName)
 {
     $orderItemsArray = $this->getOrderItems($processName);
     $orders = [];
     $txtArray = [];
     foreach ($orderItemsArray as $orderItemArray) {
         if (!isset($orders[$orderItemArray['orderId']])) {
             $order = new SpySalesOrder();
             $order->setGrandTotal(10000);
             $order->setSubtotal(9900);
             $order->setIsTest(false);
             $address = new SpySalesOrderAddress();
             $address->setLastName('Doe');
             $address->setFirstName('John');
             $address->setCity('Berlin');
             $address->setZipCode('12345');
             $address->setAddress1('Blastr 1');
             $country = SpyCountryQuery::create()->findOneByIdCountry(1);
             $address->setCountry($country);
             $order->setBillingAddress($address);
             $order->setShippingAddress($address);
             $orders[$orderItemArray['orderId']] = $order;
         }
     }
     $states = [];
     $orderItems = [];
     foreach ($orderItemsArray as $orderItemArray) {
         if (isset($states[$orderItemArray['state']])) {
             $state = $states[$orderItemArray['state']];
         } else {
             $state = new SpyOmsOrderItemState();
             $state->setName($orderItemArray['state']);
             $state->save();
             $states[$orderItemArray['state']] = $state;
         }
         $txtArray[] = 'State: ' . $state->getName();
         $process = SpyOmsOrderProcessQuery::create()->filterByName($orderItemArray['process'])->findOneOrCreate();
         $process->setName($orderItemArray['process']);
         $process->save();
         $txtArray[] = 'Process: ' . $process->getName();
         $item = new SpySalesOrderItem();
         $item->setState($state);
         $item->setProcess($process);
         $item->setName('Testproduct');
         $item->setSku('12345ABC');
         $item->setGrossPrice(10);
         $orders[$orderItemArray['orderId']]->addItem($item);
         $orderItems[] = $item;
     }
     foreach ($orderItems as $orderItem) {
         $orderItem->save();
         $txtArray[] = 'orderItem saved: ' . $orderItem->getIdSalesOrderItem();
     }
     return $txtArray;
 }
 /**
  * @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;
 }
 /**
  * @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 \Orm\Zed\Country\Persistence\SpyCountryQuery
  */
 public function createCountryQuery()
 {
     return SpyCountryQuery::create();
 }
Beispiel #6
0
 /**
  * @return \Orm\Zed\Country\Persistence\SpyCountry
  */
 protected function getCountryEntity()
 {
     $countryQuery = new SpyCountryQuery();
     $countryQuery->filterByIso2Code('DE');
     $countryQuery->filterByIso3Code('DEU');
     $countryQuery->filterByName('Germany');
     $countryQuery->filterByPostalCodeMandatory(true);
     $countryQuery->filterByPostalCodeRegex('\\d{5}');
     $countryEntity = $countryQuery->findOneOrCreate();
     $countryEntity->save();
     return $countryEntity;
 }