diff --git a/app/Classes/Jobs/UpdatePerfexCRM.php b/app/Classes/Jobs/UpdatePerfexCRM.php index 83e91df4..65d40126 100644 --- a/app/Classes/Jobs/UpdatePerfexCRM.php +++ b/app/Classes/Jobs/UpdatePerfexCRM.php @@ -26,28 +26,30 @@ class UpdatePerfexCRM implements ShouldQueue private $transaction; /** @var Boolean|null */ - private $shouldCreateInvoiceWithPayment; + private $shouldCreateInvoice; /** * @param UpdatePerfexCRMObject $updatePerfexCRMObject * @param $transaction - * @param bool|null $shouldCreateInvoiceWithPayment + * @param bool|null $shouldCreateInvoice */ - public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, ?bool $shouldCreateInvoiceWithPayment = false) + public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, ?bool $shouldCreateInvoice = false) { $this->updatePerfexCRMObject = $updatePerfexCRMObject; $this->transaction = $transaction; - $this->shouldCreateInvoiceWithPayment = $shouldCreateInvoiceWithPayment; + $this->shouldCreateInvoice = $shouldCreateInvoice; } public function handle() { //To use invoice as a reference to decide whether more tasks should be created - $this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceIdOrCreateInvoice()); + if($this->transaction != null && $this->shouldCreateInvoice){ + $this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceIdOrCreateInvoice()); + } $result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject); - if($this->transaction != null && $this->shouldCreateInvoiceWithPayment){ + if($this->transaction != null && $this->shouldCreateInvoice){ $updatePerfexCRMInvoiceObject = new UpdatePerfexCRMInvoiceObject( $this->updatePerfexCRMObject->getContactEmail(), $this->updatePerfexCRMObject->getProjectName(),