mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-04 06:37:33 -05:00 
			
		
		
		
	Share invoice counter with Quotes Error #1474
This commit is contained in:
		
							parent
							
								
									7b797da220
								
							
						
					
					
						commit
						f61b2842e7
					
				@ -26,6 +26,7 @@ trait GeneratesNumbers
 | 
				
			|||||||
        $prefix = $this->getNumberPrefix($entityType);
 | 
					        $prefix = $this->getNumberPrefix($entityType);
 | 
				
			||||||
        $counterOffset = 0;
 | 
					        $counterOffset = 0;
 | 
				
			||||||
        $check = false;
 | 
					        $check = false;
 | 
				
			||||||
 | 
					        $lastNumber = false;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if ($entityType == ENTITY_CLIENT && ! $this->clientNumbersEnabled()) {
 | 
					        if ($entityType == ENTITY_CLIENT && ! $this->clientNumbersEnabled()) {
 | 
				
			||||||
            return '';
 | 
					            return '';
 | 
				
			||||||
@ -50,6 +51,13 @@ trait GeneratesNumbers
 | 
				
			|||||||
            }
 | 
					            }
 | 
				
			||||||
            $counter++;
 | 
					            $counter++;
 | 
				
			||||||
            $counterOffset++;
 | 
					            $counterOffset++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            // prevent getting stuck in a loop
 | 
				
			||||||
 | 
					            if ($number == $lastNumber) {
 | 
				
			||||||
 | 
					                return '';
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					            $lastNumber = $number;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        } while ($check);
 | 
					        } while ($check);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // update the counter to be caught up
 | 
					        // update the counter to be caught up
 | 
				
			||||||
@ -194,15 +202,17 @@ trait GeneratesNumbers
 | 
				
			|||||||
            '{$clientCounter}',
 | 
					            '{$clientCounter}',
 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        $client = $invoice->client;
 | 
				
			||||||
 | 
					        $clientCounter = ($invoice->isQuote && ! $this->share_counter) ? $client->quote_number_counter : $client->invoice_number_counter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $replace = [
 | 
					        $replace = [
 | 
				
			||||||
            $invoice->client->custom_value1,
 | 
					            $client->custom_value1,
 | 
				
			||||||
            $invoice->client->custom_value2,
 | 
					            $client->custom_value2,
 | 
				
			||||||
            $invoice->client->id_number,
 | 
					            $client->id_number,
 | 
				
			||||||
            $invoice->client->custom_value1, // backwards compatibility
 | 
					            $client->custom_value1, // backwards compatibility
 | 
				
			||||||
            $invoice->client->custom_value2,
 | 
					            $client->custom_value2,
 | 
				
			||||||
            $invoice->client->id_number,
 | 
					            $client->id_number,
 | 
				
			||||||
            str_pad($invoice->client->invoice_number_counter, $this->invoice_number_padding, '0', STR_PAD_LEFT),
 | 
					            str_pad($clientCounter, $this->invoice_number_padding, '0', STR_PAD_LEFT),
 | 
				
			||||||
            str_pad($invoice->client->quote_number_counter, $this->invoice_number_padding, '0', STR_PAD_LEFT),
 | 
					 | 
				
			||||||
        ];
 | 
					        ];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return str_replace($search, $replace, $pattern);
 | 
					        return str_replace($search, $replace, $pattern);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user