<?php

namespace App\Classes\Modules\Bookings\Services;

use App\Models\Booking;

class CalculatesBookingFloatingAmount
{

    public function execute(Booking $booking, int $type){
        return $type === 1 ?
            $booking->transactions()->payments()->inComplete()
                ->selectRaw('sum(amount - service_charge - tax) as sub_total')
                ->get()->sum('sub_total')
            : $booking->transactions()->payments()->inComplete()->get()->sum('original_amount');
    }

}