Issue #3182022 by karengrey, rszrama: Link to free resources for U.S. sales tax calculation
Following Ryan's recommendation to use the markup used for System Status, the simplest way to inject this to the TaxTypeListBuilder was to add additional markup to the render() function.
The markup has been added to a separate file so the TaxTypeListBuilder::render function stays looking clean.
There are conditions added so the markup is only added if there are any stores with an US or CA address.
I have also added a statement to check if commerce_avatax is enabled, which changes the text in the right column to a thank you message and a link to the AvaTax login. This text is to be finalised by Ryan/Summer Baker
A new Library has been added for a new CSS file and an images folder added with two svg files for each column. The Sales Tax Risk Assessment is interactive, it would be ideal to change this svg to be static (I couldn't scale the JPG provided in the issue without losing a fair amount of quality)
Merge request reports
Activity
added 1 commit
- 23589b4f - Moved markup into seperate file for cleaner code.
29 29 return $row + parent::buildRow($entity); 30 30 } 31 31 32 /** 33 * {@inheritdoc} 34 */ 35 public function render() { 36 // Additional markup added to promote free resources for United Sates changed this line in version 4 of the diff
121 132 function commerce_tax_field_widget_info_alter(array &$info) { 122 133 $info['string_textfield']['field_types'][] = 'commerce_tax_number'; 123 134 } 135 136 /** 137 * Checks store country codes for sales tax help. 138 */ 139 function commerce_tax_sales_tax_country_check() { 140 /** @var \Drupal\commerce_store\Entity\StoreInterface $store */ 141 $entity_type_manager = \Drupal::entityTypeManager(); 142 $stores = $entity_type_manager->getStorage('commerce_store')->loadMultiple(); You don't have to load all stores, and you shouldn't as this can have a big performance impact for websites having hundreds/thousands of stores.
You can build a query that has the right conditions to determine whether a store exists with a US|CA address. You get the query object from the entity storage.
changed this line in version 4 of the diff
added 1 commit
- da2e3bb2 - Moved helper to TaxTypeListBuilder and changed to use a query so were not...