1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 21:22:58 +01:00

Merge pull request #4231 from turbo124/v5-develop

Task and Expense numbers
This commit is contained in:
David Bomba 2020-10-29 21:49:34 +11:00 committed by GitHub
commit f9062e75d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 33 additions and 5 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

@ -51,7 +51,6 @@ class TaskRepository extends BaseRepository
$task->fill($data);
$task->save();
$task->start_time = $task->start_time ?: $task->calcStartTime();
$task->number = empty($task->number) ? $this->getNextTaskNumber($task) : $task->number;
if (isset($data['description'])) {
@ -90,6 +89,7 @@ class TaskRepository extends BaseRepository
}
$task->time_log = json_encode($time_log);
$task->start_time = $task->start_time ?: $task->calcStartTime();
$task->duration = $task->calcDuration();
$task->save();

View File

@ -54,7 +54,7 @@
{{ empty($credit->public_notes) ? '/' : $credit->public_notes }}
</td>
<td class="px-6 py-4 whitespace-no-wrap text-sm leading-5 text-gray-500">
<a href="{{ route('client.credits.show', $credit->hashed_id) }}" class="button-link text-primary">
<a href="{{ route('client.credit.show', $credit->hashed_id) }}" class="button-link text-primary">
@lang('texts.view')
</a>
</td>

View File

@ -58,7 +58,9 @@ Route::group(['middleware' => ['auth:contact', 'locale'], 'prefix' => 'client',
Route::get('quotes/{quote_invitation}', 'ClientPortal\QuoteController@show')->name('quote.show_invitation');
Route::get('credits', 'ClientPortal\CreditController@index')->name('credits.index');
Route::get('credits/{credit}', 'ClientPortal\CreditController@show')->name('credits.show');
Route::get('credits/{credit}', 'ClientPortal\CreditController@show')->name('credit.show');
Route::get('credits/{credit_invitation}', 'ClientPortal\CreditController@show')->name('credits.show_invitation');
Route::get('client/switch_company/{contact}', 'ClientPortal\SwitchCompanyController')->name('switch_company');

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

View File

@ -62,7 +62,29 @@ class TaskApiTest extends TestCase
'X-API-TOKEN' => $this->token,
])->post('/api/v1/tasks', $data);
$arr = $response->json();
$response->assertStatus(200);
$this->assertNotEmpty($arr['data']['number']);
}
public function testTaskPostWithActionStart()
{
$data = [
'description' => $this->faker->firstName,
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/tasks?action=start', $data);
$arr = $response->json();
$response->assertStatus(200);
$this->assertGreaterThan(0, $arr['data']['start_time']);
}
public function testTaskPut()