<?php

namespace App\Classes\Modules\Bookings\Services;


use App\Classes\ValueObjects\Constants\ApprovalStatus;
use App\Classes\ValueObjects\Constants\TransactionType;
use App\Models\Booking;
use Carbon\Carbon;

class CalculatesBookingPayableAmount
{

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

}