mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-03 05:24:34 -04:00
Bulk credit requests
This commit is contained in:
parent
7bd5a73d70
commit
c502177470
@ -11,11 +11,11 @@
|
|||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Exceptions\ModelNotFoundException;
|
|
||||||
use App\Http\Requests\CompanyUser\UpdateCompanyUserRequest;
|
use App\Http\Requests\CompanyUser\UpdateCompanyUserRequest;
|
||||||
use App\Models\CompanyUser;
|
use App\Models\CompanyUser;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Transformers\CompanyUserTransformer;
|
use App\Transformers\CompanyUserTransformer;
|
||||||
|
use Illuminate\Database\Eloquent\ModelNotFoundException;
|
||||||
use Illuminate\Http\Response;
|
use Illuminate\Http\Response;
|
||||||
|
|
||||||
class CompanyUserController extends BaseController
|
class CompanyUserController extends BaseController
|
||||||
|
@ -17,6 +17,7 @@ use App\Factory\CloneCreditFactory;
|
|||||||
use App\Factory\CreditFactory;
|
use App\Factory\CreditFactory;
|
||||||
use App\Filters\CreditFilters;
|
use App\Filters\CreditFilters;
|
||||||
use App\Http\Requests\Credit\ActionCreditRequest;
|
use App\Http\Requests\Credit\ActionCreditRequest;
|
||||||
|
use App\Http\Requests\Credit\BulkCreditRequest;
|
||||||
use App\Http\Requests\Credit\CreateCreditRequest;
|
use App\Http\Requests\Credit\CreateCreditRequest;
|
||||||
use App\Http\Requests\Credit\DestroyCreditRequest;
|
use App\Http\Requests\Credit\DestroyCreditRequest;
|
||||||
use App\Http\Requests\Credit\EditCreditRequest;
|
use App\Http\Requests\Credit\EditCreditRequest;
|
||||||
@ -494,11 +495,11 @@ class CreditController extends BaseController
|
|||||||
* ),
|
* ),
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function bulk()
|
public function bulk(BulkCreditRequest $request)
|
||||||
{
|
{
|
||||||
$action = request()->input('action');
|
$action = $request->input('action');
|
||||||
|
|
||||||
$ids = request()->input('ids');
|
$ids = $request->input('ids');
|
||||||
|
|
||||||
if(Ninja::isHosted() && (stripos($action, 'email') !== false) && !auth()->user()->company()->account->account_sms_verified)
|
if(Ninja::isHosted() && (stripos($action, 'email') !== false) && !auth()->user()->company()->account->account_sms_verified)
|
||||||
return response(['message' => 'Please verify your account to send emails.'], 400);
|
return response(['message' => 'Please verify your account to send emails.'], 400);
|
||||||
|
@ -33,10 +33,10 @@ class BulkCompanyGatewayRequest extends Request
|
|||||||
|
|
||||||
public function rules()
|
public function rules()
|
||||||
{
|
{
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'ids' => 'required|bail|array',
|
'ids' => 'required|bail|array',
|
||||||
'action' => 'in:archive,restore,delete'
|
'action' => 'required|bail|in:archive,restore,delete'
|
||||||
];
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
40
app/Http/Requests/Credit/BulkCreditRequest.php
Normal file
40
app/Http/Requests/Credit/BulkCreditRequest.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Invoice Ninja (https://invoiceninja.com).
|
||||||
|
*
|
||||||
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||||
|
*
|
||||||
|
* @copyright Copyright (c) 2022. Invoice Ninja LLC (https://invoiceninja.com)
|
||||||
|
*
|
||||||
|
* @license https://www.elastic.co/licensing/elastic-license
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace App\Http\Requests\Credit;
|
||||||
|
|
||||||
|
use Illuminate\Foundation\Http\FormRequest;
|
||||||
|
|
||||||
|
class BulkCreditRequest extends FormRequest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Determine if the user is authorized to make this request.
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public function authorize() : bool
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the validation rules that apply to the request.
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function rules()
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'ids' => 'required|bail|array',
|
||||||
|
'action' => 'required|bail|in:archive,restore,delete,email,bulk_download,bulk_print,mark_paid,clone_to_credit,history,mark_sent,download,send_email'
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
@ -4926,6 +4926,8 @@ $LANG = array(
|
|||||||
'import_completed' => 'Import completed',
|
'import_completed' => 'Import completed',
|
||||||
'client_statement_body' => 'Your statement from :start_date to :end_date is attached.',
|
'client_statement_body' => 'Your statement from :start_date to :end_date is attached.',
|
||||||
'email_queued' => 'Email queued',
|
'email_queued' => 'Email queued',
|
||||||
|
'clone_to_recurring_invoice' => 'Clone to Recurring Invoice',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -40,6 +40,45 @@ class CreditTest extends TestCase
|
|||||||
$this->makeTestData();
|
$this->makeTestData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testBulkActions()
|
||||||
|
{
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'action' => 'archive',
|
||||||
|
'ids' => [$this->credit->hashed_id]
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->post('/api/v1/credits/bulk', $data)
|
||||||
|
->assertStatus(200);
|
||||||
|
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'ids' => [$this->credit->hashed_id],
|
||||||
|
'action' => 'restore'
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->post('/api/v1/credits/bulk', $data)
|
||||||
|
->assertStatus(200);
|
||||||
|
|
||||||
|
$data = [
|
||||||
|
'ids' => [$this->credit->hashed_id],
|
||||||
|
'action' => 'delete'
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->post('/api/v1/credits/bulk', $data)
|
||||||
|
->assertStatus(200);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function testCreditGetClientStatus()
|
public function testCreditGetClientStatus()
|
||||||
{
|
{
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user