@extends('layout.app') @section('title', __('profit_loss_report')) @section('content')
@if (count($saleProducts) > 0)
@php $totalQty = 0; $totalProfitLoss = 0; @endphp @foreach ($saleProducts as $saleProduct) @php $tax = ($saleProduct->product->price * $saleProduct->product?->tax?->rate) / 100; $profitLoss = $saleProduct->product->price - $saleProduct->product->cost; $totalQty += $saleProduct->total_qty; $totalProfitLoss += $profitLoss; @endphp @endforeach
{{ __('sl') }} {{ __('name') }} {{ __('avg_purchase_price') }} {{ __('avg_selling_price') }} {{ __('avg_tax') }} {{ __('avg_subtotal') }} {{ __('sold_qty') }} {{ __('profit') }} / {{ __('loss') }}
{{ $loop->iteration }} {{ $saleProduct->product->name }} {{ numberFormat($saleProduct->product->cost) }} {{ numberFormat($saleProduct->product->price) }} {{ numberFormat($tax) }} {{ numberFormat($saleProduct->product->price + $tax) }} {{ $saleProduct->total_qty }} @if ($profitLoss > 0) {{ numberFormat($profitLoss) }} @else {{ numberFormat($profitLoss) }} @endif
{{ __('total') }} {{ $totalQty }} {{ numberFormat($totalProfitLoss) }}
@elseif (count($sales) > 0 || count($purchases) > 0) @php $dates = explode(' - ', request('daterange')); $totalCost = $sales->sum('grand_total') + $sales->sum('order_discount') - $sales->sum('shipping_cost') - $sales->sum('order_tax'); @endphp
{{ __('from') }} {{ $dates[0] }} {{ __('to') }} {{ $dates[1] }}
{{ __('total_sales') }} {{ numberFormat($sales->sum('grand_total')) }}
{{ __('cost_of_goods_sold') }} ({{ numberFormat($totalCost) }})
@if ($totalCost - $sales->sum('grand_total') > 0) {{ __('gross_profit') }} @else {{ __('gross_loss') }} @endif {{ numberFormat($totalCost - $sales->sum('grand_total')) }}
@else
{{ __('empty_msg_title') }}
{{ __('empty_msg_text') }}
@endif
@endsection @push('scripts') @endpush