mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-04 01:24:36 -04:00
Activity for paid invoice
This commit is contained in:
parent
a43b879f0d
commit
152e9b88f6
@ -13,11 +13,15 @@ namespace App\Listeners\Invoice;
|
|||||||
|
|
||||||
use App\Libraries\MultiDB;
|
use App\Libraries\MultiDB;
|
||||||
use App\Models\Activity;
|
use App\Models\Activity;
|
||||||
|
use App\Models\ClientContact;
|
||||||
|
use App\Models\InvoiceInvitation;
|
||||||
use App\Repositories\ActivityRepository;
|
use App\Repositories\ActivityRepository;
|
||||||
|
use App\Utils\Traits\MakesHash;
|
||||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
use Illuminate\Queue\InteractsWithQueue;
|
use Illuminate\Queue\InteractsWithQueue;
|
||||||
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
class CreateInvoiceHtmlBackup implements ShouldQueue
|
class InvoicePaidActivity implements ShouldQueue
|
||||||
{
|
{
|
||||||
protected $activity_repo;
|
protected $activity_repo;
|
||||||
/**
|
/**
|
||||||
@ -38,15 +42,14 @@ class CreateInvoiceHtmlBackup implements ShouldQueue
|
|||||||
*/
|
*/
|
||||||
public function handle($event)
|
public function handle($event)
|
||||||
{
|
{
|
||||||
MultiDB::setDB($event->company->db);
|
MultiDB::setDb($event->company->db);
|
||||||
|
|
||||||
$fields = new \stdClass;
|
$fields = new \stdClass;
|
||||||
|
|
||||||
$fields->invoice_id = $event->invoice->id;
|
$fields->invoice_id = $event->invoice->id;
|
||||||
$fields->client_id = $event->invoice->client_id;
|
$fields->user_id = $event->invoice->user_id;
|
||||||
$fields->user_id = $event->invoice->user_id;
|
|
||||||
$fields->company_id = $event->invoice->company_id;
|
$fields->company_id = $event->invoice->company_id;
|
||||||
$fields->activity_type_id = Activity::MARK_SENT_INVOICE;
|
$fields->activity_type_id = Activity::PAID_INVOICE;
|
||||||
|
|
||||||
$this->activity_repo->save($fields, $event->invoice, $event->event_vars);
|
$this->activity_repo->save($fields, $event->invoice, $event->event_vars);
|
||||||
}
|
}
|
@ -56,8 +56,9 @@ class Activity extends StaticModel
|
|||||||
const ARCHIVE_EXPENSE=35;
|
const ARCHIVE_EXPENSE=35;
|
||||||
const DELETE_EXPENSE=36;
|
const DELETE_EXPENSE=36;
|
||||||
const RESTORE_EXPENSE=37;
|
const RESTORE_EXPENSE=37;
|
||||||
const VOIDED_PAYMENT=39;
|
|
||||||
const REFUNDED_PAYMENT=40;
|
const VOIDED_PAYMENT=39; //
|
||||||
|
const REFUNDED_PAYMENT=40; //
|
||||||
const FAILED_PAYMENT=41;
|
const FAILED_PAYMENT=41;
|
||||||
const CREATE_TASK=42;
|
const CREATE_TASK=42;
|
||||||
const UPDATE_TASK=43;
|
const UPDATE_TASK=43;
|
||||||
@ -65,12 +66,13 @@ class Activity extends StaticModel
|
|||||||
const DELETE_TASK=45;
|
const DELETE_TASK=45;
|
||||||
const RESTORE_TASK=46;
|
const RESTORE_TASK=46;
|
||||||
const UPDATE_EXPENSE=47;
|
const UPDATE_EXPENSE=47;
|
||||||
const CREATE_USER=48;
|
|
||||||
const UPDATE_USER=49;
|
const CREATE_USER=48; // only used in CreateUser::job
|
||||||
const ARCHIVE_USER=50;
|
const UPDATE_USER=49; // not needed?
|
||||||
const DELETE_USER=51;
|
const ARCHIVE_USER=50; // not needed?
|
||||||
const RESTORE_USER=52;
|
const DELETE_USER=51; // not needed?
|
||||||
const MARK_SENT_INVOICE=53;
|
const RESTORE_USER=52; // not needed?
|
||||||
|
const MARK_SENT_INVOICE=53; // not needed?
|
||||||
const PAID_INVOICE=54;
|
const PAID_INVOICE=54;
|
||||||
const EMAIL_INVOICE_FAILED=57;
|
const EMAIL_INVOICE_FAILED=57;
|
||||||
const REVERSED_INVOICE=58;
|
const REVERSED_INVOICE=58;
|
||||||
|
@ -86,6 +86,7 @@ use App\Listeners\Invoice\InvoiceDeletedActivity;
|
|||||||
use App\Listeners\Invoice\InvoiceEmailActivity;
|
use App\Listeners\Invoice\InvoiceEmailActivity;
|
||||||
use App\Listeners\Invoice\InvoiceEmailFailedActivity;
|
use App\Listeners\Invoice\InvoiceEmailFailedActivity;
|
||||||
use App\Listeners\Invoice\InvoiceEmailedNotification;
|
use App\Listeners\Invoice\InvoiceEmailedNotification;
|
||||||
|
use App\Listeners\Invoice\InvoicePaidActivity;
|
||||||
use App\Listeners\Invoice\InvoiceRestoredActivity;
|
use App\Listeners\Invoice\InvoiceRestoredActivity;
|
||||||
use App\Listeners\Invoice\InvoiceViewedActivity;
|
use App\Listeners\Invoice\InvoiceViewedActivity;
|
||||||
use App\Listeners\Invoice\UpdateInvoiceActivity;
|
use App\Listeners\Invoice\UpdateInvoiceActivity;
|
||||||
@ -216,7 +217,7 @@ class EventServiceProvider extends ServiceProvider
|
|||||||
// CreateInvoicePdf::class,
|
// CreateInvoicePdf::class,
|
||||||
],
|
],
|
||||||
InvoiceWasPaid::class => [
|
InvoiceWasPaid::class => [
|
||||||
// CreateInvoiceHtmlBackup::class,
|
InvoicePaidActivity::class,
|
||||||
],
|
],
|
||||||
InvoiceWasViewed::class => [
|
InvoiceWasViewed::class => [
|
||||||
InvoiceViewedActivity::class,
|
InvoiceViewedActivity::class,
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Invoice;
|
namespace App\Services\Invoice;
|
||||||
|
|
||||||
|
use App\Events\Invoice\InvoiceWasPaid;
|
||||||
use App\Events\Payment\PaymentWasCreated;
|
use App\Events\Payment\PaymentWasCreated;
|
||||||
use App\Factory\PaymentFactory;
|
use App\Factory\PaymentFactory;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
@ -72,6 +73,7 @@ class MarkPaid extends AbstractService
|
|||||||
|
|
||||||
/* Update Invoice balance */
|
/* Update Invoice balance */
|
||||||
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
|
||||||
|
event(new InvoiceWasPaid($this->invoice, $payment->company, Ninja::eventVars()));
|
||||||
|
|
||||||
$payment->ledger()
|
$payment->ledger()
|
||||||
->updatePaymentBalance($payment->amount*-1);
|
->updatePaymentBalance($payment->amount*-1);
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
|
|
||||||
namespace App\Services\Invoice;
|
namespace App\Services\Invoice;
|
||||||
|
|
||||||
use App\Events\Invoice\InvoiceWasMarkedSent;
|
use App\Events\Invoice\InvoiceWasUpdated;
|
||||||
use App\Models\Client;
|
use App\Models\Client;
|
||||||
use App\Models\Invoice;
|
use App\Models\Invoice;
|
||||||
use App\Services\AbstractService;
|
use App\Services\AbstractService;
|
||||||
@ -41,8 +41,6 @@ class MarkSent extends AbstractService
|
|||||||
|
|
||||||
$this->invoice->setReminder();
|
$this->invoice->setReminder();
|
||||||
|
|
||||||
event(new InvoiceWasMarkedSent($this->invoice, $this->invoice->company, Ninja::eventVars()));
|
|
||||||
|
|
||||||
$this->invoice
|
$this->invoice
|
||||||
->service()
|
->service()
|
||||||
->setStatus(Invoice::STATUS_SENT)
|
->setStatus(Invoice::STATUS_SENT)
|
||||||
@ -54,6 +52,8 @@ class MarkSent extends AbstractService
|
|||||||
|
|
||||||
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance);
|
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance);
|
||||||
|
|
||||||
|
event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars()));
|
||||||
|
|
||||||
return $this->invoice->fresh();
|
return $this->invoice->fresh();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
use App\DataMapper\ClientSettings;
|
use App\DataMapper\ClientSettings;
|
||||||
use App\DataMapper\CompanySettings;
|
use App\DataMapper\CompanySettings;
|
||||||
use App\DataMapper\DefaultSettings;
|
use App\DataMapper\DefaultSettings;
|
||||||
use App\Events\Invoice\InvoiceWasMarkedSent;
|
|
||||||
use App\Events\Invoice\InvoiceWasUpdated;
|
use App\Events\Invoice\InvoiceWasUpdated;
|
||||||
use App\Events\Payment\PaymentWasCreated;
|
use App\Events\Payment\PaymentWasCreated;
|
||||||
use App\Helpers\Invoice\InvoiceSum;
|
use App\Helpers\Invoice\InvoiceSum;
|
||||||
@ -200,8 +199,6 @@ class RandomDataSeeder extends Seeder
|
|||||||
|
|
||||||
$invoice->ledger()->updateInvoiceBalance($invoice->balance);
|
$invoice->ledger()->updateInvoiceBalance($invoice->balance);
|
||||||
|
|
||||||
event(new InvoiceWasMarkedSent($invoice, $company, Ninja::eventVars()));
|
|
||||||
|
|
||||||
if (rand(0, 1)) {
|
if (rand(0, 1)) {
|
||||||
$payment = App\Models\Payment::create([
|
$payment = App\Models\Payment::create([
|
||||||
'date' => now(),
|
'date' => now(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user