protected function Generator::getLastSequence in Commerce Invoice 7.2
Finds the last invoice number generated for this pattern.
Parameters
string $key:
Return value
int|FALSE The last number or FALSE if no previous number is found.
1 call to Generator::getLastSequence()
- Generator::getNextSequence in src/
InvoiceNumber/ Generator.php - Calculates the next sequential number for this pattern.
File
- src/
InvoiceNumber/ Generator.php, line 72 - Invoice Number Generator
Class
- Generator
- Invoice number generator.
Namespace
Drupal\commerce_invoice\InvoiceNumberCode
protected function getLastSequence($key) {
$query = db_select('commerce_invoice', 'ci')
->fields('ci', array(
'number_sequence',
))
->condition('number_pattern', $this->name)
->condition('number_key', $key)
->orderBy('number_sequence', 'DESC')
->range(0, 1);
$last = $query
->execute()
->fetchField();
return $last !== FALSE ? (int) $last : FALSE;
}