mirror of
https://gitlab.com/CIEFWorldwideSdnBhd/exchange-2.0.git
synced 2026-08-19 04:23:55 +00:00
CRM Task with dynamic data
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
|
||||
namespace App\Classes\Jobs;
|
||||
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMObject;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Bus\Queueable;
|
||||
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||
use Illuminate\Foundation\Bus\Dispatchable;
|
||||
use Illuminate\Queue\InteractsWithQueue;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
|
||||
class UpdatePerfexCRMPrelude implements ShouldQueue
|
||||
{
|
||||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
|
||||
|
||||
/** @var Transaction */
|
||||
private $transaction;
|
||||
|
||||
/** @var UpdatePerfexCRMObject */
|
||||
private $updatePerfexCRMObject;
|
||||
|
||||
/** @var */
|
||||
private $nextJob;
|
||||
|
||||
/**
|
||||
* UpdatePerfexCRMPrelude constructor.
|
||||
* @param Transaction $transaction
|
||||
* @param UpdatePerfexCRMObject $updatePerfexCRMObject
|
||||
* @param $nextJob
|
||||
*/
|
||||
public function __construct(Transaction $transaction, UpdatePerfexCRMObject $updatePerfexCRMObject, $nextJob)
|
||||
{
|
||||
$this->transaction = $transaction;
|
||||
$this->updatePerfexCRMObject = $updatePerfexCRMObject;
|
||||
$this->nextJob = $nextJob;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
// //dd(json_encode($supplier));
|
||||
// // if($this->transaction->payment_method == PaymentMethodType::CASH)
|
||||
// $supplier = (App()->make(FetchesCompany::class))->execute(['id' => $this->transaction->receiver]);
|
||||
// $purchaseOrder = $booking->transactions()
|
||||
// ->where('type', TransactionType::PURCHASE_ORDER)
|
||||
// ->complete()
|
||||
// ->first();
|
||||
|
||||
$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,
|
||||
];
|
||||
$data = [
|
||||
'amount' => number_format($this->transaction->amount, 2, '.', ''),
|
||||
'currency' => $this->transaction->currency_id == 1 ? "MYR" : "CNY",
|
||||
'service_type' => $serviceTypeName,
|
||||
'bank_details' => $bankDetails,
|
||||
'link_transfer' => config('app.url').'/transfer/'.$this->transaction->owner->marking,
|
||||
'link_payments' => config('app.url').'/payments',
|
||||
'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);
|
||||
|
||||
//cief todo: cleanup
|
||||
// // Do some work here
|
||||
// $result = 'some result';
|
||||
|
||||
// // Return the result
|
||||
// return $result;
|
||||
|
||||
// dd(json_encode($this->updatePerfexCRMObject->getTasks()));
|
||||
// return $this->updatePerfexCRMObject;
|
||||
$this->nextJob::dispatch($this->updatePerfexCRMObject);
|
||||
}
|
||||
|
||||
// public function then($callback)
|
||||
// {
|
||||
// $result = $this->result;
|
||||
|
||||
// dd(json_encode($result));
|
||||
// // Execute the callback with the result
|
||||
// $callback($result);
|
||||
// }
|
||||
|
||||
function replacePlaceholders($template, $data, $prefix = '')
|
||||
{
|
||||
foreach ($template as $key => $value) {
|
||||
foreach ($data as $dataKey => $dataValue) {
|
||||
if (is_array($dataValue)) {
|
||||
$template[$key] = $this->replacePlaceholders($template[$key], $dataValue, $dataKey);
|
||||
} else {
|
||||
if ($prefix != '') {
|
||||
$template[$key] = str_replace('{' .$prefix. "." .$dataKey . '}', $dataValue, $template[$key]);
|
||||
} else {
|
||||
$template[$key] = str_replace('{' . $dataKey . '}', $dataValue, $template[$key]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $template;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,10 +32,10 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
private $milestoneNames;
|
||||
|
||||
/** @var array */
|
||||
private $taskNames;
|
||||
private $tasks;
|
||||
|
||||
|
||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, array $milestoneNames, array $taskNames)
|
||||
public function __construct(string $companyName, string $companyReference, string $contactName, string $contactEmail, string $bookingMarking, string $projectName, int $projectStatus, array $milestoneNames, array $tasks)
|
||||
{
|
||||
|
||||
$this->companyName = $companyName;
|
||||
@@ -46,7 +46,7 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
$this->projectName = $projectName;
|
||||
$this->projectStatus = $projectStatus;
|
||||
$this->milestoneNames = $milestoneNames;
|
||||
$this->taskNames = $taskNames;
|
||||
$this->tasks = $tasks;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,9 +116,14 @@ class UpdatePerfexCRMObject implements DataTransferObject
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getTaskNames(): array
|
||||
public function getTasks(): array
|
||||
{
|
||||
return $this->taskNames;
|
||||
return $this->tasks;
|
||||
}
|
||||
|
||||
public function setTasks($tasks)
|
||||
{
|
||||
$this->tasks = $tasks;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Classes\ValueObjects\Constants\PerfexCRMTaskStatus;
|
||||
use App\Classes\Modules\PerfexCRM\DataTransferObjects\UpdatePerfexCRMInvoiceObject;
|
||||
use App\Classes\Jobs\UpdatePerfexCRMInvoice;
|
||||
use App\Classes\Jobs\UpdatePerfexCRM;
|
||||
use App\Classes\Jobs\UpdatePerfexCRMPrelude;
|
||||
use App\Models\Transaction;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -114,7 +115,8 @@ class TransactionToPerfexCRMProcessor
|
||||
[],
|
||||
$tasks
|
||||
);
|
||||
UpdatePerfexCRM::dispatch($updatePerfexCRMObject);
|
||||
|
||||
UpdatePerfexCRMPrelude::dispatch($model, $updatePerfexCRMObject, UpdatePerfexCRM::class);
|
||||
}
|
||||
|
||||
$updatePerfexCRMInvoiceOject = new UpdatePerfexCRMInvoiceObject(
|
||||
|
||||
@@ -176,7 +176,7 @@ class UpdatePerfexCRMProcessor
|
||||
}
|
||||
}
|
||||
|
||||
$tasks = $updatePerfexCRMObject->getTaskNames();
|
||||
$tasks = $updatePerfexCRMObject->getTasks();
|
||||
if(count($tasks) > 0){
|
||||
|
||||
//Create tasks with milestone
|
||||
|
||||
@@ -17,17 +17,17 @@ class UpdatesPerfexCRMProject
|
||||
public function execute($project, int $status) {
|
||||
try{
|
||||
$data = [
|
||||
'name' => $project->name,
|
||||
'clientid' => $project->clientid,
|
||||
'name' => $project['name'],
|
||||
'clientid' => $project['clientid'],
|
||||
// 'rel_type' => 'customer',
|
||||
'billing_type' => 1,
|
||||
'start_date' => $project->start_date,
|
||||
'start_date' => $project['start_date'],
|
||||
'status' => $status
|
||||
];
|
||||
|
||||
$response = Http::asJson()->withHeaders([
|
||||
'authtoken' => config('perfexcrm.api_key')])
|
||||
->put(config('perfexcrm.base_url').'/api/projects/'.$project->id, $data);
|
||||
->put(config('perfexcrm.base_url').'/api/projects/'.$project['id'], $data);
|
||||
|
||||
if($response->successful()){
|
||||
$data = $response->json();
|
||||
|
||||
@@ -19,13 +19,8 @@ class PerfexCRMTasks
|
||||
public const TASK_1_DAY_TRANSFER_1 = [
|
||||
'name' => 'Map Bank Transaction Record',
|
||||
'description' => '○ Purpose: To map a transaction to bank transaction in the bank statement<br>
|
||||
○ Initial Status: <b>In Progress</b> <br>
|
||||
○ Deadline: If payment is created before 4:30 pm, it must be made on the same day. If payment is created after 4:30 pm, it must be made the next day <br>
|
||||
○ Responsible department: Accounts <br>
|
||||
○ Next step: Change the status of the Approve payment status to "In Progress" upon successful completion of the operation. <br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.** <br>
|
||||
○ Dependencies: None <br>
|
||||
○ Outcomes: Bank transaction is mapped successfully, allowing the next steps in the process to be initiated. <br>',
|
||||
○ Amount: RM {amount}<br>
|
||||
○ Link to order page: {link_transfer}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_1_DAY_TRANSFER_1',
|
||||
'on_task_completion' => 'TASK_1_DAY_TRANSFER_2',
|
||||
@@ -74,8 +69,7 @@ class PerfexCRMTasks
|
||||
];
|
||||
public const TASK_1_DAY_TRANSFER_3_1 = [
|
||||
'name' => 'Issue Exchange Autocount OR',
|
||||
'description' => '○ Purpose:
|
||||
○ Outcomes: An invoice will be issued in accounting software for the customer\'s payment.<br>',
|
||||
'description' => '○ {link_autocount_or} <br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_1_DAY_TRANSFER_3_1',
|
||||
'on_task_completion' => 'TASK_1_DAY_TRANSFER_4',
|
||||
@@ -105,13 +99,15 @@ class PerfexCRMTasks
|
||||
public const TASK_1_DAY_TRANSFER_5 = [
|
||||
'name' => 'Order Placed in White Form',
|
||||
'description' => '○ Purpose: To confirm that the order has been placed with the supplier.<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline: Same day<br>
|
||||
○ Responsible department: Operations<br>
|
||||
○ Next step: Change the status of Upload China Bank Slip operation to "In Progress" upon successful completion.<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: Approve Payment operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: The order is placed with a supplier and the customer\'s order is confirmed.<br>',
|
||||
○ Amount: RM {amount}<br>
|
||||
○ Currency: {currency}<br>
|
||||
○ Service Type: {service_type}<br>
|
||||
○ Bank-in details: <br>
|
||||
○ Reference: {bank_details.reference}<br>
|
||||
○ Account Holder Name: {bank_details.holder_name}<br>
|
||||
○ Account No.: {bank_details.account_no}<br>
|
||||
○ Bank Name: {bank_details.bank_name}<br>
|
||||
○ Bank Branch: {bank_details.bank_branch}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_1_DAY_TRANSFER_5',
|
||||
'on_task_completion' => 'TASK_1_DAY_TRANSFER_6',
|
||||
@@ -160,15 +156,8 @@ class PerfexCRMTasks
|
||||
public const TASK_3_DAY_TRANSFER_2 = [
|
||||
'name' => 'Approve Payment',
|
||||
'description' => '○ Purpose: To verify and approve the customer\'s payment on exchange<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline:If payment is created before 4:30 pm, it must be made on the same day. If payment is created after 4:30 pm, it must be made the next day<br>
|
||||
○ Responsible department: Accounts<br>
|
||||
○ Next step:<br>
|
||||
i. Change the status of the Issue Exchange Autocount Invoice operation to "In Progress"<br>
|
||||
ii. Change the status of the Order Placed in White Form operation to "In Progress" upon successful completion.<br>
|
||||
○ Additional details: When the payment method is FPX or Wallet this task is performed automatically by the system.<br>
|
||||
○ Dependencies: Map Transaction operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: The payment will be approved in exchange, allowing the next steps in the process to be initiated.<br>',
|
||||
○ Amount: RM {amount}<br>
|
||||
○ Link to order page: {link_transfer}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_3_DAY_TRANSFER_2',
|
||||
'on_task_completion' => 'TASK_3_DAY_TRANSFER_3,TASK_3_DAY_TRANSFER_5',
|
||||
@@ -197,8 +186,7 @@ class PerfexCRMTasks
|
||||
];
|
||||
public const TASK_3_DAY_TRANSFER_3_1 = [
|
||||
'name' => 'Issue Exchange Autocount OR',
|
||||
'description' => '○ Purpose:
|
||||
○ Outcomes: An invoice will be issued in accounting software for the customer\'s payment.<br>',
|
||||
'description' => '○ {link_autocount_or} <br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_3_DAY_TRANSFER_3_1',
|
||||
'on_task_completion' => 'TASK_3_DAY_TRANSFER_4',
|
||||
@@ -228,13 +216,15 @@ class PerfexCRMTasks
|
||||
public const TASK_3_DAY_TRANSFER_5 = [
|
||||
'name' => 'Order Placed in White Form',
|
||||
'description' => '○ Purpose: To confirm that the order has been placed with the supplier.<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline: After 2 days<br>
|
||||
○ Responsible department: Operations<br>
|
||||
○ Next step: Change the status of Upload China Bank Slip operation to "In Progress" upon successful completion.<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: Approve Payment operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: The order is placed with a supplier and the customer\'s order is confirmed.<br>',
|
||||
○ Amount: RM {amount}<br>
|
||||
○ Currency: {currency}<br>
|
||||
○ Service Type: {service_type}<br>
|
||||
○ Bank-in details: <br>
|
||||
○ Reference: {bank_details.reference} <br>
|
||||
○ Account Holder Name: {bank_details.holder_name} <br>
|
||||
○ Account No.: {bank_details.account_no} <br>
|
||||
○ Bank Name: {bank_details.bank_name} <br>
|
||||
○ Bank Branch: {bank_details.bank_branch}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_3_DAY_TRANSFER_5',
|
||||
'on_task_completion' => 'TASK_3_DAY_TRANSFER_6',
|
||||
@@ -410,13 +400,10 @@ class PerfexCRMTasks
|
||||
public const TASK_1688_PAYMENT_8 = [
|
||||
'name' => 'Make Payment for Customer 1688 Order',
|
||||
'description' => '○ Purpose: To confirm that the order has been placed with the supplier.<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline: Same day<br>
|
||||
○ Responsible department: Operations<br>
|
||||
○ Next step: Change the status of Upload China Bank Slip operation to "In Progress" upon successful completion.<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: Authorize Customer’s 1688 Account operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: The customer’s 1688 order is paid.<br>',
|
||||
○ 1688 Username: {1688_username}<br>
|
||||
○ 1688 Password: {1688_password}<br>
|
||||
○ Branch Code: {payment_pin}<br>
|
||||
○ Amount to Transfer: RM {amount}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_1688_PAYMENT_8',
|
||||
'on_task_completion' => 'TASK_1688_PAYMENT_9',
|
||||
@@ -428,13 +415,7 @@ class PerfexCRMTasks
|
||||
public const TASK_1688_PAYMENT_9 = [
|
||||
'name' => 'Upload China Bank Slip',
|
||||
'description' => '○ Purpose: To confirm that the customer order has been transferred to the customer\'s supplier.<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline: After 3 days<br>
|
||||
○ Responsible department: Operations<br>
|
||||
○ Next step: None<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: Make Payment for Customer 1688 Order operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: The customer can download the payment transfer proof to send to their supplier.<br>',
|
||||
○ Link to order page: {link_transfer} <br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_1688_PAYMENT_9',
|
||||
'on_task_completion' => 'TASK_1688_PAYMENT_10',
|
||||
@@ -446,13 +427,7 @@ class PerfexCRMTasks
|
||||
public const TASK_1688_PAYMENT_10 = [
|
||||
'name' => 'Upload 1688 Purchase Order PDF',
|
||||
'description' => '○ Purpose: To store a copy of the original purchase order document for bookkeeping.<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline: Same day<br>
|
||||
○ Responsible department: Operations<br>
|
||||
○ Next step: Change the status of Upload China Bank Slip operation to "In Progress" upon successful completion.<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: Make Payment for Customer 1688 Order operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: The 1688 purchase order’s pdf is attached to the booking.<br>',
|
||||
○ Link to order page: {link_transfer}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_1688_PAYMENT_10',
|
||||
'on_task_completion' => 'TASK_1688_PAYMENT_11',
|
||||
@@ -464,13 +439,7 @@ class PerfexCRMTasks
|
||||
public const TASK_1688_PAYMENT_11 = [
|
||||
'name' => 'Fill Up Purchase Order',
|
||||
'description' => '○ Purpose: To store the purchase order details to generate the invoice.<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline: Same day<br>
|
||||
○ Responsible department: Operations<br>
|
||||
○ Next step: Change the status of Approve Purchase Order operation to "In Progress" upon successful completion.<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: Upload 1688 Purchase Order PDF operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: The purchase order’s details are added to the booking.<br>',
|
||||
○ Link to order page: {link_transfer}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_1688_PAYMENT_11',
|
||||
'on_task_completion' => 'TASK_1688_PAYMENT_12',
|
||||
@@ -482,13 +451,7 @@ class PerfexCRMTasks
|
||||
public const TASK_1688_PAYMENT_12 = [
|
||||
'name' => 'Approve Purchase Order',
|
||||
'description' => '○ Purpose: To check that the customer submitted a purchase order that complies with our company’s guidelines.<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline: Same day<br>
|
||||
○ Responsible department: Operations<br>
|
||||
○ Next step: Change the status of Complete Order bookkeeping operation to "In Progress" upon successful completion.<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: Fill Up Purchase Order operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: The purchase order submitted is approved.<br>',
|
||||
○ link: {link_transfer}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_1688_PAYMENT_12',
|
||||
'on_task_completion' => 'TASK_1688_PAYMENT_13',
|
||||
@@ -540,13 +503,7 @@ class PerfexCRMTasks
|
||||
public const TASK_PURCHASE_ORDER_2 = [
|
||||
'name' => 'Complete Order bookkeeping',
|
||||
'description' => '○ Purpose: To complete the bookkeeping for the booking.<br>
|
||||
○ Initial Status: Not Started<br>
|
||||
○ Deadline: Next day<br>
|
||||
○ Responsible department: Account<br>
|
||||
○ Next step: None<br>
|
||||
○ Additional details: ** Any specific requirements or notes for the operation.**<br>
|
||||
○ Dependencies: Approve Purchase Order and Upload China Bank Slip operation must be completed before this operation can begin.<br>
|
||||
○ Outcomes: A copy of the documents related to the booking should now all be in the google drive relevant folder.<br>',
|
||||
○ Link to order page: {link_transfer}<br>',
|
||||
'milestone' => '',
|
||||
'reference' => 'TASK_PURCHASE_ORDER_2',
|
||||
'on_task_completion' => '',
|
||||
|
||||
@@ -7,7 +7,7 @@ server {
|
||||
root /var/www/html/public;
|
||||
|
||||
server_name localhost;
|
||||
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
@@ -23,5 +23,9 @@ server {
|
||||
fastcgi_intercept_errors on;
|
||||
fastcgi_keep_conn on;
|
||||
fastcgi_param PHP_VALUE "auto_prepend_file= \n allow_url_include=Off";
|
||||
proxy_send_timeout 3600;
|
||||
proxy_read_timeout 3600;
|
||||
fastcgi_send_timeout 3600;
|
||||
fastcgi_read_timeout 3600;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user