mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Fixes for expense numbers
This commit is contained in:
parent
fa92dd76e4
commit
86ee5f477b
@ -39,9 +39,9 @@ class StoreExpenseRequest extends Request
|
||||
{
|
||||
$rules = [];
|
||||
|
||||
$rules['id_number'] = 'unique:expenses,id_number,'.$this->id.',id,company_id,'.$this->company_id;
|
||||
$rules['number'] = 'unique:expenses,number,'.$this->id.',id,company_id,'.auth()->user()->company()->id;
|
||||
$rules['contacts.*.email'] = 'nullable|distinct';
|
||||
$rules['number'] = new UniqueExpenseNumberRule($this->all());
|
||||
//$rules['number'] = new UniqueExpenseNumberRule($this->all());
|
||||
$rules['client_id'] = 'bail|sometimes|exists:clients,id,company_id,'.auth()->user()->company()->id;
|
||||
|
||||
|
||||
|
@ -49,6 +49,7 @@ class ExpenseRepository extends BaseRepository
|
||||
public function save(array $data, Expense $expense) : ?Expense
|
||||
{
|
||||
$expense->fill($data);
|
||||
$expense->number = empty($expense->number) ? $this->getNextExpenseNumber($expense) : $expense->number;
|
||||
|
||||
$expense->save();
|
||||
|
||||
|
@ -62,7 +62,10 @@ class ExpenseApiTest extends TestCase
|
||||
'X-API-TOKEN' => $this->token,
|
||||
])->post('/api/v1/expenses', $data);
|
||||
|
||||
$arr = $response->json();
|
||||
$response->assertStatus(200);
|
||||
|
||||
$this->assertNotEmpty($arr['data']['number']);
|
||||
}
|
||||
|
||||
public function testExpensePut()
|
||||
|
Loading…
Reference in New Issue
Block a user