fix regenerate invoice function to only include invoice documents

This commit is contained in:
omair saleh
2022-10-11 17:48:30 +08:00
parent 1ac4dd52ac
commit b5acf80a29
@@ -10,6 +10,7 @@ use App\Classes\Modules\Transactions\Services\DeletesTransaction;
use App\Classes\Modules\Documents\Services\DeletesDocument;
use App\Classes\Modules\Transactions\Processors\CreateInvoiceTransactionProcessor;
use App\Classes\ValueObjects\Constants\DocumentType;
use App\Http\Resources\BookingResource;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
@@ -57,7 +58,7 @@ class RegenerateInvoiceBookingLogic extends AbstractControllerLogic
* @param CreateInvoiceTransactionProcessor $createInvoiceTransactionProcessor
*/
public function __construct(
CanFetchBooking $canFetchBooking,
CanFetchBooking $canFetchBooking,
FetchesBooking $fetchesBooking,
DeletesTransaction $deletesTransaction,
UpdatesBookingStatus $updatesBookingStatus,
@@ -86,7 +87,7 @@ class RegenerateInvoiceBookingLogic extends AbstractControllerLogic
$this->canFetchBooking->passes();
$booking = $this->fetchesBooking->execute([
'id' => $request->route('id'),
'id' => $request->route('id'),
'status' => ApprovalStatus::COMPLETED,
'with_transactions' => true]
);
@@ -98,7 +99,7 @@ class RegenerateInvoiceBookingLogic extends AbstractControllerLogic
$this->deletesTransaction->execute($row);
}
$document = $booking->documents()->get();
$document = $booking->documents()->whereIn('document_type', [DocumentType::PURCHASE_ORDER, DocumentType::INVOICE, DocumentType::DELIVER_ORDER, DocumentType::SUPPLIER_DELIVER_ORDER])->get();
foreach ($document as $key => $row) {
$this->deletesDocument->execute($row);
}
@@ -108,4 +109,4 @@ class RegenerateInvoiceBookingLogic extends AbstractControllerLogic
return $this->resourceResponse(new BookingResource($booking));
}
}
}