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

    public function execute(Booking $booking){
        return $booking->transactions()->payments()->complete()->sum('original_amount');
    }

    public function executeUntilDate(Booking $booking, Carbon $cutOffDate = null){
        $amount = $booking->transactions()->payments()->complete();

        if($cutOffDate){
            $amount->where('created_at', '<=', $cutOffDate);
        }

        return $amount->sum('original_amount');
    }

}