<?php
namespace App\Services\Product\Cost;
use App\Models\ProductCost;
use App\Services\Currency\CurrencyService;

class CostCompany implements CostInterface
{
    public function calculateCost($product)
    {
        $product_cost = ProductCost::query()
            ->where('product_id',$product->id)
            ->where('status','company')->first();
        $currency = (new CurrencyService())->getCurrency();
        return [
            'cost'=>$product_cost->cost * $currency->currency,
            'cost_discount'=>$product_cost->cost_discount * $currency->currency,
            'percentage'=> $product_cost->cost_discount ? round(100 - (($product_cost->cost_discount / $product_cost->cost) * 100 ) ,1)  : 0,
        ];
    }
}
