Fixes for expense number patterns

This commit is contained in:
David Bomba 2024-12-09 15:57:58 +11:00
parent a97b51aed7
commit d7ae86196a
3 changed files with 13 additions and 7 deletions

View File

@ -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,
];
}

View File

@ -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,

View File

@ -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');