1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Fixes for validation

This commit is contained in:
David Bomba 2024-04-19 14:26:15 +10:00
parent 871b6dd54d
commit 56fc585828
6 changed files with 35 additions and 9 deletions

View File

@ -45,6 +45,10 @@ class Request extends FormRequest
$merge_rules = [];
foreach ($this->all() as $key => $value) {
if($key == 'user')
continue;
if (method_exists($this, $key)) {
$merge_rules = $this->{$key}($rules);
}

View File

@ -92,7 +92,6 @@ class StoreTaskRequest extends Request
$rules['file'] = $this->fileValidation();
}
return $this->globalRules($rules);
}

View File

@ -137,9 +137,6 @@ class UpdateTaskRequest extends Request
$input['time_log'] = json_encode([]);
}
if(isset($input['user']))
unset($input['user']);
$this->replace($input);
}

View File

@ -17,6 +17,7 @@ use App\Utils\Helpers;
use App\Models\Account;
use App\Models\Payment;
use Illuminate\Support\Str;
use App\Utils\Traits\MakesHash;
use App\Utils\Traits\MakesDates;
use App\Jobs\Entity\CreateRawPdf;
use Illuminate\Support\Facades\App;
@ -28,7 +29,8 @@ use App\Services\Template\TemplateAction;
class PaymentEmailEngine extends BaseEmailEngine
{
use MakesDates;
use MakesHash;
public $client;
/** @var \App\Models\Payment $payment */
@ -97,11 +99,12 @@ class PaymentEmailEngine extends BaseEmailEngine
->setViewLink('')
->setViewText('');
if ($this->client->getSetting('pdf_email_attachment') !== false && $this->company->account->hasFeature(Account::FEATURE_PDF_ATTACHMENT)) {
$template_in_use = false;
if($this->is_refund && strlen($this->payment->client->getSetting('payment_refund_design_id')) > 2) {
if($this->is_refund && \App\Models\Design::where('id', $this->decodePrimaryKey($this->payment->client->getSetting('payment_refund_design_id')))->where('is_template', true)->exists()) {
$pdf = (new TemplateAction(
[$this->payment->hashed_id],
$this->payment->client->getSetting('payment_refund_design_id'),
@ -118,7 +121,7 @@ class PaymentEmailEngine extends BaseEmailEngine
$this->setAttachments([['file' => base64_encode($pdf), 'name' => $file_name]]);
$template_in_use = true;
} elseif(!$this->is_refund && strlen($this->payment->client->getSetting('payment_receipt_design_id')) > 2) {
} elseif(!$this->is_refund && \App\Models\Design::where('id', $this->decodePrimaryKey($this->payment->client->getSetting('payment_receipt_design_id')))->where('is_template', true)->exists()) {
$pdf = (new TemplateAction(
[$this->payment->hashed_id],
$this->payment->client->getSetting('payment_receipt_design_id'),

View File

@ -66,7 +66,9 @@ class Statement
$option_template = &$this->options['template'];
if($this->client->getSetting('statement_design_id') != '' || $option_template && $option_template != '') {
$custom_statement_template = \App\Models\Design::where('id', $this->decodePrimaryKey($this->client->getSetting('statement_design_id')))->where('is_template',true)->first();
if($custom_statement_template || $option_template && $option_template != '') {
$variables['values']['$start_date'] = $this->translateDate($this->options['start_date'], $this->client->date_format(), $this->client->locale());
$variables['values']['$end_date'] = $this->translateDate($this->options['end_date'], $this->client->date_format(), $this->client->locale());

View File

@ -104,6 +104,27 @@ class TaskApiTest extends TestCase
}
}
public function testRequestRuleParsing()
{
$data = [
'client_id' => $this->client->hashed_id,
'description' => 'Test Task',
'time_log' => '[[1681165417,1681165432,"sumtin",true],[1681165446,0]]',
'assigned_user' => [],
'project' => [],
'user' => [],
// 'status' => [],
];
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->postJson("/api/v1/tasks", $data);
$response->assertStatus(200);
}
public function testUserFilters()
{