protected function InvoiceItem::recalculateTotalPrice in Commerce Invoice 8.2
Recalculates the invoice item total price.
3 calls to InvoiceItem::recalculateTotalPrice()
- InvoiceItem::preSave in src/
Entity/ InvoiceItem.php - Acts on an entity before the presave hook is invoked.
- InvoiceItem::setQuantity in src/
Entity/ InvoiceItem.php - Sets the invoice item quantity.
- InvoiceItem::setUnitPrice in src/
Entity/ InvoiceItem.php - Sets the invoice item unit price.
File
- src/
Entity/ InvoiceItem.php, line 350
Class
- InvoiceItem
- Defines the invoice item entity class.
Namespace
Drupal\commerce_invoice\EntityCode
protected function recalculateTotalPrice() {
if ($unit_price = $this
->getUnitPrice()) {
$rounder = \Drupal::service('commerce_price.rounder');
$total_price = $unit_price
->multiply($this
->getQuantity());
$this->total_price = $rounder
->round($total_price);
}
}