1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-05 18:52:44 +01:00

Merge pull request #5014 from turbo124/v5-develop

Fixes for recurring invoice number not being prefixed
This commit is contained in:
David Bomba 2021-03-02 21:59:00 +11:00 committed by GitHub
commit b818e7204c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 22 deletions

View File

@ -39,11 +39,11 @@ class ApplyNumber extends AbstractService
switch ($this->client->getSetting('counter_number_applied')) { switch ($this->client->getSetting('counter_number_applied')) {
case 'when_saved': 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; break;
case 'when_sent': case 'when_sent':
if ($this->invoice->status_id == Invoice::STATUS_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; break;

View File

@ -33,26 +33,11 @@ class ApplyNumber extends AbstractService
/* Recurring numbers are set when saved */ /* Recurring numbers are set when saved */
public function run() public function run()
{ {
if ($this->recurring_entity->number != '') { if ($this->recurring_entity->number != '')
return $this->recurring_entity; return $this->recurring_entity;
}
$this->recurring_entity->number = $this->getNextRecurringInvoiceNumber($this->client); $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; return $this->recurring_entity;
} }
} }

View File

@ -35,7 +35,7 @@ trait GeneratesCounter
private function getNextEntityNumber($entity, Client $client) private function getNextEntityNumber($entity, Client $client, $is_recurring = false)
{ {
$prefix = ''; $prefix = '';
@ -75,7 +75,7 @@ trait GeneratesCounter
$padding = $client->getSetting('counter_padding'); $padding = $client->getSetting('counter_padding');
if($entity instanceof Invoice && $entity && $entity->recurring_id) if($is_recurring)
$prefix = $client->getSetting('recurring_number_prefix'); $prefix = $client->getSetting('recurring_number_prefix');
$entity_number = $this->checkEntityNumber($entity, $client, $counter, $padding, $pattern, $prefix); $entity_number = $this->checkEntityNumber($entity, $client, $counter, $padding, $pattern, $prefix);
@ -154,9 +154,9 @@ trait GeneratesCounter
* @param Invoice|null $invoice * @param Invoice|null $invoice
* @return string The next invoice number. * @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);
} }
/** /**