protected function Shipping::calculateTaxAmount in Commerce Shipping 8.2
Calculates the tax amount for the given shipment.
Parameters
\Drupal\commerce_shipping\Entity\ShipmentInterface $shipment: The shipment.
string $percentage: The tax rate percentage.
bool $included: Whether tax is already included in the price.
Return value
\Drupal\commerce_price\Price The unrounded tax amount.
3 calls to Shipping::calculateTaxAmount()
- Shipping::applyDefault in src/
Plugin/ Commerce/ TaxType/ Shipping.php - Applies the default tax rate of the order's tax type.
- Shipping::applyHighest in src/
Plugin/ Commerce/ TaxType/ Shipping.php - Applies the highest tax rate found on the order.
- Shipping::applyProportional in src/
Plugin/ Commerce/ TaxType/ Shipping.php - Applies each order item's tax rate proportionally.
File
- src/
Plugin/ Commerce/ TaxType/ Shipping.php, line 414
Class
- Shipping
- Provides the Shipping tax type.
Namespace
Drupal\commerce_shipping\Plugin\Commerce\TaxTypeCode
protected function calculateTaxAmount(ShipmentInterface $shipment, $percentage, $included = FALSE) {
$shipment_amount = $shipment
->getAdjustedAmount([
'shipping_promotion',
]);
$tax_amount = $shipment_amount
->multiply($percentage);
if ($included) {
$divisor = Calculator::add('1', $percentage);
$tax_amount = $tax_amount
->divide($divisor);
}
return $tax_amount;
}