mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-10-30 23:47:31 -04:00 
			
		
		
		
	Merge pull request #5014 from turbo124/v5-develop
Fixes for recurring invoice number not being prefixed
This commit is contained in:
		
						commit
						b818e7204c
					
				| @ -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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user