View source
<?php
namespace Drupal\commerce_avatax;
use Drupal\commerce_order\Adjustment;
use Drupal\commerce_order\Entity\OrderInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
final class Avatax {
public static function getExemptionTypes() {
return [
'A' => new TranslatableMarkup('Federal government (United States)'),
'B' => new TranslatableMarkup('State government (United States)'),
'C' => new TranslatableMarkup('Tribe / Status Indian / Indian Band'),
'D' => new TranslatableMarkup('Foreign diplomat'),
'E' => new TranslatableMarkup('Charitable or benevolent org'),
'F' => new TranslatableMarkup('Religious or educational org'),
'G' => new TranslatableMarkup('Resale'),
'H' => new TranslatableMarkup('Commercial agricultural production'),
'I' => new TranslatableMarkup('Industrial production / manufacturer'),
'J' => new TranslatableMarkup('Direct pay permit (United States)'),
'K' => new TranslatableMarkup('Direct mail (United States)'),
'L' => new TranslatableMarkup('Other'),
'N' => new TranslatableMarkup('Local government (United States)'),
'P' => new TranslatableMarkup('Commercial aquaculture (Canada)'),
'Q' => new TranslatableMarkup('Commercial Fishery (Canada)'),
'R' => new TranslatableMarkup('Non-resident (Canada)'),
];
}
public static function hasAvataxAdjustments(OrderInterface $order) {
$avatax_adjustments = array_filter($order
->collectAdjustments(), function (Adjustment $adjustment) use ($order) {
return $adjustment
->getType() == 'tax' && strpos($adjustment
->getSourceId(), 'avatax|') !== FALSE;
});
return !empty($avatax_adjustments);
}
}