<?php

namespace App\Classes\Modules\Billing\Services;


use App\Classes\Modules\Orders\DataTransferObjects\OrderObject;
use App\Models\Order;

class CreatesShippingInvoice
{


    public function execute($orderId){

        $order = order::findOrFail($orderId);

        $orderObject = new orderObject($order->marking, $order->company_id, $order->forwarder_id, $order->warehouse_id);

        /** @var float $totalCBM */
        $totalCBM = GetsOrderTotalCBM($orderId);

        /** @var Object() [(string)state, (bool)outstation] $delivertAddress */
        $delivertAddressObject = GetDeliveryAddress($orderId);

        $forwarderSettings = getsForwarderSettings($orderObject->getForwarderId());

        $servicesArray = [];

        ((($forwarderSettings->ShippingRate +
            getsCustomerRate($orderObject->getCompanyId(), $orderObject->getForwarderId()) +
            getsLocationRate($delivertAddressObject, $orderObject->getForwarderId())) * $totalCBM) + GetServices($servicesArray)) * $forwarderSettings->ServiceFee;
    }
}