mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Fixes for recurring invoice number not being prefixed
This commit is contained in:
parent
7a2cea1d9c
commit
b57d4bfb7c
@ -39,11 +39,11 @@ class ApplyNumber extends AbstractService
|
||||
|
||||
switch ($this->client->getSetting('counter_number_applied')) {
|
||||
case 'when_saved':
|
||||
$this->invoice->number = $this->getNextInvoiceNumber($this->client, $this->invoice);
|
||||
$this->invoice->number = $this->getNextInvoiceNumber($this->client, $this->invoice, $this->invoice->recurring_id);
|
||||
break;
|
||||
case 'when_sent':
|
||||
if ($this->invoice->status_id == Invoice::STATUS_SENT) {
|
||||
$this->invoice->number = $this->getNextInvoiceNumber($this->client, $this->invoice);
|
||||
$this->invoice->number = $this->getNextInvoiceNumber($this->client, $this->invoice, $this->invoice->recurring_id);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -33,26 +33,11 @@ class ApplyNumber extends AbstractService
|
||||
/* Recurring numbers are set when saved */
|
||||
public function run()
|
||||
{
|
||||
if ($this->recurring_entity->number != '') {
|
||||
if ($this->recurring_entity->number != '')
|
||||
return $this->recurring_entity;
|
||||
}
|
||||
|
||||
|
||||
$this->recurring_entity->number = $this->getNextRecurringInvoiceNumber($this->client);
|
||||
|
||||
|
||||
// switch ($this->client->getSetting('counter_number_applied')) {
|
||||
// case 'when_saved':
|
||||
// $this->recurring_entity->number = $this->getNextRecurringInvoiceNumber($this->client);
|
||||
// break;
|
||||
// case 'when_sent':
|
||||
// break;
|
||||
|
||||
// default:
|
||||
// $this->recurring_entity->number = $this->getNextRecurringInvoiceNumber($this->client);
|
||||
// break;
|
||||
// }
|
||||
|
||||
return $this->recurring_entity;
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ trait GeneratesCounter
|
||||
|
||||
|
||||
|
||||
private function getNextEntityNumber($entity, Client $client)
|
||||
private function getNextEntityNumber($entity, Client $client, $is_recurring = false)
|
||||
{
|
||||
$prefix = '';
|
||||
|
||||
@ -75,7 +75,7 @@ trait GeneratesCounter
|
||||
|
||||
$padding = $client->getSetting('counter_padding');
|
||||
|
||||
if($entity instanceof Invoice && $entity && $entity->recurring_id)
|
||||
if($is_recurring)
|
||||
$prefix = $client->getSetting('recurring_number_prefix');
|
||||
|
||||
$entity_number = $this->checkEntityNumber($entity, $client, $counter, $padding, $pattern, $prefix);
|
||||
@ -154,9 +154,9 @@ trait GeneratesCounter
|
||||
* @param Invoice|null $invoice
|
||||
* @return string The next invoice number.
|
||||
*/
|
||||
public function getNextInvoiceNumber(Client $client, ?Invoice $invoice) :string
|
||||
public function getNextInvoiceNumber(Client $client, ?Invoice $invoice, $is_recurring = false) :string
|
||||
{
|
||||
return $this->getNextEntityNumber(Invoice::class, $client);
|
||||
return $this->getNextEntityNumber(Invoice::class, $client, $is_recurring);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user