mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-28 17:03:59 +00:00
remove accounting tasks from auto generated tasks temporarily until ready
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\Processors\UpdatePerfexCRMProcessor;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
@@ -10,7 +11,7 @@ use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
|
||||
use PhpOffice\PhpSpreadsheet\Calculation\Logical\Boolean;
|
||||
|
||||
class UpdatePerfexCRM implements ShouldQueue
|
||||
{
|
||||
@@ -19,38 +20,40 @@ class UpdatePerfexCRM implements ShouldQueue
|
||||
/** @var UpdatePerfexCRMObject */
|
||||
private $updatePerfexCRMObject;
|
||||
|
||||
/** @var UpdatePerfexCRMInvoice */
|
||||
private $nextJob;
|
||||
|
||||
/** @var */
|
||||
/** @var Transaction */
|
||||
private $transaction;
|
||||
|
||||
/** @var Boolean */
|
||||
private $shouldCreateInvoice;
|
||||
|
||||
/**
|
||||
* UpdatePerfexCRM constructor.
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @param UpdatePerfexCRMInvoice $nextJob
|
||||
* @param $transaction
|
||||
* @param Transaction $transaction
|
||||
* @param Boolean $shouldCreateInvoice
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, $transaction, $nextJob)
|
||||
public function __construct(UpdatePerfexCRMObject $updatePerfexCRMObject, Transaction $transaction, Boolean $shouldCreateInvoice)
|
||||
{
|
||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||
$this->nextJob = $nextJob;
|
||||
$this->transaction = $transaction;
|
||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
||||
}
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$result = (App()->make(UpdatePerfexCRMProcessor::class))->execute($this->updatePerfexCRMObject);
|
||||
/** @var UpdatePerfexCRMInvoice $nextJob*/
|
||||
if($this->nextJob != null && $this->transaction != null){
|
||||
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
||||
if($this->transaction != null){
|
||||
$updatePerfexCRMInvoiceObject = new UpdatePerfexCRMInvoiceObject(
|
||||
$this->updatePerfexCRMObject->getContactEmail(),
|
||||
$this->updatePerfexCRMObject->getProjectName(),
|
||||
$result->projectId,
|
||||
$this->transaction,
|
||||
true
|
||||
);
|
||||
$this->nextJob::dispatch($updatePerfexCRMInvoiceOject);
|
||||
|
||||
if($this->shouldCreateInvoice) {
|
||||
UpdatePerfexCRMInvoice::dispatch($updatePerfexCRMInvoiceObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
|
||||
|
||||
/**
|
||||
* CreatePerfexCRMSingleTask constructor.
|
||||
* @param UpdatePerfexCRMInvoiceObject $createTaskPerfexCRMObject
|
||||
* @param UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject
|
||||
*/
|
||||
public function __construct(UpdatePerfexCRMInvoiceObject $updatePerfexCRMInvoiceObject)
|
||||
{
|
||||
|
||||
@@ -21,50 +21,28 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||
/** @var UpdatePerfexCRMObject */
|
||||
private $updatePerfexCRMObject;
|
||||
|
||||
/** @var UpdatePerfexCRM */
|
||||
private $nextJob1;
|
||||
|
||||
/** @var UpdatePerfexCRMInvoice */
|
||||
private $nextJob2;
|
||||
/** @var Boolean|null */
|
||||
private $shouldCreateInvoice;
|
||||
|
||||
/**
|
||||
* UpdatePerfexCRMPrelude constructor.
|
||||
* @param Transaction $transaction
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @param UpdatePerfexCRM $nextJob1
|
||||
* @param UpdatePerfexCRMInvoice $nextJob2
|
||||
* @param bool|null $shouldCreateInvoice
|
||||
*/
|
||||
public function __construct(Transaction $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, $nextJob1, $nextJob2)
|
||||
public function __construct(Transaction $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, ?bool $shouldCreateInvoice = false)
|
||||
{
|
||||
$this->transaction = $transaction;
|
||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||
$this->nextJob1 = $nextJob1;
|
||||
$this->nextJob2 = $nextJob2;
|
||||
$this->shouldCreateInvoice = $shouldCreateInvoice;
|
||||
}
|
||||
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$serviceTypeName = $this->transaction->owner->company->services()->where('id', $this->transaction->owner->service_id)->first()->name;
|
||||
$booking = $this->transaction->booking;
|
||||
$bank = $booking->bank;
|
||||
$bankDetails = $this->transaction->owner->service_id == 4 ?
|
||||
[
|
||||
'1688_username' => $bank->account_no,
|
||||
'1688_password' => $bank->holder_name,
|
||||
'payment_pin' => $bank->bank_branch,
|
||||
]:
|
||||
[
|
||||
'id' => $bank->id,
|
||||
'type' => $bank->type,
|
||||
'reference' => $bank->reference,
|
||||
'bank_name' => $bank->bank_name,
|
||||
'bank_branch' => $bank->bank_branch,
|
||||
'holder_name' => $bank->holder_name,
|
||||
'account_no' => $bank->account_no,
|
||||
'country_id' => $bank->country_id,
|
||||
'default' => $bank->default,
|
||||
'status' => $bank->status,
|
||||
];
|
||||
$bankDetails = $this->generateBankDetails($booking->bank);
|
||||
|
||||
$data = [
|
||||
'amount' => number_format($this->transaction->amount, 2, '.', ''),
|
||||
'currency' => $this->transaction->currency_id == 1 ? "MYR" : "CNY",
|
||||
@@ -75,14 +53,36 @@ class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||
'link_autocount_or' => 'https://docs.google.com/spreadsheets/d/1Q3rJBGQ9Bo04HZp5WR9zbLp7pIW2kfDYsabxG7JON-4/edit#gid=2013983170',
|
||||
];
|
||||
|
||||
|
||||
$result = $this->replacePlaceholders($this->updatePerfexCRMObject->getTasks(), $data);
|
||||
$this->updatePerfexCRMObject->setTasks($result);
|
||||
/** @var UpdatePerfexCRM $nextJob1 */
|
||||
/** @var UpdatePerfexCRMInvoice $nextJob2 */
|
||||
$this->nextJob1::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->nextJob2);
|
||||
|
||||
UpdatePerfexCRM::dispatch($this->updatePerfexCRMObject, $this->transaction, $this->shouldCreateInvoice);
|
||||
}
|
||||
|
||||
|
||||
private function generateBankDetails($bank): array
|
||||
{
|
||||
return $this->transaction->owner->service_id == 4 ?
|
||||
[
|
||||
'1688_username' => $bank->account_no,
|
||||
'1688_password' => $bank->holder_name,
|
||||
'payment_pin' => $bank->bank_branch,
|
||||
]:
|
||||
[
|
||||
'id' => $bank->id,
|
||||
'type' => $bank->type,
|
||||
'reference' => $bank->reference,
|
||||
'bank_name' => $bank->bank_name,
|
||||
'bank_branch' => $bank->bank_branch,
|
||||
'holder_name' => $bank->holder_name,
|
||||
'account_no' => $bank->account_no,
|
||||
'country_id' => $bank->country_id,
|
||||
'default' => $bank->default,
|
||||
'status' => $bank->status,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
function replacePlaceholders($template, $data, $prefix = '')
|
||||
{
|
||||
foreach ($template as $key => $value) {
|
||||
|
||||
@@ -163,9 +163,9 @@ class TransactionToPerfexCRMProcessorV2
|
||||
private function dispatchUpdateJob(Transaction $model, int $status, UpdatePerfexCRMObject $updatePerfexCRMObject)
|
||||
{
|
||||
if($status == ApprovalStatus::APPROVED){
|
||||
UpdatePerfexCRMPrelude::dispatch($model, $updatePerfexCRMObject, UpdatePerfexCRM::class, UpdatePerfexCRMInvoice::class);
|
||||
UpdatePerfexCRMPrelude::dispatch($model, $updatePerfexCRMObject, true);
|
||||
} elseif($status == ApprovalStatus::PENDING_VERIFICATION){
|
||||
UpdatePerfexCRMPrelude::dispatch($model, $updatePerfexCRMObject, UpdatePerfexCRM::class, null);
|
||||
UpdatePerfexCRMPrelude::dispatch($model, $updatePerfexCRMObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user