mirror of
				https://github.com/crater-invoice/crater.git
				synced 2025-10-31 13:41:09 -04:00 
			
		
		
		
	Refactor Customization Page
This commit is contained in:
		| @ -66,10 +66,14 @@ class Invoice extends Model | ||||
|         'formattedDueDate' | ||||
|     ]; | ||||
|  | ||||
|     public static function getNextInvoiceNumber() | ||||
|     public static function getNextInvoiceNumber($value) | ||||
|     { | ||||
|         // Get the last created order | ||||
|         $lastOrder = Invoice::orderBy('created_at', 'desc')->first(); | ||||
|         $lastOrder = Invoice::where('invoice_number', 'LIKE', $value . '-%') | ||||
|                     ->orderBy('created_at', 'desc') | ||||
|                     ->first(); | ||||
|  | ||||
|  | ||||
|         if (!$lastOrder) { | ||||
|             // We get here if there is no order at all | ||||
|             // If there is no number set it to 0, which will be 1 at the end. | ||||
| @ -143,10 +147,15 @@ class Invoice extends Model | ||||
|  | ||||
|     public function getInvoiceNumAttribute() | ||||
|     { | ||||
|         $position = $this->strposX($this->invoice_number, "-", 2) + 1; | ||||
|         $position = $this->strposX($this->invoice_number, "-", 1) + 1; | ||||
|         return substr($this->invoice_number, $position); | ||||
|     } | ||||
|  | ||||
|     public function getInvoicePrefixAttribute () { | ||||
|         $prefix = explode("-", $this->invoice_number)[0]; | ||||
|         return $prefix; | ||||
|     } | ||||
|  | ||||
|     public function getFormattedCreatedAtAttribute($value) | ||||
|     { | ||||
|         $dateFormat = CompanySetting::getSetting('carbon_date_format', $this->company_id); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user