update call wac webhook

This commit is contained in:
edmondlang
2024-07-19 00:35:38 +08:00
parent 5fd6e6a528
commit 0ffe81d1cf
@@ -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;