You are here

class Invoice in Commerce Invoice 7.2

Same name and namespace in other branches
  1. 8.2 src/Entity/Invoice.php \Drupal\commerce_invoice\Entity\Invoice

Hierarchy

  • class \Drupal\commerce_invoice\Entity\Invoice extends \Drupal\commerce_invoice\Entity\Entity

Expanded class hierarchy of Invoice

9 files declare their use of Invoice
commerce_invoice.admin.inc in ./commerce_invoice.admin.inc
Administrative form and page callbacks for the Commerce Invoice module.
commerce_invoice.api.php in ./commerce_invoice.api.php
Documentation for the commerce_invoice module.
commerce_invoice.module in ./commerce_invoice.module
The Commerce Invoice module.
commerce_invoice.test in tests/commerce_invoice.test
Functional tests for the commerce invoice module.
commerce_invoice_mail.module in modules/mail/commerce_invoice_mail.module
The Commerce Invoice PDF module.

... See full list

3 string references to 'Invoice'
commerce_invoice_entity_info in ./commerce_invoice.module
Implements hook_entity_info().
commerce_invoice_pdf_rules_action_info in modules/pdf/commerce_invoice_pdf.rules.inc
Implements hook_rules_action_info().
Invoice::defaultLabel in src/Entity/Invoice.php

File

src/Entity/Invoice.php, line 11
Invoice entity.

Namespace

Drupal\commerce_invoice\Entity
View source
class Invoice extends \Entity {
  const STATUS_CANCELED = 'canceled';
  const STATUS_PAID = 'paid';
  const STATUS_PENDING = 'pending';
  const STATUS_REFUND_PENDING = 'refund_pending';
  const STATUS_REFUNDED = 'refunded';
  public $invoice_id;
  public $revision_id;
  public $type = 'commerce_invoice';
  public $order_id;
  public $order_revision_id;
  public $number_pattern;
  public $number_sequence;
  public $number_key;
  public $uid;
  public $invoice_date;
  public $invoice_due;
  public $invoice_status = self::STATUS_PENDING;
  public $created;
  public $changed;
  public $revision_created;
  public $revision_uid;
  public $log;
  public $content;

  /**
   * Returns the invoice number pattern for this invoice.
   *
   * @todo bundle settings logic
   *
   * @return InvoiceNumberPattern
   */
  public function getNumberPattern() {
    if ($pattern = commerce_invoice_number_pattern_load($this->number_pattern)) {
      return $pattern;
    }
    throw new \RuntimeException('Invoice number pattern not found: ' . $this->number_pattern);
  }

  /**
   * Sets the invoice number.
   *
   * @param InvoiceNumber $number
   */
  public function setInvoiceNumber(InvoiceNumber $number) {
    $this->number_key = $number
      ->getKey();
    $this->number_sequence = $number
      ->getSequence();
    $this->number_pattern = $number
      ->getPatternName();
  }

  /**
   * @return bool
   */
  public function hasInvoiceNumber() {
    return isset($this->number_sequence);
  }

  /**
   * Returns the invoice number.
   *
   * @return InvoiceNumber|NULL
   */
  public function getInvoiceNumber() {
    if (!isset($this->number_sequence)) {
      return NULL;
    }
    return new InvoiceNumber($this->number_sequence, $this->number_key, $this->number_pattern);
  }

  /**
   * {@inheritdoc}
   */
  protected function defaultUri() {
    return [
      'path' => 'admin/commerce/invoices/' . $this
        ->identifier(),
    ];
  }

  /**
   * {@inheritdoc}
   */
  protected function defaultLabel() {
    return $this
      ->hasInvoiceNumber() ? t('Invoice @number', [
      '@number' => $this
        ->getInvoiceNumber()
        ->__toString(),
    ]) : t('Invoice');
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Invoice::$changed public property
Invoice::$content public property
Invoice::$created public property
Invoice::$invoice_date public property
Invoice::$invoice_due public property
Invoice::$invoice_id public property
Invoice::$invoice_status public property
Invoice::$log public property
Invoice::$number_key public property
Invoice::$number_pattern public property
Invoice::$number_sequence public property
Invoice::$order_id public property
Invoice::$order_revision_id public property
Invoice::$revision_created public property
Invoice::$revision_id public property
Invoice::$revision_uid public property
Invoice::$type public property
Invoice::$uid public property
Invoice::defaultLabel protected function
Invoice::defaultUri protected function
Invoice::getInvoiceNumber public function Returns the invoice number.
Invoice::getNumberPattern public function Returns the invoice number pattern for this invoice.
Invoice::hasInvoiceNumber public function
Invoice::setInvoiceNumber public function Sets the invoice number.
Invoice::STATUS_CANCELED constant
Invoice::STATUS_PAID constant
Invoice::STATUS_PENDING constant
Invoice::STATUS_REFUNDED constant
Invoice::STATUS_REFUND_PENDING constant