mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-31 11:04:37 -04:00
Adjustments for template action
This commit is contained in:
parent
703c60903e
commit
9424950dbb
@ -540,10 +540,16 @@ class InvoiceController extends BaseController
|
|||||||
|
|
||||||
if($action == 'template' && $user->can('view', $invoices->first())){
|
if($action == 'template' && $user->can('view', $invoices->first())){
|
||||||
|
|
||||||
|
|
||||||
$hash_or_response = $request->boolean('send_email') ? 'email sent' : \Illuminate\Support\Str::uuid();
|
$hash_or_response = $request->boolean('send_email') ? 'email sent' : \Illuminate\Support\Str::uuid();
|
||||||
|
|
||||||
TemplateAction::dispatch($ids, $request->template_id, Invoice::class, $user->id, $user->company(), $user->company()->db, $hash_or_response, $request->boolean('send_email'));
|
TemplateAction::dispatch($ids,
|
||||||
|
$request->template_id,
|
||||||
|
Invoice::class,
|
||||||
|
$user->id,
|
||||||
|
$user->company(),
|
||||||
|
$user->company()->db,
|
||||||
|
$hash_or_response,
|
||||||
|
$request->boolean('send_email'));
|
||||||
|
|
||||||
return response()->json(['message' => $hash_or_response], 200);
|
return response()->json(['message' => $hash_or_response], 200);
|
||||||
}
|
}
|
||||||
|
0
public/storage/.htaccess
Normal file → Executable file
0
public/storage/.htaccess
Normal file → Executable file
@ -11,17 +11,19 @@
|
|||||||
|
|
||||||
namespace Tests\Feature;
|
namespace Tests\Feature;
|
||||||
|
|
||||||
use App\Helpers\Invoice\InvoiceSum;
|
|
||||||
use App\Models\Client;
|
|
||||||
use App\Models\ClientContact;
|
|
||||||
use App\Models\Invoice;
|
|
||||||
use App\Repositories\InvoiceRepository;
|
|
||||||
use App\Utils\Traits\MakesHash;
|
|
||||||
use Illuminate\Database\Eloquent\Model;
|
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
|
||||||
use Illuminate\Support\Facades\Session;
|
|
||||||
use Tests\MockAccountData;
|
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
use App\Models\Client;
|
||||||
|
use App\Models\Design;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use Tests\MockAccountData;
|
||||||
|
use App\Models\ClientContact;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
|
use App\Helpers\Invoice\InvoiceSum;
|
||||||
|
use App\Repositories\InvoiceRepository;
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Support\Facades\Session;
|
||||||
|
use App\Services\Template\TemplateAction;
|
||||||
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @test
|
* @test
|
||||||
@ -48,6 +50,45 @@ class InvoiceTest extends TestCase
|
|||||||
$this->makeTestData();
|
$this->makeTestData();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testTemplateBulkAction()
|
||||||
|
{
|
||||||
|
|
||||||
|
$design_model = Design::find(2);
|
||||||
|
|
||||||
|
$replicated_design = $design_model->replicate();
|
||||||
|
$replicated_design->company_id = $this->company->id;
|
||||||
|
$replicated_design->user_id = $this->user->id;
|
||||||
|
$replicated_design->is_template = true;
|
||||||
|
$replicated_design->is_custom = true;
|
||||||
|
$replicated_design->save();
|
||||||
|
|
||||||
|
//delete invoice
|
||||||
|
$data = [
|
||||||
|
'ids' => [$this->invoice->hashed_id],
|
||||||
|
'action' => 'template',
|
||||||
|
'template_id' => $replicated_design->hashed_id,
|
||||||
|
'send_email' => false,
|
||||||
|
];
|
||||||
|
|
||||||
|
$response = $this->withHeaders([
|
||||||
|
'X-API-SECRET' => config('ninja.api_secret'),
|
||||||
|
'X-API-TOKEN' => $this->token,
|
||||||
|
])->post('/api/v1/invoices/bulk', $data)
|
||||||
|
->assertStatus(200);
|
||||||
|
|
||||||
|
|
||||||
|
(new TemplateAction([$this->invoice->hashed_id],
|
||||||
|
$replicated_design->hashed_id,
|
||||||
|
Invoice::class,
|
||||||
|
$this->user->id,
|
||||||
|
$this->company,
|
||||||
|
$this->company->db,
|
||||||
|
'dd',
|
||||||
|
false))->handle();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function testInvoiceGetDatesBetween()
|
public function testInvoiceGetDatesBetween()
|
||||||
{
|
{
|
||||||
$response = $this->withHeaders([
|
$response = $this->withHeaders([
|
||||||
|
Loading…
x
Reference in New Issue
Block a user