<?php

namespace App\Classes\Modules\Bookings\Services;

use App\Models\Booking;

class CalculatesBookingOutstanding
{

    /** @var CalculatesBookingPayableAmount */
    private $calculatesBookingPayableAmount;

    /** @var CalculatesBookingFloatingAmount */
    private $calculatesBookingFloatingAmount;

    /**
     * CalculatesBookingOutstanding constructor.
     * @param CalculatesBookingPayableAmount $calculatesBookingPayableAmount
     * @param CalculatesBookingFloatingAmount $calculatesBookingFloatingAmount
     */
    public function __construct(CalculatesBookingPayableAmount $calculatesBookingPayableAmount, CalculatesBookingFloatingAmount $calculatesBookingFloatingAmount)
    {
        $this->calculatesBookingPayableAmount = $calculatesBookingPayableAmount;
        $this->calculatesBookingFloatingAmount = $calculatesBookingFloatingAmount;
    }


    public function execute(Booking $booking){
        return $booking->fix_amount - $this->calculatesBookingFloatingAmount->execute($booking, $booking->fix_currency_id) - $this->calculatesBookingPayableAmount->execute($booking, $booking->fix_currency_id);
    }

}