Merge branch 'dillon/39-crm-changes' into development

This commit is contained in:
Dillon
2023-08-05 00:14:01 +08:00
+8 -6
View File
@@ -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(),