diff --git a/app/Listeners/Invoice/CreateInvoiceActivity.php b/app/Listeners/Invoice/CreateInvoiceActivity.php index 991a095f3..062494a08 100644 --- a/app/Listeners/Invoice/CreateInvoiceActivity.php +++ b/app/Listeners/Invoice/CreateInvoiceActivity.php @@ -21,6 +21,8 @@ class CreateInvoiceActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/InvoiceArchivedActivity.php b/app/Listeners/Invoice/InvoiceArchivedActivity.php index ff4800f41..1ceff8ede 100644 --- a/app/Listeners/Invoice/InvoiceArchivedActivity.php +++ b/app/Listeners/Invoice/InvoiceArchivedActivity.php @@ -21,6 +21,8 @@ class InvoiceArchivedActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/InvoiceCancelledActivity.php b/app/Listeners/Invoice/InvoiceCancelledActivity.php index 80f1f55c7..0e50683a3 100644 --- a/app/Listeners/Invoice/InvoiceCancelledActivity.php +++ b/app/Listeners/Invoice/InvoiceCancelledActivity.php @@ -21,6 +21,8 @@ class InvoiceCancelledActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/InvoiceCreatedNotification.php b/app/Listeners/Invoice/InvoiceCreatedNotification.php index 8d1ed9b38..4f6d117f8 100644 --- a/app/Listeners/Invoice/InvoiceCreatedNotification.php +++ b/app/Listeners/Invoice/InvoiceCreatedNotification.php @@ -24,6 +24,8 @@ class InvoiceCreatedNotification implements ShouldQueue { use UserNotifies; + public $delay = 5; + public function __construct() { } diff --git a/app/Listeners/Invoice/InvoiceDeletedActivity.php b/app/Listeners/Invoice/InvoiceDeletedActivity.php index f7bed8b89..cdaf1d335 100644 --- a/app/Listeners/Invoice/InvoiceDeletedActivity.php +++ b/app/Listeners/Invoice/InvoiceDeletedActivity.php @@ -21,6 +21,8 @@ class InvoiceDeletedActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/InvoiceEmailActivity.php b/app/Listeners/Invoice/InvoiceEmailActivity.php index 7515709a2..28d425395 100644 --- a/app/Listeners/Invoice/InvoiceEmailActivity.php +++ b/app/Listeners/Invoice/InvoiceEmailActivity.php @@ -21,6 +21,8 @@ class InvoiceEmailActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/InvoiceEmailFailedActivity.php b/app/Listeners/Invoice/InvoiceEmailFailedActivity.php index 530c4929e..72a306b34 100644 --- a/app/Listeners/Invoice/InvoiceEmailFailedActivity.php +++ b/app/Listeners/Invoice/InvoiceEmailFailedActivity.php @@ -21,6 +21,8 @@ class InvoiceEmailFailedActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/InvoiceEmailedNotification.php b/app/Listeners/Invoice/InvoiceEmailedNotification.php index 3918c630f..dd1f02c40 100644 --- a/app/Listeners/Invoice/InvoiceEmailedNotification.php +++ b/app/Listeners/Invoice/InvoiceEmailedNotification.php @@ -24,6 +24,8 @@ class InvoiceEmailedNotification implements ShouldQueue { use UserNotifies; + public $delay = 5; + public function __construct() { } diff --git a/app/Listeners/Invoice/InvoiceFailedEmailNotification.php b/app/Listeners/Invoice/InvoiceFailedEmailNotification.php index ac89010ca..5603e9450 100644 --- a/app/Listeners/Invoice/InvoiceFailedEmailNotification.php +++ b/app/Listeners/Invoice/InvoiceFailedEmailNotification.php @@ -24,6 +24,8 @@ class InvoiceFailedEmailNotification { use UserNotifies; + public $delay = 5; + public function __construct() { } diff --git a/app/Listeners/Invoice/InvoicePaidActivity.php b/app/Listeners/Invoice/InvoicePaidActivity.php index c1b9e6878..5bc5d42a6 100644 --- a/app/Listeners/Invoice/InvoicePaidActivity.php +++ b/app/Listeners/Invoice/InvoicePaidActivity.php @@ -21,6 +21,8 @@ class InvoicePaidActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/InvoiceReminderEmailActivity.php b/app/Listeners/Invoice/InvoiceReminderEmailActivity.php index aba48ce03..e2a197339 100644 --- a/app/Listeners/Invoice/InvoiceReminderEmailActivity.php +++ b/app/Listeners/Invoice/InvoiceReminderEmailActivity.php @@ -20,6 +20,8 @@ class InvoiceReminderEmailActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/InvoiceRestoredActivity.php b/app/Listeners/Invoice/InvoiceRestoredActivity.php index b0671f45f..fcf30eaeb 100644 --- a/app/Listeners/Invoice/InvoiceRestoredActivity.php +++ b/app/Listeners/Invoice/InvoiceRestoredActivity.php @@ -21,6 +21,8 @@ class InvoiceRestoredActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/InvoiceReversedActivity.php b/app/Listeners/Invoice/InvoiceReversedActivity.php index b7b26ba33..671d1be98 100644 --- a/app/Listeners/Invoice/InvoiceReversedActivity.php +++ b/app/Listeners/Invoice/InvoiceReversedActivity.php @@ -21,6 +21,8 @@ class InvoiceReversedActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/InvoiceViewedActivity.php b/app/Listeners/Invoice/InvoiceViewedActivity.php index c876b28fd..091d3f53b 100644 --- a/app/Listeners/Invoice/InvoiceViewedActivity.php +++ b/app/Listeners/Invoice/InvoiceViewedActivity.php @@ -21,6 +21,8 @@ class InvoiceViewedActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/UpdateInvoiceActivity.php b/app/Listeners/Invoice/UpdateInvoiceActivity.php index 232dc69b0..0228d6de5 100644 --- a/app/Listeners/Invoice/UpdateInvoiceActivity.php +++ b/app/Listeners/Invoice/UpdateInvoiceActivity.php @@ -21,6 +21,8 @@ class UpdateInvoiceActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Invoice/UpdateInvoiceInvitations.php b/app/Listeners/Invoice/UpdateInvoiceInvitations.php index 8a0ef7173..55c1c6468 100644 --- a/app/Listeners/Invoice/UpdateInvoiceInvitations.php +++ b/app/Listeners/Invoice/UpdateInvoiceInvitations.php @@ -16,6 +16,9 @@ use Illuminate\Contracts\Queue\ShouldQueue; class UpdateInvoiceInvitations implements ShouldQueue { + + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Payment/PaymentEmailFailureActivity.php b/app/Listeners/Payment/PaymentEmailFailureActivity.php index afd629270..873d70ac1 100644 --- a/app/Listeners/Payment/PaymentEmailFailureActivity.php +++ b/app/Listeners/Payment/PaymentEmailFailureActivity.php @@ -19,6 +19,8 @@ class PaymentEmailFailureActivity implements ShouldQueue { use UserNotifies; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Payment/PaymentEmailedActivity.php b/app/Listeners/Payment/PaymentEmailedActivity.php index dfef8e2d1..48bff9abf 100644 --- a/app/Listeners/Payment/PaymentEmailedActivity.php +++ b/app/Listeners/Payment/PaymentEmailedActivity.php @@ -17,6 +17,8 @@ use Illuminate\Contracts\Queue\ShouldQueue; class PaymentEmailedActivity implements ShouldQueue { + public $delay = 5; + use UserNotifies; /** diff --git a/app/Listeners/Payment/PaymentNotification.php b/app/Listeners/Payment/PaymentNotification.php index afe1d4057..81e5edced 100644 --- a/app/Listeners/Payment/PaymentNotification.php +++ b/app/Listeners/Payment/PaymentNotification.php @@ -26,6 +26,9 @@ class PaymentNotification implements ShouldQueue { use UserNotifies; + public $delay = 5; + + /** * Create the event listener. * diff --git a/app/Listeners/Payment/PaymentRestoredActivity.php b/app/Listeners/Payment/PaymentRestoredActivity.php index 5d89d7a8b..842980a25 100644 --- a/app/Listeners/Payment/PaymentRestoredActivity.php +++ b/app/Listeners/Payment/PaymentRestoredActivity.php @@ -21,6 +21,8 @@ class PaymentRestoredActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Quote/CreateQuoteInvitation.php b/app/Listeners/Quote/CreateQuoteInvitation.php index 9c5f08a25..d0d7d0797 100644 --- a/app/Listeners/Quote/CreateQuoteInvitation.php +++ b/app/Listeners/Quote/CreateQuoteInvitation.php @@ -21,6 +21,8 @@ class CreateQuoteInvitation implements ShouldQueue { use MakesHash; + public $delay = 5; + /** * Handle the event. * diff --git a/app/Listeners/Quote/QuoteApprovedActivity.php b/app/Listeners/Quote/QuoteApprovedActivity.php index 2e0c7c79f..f79ceec5e 100644 --- a/app/Listeners/Quote/QuoteApprovedActivity.php +++ b/app/Listeners/Quote/QuoteApprovedActivity.php @@ -21,6 +21,8 @@ class QuoteApprovedActivity implements ShouldQueue { protected $activity_repo; + public $delay = 5; + /** * Create the event listener. * diff --git a/app/Listeners/Quote/QuoteApprovedNotification.php b/app/Listeners/Quote/QuoteApprovedNotification.php index 591e2a8b8..f5911c48c 100644 --- a/app/Listeners/Quote/QuoteApprovedNotification.php +++ b/app/Listeners/Quote/QuoteApprovedNotification.php @@ -25,6 +25,8 @@ class QuoteApprovedNotification implements ShouldQueue { use UserNotifies; + public $delay = 5; + public function __construct() { } diff --git a/app/Listeners/Quote/QuoteApprovedWebhook.php b/app/Listeners/Quote/QuoteApprovedWebhook.php index a15ad3e75..c5a230a26 100644 --- a/app/Listeners/Quote/QuoteApprovedWebhook.php +++ b/app/Listeners/Quote/QuoteApprovedWebhook.php @@ -18,7 +18,8 @@ use Illuminate\Contracts\Queue\ShouldQueue; class QuoteApprovedWebhook implements ShouldQueue { - + public $delay = 5; + public function __construct() { } diff --git a/app/Listeners/Quote/QuoteArchivedActivity.php b/app/Listeners/Quote/QuoteArchivedActivity.php index 27add2bba..72f2d9c24 100644 --- a/app/Listeners/Quote/QuoteArchivedActivity.php +++ b/app/Listeners/Quote/QuoteArchivedActivity.php @@ -19,6 +19,8 @@ use stdClass; class QuoteArchivedActivity implements ShouldQueue { + public $delay = 5; + protected $activity_repo; /** diff --git a/app/Listeners/Quote/QuoteCreatedNotification.php b/app/Listeners/Quote/QuoteCreatedNotification.php index 0336bf036..3e9f68890 100644 --- a/app/Listeners/Quote/QuoteCreatedNotification.php +++ b/app/Listeners/Quote/QuoteCreatedNotification.php @@ -22,6 +22,8 @@ use Illuminate\Contracts\Queue\ShouldQueue; class QuoteCreatedNotification implements ShouldQueue { + public $delay = 5; + use UserNotifies; public function __construct() diff --git a/app/Listeners/Quote/QuoteDeletedActivity.php b/app/Listeners/Quote/QuoteDeletedActivity.php index a3b4d51f8..ea35eb093 100644 --- a/app/Listeners/Quote/QuoteDeletedActivity.php +++ b/app/Listeners/Quote/QuoteDeletedActivity.php @@ -19,6 +19,8 @@ use stdClass; class QuoteDeletedActivity implements ShouldQueue { + public $delay = 5; + protected $activity_repo; /** diff --git a/app/Listeners/Quote/QuoteEmailActivity.php b/app/Listeners/Quote/QuoteEmailActivity.php index 4dcf747e5..cfdb3b523 100644 --- a/app/Listeners/Quote/QuoteEmailActivity.php +++ b/app/Listeners/Quote/QuoteEmailActivity.php @@ -19,6 +19,8 @@ use stdClass; class QuoteEmailActivity implements ShouldQueue { + public $delay = 5; + protected $activity_repo; /** diff --git a/app/Listeners/Quote/QuoteEmailedNotification.php b/app/Listeners/Quote/QuoteEmailedNotification.php index 68d1264c1..bf7f348c7 100644 --- a/app/Listeners/Quote/QuoteEmailedNotification.php +++ b/app/Listeners/Quote/QuoteEmailedNotification.php @@ -22,6 +22,9 @@ use Illuminate\Contracts\Queue\ShouldQueue; class QuoteEmailedNotification implements ShouldQueue { + + public $delay = 5; + use UserNotifies; public function __construct() diff --git a/app/Listeners/Quote/QuoteRestoredActivity.php b/app/Listeners/Quote/QuoteRestoredActivity.php index 11dc0152a..b10d12cfb 100644 --- a/app/Listeners/Quote/QuoteRestoredActivity.php +++ b/app/Listeners/Quote/QuoteRestoredActivity.php @@ -19,6 +19,8 @@ use stdClass; class QuoteRestoredActivity implements ShouldQueue { + public $delay = 5; + protected $activity_repo; /** diff --git a/app/Listeners/Quote/QuoteViewedActivity.php b/app/Listeners/Quote/QuoteViewedActivity.php index 8c7041f26..5f5d7fd2f 100644 --- a/app/Listeners/Quote/QuoteViewedActivity.php +++ b/app/Listeners/Quote/QuoteViewedActivity.php @@ -19,6 +19,8 @@ use stdClass; class QuoteViewedActivity implements ShouldQueue { + public $delay = 5; + protected $activity_repo; /** diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index 3fb5e9142..435707719 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -91,9 +91,16 @@ class UpdateInvoicePayment ->workFlow() ->save(); - event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); }); + /* Remove the event updater from within the loop to prevent race conditions */ + + $invoices->each(function ($invoice) { + + event(new InvoiceWasUpdated($invoice, $invoice->company, Ninja::eventVars(auth()->user() ? auth()->user()->id : null))); + + }); + $this->payment->saveQuietly(); return $this->payment; diff --git a/app/Utils/Traits/MakesInvoiceValues.php b/app/Utils/Traits/MakesInvoiceValues.php index 040f6fbff..f284bcae9 100644 --- a/app/Utils/Traits/MakesInvoiceValues.php +++ b/app/Utils/Traits/MakesInvoiceValues.php @@ -330,17 +330,17 @@ trait MakesInvoiceValues // but that's no longer necessary. if (isset($item->tax_rate1)) { - $data[$key][$table_type.'.tax_rate1'] = round($item->tax_rate1, 2).'%'; + $data[$key][$table_type.'.tax_rate1'] = floatval($item->tax_rate1).'%'; $data[$key][$table_type.'.tax1'] = &$data[$key][$table_type.'.tax_rate1']; } if (isset($item->tax_rate2)) { - $data[$key][$table_type.'.tax_rate2'] = round($item->tax_rate2, 2).'%'; + $data[$key][$table_type.'.tax_rate2'] = floatval($item->tax_rate2).'%'; $data[$key][$table_type.'.tax2'] = &$data[$key][$table_type.'.tax_rate2']; } if (isset($item->tax_rate3)) { - $data[$key][$table_type.'.tax_rate3'] = round($item->tax_rate3, 2).'%'; + $data[$key][$table_type.'.tax_rate3'] = floatval($item->tax_rate3).'%'; $data[$key][$table_type.'.tax3'] = &$data[$key][$table_type.'.tax_rate3']; } diff --git a/tests/Unit/RedisVsDatabaseTest.php b/tests/Unit/RedisVsDatabaseTest.php index f7b1b7674..8a67f10fd 100644 --- a/tests/Unit/RedisVsDatabaseTest.php +++ b/tests/Unit/RedisVsDatabaseTest.php @@ -38,12 +38,11 @@ class RedisVsDatabaseTest extends TestCase $currencies = Cache::get('currencies'); - $currency = $currencies->filter(function ($item) { + $currencies->filter(function ($item) { return $item->id == 17; })->first(); - - $total_time = microtime(true) - $start; + nlog(microtime(true) - $start); $this->assertTrue(true); // nlog($total_time); @@ -57,8 +56,7 @@ class RedisVsDatabaseTest extends TestCase $currency = Currency::find(17); - $total_time = microtime(true) - $start; - + nlog(microtime(true) - $start); $this->assertTrue(true); // nlog($total_time);