You are here

public function Invoice::getBalance in Commerce Invoice 8.2

Gets the invoice balance.

Calculated by subtracting the total paid price from the total price. Can be negative in case the invoice was overpaid.

Return value

\Drupal\commerce_price\Price|null The invoice balance, or NULL.

Overrides InvoiceInterface::getBalance

1 call to Invoice::getBalance()
Invoice::isPaid in src/Entity/Invoice.php
Gets whether the invoice has been fully paid.

File

src/Entity/Invoice.php, line 449

Class

Invoice
Defines the invoice entity class.

Namespace

Drupal\commerce_invoice\Entity

Code

public function getBalance() {
  if ($total_price = $this
    ->getTotalPrice()) {
    return $total_price
      ->subtract($this
      ->getTotalPaid());
  }
}