mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-05-24 02:14:21 -04:00
Add client ids to activities
This commit is contained in:
parent
6ca56d3cb0
commit
41fdbd7978
@ -149,7 +149,6 @@ class BaseController extends Controller
|
||||
$query->with(
|
||||
[
|
||||
'company' => function ($query) use($updated_at){$query->where('updated_at', '>=', 0);},
|
||||
'company.activities' => function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
||||
'company.clients' =>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
||||
'company.tax_rates'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
||||
'company.groups'=>function ($query) use($updated_at){$query->where('updated_at', '>=', $updated_at);},
|
||||
|
@ -12,6 +12,7 @@
|
||||
namespace App\Http\Requests\Invoice;
|
||||
|
||||
use App\Http\Requests\Request;
|
||||
use App\Http\ValidationRules\Invoice\UniqueInvoiceNumberRule;
|
||||
use App\Models\ClientContact;
|
||||
use App\Models\Invoice;
|
||||
use App\Utils\Traits\CleanLineItems;
|
||||
@ -51,7 +52,8 @@ class StoreInvoiceRequest extends Request
|
||||
|
||||
$rules['invitations.*.client_contact_id'] = 'distinct';
|
||||
|
||||
|
||||
$rules['number'] = new UniqueInvoiceNumberRule($this->all());
|
||||
|
||||
return $rules;
|
||||
}
|
||||
|
||||
|
66
app/Http/ValidationRules/Invoice/UniqueInvoiceNumberRule.php
Normal file
66
app/Http/ValidationRules/Invoice/UniqueInvoiceNumberRule.php
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
/**
|
||||
* Invoice Ninja (https://invoiceninja.com)
|
||||
*
|
||||
* @link https://github.com/invoiceninja/invoiceninja source repository
|
||||
*
|
||||
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
||||
*
|
||||
* @license https://opensource.org/licenses/AAL
|
||||
*/
|
||||
|
||||
namespace App\Http\ValidationRules\Invoice;
|
||||
|
||||
use App\Libraries\MultiDB;
|
||||
use App\Models\Invoice;
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Validation\Rule;
|
||||
|
||||
/**
|
||||
* Class UniqueInvoiceNumberRule
|
||||
* @package App\Http\ValidationRules
|
||||
*/
|
||||
class UniqueInvoiceNumberRule implements Rule
|
||||
{
|
||||
public $input;
|
||||
|
||||
public function __construct($input)
|
||||
{
|
||||
$this->input = $input;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $attribute
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
public function passes($attribute, $value)
|
||||
{
|
||||
return $this->checkIfInvoiceNumberUnique(); //if it exists, return false!
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function message()
|
||||
{
|
||||
return "Invoice number already taken";
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $email
|
||||
*
|
||||
* //off,when_sent,when_paid
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function checkIfInvoiceNumberUnique($value) : bool
|
||||
{
|
||||
|
||||
return Invoice::where('client_id', $this->input['client_id'])
|
||||
->where('number', $this->input['number'])
|
||||
->withTrashed()
|
||||
->exists();
|
||||
|
||||
}
|
||||
}
|
@ -45,6 +45,8 @@ class CreatedCreditActivity implements ShouldQueue
|
||||
|
||||
$fields->credit_id = $event->credit->id;
|
||||
$fields->user_id = $event->credit->user_id;
|
||||
$fields->client_id = $event->credit->client_id;
|
||||
|
||||
$fields->company_id = $event->credit->company_id;
|
||||
$fields->activity_type_id = Activity::CREATE_CREDIT;
|
||||
|
||||
|
@ -44,6 +44,7 @@ class CreatedQuoteActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->quote_id = $event->quote->id;
|
||||
$fields->client_id = $event->quote->client_id;
|
||||
$fields->user_id = $event->quote->user_id;
|
||||
$fields->company_id = $event->quote->company_id;
|
||||
$fields->activity_type_id = Activity::CREATE_QUOTE;
|
||||
|
@ -46,7 +46,8 @@ class CreditArchivedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->payment_id = $event->credit->id;
|
||||
$fields->user_id = $event->credit->user_id;
|
||||
$fields->client_id = $event->credit->client_id;
|
||||
$fields->user_id = $event->credit->user_id;
|
||||
$fields->company_id = $event->credit->company_id;
|
||||
$fields->activity_type_id = Activity::ARCHIVE_CREDIT;
|
||||
|
||||
|
@ -50,6 +50,7 @@ class PaymentArchivedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->payment_id = $payment->id;
|
||||
$fields->client_id = $payment->client_id;
|
||||
$fields->user_id = $payment->user_id;
|
||||
$fields->company_id = $payment->company_id;
|
||||
$fields->activity_type_id = Activity::ARCHIVE_PAYMENT;
|
||||
|
@ -50,6 +50,7 @@ class PaymentCreatedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->payment_id = $payment->id;
|
||||
$fields->client_id = $payment->client_id;
|
||||
$fields->user_id = $payment->user_id;
|
||||
$fields->company_id = $payment->company_id;
|
||||
$fields->activity_type_id = Activity::CREATE_PAYMENT;
|
||||
|
@ -50,6 +50,7 @@ class PaymentDeletedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->payment_id = $payment->id;
|
||||
$fields->client_id = $payment->client_id;
|
||||
$fields->user_id = $payment->user_id;
|
||||
$fields->company_id = $payment->company_id;
|
||||
$fields->activity_type_id = Activity::DELETE_PAYMENT;
|
||||
|
@ -43,6 +43,7 @@ class PaymentRefundedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->client_id = $event->payment->id;
|
||||
$fields->client_id = $event->payment->client_id;
|
||||
$fields->user_id = $event->payment->user_id;
|
||||
$fields->company_id = $event->payment->company_id;
|
||||
$fields->activity_type_id = Activity::REFUNDED_PAYMENT;
|
||||
|
@ -50,6 +50,7 @@ class PaymentUpdatedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->payment_id = $payment->id;
|
||||
$fields->client_id = $payment->client_id;
|
||||
$fields->user_id = $payment->user_id;
|
||||
$fields->company_id = $payment->company_id;
|
||||
$fields->activity_type_id = Activity::UPDATE_PAYMENT;
|
||||
|
@ -50,7 +50,8 @@ class QuoteUpdatedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->payment_id = $quote->id;
|
||||
$fields->user_id = $quote->user_id;
|
||||
$fields->client_id = $quote->client_id;
|
||||
$fields->user_id = $quote->user_id;
|
||||
$fields->company_id = $quote->company_id;
|
||||
$fields->activity_type_id = Activity::UPDATE_QUOTE;
|
||||
|
||||
|
@ -44,6 +44,7 @@ class UpdatedCreditActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->credit_id = $event->credit->id;
|
||||
$fields->client_id = $event->credit->client_id;
|
||||
$fields->user_id = $event->credit->user_id;
|
||||
$fields->company_id = $event->credit->company_id;
|
||||
$fields->activity_type_id = Activity::UPDATE_CREDIT;
|
||||
|
@ -48,6 +48,7 @@ class CreditRestoredActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->credit_id = $event->credit->id;
|
||||
$fields->client_id = $event->credit->client_id;
|
||||
$fields->user_id = $event->credit->user_id;
|
||||
$fields->company_id = $event->credit->company_id;
|
||||
$fields->activity_type_id = Activity::RESTORE_CREDIT;
|
||||
|
@ -47,7 +47,8 @@ class CreateInvoiceActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->client_id = $event->invoice->client_id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->company_id = $event->invoice->company_id;
|
||||
$fields->activity_type_id = Activity::CREATE_INVOICE;
|
||||
|
||||
|
@ -43,7 +43,8 @@ class CreateInvoiceHtmlBackup implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->client_id = $event->invoice->client_id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->company_id = $event->invoice->company_id;
|
||||
$fields->activity_type_id = Activity::MARK_SENT_INVOICE;
|
||||
|
||||
|
@ -48,6 +48,7 @@ class InvoiceArchivedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
$fields->client_id = $event->invoice->client_id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->company_id = $event->invoice->company_id;
|
||||
$fields->activity_type_id = Activity::ARCHIVE_INVOICE;
|
||||
|
@ -48,7 +48,8 @@ class InvoiceCancelledActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->client_id = $event->invoice->client_id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->company_id = $event->invoice->company_id;
|
||||
$fields->activity_type_id = Activity::CANCELLED_INVOICE;
|
||||
|
||||
|
@ -48,7 +48,8 @@ class InvoiceDeletedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->client_id = $event->invoice->client_id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->company_id = $event->invoice->company_id;
|
||||
$fields->activity_type_id = Activity::DELETE_INVOICE;
|
||||
|
||||
|
@ -47,7 +47,8 @@ class InvoiceEmailFailedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->client_id = $event->invoice->client_id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->company_id = $event->invoice->company_id;
|
||||
$fields->activity_type_id = Activity::EMAIL_INVOICE_FAILED;
|
||||
|
||||
|
@ -48,7 +48,8 @@ class InvoiceRestoredActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->client_id = $event->invoice->client_id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->company_id = $event->invoice->company_id;
|
||||
$fields->activity_type_id = Activity::RESTORE_INVOICE;
|
||||
|
||||
|
@ -47,7 +47,8 @@ class InvoiceReversedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->invoice_id = $event->invoice->id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->client_id = $event->invoice->client_id;
|
||||
$fields->user_id = $event->invoice->user_id;
|
||||
$fields->company_id = $event->invoice->company_id;
|
||||
$fields->activity_type_id = Activity::REVERSED_INVOICE;
|
||||
|
||||
|
@ -48,7 +48,8 @@ class PaymentRestoredActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->payment_id = $event->payment->id;
|
||||
$fields->user_id = $event->payment->user_id;
|
||||
$fields->client_id = $event->payment->client_id;
|
||||
$fields->user_id = $event->payment->user_id;
|
||||
$fields->company_id = $event->payment->company_id;
|
||||
$fields->activity_type_id = Activity::RESTORE_PAYMENT;
|
||||
|
||||
|
@ -48,7 +48,8 @@ class QuoteApprovedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->quote_id = $event->quote->id;
|
||||
$fields->user_id = $event->quote->user_id;
|
||||
$fields->client_id = $event->quote->client_id;
|
||||
$fields->user_id = $event->quote->user_id;
|
||||
$fields->client_contact_id = $event->contact->id;
|
||||
$fields->company_id = $event->payment->company_id;
|
||||
$fields->activity_type_id = Activity::RESTORE_PAYMENT;
|
||||
|
@ -48,7 +48,8 @@ class QuoteArchivedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->quote_id = $event->quote->id;
|
||||
$fields->user_id = $event->quote->user_id;
|
||||
$fields->client_id = $event->quote->client_id;
|
||||
$fields->user_id = $event->quote->user_id;
|
||||
$fields->company_id = $event->quote->company_id;
|
||||
$fields->activity_type_id = Activity::ARCHIVE_QUOTE;
|
||||
|
||||
|
@ -48,7 +48,8 @@ class QuoteDeletedActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->quote_id = $event->quote->id;
|
||||
$fields->user_id = $event->quote->user_id;
|
||||
$fields->client_id = $event->quote->client_id;
|
||||
$fields->user_id = $event->quote->user_id;
|
||||
$fields->company_id = $event->quote->company_id;
|
||||
$fields->activity_type_id = Activity::DELETE_QUOTE;
|
||||
|
||||
|
@ -47,7 +47,8 @@ class QuoteEmailActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->quote_id = $event->invitation->quote->id;
|
||||
$fields->user_id = $event->invitation->quote->user_id;
|
||||
$fields->client_id = $event->invitation->quote->client_id;
|
||||
$fields->user_id = $event->invitation->quote->user_id;
|
||||
$fields->company_id = $event->invitation->quote->company_id;
|
||||
$fields->client_contact_id = $event->invitation->quote->client_contact_id;
|
||||
$fields->activity_type_id = Activity::EMAIL_QUOTE;
|
||||
|
@ -48,7 +48,8 @@ class QuoteRestoredActivity implements ShouldQueue
|
||||
$fields = new \stdClass;
|
||||
|
||||
$fields->quote_id = $event->quote->id;
|
||||
$fields->user_id = $event->quote->user_id;
|
||||
$fields->client_id = $event->quote->client_id;
|
||||
$fields->user_id = $event->quote->user_id;
|
||||
$fields->company_id = $event->quote->company_id;
|
||||
$fields->activity_type_id = Activity::RESTORE_QUOTE;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user