Recurring Expenses

This commit is contained in:
David Bomba 2021-08-24 11:29:56 +10:00
parent 174248e03d
commit 2bafe5d1fc
3 changed files with 63 additions and 56 deletions

View File

@ -98,6 +98,9 @@ class CompanySettings extends BaseSettings
public $expense_number_pattern = ''; //@implemented
public $expense_number_counter = 1; //@implemented
public $recurring_expense_number_pattern = '';
public $recurring_expense_number_counter = 1;
public $vendor_number_pattern = ''; //@implemented
public $vendor_number_counter = 1; //@implemented
@ -347,6 +350,8 @@ class CompanySettings extends BaseSettings
'task_number_counter' => 'int',
'expense_number_pattern' => 'string',
'expense_number_counter' => 'int',
'recurring_expense_number_pattern' => 'string',
'recurring_expense_number_counter' => 'int',
'vendor_number_pattern' => 'string',
'vendor_number_counter' => 'int',
'ticket_number_pattern' => 'string',

View File

@ -130,6 +130,10 @@ Route::group(['middleware' => ['api_db', 'token_auth', 'locale'], 'prefix' => 'a
Route::put('quotes/{quote}/upload', 'QuoteController@upload');
Route::resource('recurring_expenses', 'RecurringExpenseController');
Route::post('recurring_expenses/bulk', 'RecurringExpenseController@bulk')->name('recurring_expenses.bulk');
Route::put('recurring_expenses/{recurring_expense}/upload', 'RecurringExpenseController@upload');
Route::resource('recurring_invoices', 'RecurringInvoiceController'); // name = (recurring_invoices. index / create / show / update / destroy / edit
Route::post('recurring_invoices/bulk', 'RecurringInvoiceController@bulk')->name('recurring_invoices.bulk');
Route::put('recurring_invoices/{recurring_invoice}/upload', 'RecurringInvoiceController@upload');

View File

@ -75,76 +75,74 @@ class RecurringExpenseApiTest extends TestCase
])->post('/api/v1/recurring_expenses', $data);
$response->assertStatus(200);
$arr = $response->json();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->put('/api/v1/recurring_expenses/'.$arr['data']['id'], $data)->assertStatus(200);
try{
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/recurring_expenses', $data);
}
catch(ValidationException $e){
$response->assertStatus(302);
}
}
// $arr = $response->json();
// $response = $this->withHeaders([
// 'X-API-SECRET' => config('ninja.api_secret'),
// 'X-API-TOKEN' => $this->token,
// ])->put('/api/v1/recurring_expenses/'.$arr['data']['id'], $data)->assertStatus(200);
public function testRecurringExpensePut()
{
$data = [
'amount' => 20,
'public_notes' => 'Coolio',
];
// try{
// $response = $this->withHeaders([
// 'X-API-SECRET' => config('ninja.api_secret'),
// 'X-API-TOKEN' => $this->token,
// ])->post('/api/v1/recurring_expenses', $data);
// }
// catch(ValidationException $e){
// $response->assertStatus(302);
// }
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->put('/api/v1/recurring_expenses/'.$this->encodePrimaryKey($this->recurring_expense->id), $data);
$response->assertStatus(200);
}
public function testRecurringExpenseNotArchived()
{
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get('/api/v1/recurring_expenses/'.$this->encodePrimaryKey($this->recurring_expense->id));
// }
$arr = $response->json();
// public function testRecurringExpensePut()
// {
// $data = [
// 'name' => $this->faker->firstName,
// 'public_notes' => 'Coolio',
// ];
$this->assertEquals(0, $arr['data']['archived_at']);
}
// $response = $this->withHeaders([
// 'X-API-SECRET' => config('ninja.api_secret'),
// 'X-API-TOKEN' => $this->token,
// ])->put('/api/v1/recurring_expenses/'.$this->encodePrimaryKey($this->project->id), $data);
public function testRecurringExpenseArchived()
{
$data = [
'ids' => [$this->encodePrimaryKey($this->recurring_expense->id)],
];
// $response->assertStatus(200);
// }
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->post('/api/v1/recurring_expenses/bulk?action=archive', $data);
$arr = $response->json();
// public function testRecurringExpenseNotArchived()
// {
// $response = $this->withHeaders([
// 'X-API-SECRET' => config('ninja.api_secret'),
// 'X-API-TOKEN' => $this->token,
// ])->get('/api/v1/recurring_expenses/'.$this->encodePrimaryKey($this->project->id));
// $arr = $response->json();
// $this->assertEquals(0, $arr['data']['archived_at']);
// }
// public function testRecurringExpenseArchived()
// {
// $data = [
// 'ids' => [$this->encodePrimaryKey($this->project->id)],
// ];
// $response = $this->withHeaders([
// 'X-API-SECRET' => config('ninja.api_secret'),
// 'X-API-TOKEN' => $this->token,
// ])->post('/api/v1/recurring_expenses/bulk?action=archive', $data);
// $arr = $response->json();
// $this->assertNotNull($arr['data'][0]['archived_at']);
// }
$this->assertNotNull($arr['data'][0]['archived_at']);
}
// public function testRecurringExpenseRestored()
// {
// $data = [
// 'ids' => [$this->encodePrimaryKey($this->project->id)],
// 'ids' => [$this->encodePrimaryKey($this->recurring_expense->id)],
// ];
// $response = $this->withHeaders([
@ -160,7 +158,7 @@ class RecurringExpenseApiTest extends TestCase
// public function testRecurringExpenseDeleted()
// {
// $data = [
// 'ids' => [$this->encodePrimaryKey($this->project->id)],
// 'ids' => [$this->encodePrimaryKey($this->recurring_expense->id)],
// ];
// $response = $this->withHeaders([