<?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 CalculatesBookingRefundAmount
{

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

}