You are here

public function Invoice::getTotalPaid in Commerce Invoice 8.2

Gets the total paid price.

Return value

\Drupal\commerce_price\Price|null The total paid price, or NULL.

Overrides InvoiceInterface::getTotalPaid

1 call to Invoice::getTotalPaid()
Invoice::getBalance in src/Entity/Invoice.php
Gets the invoice balance.

File

src/Entity/Invoice.php, line 430

Class

Invoice
Defines the invoice entity class.

Namespace

Drupal\commerce_invoice\Entity

Code

public function getTotalPaid() {
  if (!$this
    ->get('total_paid')
    ->isEmpty()) {
    return $this
      ->get('total_paid')
      ->first()
      ->toPrice();
  }
  elseif ($total_price = $this
    ->getTotalPrice()) {
    return new Price('0', $total_price
      ->getCurrencyCode());
  }
}