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

Activity for paid invoice

This commit is contained in:
David Bomba 2020-08-12 11:45:40 +10:00
parent a43b879f0d
commit 152e9b88f6
6 changed files with 25 additions and 20 deletions

View File

@ -13,11 +13,15 @@ namespace App\Listeners\Invoice;
use App\Libraries\MultiDB;
use App\Models\Activity;
use App\Models\ClientContact;
use App\Models\InvoiceInvitation;
use App\Repositories\ActivityRepository;
use App\Utils\Traits\MakesHash;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Support\Facades\Log;
class CreateInvoiceHtmlBackup implements ShouldQueue
class InvoicePaidActivity implements ShouldQueue
{
protected $activity_repo;
/**
@ -38,15 +42,14 @@ class CreateInvoiceHtmlBackup implements ShouldQueue
*/
public function handle($event)
{
MultiDB::setDB($event->company->db);
MultiDB::setDb($event->company->db);
$fields = new \stdClass;
$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->activity_type_id = Activity::MARK_SENT_INVOICE;
$fields->activity_type_id = Activity::PAID_INVOICE;
$this->activity_repo->save($fields, $event->invoice, $event->event_vars);
}

View File

@ -56,8 +56,9 @@ class Activity extends StaticModel
const ARCHIVE_EXPENSE=35;
const DELETE_EXPENSE=36;
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 CREATE_TASK=42;
const UPDATE_TASK=43;
@ -65,12 +66,13 @@ class Activity extends StaticModel
const DELETE_TASK=45;
const RESTORE_TASK=46;
const UPDATE_EXPENSE=47;
const CREATE_USER=48;
const UPDATE_USER=49;
const ARCHIVE_USER=50;
const DELETE_USER=51;
const RESTORE_USER=52;
const MARK_SENT_INVOICE=53;
const CREATE_USER=48; // only used in CreateUser::job
const UPDATE_USER=49; // not needed?
const ARCHIVE_USER=50; // not needed?
const DELETE_USER=51; // not needed?
const RESTORE_USER=52; // not needed?
const MARK_SENT_INVOICE=53; // not needed?
const PAID_INVOICE=54;
const EMAIL_INVOICE_FAILED=57;
const REVERSED_INVOICE=58;

View File

@ -86,6 +86,7 @@ use App\Listeners\Invoice\InvoiceDeletedActivity;
use App\Listeners\Invoice\InvoiceEmailActivity;
use App\Listeners\Invoice\InvoiceEmailFailedActivity;
use App\Listeners\Invoice\InvoiceEmailedNotification;
use App\Listeners\Invoice\InvoicePaidActivity;
use App\Listeners\Invoice\InvoiceRestoredActivity;
use App\Listeners\Invoice\InvoiceViewedActivity;
use App\Listeners\Invoice\UpdateInvoiceActivity;
@ -216,7 +217,7 @@ class EventServiceProvider extends ServiceProvider
// CreateInvoicePdf::class,
],
InvoiceWasPaid::class => [
// CreateInvoiceHtmlBackup::class,
InvoicePaidActivity::class,
],
InvoiceWasViewed::class => [
InvoiceViewedActivity::class,

View File

@ -11,6 +11,7 @@
namespace App\Services\Invoice;
use App\Events\Invoice\InvoiceWasPaid;
use App\Events\Payment\PaymentWasCreated;
use App\Factory\PaymentFactory;
use App\Models\Invoice;
@ -72,6 +73,7 @@ class MarkPaid extends AbstractService
/* Update Invoice balance */
event(new PaymentWasCreated($payment, $payment->company, Ninja::eventVars()));
event(new InvoiceWasPaid($this->invoice, $payment->company, Ninja::eventVars()));
$payment->ledger()
->updatePaymentBalance($payment->amount*-1);

View File

@ -11,7 +11,7 @@
namespace App\Services\Invoice;
use App\Events\Invoice\InvoiceWasMarkedSent;
use App\Events\Invoice\InvoiceWasUpdated;
use App\Models\Client;
use App\Models\Invoice;
use App\Services\AbstractService;
@ -41,8 +41,6 @@ class MarkSent extends AbstractService
$this->invoice->setReminder();
event(new InvoiceWasMarkedSent($this->invoice, $this->invoice->company, Ninja::eventVars()));
$this->invoice
->service()
->setStatus(Invoice::STATUS_SENT)
@ -54,6 +52,8 @@ class MarkSent extends AbstractService
$this->invoice->ledger()->updateInvoiceBalance($this->invoice->balance);
event(new InvoiceWasUpdated($this->invoice, $this->invoice->company, Ninja::eventVars()));
return $this->invoice->fresh();
}
}

View File

@ -3,7 +3,6 @@
use App\DataMapper\ClientSettings;
use App\DataMapper\CompanySettings;
use App\DataMapper\DefaultSettings;
use App\Events\Invoice\InvoiceWasMarkedSent;
use App\Events\Invoice\InvoiceWasUpdated;
use App\Events\Payment\PaymentWasCreated;
use App\Helpers\Invoice\InvoiceSum;
@ -200,8 +199,6 @@ class RandomDataSeeder extends Seeder
$invoice->ledger()->updateInvoiceBalance($invoice->balance);
event(new InvoiceWasMarkedSent($invoice, $company, Ninja::eventVars()));
if (rand(0, 1)) {
$payment = App\Models\Payment::create([
'date' => now(),