Exemplo n.º 1
0
 /**
  * Convert a tax rule data object to tax rule model
  *
  * @param TaxRuleDataObject $taxRule
  * @return TaxRuleModel
  */
 public function createTaxRuleModel(TaxRuleDataObject $taxRuleDataObject)
 {
     $taxRuleModel = $this->taxRuleModelFactory->create();
     $ruleId = $taxRuleDataObject->getId();
     if ($ruleId) {
         $taxRuleModel->setId($ruleId);
     }
     $taxRuleModel->setTaxCustomerClass($taxRuleDataObject->getCustomerTaxClassIds());
     $taxRuleModel->setTaxProductClass($taxRuleDataObject->getProductTaxClassIds());
     $taxRuleModel->setTaxRate($taxRuleDataObject->getTaxRateIds());
     $taxRuleModel->setCode($taxRuleDataObject->getCode());
     $taxRuleModel->setPriority($taxRuleDataObject->getPriority());
     $taxRuleModel->setPosition($taxRuleDataObject->getSortOrder());
     $taxRuleModel->setCalculateSubtotal($taxRuleDataObject->getCalculateSubtotal());
     return $taxRuleModel;
 }
Exemplo n.º 2
0
 /**
  * Extract tax rule data in a format which is
  *
  * @param \Magento\Tax\Service\V1\Data\TaxRule $taxRule
  * @return array
  */
 protected function extractTaxRuleData($taxRule)
 {
     $taxRuleData = ['code' => $taxRule->getCode(), 'tax_customer_class' => $taxRule->getCustomerTaxClassIds(), 'tax_product_class' => $taxRule->getProductTaxClassIds(), 'tax_rate' => $taxRule->getTaxRateIds(), 'priority' => $taxRule->getPriority(), 'position' => $taxRule->getSortOrder(), 'calculate_subtotal' => $taxRule->getCalculateSubtotal()];
     return $taxRuleData;
 }
Exemplo n.º 3
0
 /**
  * Creates a collection item that represents a tax rule for the tax rules grid.
  *
  * @param TaxRule $taxRule Input data for creating the item.
  * @return \Magento\Framework\Object Collection item that represents a tax rule
  */
 protected function createTaxRuleCollectionItem(TaxRule $taxRule)
 {
     $collectionItem = new \Magento\Framework\Object();
     $collectionItem->setTaxCalculationRuleId($taxRule->getId());
     $collectionItem->setCode($taxRule->getCode());
     /* should cast to string so that some optional fields won't be null on the collection grid pages */
     $collectionItem->setPriority((string) $taxRule->getPriority());
     $collectionItem->setPosition((string) $taxRule->getSortOrder());
     $collectionItem->setCalculateSubtotal($taxRule->getCalculateSubtotal() ? '1' : '0');
     $collectionItem->setCustomerTaxClasses($taxRule->getCustomerTaxClassIds());
     $collectionItem->setProductTaxClasses($taxRule->getProductTaxClassIds());
     $collectionItem->setTaxRates($taxRule->getTaxRateIds());
     return $collectionItem;
 }