mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Updates for static analysis
This commit is contained in:
parent
fab3b30b38
commit
ada3c78556
@ -33,6 +33,8 @@ use Illuminate\Database\Eloquent\ModelNotFoundException as ModelNotFoundExceptio
|
|||||||
* @property string $number
|
* @property string $number
|
||||||
* @property int $company_id
|
* @property int $company_id
|
||||||
* @property int $id
|
* @property int $id
|
||||||
|
* @property int $user_id
|
||||||
|
* @property int @assigned_user_id
|
||||||
* @property \App\Models\Company $company
|
* @property \App\Models\Company $company
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company()
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\BelongsTo|\Awobaz\Compoships\Database\Eloquent\Relations\BelongsTo|\App\Models\Company company()
|
||||||
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\HasMany|BaseModel orderBy()
|
* @method static \Illuminate\Database\Eloquent\Builder|BaseModel|Illuminate\Database\Eloquent\Relations\HasMany|BaseModel orderBy()
|
||||||
|
@ -57,7 +57,7 @@ class EmailStats
|
|||||||
* Iterates through a list of companies
|
* Iterates through a list of companies
|
||||||
* and flushes the email sent data.
|
* and flushes the email sent data.
|
||||||
*
|
*
|
||||||
* @param Collection $companies The company key
|
* @param \Illuminate\Database\Eloquent\Collection<\App\Models\Company> $companies The company key
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public static function clearCompanies($companies)
|
public static function clearCompanies($companies)
|
||||||
|
@ -49,7 +49,7 @@ class Helpers
|
|||||||
* @param mixed|null $custom_fields
|
* @param mixed|null $custom_fields
|
||||||
* @param mixed $field
|
* @param mixed $field
|
||||||
* @param mixed $value
|
* @param mixed $value
|
||||||
* @param \App\Models\Client|null $client
|
* @param \App\Models\Client|null $entity
|
||||||
*
|
*
|
||||||
* @return null|string
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
@ -143,7 +143,7 @@ class Helpers
|
|||||||
* Process reserved keywords on PDF.
|
* Process reserved keywords on PDF.
|
||||||
*
|
*
|
||||||
* @param string $value
|
* @param string $value
|
||||||
* @param Client|Company|Vendor $entity
|
* @param \App\Models\Client|\App\Models\Company|\App\Models\Vendor $entity
|
||||||
* @param null|Carbon $currentDateTime
|
* @param null|Carbon $currentDateTime
|
||||||
* @return null|string
|
* @return null|string
|
||||||
*/
|
*/
|
||||||
|
@ -64,7 +64,7 @@ class PaymentHtmlEngine
|
|||||||
$data['$amount'] = &$data['$payment.amount'];
|
$data['$amount'] = &$data['$payment.amount'];
|
||||||
$data['$payment.date'] = ['value' => $this->translateDate($this->payment->date, $this->client->date_format(), $this->client->locale()), 'label' => ctrans('texts.payment_date')];
|
$data['$payment.date'] = ['value' => $this->translateDate($this->payment->date, $this->client->date_format(), $this->client->locale()), 'label' => ctrans('texts.payment_date')];
|
||||||
$data['$transaction_reference'] = ['value' => $this->payment->transaction_reference, 'label' => ctrans('texts.transaction_reference')];
|
$data['$transaction_reference'] = ['value' => $this->payment->transaction_reference, 'label' => ctrans('texts.transaction_reference')];
|
||||||
$data['$public_notes'] = ['value' => $this->payment->public_notes, 'label' => ctrans('texts.notes')];
|
// $data['$public_notes'] = ['value' => $this->payment->public_notes, 'label' => ctrans('texts.notes')];
|
||||||
|
|
||||||
$data['$payment1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment1', $this->payment->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment1')];
|
$data['$payment1'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment1', $this->payment->custom_value1, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment1')];
|
||||||
$data['$payment2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment2', $this->payment->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment2')];
|
$data['$payment2'] = ['value' => $this->helpers->formatCustomFieldValue($this->company->custom_fields, 'payment2', $this->payment->custom_value2, $this->client) ?: ' ', 'label' => $this->helpers->makeCustomField($this->company->custom_fields, 'payment2')];
|
||||||
|
@ -50,8 +50,10 @@ class TemplateEngine
|
|||||||
|
|
||||||
public $template;
|
public $template;
|
||||||
|
|
||||||
|
/** @var \App\Models\Invoice | \App\Models\Quote | \App\Models\Credit | \App\Models\PurchaseOrder | null $entity_obj **/
|
||||||
private $entity_obj;
|
private $entity_obj;
|
||||||
|
|
||||||
|
/** @var \App\Models\Company | \App\Models\Client | null $settings_entity **/
|
||||||
private $settings_entity;
|
private $settings_entity;
|
||||||
|
|
||||||
private $settings;
|
private $settings;
|
||||||
@ -117,14 +119,17 @@ class TemplateEngine
|
|||||||
|
|
||||||
private function setSettingsObject()
|
private function setSettingsObject()
|
||||||
{
|
{
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
if ($this->entity == 'purchaseOrder' || $this->entity == 'purchase_order') {
|
if ($this->entity == 'purchaseOrder' || $this->entity == 'purchase_order') {
|
||||||
$this->settings_entity = auth()->user()->company();
|
$this->settings_entity = $user->company();
|
||||||
$this->settings = $this->settings_entity->settings;
|
$this->settings = $this->settings_entity->settings;
|
||||||
} elseif ($this->entity_obj->client()->exists()) {
|
} elseif ($this->entity_obj->client()->exists()) {
|
||||||
$this->settings_entity = $this->entity_obj->client;
|
$this->settings_entity = $this->entity_obj->client;
|
||||||
$this->settings = $this->settings_entity->getMergedSettings();
|
$this->settings = $this->settings_entity->getMergedSettings();
|
||||||
} else {
|
} else {
|
||||||
$this->settings_entity = auth()->user()->company();
|
$this->settings_entity = $user->company();
|
||||||
$this->settings = $this->settings_entity->settings;
|
$this->settings = $this->settings_entity->settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,13 +224,16 @@ class TemplateEngine
|
|||||||
|
|
||||||
private function renderTemplate()
|
private function renderTemplate()
|
||||||
{
|
{
|
||||||
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
/* wrapper */
|
/* wrapper */
|
||||||
$email_style = $this->settings_entity->getSetting('email_style');
|
$email_style = $this->settings_entity->getSetting('email_style');
|
||||||
|
|
||||||
$data['title'] = '';
|
$data['title'] = '';
|
||||||
$data['body'] = '$body';
|
$data['body'] = '$body';
|
||||||
$data['footer'] = '';
|
$data['footer'] = '';
|
||||||
$data['logo'] = auth()->user()->company()->present()->logo();
|
$data['logo'] = $user->company()->present()->logo();
|
||||||
|
|
||||||
if ($this->entity_obj->client()->exists()) {
|
if ($this->entity_obj->client()->exists()) {
|
||||||
$data = array_merge($data, Helpers::sharedEmailVariables($this->entity_obj->client));
|
$data = array_merge($data, Helpers::sharedEmailVariables($this->entity_obj->client));
|
||||||
@ -284,16 +292,19 @@ class TemplateEngine
|
|||||||
|
|
||||||
DB::connection(config('database.default'))->beginTransaction();
|
DB::connection(config('database.default'))->beginTransaction();
|
||||||
|
|
||||||
$vendor = false;
|
/** @var \App\Models\User $user */
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
$vendor = false;
|
||||||
|
/** @var \App\Models\Client $client */
|
||||||
$client = Client::factory()->create([
|
$client = Client::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$contact = ClientContact::factory()->create([
|
$contact = ClientContact::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
'is_primary' => 1,
|
'is_primary' => 1,
|
||||||
'send_email' => true,
|
'send_email' => true,
|
||||||
@ -301,26 +312,28 @@ class TemplateEngine
|
|||||||
|
|
||||||
if ($this->entity == 'payment') {
|
if ($this->entity == 'payment') {
|
||||||
$this->entity_obj = Payment::factory()->create([
|
$this->entity_obj = Payment::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
'amount' => 10,
|
'amount' => 10,
|
||||||
'applied' => 10,
|
'applied' => 10,
|
||||||
'refunded' => 5,
|
'refunded' => 5,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
/** @var \App\Models\Invoice $invoice */
|
||||||
$invoice = Invoice::factory()->create([
|
$invoice = Invoice::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
'amount' => 10,
|
'amount' => 10,
|
||||||
'balance' => 10,
|
'balance' => 10,
|
||||||
'number' => rand(1, 10000)
|
'number' => rand(1, 10000)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
/** @var \App\Models\InvoiceInvitation $invitation */
|
||||||
$invitation = InvoiceInvitation::factory()->create([
|
$invitation = InvoiceInvitation::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
'invoice_id' => $invoice->id,
|
'invoice_id' => $invoice->id,
|
||||||
'client_contact_id' => $contact->id,
|
'client_contact_id' => $contact->id,
|
||||||
]);
|
]);
|
||||||
@ -332,16 +345,16 @@ class TemplateEngine
|
|||||||
|
|
||||||
if (!$this->entity || $this->entity == 'invoice') {
|
if (!$this->entity || $this->entity == 'invoice') {
|
||||||
$this->entity_obj = Invoice::factory()->create([
|
$this->entity_obj = Invoice::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
'amount' => '10',
|
'amount' => '10',
|
||||||
'balance' => '10',
|
'balance' => '10',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$invitation = InvoiceInvitation::factory()->create([
|
$invitation = InvoiceInvitation::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
'invoice_id' => $this->entity_obj->id,
|
'invoice_id' => $this->entity_obj->id,
|
||||||
'client_contact_id' => $contact->id,
|
'client_contact_id' => $contact->id,
|
||||||
]);
|
]);
|
||||||
@ -349,14 +362,14 @@ class TemplateEngine
|
|||||||
|
|
||||||
if ($this->entity == 'quote') {
|
if ($this->entity == 'quote') {
|
||||||
$this->entity_obj = Quote::factory()->create([
|
$this->entity_obj = Quote::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
'client_id' => $client->id,
|
'client_id' => $client->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$invitation = QuoteInvitation::factory()->create([
|
$invitation = QuoteInvitation::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
'quote_id' => $this->entity_obj->id,
|
'quote_id' => $this->entity_obj->id,
|
||||||
'client_contact_id' => $contact->id,
|
'client_contact_id' => $contact->id,
|
||||||
]);
|
]);
|
||||||
@ -364,13 +377,13 @@ class TemplateEngine
|
|||||||
|
|
||||||
if ($this->entity == 'purchaseOrder') {
|
if ($this->entity == 'purchaseOrder') {
|
||||||
$vendor = Vendor::factory()->create([
|
$vendor = Vendor::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$contact = VendorContact::factory()->create([
|
$contact = VendorContact::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
'vendor_id' => $vendor->id,
|
'vendor_id' => $vendor->id,
|
||||||
'is_primary' => 1,
|
'is_primary' => 1,
|
||||||
'send_email' => true,
|
'send_email' => true,
|
||||||
@ -378,14 +391,14 @@ class TemplateEngine
|
|||||||
|
|
||||||
|
|
||||||
$this->entity_obj = PurchaseOrder::factory()->create([
|
$this->entity_obj = PurchaseOrder::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
'vendor_id' => $vendor->id,
|
'vendor_id' => $vendor->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$invitation = PurchaseOrderInvitation::factory()->create([
|
$invitation = PurchaseOrderInvitation::factory()->create([
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => $user->id,
|
||||||
'company_id' => auth()->user()->company()->id,
|
'company_id' => $user->company()->id,
|
||||||
'purchase_order_id' => $this->entity_obj->id,
|
'purchase_order_id' => $this->entity_obj->id,
|
||||||
'vendor_contact_id' => $contact->id,
|
'vendor_contact_id' => $contact->id,
|
||||||
]);
|
]);
|
||||||
@ -394,16 +407,16 @@ class TemplateEngine
|
|||||||
if ($vendor) {
|
if ($vendor) {
|
||||||
$this->entity_obj->setRelation('invitations', $invitation);
|
$this->entity_obj->setRelation('invitations', $invitation);
|
||||||
$this->entity_obj->setRelation('vendor', $vendor);
|
$this->entity_obj->setRelation('vendor', $vendor);
|
||||||
$this->entity_obj->setRelation('company', auth()->user()->company());
|
$this->entity_obj->setRelation('company', $user->company());
|
||||||
$this->entity_obj->load('vendor');
|
$this->entity_obj->load('vendor');
|
||||||
$vendor->setRelation('company', auth()->user()->company());
|
$vendor->setRelation('company', $user->company());
|
||||||
$vendor->load('company');
|
$vendor->load('company');
|
||||||
} else {
|
} else {
|
||||||
$this->entity_obj->setRelation('invitations', $invitation);
|
$this->entity_obj->setRelation('invitations', $invitation);
|
||||||
$this->entity_obj->setRelation('client', $client);
|
$this->entity_obj->setRelation('client', $client);
|
||||||
$this->entity_obj->setRelation('company', auth()->user()->company());
|
$this->entity_obj->setRelation('company', $user->company());
|
||||||
$this->entity_obj->load('client');
|
$this->entity_obj->load('client');
|
||||||
$client->setRelation('company', auth()->user()->company());
|
$client->setRelation('company', $user->company());
|
||||||
$client->load('company');
|
$client->load('company');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -650,7 +650,7 @@ trait GeneratesConvertedQuoteCounter
|
|||||||
$replace[] = str_pad(($user_id), 2, '0', STR_PAD_LEFT);
|
$replace[] = str_pad(($user_id), 2, '0', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
$matches = false;
|
$matches = [];
|
||||||
preg_match('/{\$date:(.*?)}/', $pattern, $matches);
|
preg_match('/{\$date:(.*?)}/', $pattern, $matches);
|
||||||
if (count($matches) > 1) {
|
if (count($matches) > 1) {
|
||||||
$format = $matches[1];
|
$format = $matches[1];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user