diff --git a/app/Listeners/Invoice/CreateInvoiceActivity.php b/app/Listeners/Invoice/CreateInvoiceActivity.php index 991a095f3118..062494a08de7 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 ff4800f41c4e..1ceff8ede006 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 80f1f55c7a11..0e50683a3ef3 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 8d1ed9b3864d..4f6d117f8176 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 f7bed8b89232..cdaf1d335c4b 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 7515709a2e1d..28d42539548e 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 530c4929e146..72a306b34483 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 3918c630f1da..dd1f02c4013d 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 ac89010cadeb..5603e9450a8d 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 c1b9e6878476..5bc5d42a6f62 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 aba48ce03c19..e2a197339f06 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 b0671f45f06d..fcf30eaeb3b3 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 b7b26ba33e17..671d1be98337 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 c876b28fd6da..091d3f53b301 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 232dc69b0fd3..0228d6de5ec2 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 8a0ef7173fed..55c1c6468264 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 afd62927001f..873d70ac1863 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 dfef8e2d1be1..48bff9abf00c 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 afe1d40571e5..81e5edced973 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 5d89d7a8b74b..842980a25a39 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 9c5f08a25430..d0d7d0797402 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 2e0c7c79f5a9..f79ceec5e8d9 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 591e2a8b8102..f5911c48cf05 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 a15ad3e7582e..c5a230a26b1e 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 27add2bbad15..72f2d9c2427c 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 0336bf036595..3e9f6889028c 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 a3b4d51f80ff..ea35eb093bac 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 4dcf747e595c..cfdb3b523e94 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 68d1264c11b6..bf7f348c7fab 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 11dc0152a8d0..b10d12cfb88b 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 8c7041f26a0c..5f5d7fd2ff6e 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 3fb5e91428ed..4357077196ed 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 040f6fbff646..f284bcae9458 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 f7b1b767466d..8a67f10fd6f9 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);