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

This commit is contained in:
Dillon
2023-08-02 20:44:49 +08:00
3 changed files with 20 additions and 20 deletions
+16 -16
View File
@@ -42,22 +42,9 @@ class UpdatePerfexCRM implements ShouldQueue
public function handle()
{
$invoiceId = 0;
//To use invoice as a reference to decide whether more tasks should be created
if($this->transaction != null){
$updatePerfexCRMInvoiceObject = new UpdatePerfexCRMInvoiceObject(
$this->updatePerfexCRMObject->getContactEmail(),
$this->updatePerfexCRMObject->getProjectName(),
'',
$this->transaction,
true
);
// UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceObject);
$invoiceId = (App()->make(CreatePerfexCRMInvoiceV2Processor::class))->execute($updatePerfexCRMInvoiceObject);
}
$this->updatePerfexCRMObject->setInvoiceId($this->getInvoiceId());
$this->updatePerfexCRMObject->setInvoiceId($invoiceId);
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
if($this->transaction != null && $this->shouldCreateInvoice){
$updatePerfexCRMInvoiceObject = new UpdatePerfexCRMInvoiceObject(
@@ -67,9 +54,22 @@ class UpdatePerfexCRM implements ShouldQueue
$this->transaction,
true
);
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceObject);
}
}
private function getInvoiceId(){
if($this->transaction != null){
$updatePerfexCRMInvoiceObject = new UpdatePerfexCRMInvoiceObject(
$this->updatePerfexCRMObject->getContactEmail(),
$this->updatePerfexCRMObject->getProjectName(),
'',
$this->transaction,
true
);
$invoiceId = (App()->make(CreatePerfexCRMInvoiceV2Processor::class))->execute($updatePerfexCRMInvoiceObject);
return $invoiceId;
}
return 0;
}
}
@@ -35,7 +35,7 @@ class UpdatePerfexCRMObject implements DataTransferObject
private $tasks;
/** @var int */
private $invoiceId;
private $invoiceId = 0;
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, int $invoiceId, array $milestoneNames, array $tasks)
@@ -39,13 +39,13 @@ class CreatePerfexCRMInvoiceV2Processor
public function execute(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
{
//invoiceId to be returned - fetch or create
$invoiceId = 0;
//get the client id
$customer = $this->fetchesPerfexCRMCustomer->execute($updatePerfexCRMInvoiceObject->getEmail());
$transaction = $updatePerfexCRMInvoiceObject->getTransaction();
//get the invoice id
$invoiceId = 0;
$number = $transaction->bill_no;
$prefix = "INV-";