delete duplicated purchase orders on approval

This commit is contained in:
omair saleh
2021-12-23 12:00:30 +08:00
parent 6b21e162b6
commit 85ba5f074e
@@ -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);