/** * Calculate the store profit. * * @param \Paxifi\Order\Repository\OrderRepositoryInterface $order * * @return mixed */ public function calculateProfit(OrderRepositoryInterface $order) { $sales = $order->getTotalSales(); $costs = $order->getTotalCosts(); $tax = $order->getTotalTax(); return $sales - $costs - $tax - $this->calculateCommission($order); }
/** * @param OrderRepositoryInterface $order * * @return array */ public function transform(OrderRepositoryInterface $order) { return array('id' => $order->id, 'total_costs' => $order->getTotalCosts(), 'total_sales' => $order->getTotalSales(), 'total_tax' => $order->getTotalTax(), 'products' => $this->embedProducts($order)); }