diff --git a/app/Classes/Modules/Bookings/ControllersLogic/ApprovePurchaseOrderLogic.php b/app/Classes/Modules/Bookings/ControllersLogic/ApprovePurchaseOrderLogic.php index ff4796cc..f7d1d775 100644 --- a/app/Classes/Modules/Bookings/ControllersLogic/ApprovePurchaseOrderLogic.php +++ b/app/Classes/Modules/Bookings/ControllersLogic/ApprovePurchaseOrderLogic.php @@ -61,7 +61,11 @@ class ApprovePurchaseOrderLogic extends AbstractControllerLogic $booking = $this->fetchesBooking->execute(['id' => $request->route('id')]); - $this->updatesTransactionStatus->execute($booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(), ApprovalStatus::APPROVED); + $purchaseOrder = $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->first(); + + $booking->transactions()->where('type', TransactionType::PURCHASE_ORDER)->where('id', '!=', $purchaseOrder->id)->delete(); + + $this->updatesTransactionStatus->execute($purchaseOrder, ApprovalStatus::APPROVED); $this->createInvoiceTransactionProcessor->execute($booking);