Skip to content
This repository has been archived by the owner on Apr 22, 2019. It is now read-only.

Commit

Permalink
Merge branch 'release/1.5.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Preston Choate committed Feb 22, 2019
2 parents 4596a54 + 9cb7f9a commit cbebfa6
Show file tree
Hide file tree
Showing 10 changed files with 78 additions and 13 deletions.
8 changes: 7 additions & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
<!--- Provide a general summary of the issue in the Title above -->
<!-- NOTE: Please contact Avalara support (https://github.com/classyllama/ClassyLlama_AvaTax#support) if you are experiencing issues with this extension. They will then escalate issues to Github/Classy Llama if they determine there is an issue with the extension. -->


<!-- The following template is intended for Avalara's support team to create issues. -->

<!-- See this documentation for how to provide detailed logging information:
https://github.com/classyllama/ClassyLlama_AvaTax/blob/develop/docs/getting-started.md#troubleshooting -->

### Preconditions
<!--- Provide a more detailed information of environment you use -->
Expand Down
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
### 1.5.1 (2019-1-30)
### 1.5.3 (2019-02-22)
* Added config fields to allow for calculating tax prior to discounts and send custom shipping tax code [PR #239](https://github.com/classyllama/ClassyLlama_AvaTax/pull/239) and [PR #231](https://github.com/classyllama/ClassyLlama_AvaTax/pull/231)
* Updated support documentation

### 1.5.1 (2019-01-30)
* Fix issue with payload extender in shipping-save-processor [#181](https://github.com/classyllama/ClassyLlama_AvaTax/issues/181)
* Add message about known issue with admin order creation [#215](https://github.com/classyllama/ClassyLlama_AvaTax/issues/215)

Expand Down
2 changes: 1 addition & 1 deletion Framework/AppInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ interface AppInterface
/**
* If this is updated it must also be updated in composer.json
*/
const APP_VERSION = '1.5.1';
const APP_VERSION = '1.5.3';
}
9 changes: 6 additions & 3 deletions Framework/Interaction/Line.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,12 @@ protected function convertTaxQuoteDetailsItemToData(\Magento\Tax\Api\Data\QuoteD
$description = $extensionAttributes ? $extensionAttributes->getAvataxDescription() : '';
$taxCode = $extensionAttributes ? $extensionAttributes->getAvataxTaxCode() : null;

// The AvaTax 15 API doesn't support the concept of line-based discounts, so subtract discount amount
// from taxable amount
$amount = ($item->getUnitPrice() * $quantity) - $item->getDiscountAmount();
// Calculate tax with or without discount based on config setting
if ($this->config->getCalculateTaxBeforeDiscount($item->getStoreId())) {
$amount = $item->getUnitPrice() * $quantity;
} else {
$amount = ($item->getUnitPrice() * $quantity) - $item->getDiscountAmount();
}

$ref1 = $extensionAttributes ? $extensionAttributes->getAvataxRef1() : null;
$ref2 = $extensionAttributes ? $extensionAttributes->getAvataxRef2() : null;
Expand Down
33 changes: 33 additions & 0 deletions Helper/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class Config extends AbstractHelper

const XML_PATH_AVATAX_REGION_FILTER_LIST = 'tax/avatax/region_filter_list';

const XML_PATH_AVATAX_CALCULATE_BEFORE_DISCOUNT = 'tax/avatax/calculate_tax_before_discounts';

const XML_PATH_AVATAX_LIVE_MODE = 'tax/avatax/live_mode';

const XML_PATH_AVATAX_PRODUCTION_ACCOUNT_NUMBER = 'tax/avatax/production_account_number';
Expand Down Expand Up @@ -132,6 +134,8 @@ class Config extends AbstractHelper
const XML_PATH_AVATAX_ADMIN_NOTIFICATION_IGNORE_NATIVE_TAX_RULES = 'tax/avatax/ignore_native_tax_rules_notification';

const XML_PATH_AVATAX_ADMIN_IS_SELLER_IMPORTER_OF_RECORD = 'tax/avatax/is_seller_importer_of_record';

const XML_PATH_AVATAX_SHIPPING_TAX_CODE = 'tax/avatax/shipping_tax_code';
/**#@-*/

/**
Expand Down Expand Up @@ -1072,4 +1076,33 @@ public function isSellerImporterOfRecord($originAddress, $destAddress, $storeId)
}
return $isSellerImporterOfRecord;
}

/**
* @param $store
* @return mixed
*/
public function getCalculateTaxBeforeDiscount($store)
{
return $this->scopeConfig->getValue(
self::XML_PATH_AVATAX_CALCULATE_BEFORE_DISCOUNT,
ScopeInterface::SCOPE_STORE,
$store
);
}

/**
* Get Shipping Tax Code.
*
* @param $store
*
* @return string
*/
public function getShippingTaxCode($store = null)
{
return $this->scopeConfig->getValue(
self::XML_PATH_AVATAX_SHIPPING_TAX_CODE,
ScopeInterface::SCOPE_STORE,
$store
);
}
}
8 changes: 2 additions & 6 deletions Helper/TaxClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
*/
class TaxClass
{
/**
* Avatax shipping tax code
*/
const SHIPPING_LINE_AVATAX_TAX_CODE = 'FR020100';

/**
* Avatax gift certificate tax code
*/
Expand Down Expand Up @@ -177,12 +172,13 @@ public function getRef2ForProduct(\Magento\Catalog\Model\Product $product)

/**
* Get AvaTax Tax Code for shipping
* Default Configuration Setting: FR020100
*
* @return string
*/
public function getAvataxTaxCodeForShipping()
{
return self::SHIPPING_LINE_AVATAX_TAX_CODE;
return $this->config->getShippingTaxCode();
}

/**
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

Agile, successful companies focus on their core business and outsource complex, administrative functions – such as payroll and sales tax management – to the experts. Avalara can address your sales tax challenges with AvaTax. It’s the fastest, easiest, most accurate and affordable way to calculate sales tax; manage exemption certificates; file returns; and remit payments across multiple tax regions. Our tax decision engine determines rates based on 100,000+ taxability rules in 11,000+ taxing jurisdictions and instantly applies them to each transaction within your Magento shopping cart.

# Support

Contact Avalara for any support requests, either via [their support email]([email protected]) or via [this page](https://salestax.avalara.com/contact-us/).

<!-- This list is in each of the documentation files. Ensure any updates are applied to the list in each file. -->
# Documentation

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "classyllama/module-avatax",
"type": "magento2-module",
"version": "1.5.1",
"version": "1.5.3",
"license": "OSL-3.0",
"require": {
"magento/framework": "^100.1.0|101.0.*|^102.0.0",
Expand Down
17 changes: 17 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@
<field id="filter_tax_by_region">1</field>
</depends>
</field>
<field id="calculate_tax_before_discounts" translate="label" type="select" sortOrder="1008" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Calculate Tax Before Discount</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
<comment><![CDATA[Should tax be calculated on each item before discounts are applied ]]></comment>
<depends>
<field id="enabled">1</field>
<field id="tax_mode" negative="1">1</field>
</depends>
</field>
<field id="is_seller_importer_of_record" translate="label comment" type="select" sortOrder="1008" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Set Seller as Importer of Record for Global Transactions</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
Expand Down Expand Up @@ -230,6 +239,14 @@
<depends>
<field id="enabled">1</field>
</depends>
</field>
<field id="shipping_tax_code" translate="label" type="text" sortOrder="3065" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1">
<config_path>tax/avatax/shipping_tax_code</config_path>
<label>Shipping Tax Code</label>
<comment>The Avalara tax code used to classify the shipping service type.</comment>
<depends>
<field id="enabled">1</field>
</depends>
</field>
<field id="sku_shipping" translate="label" type="text" sortOrder="3070" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Shipping SKU</label>
Expand Down
2 changes: 2 additions & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<tax_calculation_countries_enabled>CA,US</tax_calculation_countries_enabled>
<is_seller_importer_of_record>0</is_seller_importer_of_record>
<use_business_identification_number>1</use_business_identification_number>
<shipping_tax_code>FR020100</shipping_tax_code>
<sku_shipping>Shipping</sku_shipping>
<sku_gift_wrap_order>GwOrder</sku_gift_wrap_order>
<sku_gift_wrap_item>GwItems</sku_gift_wrap_item>
Expand Down Expand Up @@ -55,6 +56,7 @@
<queue_admin_notification_enabled>1</queue_admin_notification_enabled>
<queue_failure_notification_enabled>1</queue_failure_notification_enabled>
<customer_code_format>id</customer_code_format>
<calculate_tax_before_discounts>0</calculate_tax_before_discounts>
</avatax>
</tax>
</default>
Expand Down

0 comments on commit cbebfa6

Please sign in to comment.