コード例 #1
0
 /**
  * @magentoDbIsolation enabled
  * @expectedException \Magento\Framework\Exception\InputException
  * @expectedExceptionMessage country_id
  */
 public function testUpdateTaxRateMissingRequiredFields()
 {
     $taxRate = $this->taxRateBuilder->setRegionId(42)->setPercentageRate(8.25)->setCode('UpdateTaxRates')->setPostcode('78780')->create();
     $taxRate = $this->taxRateService->createTaxRate($taxRate);
     $updatedTaxRate = $this->taxRateBuilder->populate($taxRate)->setPostcode(null)->create();
     $this->taxRateService->updateTaxRate($updatedTaxRate);
 }
コード例 #2
0
ファイル: Converter.php プロジェクト: aiesh/magento2
 /**
  * Convert a rate model to a TaxRate data object
  *
  * @param TaxRateModel $rateModel
  * @return TaxRateDataObject
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function createTaxRateDataObjectFromModel(TaxRateModel $rateModel)
 {
     $this->taxRateDataObjectBuilder->populateWithArray([]);
     if ($rateModel->getId()) {
         $this->taxRateDataObjectBuilder->setId($rateModel->getId());
     }
     if ($rateModel->getTaxCountryId()) {
         $this->taxRateDataObjectBuilder->setCountryId($rateModel->getTaxCountryId());
     }
     /* tax region id may be 0 which is "*" which would fail an if check */
     if ($rateModel->getTaxRegionId() !== null) {
         $this->taxRateDataObjectBuilder->setRegionId($rateModel->getTaxRegionId());
         $regionName = $this->directoryRegion->load($rateModel->getTaxRegionId())->getCode();
         $this->taxRateDataObjectBuilder->setRegionName($regionName);
     }
     if ($rateModel->getRegionName()) {
         $this->taxRateDataObjectBuilder->setRegionName($rateModel->getRegionName());
     }
     if ($rateModel->getTaxPostcode()) {
         $this->taxRateDataObjectBuilder->setPostcode($rateModel->getTaxPostcode());
     }
     if ($rateModel->getCode()) {
         $this->taxRateDataObjectBuilder->setCode($rateModel->getCode());
     }
     if ($rateModel->getRate()) {
         $this->taxRateDataObjectBuilder->setPercentageRate((double) $rateModel->getRate());
     }
     if ($rateModel->getZipIsRange()) {
         $zipRange = $this->zipRangeDataObjectBuilder->populateWithArray([])->setFrom($rateModel->getZipFrom())->setTo($rateModel->getZipTo())->create();
         $this->taxRateDataObjectBuilder->setZipRange($zipRange);
     }
     $this->taxRateDataObjectBuilder->setTitles($this->createTitleArrayFromModel($rateModel));
     return $this->taxRateDataObjectBuilder->create();
 }