1
0
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:
David Bomba 2020-10-29 21:48:56 +11:00
parent fa92dd76e4
commit 86ee5f477b
3 changed files with 6 additions and 2 deletions

View File

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

View File

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

View File

@ -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()