mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-05 18:52:44 +01:00
Credit events and listeners
This commit is contained in:
parent
8fa1bd5c7a
commit
cd5bebbe5f
41
app/Events/Credit/CreditWasArchived.php
Normal file
41
app/Events/Credit/CreditWasArchived.php
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<?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\Events\Credit;
|
||||||
|
|
||||||
|
use App\Models\Company;
|
||||||
|
use App\Models\Credit;
|
||||||
|
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||||
|
use Illuminate\Foundation\Events\Dispatchable;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
|
||||||
|
class CreditWasArchived
|
||||||
|
{
|
||||||
|
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||||
|
|
||||||
|
public $credit;
|
||||||
|
|
||||||
|
public $company;
|
||||||
|
|
||||||
|
public $event_vars;
|
||||||
|
/**
|
||||||
|
* Create a new event instance.
|
||||||
|
*
|
||||||
|
* @param Credit $credit
|
||||||
|
*/
|
||||||
|
public function __construct(Credit $credit, Company $company, array $event_vars)
|
||||||
|
{
|
||||||
|
$this->credit = $credit;
|
||||||
|
$this->company = $company;
|
||||||
|
$this->event_vars = $event_vars;
|
||||||
|
}
|
||||||
|
}
|
53
app/Listeners/Activity/CreatedCreditActivity.php
Normal file
53
app/Listeners/Activity/CreatedCreditActivity.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?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\Listeners\Activity;
|
||||||
|
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use App\Repositories\ActivityRepository;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
class CreatedCreditActivity implements ShouldQueue
|
||||||
|
{
|
||||||
|
protected $activity_repo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(ActivityRepository $activity_repo)
|
||||||
|
{
|
||||||
|
$this->activity_repo = $activity_repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
|
$fields = new \stdClass;
|
||||||
|
|
||||||
|
$fields->credit_id = $event->credit->id;
|
||||||
|
$fields->user_id = $event->credit->user_id;
|
||||||
|
$fields->company_id = $event->credit->company_id;
|
||||||
|
$fields->activity_type_id = Activity::CREATE_CREDIT;
|
||||||
|
|
||||||
|
$this->activity_repo->save($fields, $event->credit, $event->event_vars);
|
||||||
|
}
|
||||||
|
}
|
56
app/Listeners/Activity/CreditArchivedActivity.php
Normal file
56
app/Listeners/Activity/CreditArchivedActivity.php
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
<?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\Listeners\Activity;
|
||||||
|
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use App\Models\Invoice;
|
||||||
|
use App\Models\Payment;
|
||||||
|
use App\Repositories\ActivityRepository;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
class CreditArchivedActivity implements ShouldQueue
|
||||||
|
{
|
||||||
|
protected $activity_repo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(ActivityRepository $activity_repo)
|
||||||
|
{
|
||||||
|
$this->activity_repo = $activity_repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
|
$fields = new \stdClass;
|
||||||
|
|
||||||
|
$fields->payment_id = $event->credit->id;
|
||||||
|
$fields->user_id = $event->credit->user_id;
|
||||||
|
$fields->company_id = $event->credit->company_id;
|
||||||
|
$fields->activity_type_id = Activity::ARCHIVE_CREDIT;
|
||||||
|
|
||||||
|
$this->activity_repo->save($fields, $$event->credit, $event->event_vars);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
53
app/Listeners/Activity/UpdatedCreditActivity.php
Normal file
53
app/Listeners/Activity/UpdatedCreditActivity.php
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
<?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\Listeners\Activity;
|
||||||
|
|
||||||
|
use App\Libraries\MultiDB;
|
||||||
|
use App\Models\Activity;
|
||||||
|
use App\Repositories\ActivityRepository;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
|
||||||
|
class UpdatedCreditActivity implements ShouldQueue
|
||||||
|
{
|
||||||
|
protected $activity_repo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create the event listener.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function __construct(ActivityRepository $activity_repo)
|
||||||
|
{
|
||||||
|
$this->activity_repo = $activity_repo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle the event.
|
||||||
|
*
|
||||||
|
* @param object $event
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function handle($event)
|
||||||
|
{
|
||||||
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
|
$fields = new \stdClass;
|
||||||
|
|
||||||
|
$fields->credit_id = $event->credit->id;
|
||||||
|
$fields->user_id = $event->credit->user_id;
|
||||||
|
$fields->company_id = $event->credit->company_id;
|
||||||
|
$fields->activity_type_id = Activity::UPDATE_CREDIT;
|
||||||
|
|
||||||
|
$this->activity_repo->save($fields, $event->credit, $event->event_vars);
|
||||||
|
}
|
||||||
|
}
|
@ -28,8 +28,8 @@ class Activity extends StaticModel
|
|||||||
const UPDATE_PAYMENT=11; //
|
const UPDATE_PAYMENT=11; //
|
||||||
const ARCHIVE_PAYMENT=12; //
|
const ARCHIVE_PAYMENT=12; //
|
||||||
const DELETE_PAYMENT=13; //
|
const DELETE_PAYMENT=13; //
|
||||||
const CREATE_CREDIT=14;
|
const CREATE_CREDIT=14; //
|
||||||
const UPDATE_CREDIT=15;
|
const UPDATE_CREDIT=15; //
|
||||||
const ARCHIVE_CREDIT=16;
|
const ARCHIVE_CREDIT=16;
|
||||||
const DELETE_CREDIT=17;
|
const DELETE_CREDIT=17;
|
||||||
const CREATE_QUOTE=18;
|
const CREATE_QUOTE=18;
|
||||||
|
@ -21,8 +21,11 @@ use App\Events\Client\DesignWasRestored;
|
|||||||
use App\Events\Client\DesignWasUpdated;
|
use App\Events\Client\DesignWasUpdated;
|
||||||
use App\Events\Company\CompanyDocumentsDeleted;
|
use App\Events\Company\CompanyDocumentsDeleted;
|
||||||
use App\Events\Contact\ContactLoggedIn;
|
use App\Events\Contact\ContactLoggedIn;
|
||||||
|
use App\Events\Credit\CreditWasArchived;
|
||||||
|
use App\Events\Credit\CreditWasCreated;
|
||||||
use App\Events\Credit\CreditWasEmailedAndFailed;
|
use App\Events\Credit\CreditWasEmailedAndFailed;
|
||||||
use App\Events\Credit\CreditWasMarkedSent;
|
use App\Events\Credit\CreditWasMarkedSent;
|
||||||
|
use App\Events\Credit\CreditWasUpdated;
|
||||||
use App\Events\Design\DesignWasArchived;
|
use App\Events\Design\DesignWasArchived;
|
||||||
use App\Events\Invoice\InvoiceWasArchived;
|
use App\Events\Invoice\InvoiceWasArchived;
|
||||||
use App\Events\Invoice\InvoiceWasCancelled;
|
use App\Events\Invoice\InvoiceWasCancelled;
|
||||||
@ -47,6 +50,8 @@ use App\Events\User\UserWasCreated;
|
|||||||
use App\Events\User\UserWasDeleted;
|
use App\Events\User\UserWasDeleted;
|
||||||
use App\Listeners\Activity\ArchivedClientActivity;
|
use App\Listeners\Activity\ArchivedClientActivity;
|
||||||
use App\Listeners\Activity\CreatedClientActivity;
|
use App\Listeners\Activity\CreatedClientActivity;
|
||||||
|
use App\Listeners\Activity\CreatedCreditActivity;
|
||||||
|
use App\Listeners\Activity\CreditArchivedActivity;
|
||||||
use App\Listeners\Activity\DeleteClientActivity;
|
use App\Listeners\Activity\DeleteClientActivity;
|
||||||
use App\Listeners\Activity\PaymentCreatedActivity;
|
use App\Listeners\Activity\PaymentCreatedActivity;
|
||||||
use App\Listeners\Activity\PaymentDeletedActivity;
|
use App\Listeners\Activity\PaymentDeletedActivity;
|
||||||
@ -54,6 +59,7 @@ use App\Listeners\Activity\PaymentRefundedActivity;
|
|||||||
use App\Listeners\Activity\PaymentUpdatedActivity;
|
use App\Listeners\Activity\PaymentUpdatedActivity;
|
||||||
use App\Listeners\Activity\PaymentVoidedActivity;
|
use App\Listeners\Activity\PaymentVoidedActivity;
|
||||||
use App\Listeners\Activity\RestoreClientActivity;
|
use App\Listeners\Activity\RestoreClientActivity;
|
||||||
|
use App\Listeners\Activity\UpdatedCreditActivity;
|
||||||
use App\Listeners\Contact\UpdateContactLastLogin;
|
use App\Listeners\Contact\UpdateContactLastLogin;
|
||||||
use App\Listeners\Document\DeleteCompanyDocuments;
|
use App\Listeners\Document\DeleteCompanyDocuments;
|
||||||
use App\Listeners\Invoice\CreateInvoiceActivity;
|
use App\Listeners\Invoice\CreateInvoiceActivity;
|
||||||
@ -142,12 +148,21 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
],
|
],
|
||||||
DocumentWasRestored::class =>[
|
DocumentWasRestored::class =>[
|
||||||
],
|
],
|
||||||
|
CreditWasCreated::class => [
|
||||||
|
CreatedCreditActivity::class,
|
||||||
|
],
|
||||||
|
CreditWasUpdated::class => [
|
||||||
|
UpdatedCreditActivity::class,
|
||||||
|
],
|
||||||
CreditWasEmailedAndFailed::class => [
|
CreditWasEmailedAndFailed::class => [
|
||||||
],
|
],
|
||||||
CreditWasEmailed::class => [
|
CreditWasEmailed::class => [
|
||||||
],
|
],
|
||||||
CreditWasMarkedSent::class => [
|
CreditWasMarkedSent::class => [
|
||||||
],
|
],
|
||||||
|
CreditWasArchived::class => [
|
||||||
|
CreditArchivedActivity::class,
|
||||||
|
],
|
||||||
//Designs
|
//Designs
|
||||||
DesignWasArchived::class => [
|
DesignWasArchived::class => [
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user