diff --git a/app/Models/Expense.php b/app/Models/Expense.php index f0d4b9321d..e8a3b56fdb 100644 --- a/app/Models/Expense.php +++ b/app/Models/Expense.php @@ -173,16 +173,16 @@ class Expense extends BaseModel return [ 'id' => $this->id, - 'name' => ctrans('texts.expense') . " " . $this->number . ' | ' . Number::formatMoney($this->amount, $this->company) . ' | ' . $this->translateDate($this->date, $this->company->date_format(), $locale), + 'name' => ctrans('texts.expense') . " " . ($this->number ?? '') . ' | ' . Number::formatMoney($this->amount, $this->company) . ' | ' . $this->translateDate($this->date, $this->company->date_format(), $locale), 'hashed_id' => $this->hashed_id, 'number' => $this->number, 'is_deleted' => $this->is_deleted, 'amount' => (float) $this->amount, 'date' => $this->date ?? null, - 'custom_value1' => (string)$this->custom_value1 ?? '', - 'custom_value2' => (string)$this->custom_value2 ?? '', - 'custom_value3' => (string)$this->custom_value3 ?? '', - 'custom_value4' => (string)$this->custom_value4 ?? '', + 'custom_value1' => (string)$this->custom_value1, + 'custom_value2' => (string)$this->custom_value2, + 'custom_value3' => (string)$this->custom_value3, + 'custom_value4' => (string)$this->custom_value4, 'company_key' => $this->company->company_key, ]; } diff --git a/app/Models/Quote.php b/app/Models/Quote.php index c7ef099c24..7f3fe8087d 100644 --- a/app/Models/Quote.php +++ b/app/Models/Quote.php @@ -199,7 +199,7 @@ class Quote extends BaseModel return [ 'id' => $this->id, - 'name' => ctrans('texts.quote') . " " . $this->number . " | " . $this->client->present()->name() . ' | ' . Number::formatMoney($this->amount, $this->company) . ' | ' . $this->translateDate($this->date, $this->company->date_format(), $locale), + 'name' => ctrans('texts.quote') . " " . ($this->number ?? '') . " | " . $this->client->present()->name() . ' | ' . Number::formatMoney($this->amount, $this->company) . ' | ' . $this->translateDate($this->date, $this->company->date_format(), $locale), 'hashed_id' => $this->hashed_id, 'number' => $this->number, 'is_deleted' => $this->is_deleted, diff --git a/app/Utils/Traits/GeneratesCounter.php b/app/Utils/Traits/GeneratesCounter.php index 82e93c6afd..4bec6fef0b 100644 --- a/app/Utils/Traits/GeneratesCounter.php +++ b/app/Utils/Traits/GeneratesCounter.php @@ -328,7 +328,13 @@ trait GeneratesCounter $counter = $expense->company->settings->expense_number_counter; $setting_entity = $expense->company->settings->expense_number_counter; - $expense_number = $this->checkEntityNumber(Expense::class, $expense, $counter, $expense->company->settings->counter_padding, $expense->company->settings->expense_number_pattern); + $pattern = $expense->company->settings->expense_number_pattern; + + if (strlen($pattern) > 1 && (stripos($pattern, 'counter') === false)) { + $pattern = $pattern.'{$counter}'; + } + + $expense_number = $this->checkEntityNumber(Expense::class, $expense, $counter, $expense->company->settings->counter_padding, $pattern); $this->incrementCounter($expense->company, 'expense_number_counter');