Merge branch 'dillon/debug-and-fixes-1' into 'master'

Insert logs for debugging

See merge request CIEFWorldwideSdnBhd/shipping-portal!153
This commit is contained in:
Dillon Ngo
2023-03-18 08:28:57 +00:00
3 changed files with 48 additions and 26 deletions
@@ -18,6 +18,8 @@ use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
class UpdatePerfexCRMInvoice implements ShouldQueue
{
@@ -58,6 +60,7 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
if($invoiceStatus != PerfexCRMInvoiceStatus::PAID){
//get project
$projectId = "";
$projectName = "";
if($transaction->owner instanceof Transaction){
$orderReference = $transaction->owner->owner->owner()->first()->reference;
$packingListReference = $transaction->owner->owner->reference;
@@ -68,6 +71,11 @@ class UpdatePerfexCRMInvoice implements ShouldQueue
}
}
if($projectId == ""){
Log::error(json_encode('UpdatePerfexCRMInvoice debug: '.$projectName));
Log::error(json_encode($transaction->owner));
}
//update invoice
(App()->make(UpdatesPerfexCRMInvoice::class))->execute($invoice, $projectId);
}
@@ -14,6 +14,7 @@ use App\Classes\Modules\PerfexCRM\Services\CreatesPerfexCRMCustomerProject;
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
use App\Models\PackingList;
use Carbon\Carbon;
use Illuminate\Support\Facades\Log;
class CreatePerfexCRMInvoiceProcessor
{
@@ -99,6 +100,7 @@ class CreatePerfexCRMInvoiceProcessor
//get project
$projectId = ""; //Project only exist in CRM if the customer already made payment
$projectName = "";
if($isPaid){
if($transaction->owner instanceof PackingList){
$orderReference = $transaction->owner->owner->reference;
@@ -115,6 +117,11 @@ class CreatePerfexCRMInvoiceProcessor
}
}
}
if($projectId == ""){
Log::error(json_encode('CreatePerfexCRMInvoiceProcessor debug: '.$projectName));
Log::error(json_encode($transaction->owner));
}
}
//newitems
@@ -7,6 +7,7 @@ use App\Classes\ValueObjects\Constants\PerfexCRMTasks;
use App\Classes\Jobs\UpdatePerfexCRM;
use App\Models\PackingList;
use App\Classes\ValueObjects\Constants\PerfexCRMProjectStatus;
use Illuminate\Support\Facades\Log;
class PackingListToPerfexCRMProcessor
{
@@ -17,35 +18,41 @@ class PackingListToPerfexCRMProcessor
*/
public function execute(PackingList $packingList)
{
$order = $packingList->owner;
$companyModule = $order->companyModule()->first();
$connection = $companyModule->inviters()->withPivot('invitee_reference')->first();
$companyName = $companyModule->name;
$companyReference = $connection ? $connection->pivot->invitee_reference:'';
$employee = $companyModule->employees()->first();
$contactEmail = $employee->email;
$contactName = $employee->name;
try {
$order = $packingList->owner;
$companyModule = $order->companyModule()->first();
$connection = $companyModule->inviters()->withPivot('invitee_reference')->first();
$companyName = $companyModule->name;
$companyReference = $connection ? $connection->pivot->invitee_reference:'';
$employee = $companyModule->employees()->first();
$contactEmail = $employee->email;
$contactName = $employee->name;
$orderReference = $packingList->owner->reference;
$packingListReference = $packingList->reference;
$projectName = 'IZYIM | X1 Shipping | '.$orderReference.' | '.$packingListReference;
$orderReference = $packingList->owner->reference;
$packingListReference = $packingList->reference;
$projectName = 'IZYIM | X1 Shipping | '.$orderReference.' | '.$packingListReference;
$updatePerfexCRMObject = new UpdatePerfexCRMObject(
$companyName,
$companyReference,
$contactName,
$contactEmail,
"",
$projectName,
PerfexCRMProjectStatus::NOT_STARTED,
[],
[
PerfexCRMTasks::TASK_LOADED_CONTAINER_1,
PerfexCRMTasks::TASK_LOADED_CONTAINER_2,
]
);
UpdatePerfexCRM::dispatch($updatePerfexCRMObject);
$updatePerfexCRMObject = new UpdatePerfexCRMObject(
$companyName,
$companyReference,
$contactName,
$contactEmail,
"",
$projectName,
PerfexCRMProjectStatus::NOT_STARTED,
[],
[
PerfexCRMTasks::TASK_LOADED_CONTAINER_1,
PerfexCRMTasks::TASK_LOADED_CONTAINER_2,
]
);
UpdatePerfexCRM::dispatch($updatePerfexCRMObject);
} catch (\Exception $exception){
Log::error(json_encode('PackingListToPerfexCRMProcessor debug:'));
Log::error(json_encode($packingList));
Log::error($exception);
}
return true;
}
}