mirror of
				https://github.com/invoiceninja/invoiceninja.git
				synced 2025-11-01 20:17:35 -04:00 
			
		
		
		
	Process Invoice Numbers which includes letters
-Using custom Invoice Number Patterns like R-ABC-P224301 breaks the QR Bill Generation -This solution loops through the Invoice Number and translates letter into ASCII -Makes sure that the field Additional Information not shows the wrong content
This commit is contained in:
		
							parent
							
								
									577f2a4809
								
							
						
					
					
						commit
						b2e3ea53d0
					
				| @ -19,7 +19,7 @@ use Sprain\SwissQrBill as QrBill; | ||||
| /** | ||||
|  * SwissQrGenerator. | ||||
|  */ | ||||
| class SwissQrGenerator  | ||||
| class SwissQrGenerator | ||||
| { | ||||
| 
 | ||||
|     protected Company $company; | ||||
| @ -33,7 +33,7 @@ class SwissQrGenerator | ||||
|         $this->company = $company; | ||||
| 
 | ||||
|         $this->invoice = $invoice; | ||||
|      | ||||
| 
 | ||||
|         $this->client = $invoice->client; | ||||
|     } | ||||
| 
 | ||||
| @ -104,15 +104,42 @@ class SwissQrGenerator | ||||
| 
 | ||||
|     // Add payment reference
 | ||||
|     // This is what you will need to identify incoming payments.
 | ||||
| 
 | ||||
|    if(stripos($this->invoice->number, "Live-") === 0)                                                                                                                                                                             | ||||
|     {                                                                                                                                                                                                                              | ||||
|        // we're currently in preview status. Let's give a dummy reference for now                                                                                                                                                 
 | ||||
|        $invoice_number = "123456789";                                                                                                                                                                                               | ||||
|     }                                                                                                                                                                                                                              | ||||
|     else                                                                                                                                                                                                                           | ||||
|     {                                                                                                                                                                                                                              | ||||
|        $invoice_number = $this->invoice->number;                                                                                                                                                                                    | ||||
|          | ||||
|     if(stripos($this->invoice->number, "Live-") === 0) | ||||
|     { | ||||
|         // we're currently in preview status. Let's give a dummy reference for now
 | ||||
|         $invoice_number = "123456789"; | ||||
|     } | ||||
|     else | ||||
|     { | ||||
|         $tempInvoiceNumber = $this->invoice->number; | ||||
|         $tempInvoiceNumber = preg_replace('/[^A-Za-z0-9]/', '', $tempInvoiceNumber); | ||||
|         $tempInvoiceNumber = substr($tempInvoiceNumber, 1); | ||||
|          | ||||
|         $calcInvoiceNumber = ""; | ||||
|         $array = str_split($tempInvoiceNumber); | ||||
|         foreach($array as $char) | ||||
| 		{ | ||||
|             if (is_numeric($char)) | ||||
| 			{ | ||||
| 				//
 | ||||
| 			} | ||||
| 			else | ||||
| 			{ | ||||
| 				if ($char) | ||||
| 				{ | ||||
| 					$char = strtolower($char); | ||||
| 					$char = ord($char) - 96; | ||||
| 				} | ||||
| 				else | ||||
| 				{ | ||||
| 					return 0; | ||||
| 				} | ||||
| 			} | ||||
| 			$calcInvoiceNumber .= $char; | ||||
| 		} | ||||
|         | ||||
|         $invoice_number = $calcInvoiceNumber; | ||||
|     }        | ||||
| 
 | ||||
|     if(strlen($this->company->present()->besr_id()) > 1) | ||||
| @ -141,7 +168,7 @@ class SwissQrGenerator | ||||
|     // Optionally, add some human-readable information about what the bill is for.
 | ||||
|     $qrBill->setAdditionalInformation( | ||||
|         QrBill\DataGroup\Element\AdditionalInformation::create( | ||||
|             $this->invoice->public_notes ? substr($this->invoice->public_notes, 0, 139) : ctrans('texts.invoice_number_placeholder', ['invoice' => $invoice_number]) | ||||
|             $this->invoice->public_notes ? substr($this->invoice->public_notes, 0, 139) : ctrans('texts.invoice_number_placeholder', ['invoice' => $this->invoice->number]) | ||||
|         ) | ||||
|     ); | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user