diff --git a/app/Classes/Jobs/UpdatePerfexCRMPrelude.php b/app/Classes/Jobs/UpdatePerfexCRMPrelude.php
new file mode 100644
index 00000000..efb16fcd
--- /dev/null
+++ b/app/Classes/Jobs/UpdatePerfexCRMPrelude.php
@@ -0,0 +1,126 @@
+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;
+ }
+
+}
diff --git a/app/Classes/Modules/PerfexCRM/DataTransferObjects/UpdatePerfexCRMObject.php b/app/Classes/Modules/PerfexCRM/DataTransferObjects/UpdatePerfexCRMObject.php
index a246d25a..023bd786 100644
--- a/app/Classes/Modules/PerfexCRM/DataTransferObjects/UpdatePerfexCRMObject.php
+++ b/app/Classes/Modules/PerfexCRM/DataTransferObjects/UpdatePerfexCRMObject.php
@@ -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;
}
}
diff --git a/app/Classes/Modules/PerfexCRM/Processors/TransactionToPerfexCRMProcessor.php b/app/Classes/Modules/PerfexCRM/Processors/TransactionToPerfexCRMProcessor.php
index d89c54e6..0ade1e80 100644
--- a/app/Classes/Modules/PerfexCRM/Processors/TransactionToPerfexCRMProcessor.php
+++ b/app/Classes/Modules/PerfexCRM/Processors/TransactionToPerfexCRMProcessor.php
@@ -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(
diff --git a/app/Classes/Modules/PerfexCRM/Processors/UpdatePerfexCRMProcessor.php b/app/Classes/Modules/PerfexCRM/Processors/UpdatePerfexCRMProcessor.php
index 3f133e46..1f5f49d2 100644
--- a/app/Classes/Modules/PerfexCRM/Processors/UpdatePerfexCRMProcessor.php
+++ b/app/Classes/Modules/PerfexCRM/Processors/UpdatePerfexCRMProcessor.php
@@ -176,7 +176,7 @@ class UpdatePerfexCRMProcessor
}
}
- $tasks = $updatePerfexCRMObject->getTaskNames();
+ $tasks = $updatePerfexCRMObject->getTasks();
if(count($tasks) > 0){
//Create tasks with milestone
diff --git a/app/Classes/Modules/PerfexCRM/Services/UpdatesPerfexCRMProject.php b/app/Classes/Modules/PerfexCRM/Services/UpdatesPerfexCRMProject.php
index 6c016ff0..cf782806 100644
--- a/app/Classes/Modules/PerfexCRM/Services/UpdatesPerfexCRMProject.php
+++ b/app/Classes/Modules/PerfexCRM/Services/UpdatesPerfexCRMProject.php
@@ -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();
diff --git a/app/Classes/ValueObjects/Constants/PerfexCRMTasks.php b/app/Classes/ValueObjects/Constants/PerfexCRMTasks.php
index c9042f78..1e6bacc4 100644
--- a/app/Classes/ValueObjects/Constants/PerfexCRMTasks.php
+++ b/app/Classes/ValueObjects/Constants/PerfexCRMTasks.php
@@ -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
- ○ Initial Status: In Progress
- ○ 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
- ○ Responsible department: Accounts
- ○ Next step: Change the status of the Approve payment status to "In Progress" upon successful completion of the operation.
- ○ Additional details: ** Any specific requirements or notes for the operation.**
- ○ Dependencies: None
- ○ Outcomes: Bank transaction is mapped successfully, allowing the next steps in the process to be initiated.
',
+ ○ Amount: RM {amount}
+ ○ Link to order page: {link_transfer}
',
'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.
',
+ 'description' => '○ {link_autocount_or}
',
'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.
- ○ Initial Status: Not Started
- ○ Deadline: Same day
- ○ Responsible department: Operations
- ○ Next step: Change the status of Upload China Bank Slip operation to "In Progress" upon successful completion.
- ○ Additional details: ** Any specific requirements or notes for the operation.**
- ○ Dependencies: Approve Payment operation must be completed before this operation can begin.
- ○ Outcomes: The order is placed with a supplier and the customer\'s order is confirmed.
',
+ ○ Amount: RM {amount}
+ ○ Currency: {currency}
+ ○ Service Type: {service_type}
+ ○ Bank-in details:
+ ○ Reference: {bank_details.reference}
+ ○ Account Holder Name: {bank_details.holder_name}
+ ○ Account No.: {bank_details.account_no}
+ ○ Bank Name: {bank_details.bank_name}
+ ○ Bank Branch: {bank_details.bank_branch}
',
'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
- ○ Initial Status: Not Started
- ○ 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
- ○ Responsible department: Accounts
- ○ Next step:
- i. Change the status of the Issue Exchange Autocount Invoice operation to "In Progress"
- ii. Change the status of the Order Placed in White Form operation to "In Progress" upon successful completion.
- ○ Additional details: When the payment method is FPX or Wallet this task is performed automatically by the system.
- ○ Dependencies: Map Transaction operation must be completed before this operation can begin.
- ○ Outcomes: The payment will be approved in exchange, allowing the next steps in the process to be initiated.
',
+ ○ Amount: RM {amount}
+ ○ Link to order page: {link_transfer}
',
'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.
',
+ 'description' => '○ {link_autocount_or}
',
'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.
- ○ Initial Status: Not Started
- ○ Deadline: After 2 days
- ○ Responsible department: Operations
- ○ Next step: Change the status of Upload China Bank Slip operation to "In Progress" upon successful completion.
- ○ Additional details: ** Any specific requirements or notes for the operation.**
- ○ Dependencies: Approve Payment operation must be completed before this operation can begin.
- ○ Outcomes: The order is placed with a supplier and the customer\'s order is confirmed.
',
+ ○ Amount: RM {amount}
+ ○ Currency: {currency}
+ ○ Service Type: {service_type}
+ ○ Bank-in details:
+ ○ Reference: {bank_details.reference}
+ ○ Account Holder Name: {bank_details.holder_name}
+ ○ Account No.: {bank_details.account_no}
+ ○ Bank Name: {bank_details.bank_name}
+ ○ Bank Branch: {bank_details.bank_branch}
',
'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.
- ○ Initial Status: Not Started
- ○ Deadline: Same day
- ○ Responsible department: Operations
- ○ Next step: Change the status of Upload China Bank Slip operation to "In Progress" upon successful completion.
- ○ Additional details: ** Any specific requirements or notes for the operation.**
- ○ Dependencies: Authorize Customer’s 1688 Account operation must be completed before this operation can begin.
- ○ Outcomes: The customer’s 1688 order is paid.
',
+ ○ 1688 Username: {1688_username}
+ ○ 1688 Password: {1688_password}
+ ○ Branch Code: {payment_pin}
+ ○ Amount to Transfer: RM {amount}
',
'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.
- ○ Initial Status: Not Started
- ○ Deadline: After 3 days
- ○ Responsible department: Operations
- ○ Next step: None
- ○ Additional details: ** Any specific requirements or notes for the operation.**
- ○ Dependencies: Make Payment for Customer 1688 Order operation must be completed before this operation can begin.
- ○ Outcomes: The customer can download the payment transfer proof to send to their supplier.
',
+ ○ Link to order page: {link_transfer}
',
'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.
- ○ Initial Status: Not Started
- ○ Deadline: Same day
- ○ Responsible department: Operations
- ○ Next step: Change the status of Upload China Bank Slip operation to "In Progress" upon successful completion.
- ○ Additional details: ** Any specific requirements or notes for the operation.**
- ○ Dependencies: Make Payment for Customer 1688 Order operation must be completed before this operation can begin.
- ○ Outcomes: The 1688 purchase order’s pdf is attached to the booking.
',
+ ○ Link to order page: {link_transfer}
',
'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.
- ○ Initial Status: Not Started
- ○ Deadline: Same day
- ○ Responsible department: Operations
- ○ Next step: Change the status of Approve Purchase Order operation to "In Progress" upon successful completion.
- ○ Additional details: ** Any specific requirements or notes for the operation.**
- ○ Dependencies: Upload 1688 Purchase Order PDF operation must be completed before this operation can begin.
- ○ Outcomes: The purchase order’s details are added to the booking.
',
+ ○ Link to order page: {link_transfer}
',
'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.
- ○ Initial Status: Not Started
- ○ Deadline: Same day
- ○ Responsible department: Operations
- ○ Next step: Change the status of Complete Order bookkeeping operation to "In Progress" upon successful completion.
- ○ Additional details: ** Any specific requirements or notes for the operation.**
- ○ Dependencies: Fill Up Purchase Order operation must be completed before this operation can begin.
- ○ Outcomes: The purchase order submitted is approved.
',
+ ○ link: {link_transfer}
',
'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.
- ○ Initial Status: Not Started
- ○ Deadline: Next day
- ○ Responsible department: Account
- ○ Next step: None
- ○ Additional details: ** Any specific requirements or notes for the operation.**
- ○ Dependencies: Approve Purchase Order and Upload China Bank Slip operation must be completed before this operation can begin.
- ○ Outcomes: A copy of the documents related to the booking should now all be in the google drive relevant folder.
',
+ ○ Link to order page: {link_transfer}
',
'milestone' => '',
'reference' => 'TASK_PURCHASE_ORDER_2',
'on_task_completion' => '',
diff --git a/docker-setup/nginx/default.conf b/docker-setup/nginx/default.conf
index 8761015c..b594e701 100644
--- a/docker-setup/nginx/default.conf
+++ b/docker-setup/nginx/default.conf
@@ -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;
}
-}
\ No newline at end of file
+}