<?php


namespace App\Http\Controllers\Transactions;

use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use App\Classes\Modules\Transactions\ControllersLogic\CreatePurchaseOrderTransactionLogic;
use App\Classes\Modules\Bookings\ControllersLogic\UpdateBookingAmountWithPOLogic;



class CreatePurchaseOrderTransactionController
{
    /**
     * @param Request $request
     * @param CreatePurchaseOrderTransactionLogic $logic
     * @return JsonResponse
     */
    public function create(Request $request, CreatePurchaseOrderTransactionLogic $createLogic, UpdateBookingAmountWithPOLogic $updateLogic) : JsonResponse {
        // return $logic->execute($request);
        $updateResult = $updateLogic->execute($request);

        if ($updateResult instanceof JsonResponse && $updateResult->getStatusCode() !== 200) {
            return $updateResult;
        }
        return $createLogic->execute($request);
    }
}
