From 0ffe81d1cf3f7c4f33baf1d6d9b98db7f3c2de31 Mon Sep 17 00:00:00 2001 From: edmondlang Date: Fri, 19 Jul 2024 00:35:38 +0800 Subject: [PATCH] update call wac webhook --- .../CreateInvoiceTransactionProcessor.php | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php index 78d1d2b9..f7697505 100644 --- a/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php +++ b/app/Classes/Modules/Transactions/Processors/CreateInvoiceTransactionProcessor.php @@ -76,6 +76,16 @@ class CreateInvoiceTransactionProcessor public function execute(PackingList $packingList) { $ori_packing_list = $packingList; + // call wac webhook + $hasInvoiceCreated = Transaction::withTrashed() + ->where('type', TransactionType::SHIPPING_INVOICE) + ->where('owner_type', PackingList::class) + ->where('owner_id', $ori_packing_list->id) + ->exists(); + + if ($hasInvoiceCreated) { + Log::channel('wac_webhook')->info('Regenerating Invoice for PackingList: ' . $ori_packing_list->id . '. No call wac api.'); + } $packing_list = PackingList::where('reference', $packingList->reference)->where('type', PackingListType::SHIPPING_PACKING_LIST)->first(); @@ -241,17 +251,6 @@ class CreateInvoiceTransactionProcessor $this->createsTransactionDetail->execute($invoice_transaction, $object_detail); } - - // call wac webhook - $hasInvoiceCreated = Transaction::withTrashed() - ->where('type', TransactionType::SHIPPING_INVOICE) - ->where('owner_type', PackingList::class) - ->where('owner_id', $ori_packing_list->id) - ->exists(); - - if ($hasInvoiceCreated) { - Log::channel('wac_webhook')->info('Regenerating Invoice for PackingList: ' . $ori_packing_list->id . '. No call wac api.'); - } if (app()->environment('production') && !$hasInvoiceCreated) { $order = $ori_packing_list->owner;