コード例 #1
0
 /**
  * Helper function that sets up some default rules
  */
 private function setUpDefaultRules()
 {
     $this->taxClasses = $this->taxRuleFixtureFactory->createTaxClasses([['name' => 'DefaultCustomerClass', 'type' => ClassModel::TAX_CLASS_TYPE_CUSTOMER], ['name' => 'DefaultProductClass', 'type' => ClassModel::TAX_CLASS_TYPE_PRODUCT], ['name' => 'HigherProductClass', 'type' => ClassModel::TAX_CLASS_TYPE_PRODUCT]]);
     $this->taxRates = $this->taxRuleFixtureFactory->createTaxRates([['percentage' => 7.5, 'country' => 'US', 'region' => 42], ['percentage' => 7.5, 'country' => 'US', 'region' => 12]]);
     $higherRates = $this->taxRuleFixtureFactory->createTaxRates([['percentage' => 22, 'country' => 'US', 'region' => 42], ['percentage' => 10, 'country' => 'US', 'region' => 12]]);
     $this->taxRules = $this->taxRuleFixtureFactory->createTaxRules([['code' => 'Default Rule', 'customer_tax_class_ids' => [$this->taxClasses['DefaultCustomerClass'], 3], 'product_tax_class_ids' => [$this->taxClasses['DefaultProductClass']], 'tax_rate_ids' => array_values($this->taxRates), 'sort_order' => 0, 'priority' => 0, 'calculate_subtotal' => 1], ['code' => 'Higher Rate Rule', 'customer_tax_class_ids' => [$this->taxClasses['DefaultCustomerClass'], 3], 'product_tax_class_ids' => [$this->taxClasses['HigherProductClass']], 'tax_rate_ids' => array_values($higherRates), 'sort_order' => 0, 'priority' => 0, 'calculate_subtotal' => 1], ['code' => 'Highest Rate', 'customer_tax_class_ids' => [$this->taxClasses['DefaultCustomerClass'], 3], 'product_tax_class_ids' => [$this->taxClasses['HigherProductClass']], 'tax_rate_ids' => array_values($higherRates), 'sort_order' => 1, 'priority' => 1, 'calculate_subtotal' => 0]]);
     // For cleanup
     $this->taxRates = array_merge($this->taxRates, $higherRates);
 }
コード例 #2
0
 /**
  * Helper function that sets up some default rules
  */
 private function setUpDefaultRules()
 {
     $this->taxClassIds = $this->taxRuleFixtureFactory->createTaxClasses([['name' => 'DefaultCustomerClass', 'type' => ClassModel::TAX_CLASS_TYPE_CUSTOMER], ['name' => 'DefaultProductClass', 'type' => ClassModel::TAX_CLASS_TYPE_PRODUCT], ['name' => 'HigherProductClass', 'type' => ClassModel::TAX_CLASS_TYPE_PRODUCT], ['name' => 'MultipleRulesProductClass', 'type' => ClassModel::TAX_CLASS_TYPE_PRODUCT]]);
     $this->taxRates = $this->taxRuleFixtureFactory->createTaxRates([['percentage' => 7.5, 'country' => 'US', 'region' => 42], ['percentage' => 7.5, 'country' => 'US', 'region' => 12]]);
     $multiTaxRates1 = $this->taxRuleFixtureFactory->createTaxRates([['percentage' => 8.25, 'country' => 'US', 'region' => 42], ['percentage' => 12, 'country' => 'US', 'region' => 12]]);
     $multiTaxRatesSamePriority = $this->taxRuleFixtureFactory->createTaxRates([['percentage' => 5, 'country' => 'US', 'region' => 42, 'postcode' => '55555']]);
     $multiTaxRatesDifferentPriority = $this->taxRuleFixtureFactory->createTaxRates([['percentage' => 11, 'country' => 'US', 'region' => 42, 'postcode' => '55555']]);
     $higherRates = $this->taxRuleFixtureFactory->createTaxRates([['percentage' => 22, 'country' => 'US', 'region' => 42], ['percentage' => 10, 'country' => 'US', 'region' => 12]]);
     $this->taxRules = $this->taxRuleFixtureFactory->createTaxRules([['code' => 'Default Rule', 'customer_tax_class_ids' => [$this->taxClassIds['DefaultCustomerClass'], 3], 'product_tax_class_ids' => [$this->taxClassIds['DefaultProductClass']], 'tax_rate_ids' => array_values($this->taxRates), 'sort_order' => 0, 'priority' => 0], ['code' => 'Higher Rate Rule', 'customer_tax_class_ids' => [$this->taxClassIds['DefaultCustomerClass'], 3], 'product_tax_class_ids' => [$this->taxClassIds['HigherProductClass']], 'tax_rate_ids' => array_values($higherRates), 'sort_order' => 0, 'priority' => 0], ['code' => 'MultiRule-1', 'customer_tax_class_ids' => [$this->taxClassIds['DefaultCustomerClass'], 3], 'product_tax_class_ids' => [$this->taxClassIds['MultipleRulesProductClass']], 'tax_rate_ids' => array_values($multiTaxRates1), 'sort_order' => 0, 'priority' => 0], ['code' => 'MultiRule-2', 'customer_tax_class_ids' => [$this->taxClassIds['DefaultCustomerClass'], 3], 'product_tax_class_ids' => [$this->taxClassIds['MultipleRulesProductClass']], 'tax_rate_ids' => array_values($multiTaxRatesSamePriority), 'sort_order' => 0, 'priority' => 0], ['code' => 'MultiRule-3', 'customer_tax_class_ids' => [$this->taxClassIds['DefaultCustomerClass'], 3], 'product_tax_class_ids' => [$this->taxClassIds['MultipleRulesProductClass']], 'tax_rate_ids' => array_values($multiTaxRatesDifferentPriority), 'sort_order' => 0, 'priority' => 1]]);
     // For cleanup
     $this->taxRates = array_merge($this->taxRates, $higherRates);
     $this->taxRates = array_merge($this->taxRates, $multiTaxRates1);
     $this->taxRates = array_merge($this->taxRates, $multiTaxRatesSamePriority);
     $this->taxRates = array_merge($this->taxRates, $multiTaxRatesDifferentPriority);
 }